当前位置: 首页 > news >正文

做门户网站用什么技术好网站 的建设意义

做门户网站用什么技术好,网站 的建设意义,可以免费做3dLOGO的网站,网站购物流程模块怎么实现场景: 我目前设计到的场景是:即在地图应用中,对GPS轨迹数据进行压缩,减少数据传输和存储开销,因为轨迹点太频繁了,占用空间太大,运行节点太慢了,经过小组讨论需要上这个算法&#x…

场景:

我目前设计到的场景是:即在地图应用中,对GPS轨迹数据进行压缩,减少数据传输和存储开销,因为轨迹点太频繁了,占用空间太大,运行节点太慢了,经过小组讨论需要上这个算法,。

涉及到的算法

  1. Douglas-Peucker算法:该算法通过递归地将轨迹分割为线段,并丢弃那些与整体轨迹偏差较小的线段,从而实现轨迹的压缩。
    1. Visvalingam-Whyatt算法:该算法基于三角形面积的概念,通过不断移除面积最小的点来达到轨迹压缩的目的

                                图片来源:郑宇博士《computing with spatial trajectories》

Haversine公式计算距离和Douglas-Peucker压缩算法代码实现-scala版

import org.apache.spark.sql.{DataFrame, SparkSession}
import org.apache.spark.sql.functions._
import scala.math._// 定义表示点的类
case class Point(lon: Double, lat: Double, time: String, id: String)// Haversine距离计算函数
def haversineDistance(point1: Point, point2: Point): Double = {val R = 6371000.0 // 地球半径(米)val dLat = toRadians(point2.lat - point1.lat)val dLon = toRadians(point2.lon - point1.lon)val a = pow(sin(dLat / 2), 2) + cos(toRadians(point1.lat)) * cos(toRadians(point2.lat)) * pow(sin(dLon / 2), 2)val c = 2 * atan2(sqrt(a), sqrt(1 - a))R * c
}// Douglas-Peucker轨迹压缩函数
def douglasPeucker(points: List[Point], epsilon: Double): List[Point] = {if (points.length < 3) {return points}val dmax = points.view.zipWithIndex.map { case (point, index) =>if (index != 0 && index != points.length - 1) {perpendicularDistance(point, points.head, points.last)} else {0.0}}.maxif (dmax > epsilon) {val index = points.view.zipWithIndex.maxBy { case (point, index) =>if (index != 0 && index != points.length - 1) {perpendicularDistance(point, points.head, points.last)} else {0.0}}._2val recResults1 = douglasPeucker(points.take(index+1), epsilon)val recResults2 = douglasPeucker(points.drop(index), epsilon)recResults1.init ::: recResults2} else {List(points.head, points.last)}
}// 创建Spark会话
val spark = SparkSession.builder().appName("TrajectoryCompression").getOrCreate()// 创建包含lon、lat、time和id列的示例DataFrame
//https://blog.csdn.net/qq_52128187?type=blog,by_laoli
val data = Seq((40.7128, -74.0060, "2023-11-18 08:00:00", "1"),(40.7215, -74.0112, "2023-11-18 08:05:00", "1"),(40.7312, -74.0146, "2023-11-18 08:10:00", "1"),(40.7356, -74.0162, "2023-11-18 08:15:00", "1"),(40.7391, -74.0182, "2023-11-18 08:20:00", "1"),(40.7483, -74.0224, "2023-11-18 08:25:00", "1"),(40.7527, -74.0260, "2023-11-18 08:30:00", "1")
).toDF("lon", "lat", "time", "id")// 为DataFrame添加id列
val dfWithId = data.withColumn("id", monotonically_increasing_id())// 将DataFrame转换为Point列表
val points = dfWithId.as[(Double, Double, String, Long)].collect().map(p => Point(p._1, p._2, p._3, p._4.toString)).toList// 执行轨迹压缩
val compressedPoints = douglasPeucker(points, epsilon = 10)  // 设置您期望的epsilon值// 将压缩后的数据重新转换为DataFrame
import spark.implicits._
val df2 = compressedPoints.toDF("lon", "lat", "time", "id")

参考文章

  • Douglas, D.H., and Peucker, T.K. "Algorithms for the reduction of the number of points required to represent a digitized line or its caricature." The Canadian Cartographer 10.2 (1973): 112-122.
  • Visvalingam, M., and Whyatt, J.D. "Line generalization by repeated elimination of the smallest-area triangle." Cartographic Journal 30.1 (1993): 46-51.
  • 轨迹数据压缩的Douglas-Peucker算法(附代码及原始数据) - 知乎
http://www.yayakq.cn/news/983487/

相关文章:

  • 南宁网站建设哪家好关于asp.net的网站模板
  • 个人做外贸网站2345网址导航怎么下载
  • 网站的优化 设计搭建一个小程序需要多少钱
  • 设计网站页面出现问题公司网络推广平台
  • 网站界面分类wordpress弹窗插件
  • 邢台网站建设服务wordpress中文附件乱码
  • 饮料网站建设规划书国外做调查问卷的网站
  • 网站设计公司建设无货源网店进货app
  • 杭州专业网站营销中小企业做网站贷款
  • 网站建设论坛报告海外医疗网站建设
  • 深圳seo网站设计wordpress 中文 图片
  • 上传网站再备案站长之家域名解析
  • 网站建设价格微信微网站开通
  • 建官方网站的公司注册域名怎么做网站
  • 如何选择南京网站建设大网站制作
  • 网站 域名第九影院用wordpress版权信息
  • 新余 网站建站 设计 公司wordpress赚钱插件
  • 兴安盟老区建设促进会网站创意设计
  • 中山企业网站多少钱杭州 做网站
  • 专门做推广的网站财政厅三基建设网站
  • 网站建设应该注意哪些原则wordpress js加速
  • 动漫做a视频网站网站建设微信营销
  • 网站注册搜索引擎的目的工商网官网查询企业信息
  • 毕业设计购物网站开发的意义淘宝客做连接网站吗
  • 网站服务器维护工具网页设计地址
  • 用flask做的网站wordpress配置多站点
  • 公司做网站收费网站建设发展现状
  • dw软件网站建设教程视频南阳做网站
  • 无锡建设网站的公司简介网站快速排名技巧
  • 洛阳网站制作建设网页剪辑app