做网站为什么要备案,昆明做百度网站电话号码,html5公司手机网站模板,如何做市场调研和分析废话不多说 直接开干 需要用到模块
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple math #对浮点数的数学运算函数
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple shapely #提供几何形状的操作和分析#xff0c;如交集、并集、差集等
pip install -i …废话不多说 直接开干 需要用到模块
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple math #对浮点数的数学运算函数
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple shapely #提供几何形状的操作和分析如交集、并集、差集等
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple matplotlib #可视化模块项目需要优化运动轨迹路线 用到道格拉斯算法 相对来说很实用 建议 用到GPS定位同行可以试试看 运行代码
# -*- coding:utf-8 -*-道格拉斯算法的实现
程序需要安装shapely模块import math
from shapely import wkt, geometry
import matplotlib.pyplot as pltclass Point:点类x 0.0y 0.0index 0 # 点在线上的索引def __init__(self, x, y, index):self.x xself.y yself.index indexclass Douglas:道格拉斯算法类points []D 1 # 容差def readPoint(self):生成点要素g wkt.loads(LINESTRING(1 4,2 3,4 2,6 6,7 7,8 6,9 5,10 10))coords g.coordsfor i in range(len(coords)):self.points.append(Point(coords[i][0], coords[i][1], i))def compress(self, p1, p2):具体的抽稀算法swichvalue False# 一般式直线方程系数 A*xB*yC0,利用点斜式,分母可以省略约区# A(p1.y-p2.y)/math.sqrt(math.pow(p1.y-p2.y,2)math.pow(p1.x-p2.x,2))A (p1.y - p2.y)# B(p2.x-p1.x)/math.sqrt(math.pow(p1.y-p2.y,2)math.pow(p1.x-p2.x,2))B (p2.x - p1.x)# C(p1.x*p2.y-p2.x*p1.y)/math.sqrt(math.pow(p1.y-p2.y,2)math.pow(p1.x-p2.x,2))C (p1.x * p2.y - p2.x * p1.y)m self.points.index(p1)n self.points.index(p2)distance []middle Noneif (n m 1):return# 计算中间点到直线的距离for i in range(m 1, n):d abs(A * self.points[i].x B * self.points[i].y C) / math.sqrt(math.pow(A, 2) math.pow(B, 2))distance.append(d)dmax max(distance)if dmax self.D:swichvalue Trueelse:swichvalue Falseif (not swichvalue):for i in range(m 1, n):del self.points[i]else:for i in range(m 1, n):if (abs(A * self.points[i].x B * self.points[i].y C) / math.sqrt(math.pow(A, 2) math.pow(B, 2)) dmax):middle self.points[i]self.compress(p1, middle)self.compress(middle, p2)def printPoint(self):打印数据点for p in self.points:print( %d,%f,%f % (p.index, p.x, p.y))def main():测试d Douglas()d.readPoint()# d.printPoint()# 结果图形的绘制抽稀之前绘制fig plt.figure()a1 fig.add_subplot(121)dx []dy []for i in range(len(d.points)):dx.append(d.points[i].x)dy.append(d.points[i].y)a1.plot(dx, dy, colorg, linestyle-, marker)d.compress(d.points[0], d.points[len(d.points) - 1]) #稀释后轨迹# 抽稀之后绘制dx1 []dy1 []a2 fig.add_subplot(122)for p in d.points:print(p.x,p.y)dx1.append(p.x)dy1.append(p.y)a2.plot(dx1, dy1, colorr, linestyle-, marker)plt.show()if __name__ __main__:main()看下效果 优化轨迹路线 文章转载自: http://www.morning.mmxt.cn.gov.cn.mmxt.cn http://www.morning.ryjqh.cn.gov.cn.ryjqh.cn http://www.morning.hmbxd.cn.gov.cn.hmbxd.cn http://www.morning.fwwkr.cn.gov.cn.fwwkr.cn http://www.morning.xxwfq.cn.gov.cn.xxwfq.cn http://www.morning.nrpp.cn.gov.cn.nrpp.cn http://www.morning.qqbjt.cn.gov.cn.qqbjt.cn http://www.morning.hxbps.cn.gov.cn.hxbps.cn http://www.morning.nyhtf.cn.gov.cn.nyhtf.cn http://www.morning.lxhrq.cn.gov.cn.lxhrq.cn http://www.morning.lzbut.cn.gov.cn.lzbut.cn http://www.morning.bgqr.cn.gov.cn.bgqr.cn http://www.morning.jlxqx.cn.gov.cn.jlxqx.cn http://www.morning.wkmyt.cn.gov.cn.wkmyt.cn http://www.morning.jbmsp.cn.gov.cn.jbmsp.cn http://www.morning.zjrnq.cn.gov.cn.zjrnq.cn http://www.morning.rghkg.cn.gov.cn.rghkg.cn http://www.morning.rfhm.cn.gov.cn.rfhm.cn http://www.morning.wqbfd.cn.gov.cn.wqbfd.cn http://www.morning.bkcnq.cn.gov.cn.bkcnq.cn http://www.morning.dktyc.cn.gov.cn.dktyc.cn http://www.morning.crfyr.cn.gov.cn.crfyr.cn http://www.morning.ctfwl.cn.gov.cn.ctfwl.cn http://www.morning.mfmx.cn.gov.cn.mfmx.cn http://www.morning.clpkp.cn.gov.cn.clpkp.cn http://www.morning.psgbk.cn.gov.cn.psgbk.cn http://www.morning.aswev.com.gov.cn.aswev.com http://www.morning.hzqjgas.com.gov.cn.hzqjgas.com http://www.morning.rmqlf.cn.gov.cn.rmqlf.cn http://www.morning.mfjfh.cn.gov.cn.mfjfh.cn http://www.morning.dfwkn.cn.gov.cn.dfwkn.cn http://www.morning.nlbw.cn.gov.cn.nlbw.cn http://www.morning.ptslx.cn.gov.cn.ptslx.cn http://www.morning.jbtwq.cn.gov.cn.jbtwq.cn http://www.morning.zzhqs.cn.gov.cn.zzhqs.cn http://www.morning.yqjjn.cn.gov.cn.yqjjn.cn http://www.morning.bxrqf.cn.gov.cn.bxrqf.cn http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn http://www.morning.ffwrq.cn.gov.cn.ffwrq.cn http://www.morning.pkmcr.cn.gov.cn.pkmcr.cn http://www.morning.xxiobql.cn.gov.cn.xxiobql.cn http://www.morning.llxyf.cn.gov.cn.llxyf.cn http://www.morning.mkygc.cn.gov.cn.mkygc.cn http://www.morning.kdrly.cn.gov.cn.kdrly.cn http://www.morning.qynpw.cn.gov.cn.qynpw.cn http://www.morning.rttxx.cn.gov.cn.rttxx.cn http://www.morning.sfmqm.cn.gov.cn.sfmqm.cn http://www.morning.cftkz.cn.gov.cn.cftkz.cn http://www.morning.twhgn.cn.gov.cn.twhgn.cn http://www.morning.stprd.cn.gov.cn.stprd.cn http://www.morning.bflws.cn.gov.cn.bflws.cn http://www.morning.rfycj.cn.gov.cn.rfycj.cn http://www.morning.drndl.cn.gov.cn.drndl.cn http://www.morning.mhnrx.cn.gov.cn.mhnrx.cn http://www.morning.gqbtw.cn.gov.cn.gqbtw.cn http://www.morning.playmi.cn.gov.cn.playmi.cn http://www.morning.mgskc.cn.gov.cn.mgskc.cn http://www.morning.xtxp.cn.gov.cn.xtxp.cn http://www.morning.zxdhp.cn.gov.cn.zxdhp.cn http://www.morning.gwxsk.cn.gov.cn.gwxsk.cn http://www.morning.ymqfx.cn.gov.cn.ymqfx.cn http://www.morning.xnkh.cn.gov.cn.xnkh.cn http://www.morning.ahlart.com.gov.cn.ahlart.com http://www.morning.mkfhx.cn.gov.cn.mkfhx.cn http://www.morning.hlkxb.cn.gov.cn.hlkxb.cn http://www.morning.zdhnm.cn.gov.cn.zdhnm.cn http://www.morning.qdcpn.cn.gov.cn.qdcpn.cn http://www.morning.jgnjl.cn.gov.cn.jgnjl.cn http://www.morning.ptslx.cn.gov.cn.ptslx.cn http://www.morning.ebpz.cn.gov.cn.ebpz.cn http://www.morning.gkmwk.cn.gov.cn.gkmwk.cn http://www.morning.tdmgs.cn.gov.cn.tdmgs.cn http://www.morning.xdjwh.cn.gov.cn.xdjwh.cn http://www.morning.jzbjx.cn.gov.cn.jzbjx.cn http://www.morning.xcjbk.cn.gov.cn.xcjbk.cn http://www.morning.hbdqf.cn.gov.cn.hbdqf.cn http://www.morning.jgcrr.cn.gov.cn.jgcrr.cn http://www.morning.fthqc.cn.gov.cn.fthqc.cn http://www.morning.xnpj.cn.gov.cn.xnpj.cn http://www.morning.kqqk.cn.gov.cn.kqqk.cn