├── .gitignore ├── LICENSE ├── README.md ├── _config.yml ├── pic ├── 1555286763223.png ├── Kmean.PNG ├── 凹点切割1.png ├── 凹点切割2.jpg ├── 凹点切割流程示意图.jpg ├── 凹点延长线1.png ├── 凹点延长线2.png ├── 凹点计算.png ├── 拟合球体.png ├── 最.png ├── 最大内接圆.jpg ├── 最小外接圆.png ├── 最小外接面.gif ├── 面选择_线段.png └── 面选择_结点.png ├── pom.xml ├── python-planar-algorithm ├── 拟合椭球.py └── 拟合球体.py └── src ├── main ├── java │ └── com │ │ └── huifer │ │ └── planar │ │ └── aset │ │ ├── algo │ │ ├── AverageWidthAverageLength.java │ │ ├── CuttingConcavePolygon.java │ │ ├── DateInterface.java │ │ ├── DijlstraInterface.java │ │ ├── GraphInterface.java │ │ ├── KmeanPolygonSplitInterface.java │ │ ├── LineOverInterface.java │ │ ├── MatirxInterface.java │ │ ├── MinimumEnclosingInterface.java │ │ ├── MyRectangleOver.java │ │ ├── NearbyInterface.java │ │ ├── PolygonAngleInterface.java │ │ ├── PolygonCenterOfGravityInterface.java │ │ ├── PolygonRemoveNodeInterface.java │ │ ├── RailInterface.java │ │ ├── RamerDouglasPeuckerInterface.java │ │ ├── RemoveNodesInterface.java │ │ ├── VoronoiInterface.java │ │ └── impl │ │ │ ├── AverageWidthAverageLengthImpl.java │ │ │ ├── DateInterfaceImpl.java │ │ │ ├── MatirxCore.java │ │ │ ├── NearbyInterfaceImpl.java │ │ │ ├── concave │ │ │ ├── ConcaveSplit.java │ │ │ ├── CutPolygon.java │ │ │ ├── IsConcave.java │ │ │ ├── SimpleCutPolygon.java │ │ │ └── 切割凹多边形的测试用例.csv │ │ │ ├── line │ │ │ ├── RamerDouglasPeuckerInterfaceCore.java │ │ │ ├── RemoveLine.java │ │ │ ├── RemoveNodesCore.java │ │ │ └── SimpleDijkstra.java │ │ │ ├── minrect │ │ │ ├── MaximumInnerCircle.java │ │ │ ├── MinCircle.java │ │ │ ├── MinCircleToE.java │ │ │ ├── MinimumBoundingRectangle.java │ │ │ ├── MinimumEnclosingCore.java │ │ │ ├── Rotation.java │ │ │ └── WelzlAlgo.java │ │ │ ├── ovlayer │ │ │ ├── GraphCore.java │ │ │ └── LineOverCore.java │ │ │ └── polygon │ │ │ ├── CuttingConcavePolygonImpl.java │ │ │ ├── KmeanPolygonSplitCore.java │ │ │ ├── MyRecatngleOverCore.java │ │ │ ├── PolygonAngleCore.java │ │ │ ├── PolygonCenterOfGravityCore.java │ │ │ ├── PolygonRemoveNodeByLength.java │ │ │ ├── PolygonSegmentationCore.java │ │ │ ├── RailCore.java │ │ │ └── VoronoiInterfaceImpl.java │ │ ├── entity │ │ ├── ConcavePolygonCut.java │ │ ├── FourBox.java │ │ ├── KmeanPolygonResult.java │ │ ├── Kmeans.java │ │ ├── MyLine.java │ │ ├── MyPoint.java │ │ ├── MyPolygon.java │ │ ├── MyRectangle.java │ │ ├── OvlayerEnum.java │ │ ├── PolygonAngleResult.java │ │ ├── PolygonRemoveNodeResult.java │ │ ├── PublicRadial.java │ │ ├── RefObject.java │ │ ├── ResultShortestPath.java │ │ └── SortPoint.java │ │ ├── factory │ │ └── MyGeoFactory.java │ │ ├── mappingalgo │ │ ├── Convolution.java │ │ ├── coortrans │ │ │ ├── ReadHelper.java │ │ │ ├── RunT.java │ │ │ ├── lib │ │ │ │ ├── AllData.java │ │ │ │ ├── Ellipsoid.java │ │ │ │ ├── Gauss.java │ │ │ │ ├── PointInfo.java │ │ │ │ ├── Position.java │ │ │ │ └── Rad2Dms.java │ │ │ └── 坐标数据.txt │ │ ├── fanjuli │ │ │ ├── InverseDistanceCore.java │ │ │ ├── MyPoint.java │ │ │ ├── ReadHelper.java │ │ │ └── 测站坐标.txt │ │ ├── grid │ │ │ ├── GRID数据.txt │ │ │ ├── ReadHelper.java │ │ │ └── lib │ │ │ │ ├── Convex.java │ │ │ │ ├── GeoCalc.java │ │ │ │ ├── Grid.java │ │ │ │ ├── GridCell.java │ │ │ │ ├── HeightCalc.java │ │ │ │ ├── PointInfo.java │ │ │ │ ├── ResultData.java │ │ │ │ ├── Stack.java │ │ │ │ └── Vector.java │ │ ├── sortpath │ │ │ ├── Edge.java │ │ │ ├── Graph.java │ │ │ ├── SortPathRunt.java │ │ │ ├── Vertex.java │ │ │ └── 路径数据.txt │ │ ├── trajectorycompression │ │ │ ├── DpLine.java │ │ │ ├── Point.java │ │ │ ├── ReadText.java │ │ │ └── read.txt │ │ └── zongduanmian │ │ │ ├── ReadHelper.java │ │ │ ├── Zongduanmian.java │ │ │ ├── lib │ │ │ ├── AllData.java │ │ │ ├── CrossSection.java │ │ │ ├── Dwh.java │ │ │ ├── HeightCal.java │ │ │ ├── PointInfo.java │ │ │ └── VerticleSection.java │ │ │ └── 断面数据.txt │ │ ├── utils │ │ ├── AdjacentMatrixUtil.java │ │ ├── Arith.java │ │ ├── CommonUtils.java │ │ ├── DijkstraUtil.java │ │ ├── FileCommonMethod.java │ │ ├── JSONUtil.java │ │ ├── KmeanPolygon.java │ │ ├── Miact.java │ │ ├── PolygonUtils.java │ │ ├── Project.java │ │ ├── TmeanLength.java │ │ ├── geo │ │ │ ├── ColorUtil.java │ │ │ ├── GeoJsonUtil.java │ │ │ ├── GeoMapContentUtil.java │ │ │ ├── GeoStyleUtil.java │ │ │ ├── GeomtryUtil.java │ │ │ └── GridUtil.java │ │ ├── kriging │ │ │ ├── Kpoint.java │ │ │ ├── KriginCore.java │ │ │ └── ReadFile.java │ │ ├── polygonselect │ │ │ ├── Algo.java │ │ │ ├── ReadShpHelper.java │ │ │ ├── ToceLineString.java │ │ │ ├── TocePoint.java │ │ │ └── TocePolygon.java │ │ ├── shptools │ │ │ ├── Shp2Wkt.java │ │ │ ├── ShpClip.java │ │ │ ├── ShpUtils.java │ │ │ ├── center │ │ │ │ ├── Regression.java │ │ │ │ ├── Run.java │ │ │ │ └── ThiessenPolygon.java │ │ │ ├── geojson │ │ │ │ └── MainTest.java │ │ │ ├── overlay │ │ │ │ └── Operation.java │ │ │ ├── polygontools │ │ │ │ ├── ForTest.java │ │ │ │ ├── PolygonGravityCenter.java │ │ │ │ ├── PolygonNodeTriangle.java │ │ │ │ ├── entity │ │ │ │ │ └── LatLngEntity.java │ │ │ │ └── geometry │ │ │ │ │ ├── Bounds.java │ │ │ │ │ ├── ComparatorLatLng.java │ │ │ │ │ ├── ConvexHull.java │ │ │ │ │ ├── ConvexTest.java │ │ │ │ │ └── Polygon.java │ │ │ └── triangulation │ │ │ │ ├── 1c.txt │ │ │ │ ├── DelaunayTriangulator.java │ │ │ │ ├── Edge2D.java │ │ │ │ ├── EdgeDistancePack.java │ │ │ │ ├── FileRd.java │ │ │ │ ├── NotEnoughPointsException.java │ │ │ │ ├── Triangle2D.java │ │ │ │ ├── Triangle2DEnum.java │ │ │ │ ├── Triangle2dTools.java │ │ │ │ ├── TriangleSoup.java │ │ │ │ └── Vector2D.java │ │ ├── simplecycles │ │ │ ├── SearchCycles.java │ │ │ ├── SimpleCycles.java │ │ │ └── SimpleResult.java │ │ └── threepoint │ │ │ └── SortThreePoint.java │ │ └── view │ │ ├── KmeanView.java │ │ ├── MyContext.java │ │ ├── PolygonAngleMergeView.java │ │ ├── PolygonAngleView.java │ │ └── base │ │ ├── Aframe.java │ │ ├── BaseFrame.java │ │ ├── FrameContext.java │ │ └── ViewHelper.java └── resources │ ├── 1.csv │ ├── data │ └── shp │ │ ├── 555555.cpg │ │ ├── 555555.dbf │ │ ├── 555555.sbn │ │ ├── 555555.sbx │ │ ├── 555555.shp │ │ ├── 555555.shp.xml │ │ ├── 555555.shx │ │ ├── 省范围.cpg │ │ ├── 省范围.dbf │ │ ├── 省范围.prj │ │ ├── 省范围.sbn │ │ ├── 省范围.sbx │ │ ├── 省范围.shp │ │ └── 省范围.shx │ ├── logback.xml │ └── polygon_select │ ├── 原始数据.dwg │ ├── 根据点 │ ├── 中间过程数据.csv │ ├── 原始数据.dwg │ ├── 数据要求.txt │ ├── 测试数据.cpg │ ├── 测试数据.dbf │ ├── 测试数据.sbn │ ├── 测试数据.sbx │ ├── 测试数据.shp │ ├── 测试数据.shx │ ├── 测试数据.xml │ ├── 结果.cpg │ ├── 结果.dbf │ ├── 结果.sbn │ ├── 结果.sbx │ ├── 结果.shp │ ├── 结果.shx │ └── 说明.png │ ├── 根据线 │ ├── 中间过程数据.csv │ ├── 原始数据.dwg │ ├── 测试数据.cpg │ ├── 测试数据.dbf │ ├── 测试数据.sbn │ ├── 测试数据.sbx │ ├── 测试数据.shp │ ├── 测试数据.shx │ └── 测试数据.xml │ ├── 测试数据.cpg │ ├── 测试数据.dbf │ ├── 测试数据.sbn │ ├── 测试数据.sbx │ ├── 测试数据.shp │ ├── 测试数据.shx │ └── 测试数据.xml └── test └── java └── com └── huifer └── planar └── aset ├── OT.java ├── algo ├── DigraphCoreTest.java ├── KmeanPolygonSplitInterfaceTest.java ├── LineOverCoreTest.java ├── PolygonAngleInterfaceTest.java ├── PolygonCenterOfGravityInterfaceTest.java ├── PolygonRemoveNodeInterfaceTest.java ├── RailCoreTest.java ├── SimpleDijkstraTest.java └── impl │ ├── AverageWidthAverageLengthImplTest.java │ ├── KmeanPolygon.java │ ├── MyRecatngleOverCoreTest.java │ ├── NearbyInterfaceImplTest.java │ ├── PolygonAngleCoreTest.java │ ├── PolygonSegmentationCoreTest.java │ ├── RemoveLineTest.java │ ├── RemoveNodesCoreTest.java │ ├── VoronoiInterfaceImplTest.java │ ├── concave │ ├── ConcaveSplitTest.java │ ├── CutPolygonTest.java │ ├── IsConcaveTest.java │ ├── LineEquationTest.java │ ├── PolygonizerT.java │ └── SimpleCutPolygonTest.java │ └── minrect │ ├── MaximumInnerCircleTest.java │ ├── MinCircleToETest.java │ ├── MinimumBoundingRectangleTest.java │ ├── MinimumEnclosingCoreTest.java │ └── WelzlAlgoTest.java ├── entity ├── MyLineTest.java ├── MyPointTest.java └── PublicRadialTest.java ├── mappingalgo ├── ConvolutionTest.java ├── coortrans │ └── CoortransTest.java ├── fanjuli │ └── InverseDistanceCoreTest.java ├── grid │ └── GridTest.java ├── sortpath │ └── SortPathRuntTest.java ├── trajectorycompression │ └── DpLineTest.java └── zongduanmian │ └── ZongduanmianTest.java └── utils ├── AdjacentMatrixUtilTest.java ├── CommonUtilsTest.java ├── GeomtryUtilTest.java ├── KmeansTest.java ├── PolygonUtilsTest.java ├── TmeanLengthTest.java ├── geo ├── GeoJsonUtilTest.java └── GridUtilTest.java ├── shptools └── ShpUtilsTest.java └── simplecycles ├── SearchCyclesTest.java └── SimpleCyclesTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### JetBrains template 3 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 4 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 5 | 6 | # User-specific stuff 7 | .idea/**/workspace.xml 8 | .idea/**/tasks.xml 9 | .idea/**/usage.statistics.xml 10 | .idea/**/dictionaries 11 | .idea/**/shelf 12 | 13 | # Generated files 14 | .idea/**/contentModel.xml 15 | 16 | # Sensitive or high-churn files 17 | .idea/**/dataSources/ 18 | .idea/**/dataSources.ids 19 | .idea/**/dataSources.local.xml 20 | .idea/**/sqlDataSources.xml 21 | .idea/**/dynamic.xml 22 | .idea/**/uiDesigner.xml 23 | .idea/**/dbnavigator.xml 24 | 25 | # Gradle 26 | .idea/**/gradle.xml 27 | .idea/**/libraries 28 | 29 | # Gradle and Maven with auto-import 30 | # When using Gradle or Maven with auto-import, you should exclude module files, 31 | # since they will be recreated, and may cause churn. Uncomment if using 32 | # auto-import. 33 | # .idea/modules.xml 34 | # .idea/*.iml 35 | # .idea/modules 36 | # *.iml 37 | # *.ipr 38 | 39 | # CMake 40 | cmake-build-*/ 41 | 42 | # Mongo Explorer plugin 43 | .idea/**/mongoSettings.xml 44 | 45 | # File-based project format 46 | *.iws 47 | 48 | # IntelliJ 49 | out/ 50 | 51 | # mpeltonen/sbt-idea plugin 52 | .idea_modules/ 53 | 54 | # JIRA plugin 55 | atlassian-ide-plugin.xml 56 | 57 | # Cursive Clojure plugin 58 | .idea/replstate.xml 59 | 60 | # Crashlytics plugin (for Android Studio and IntelliJ) 61 | com_crashlytics_export_strings.xml 62 | crashlytics.properties 63 | crashlytics-build.properties 64 | fabric.properties 65 | 66 | # Editor-based Rest Client 67 | .idea/httpRequests 68 | 69 | # Android studio 3.1+ serialized cache file 70 | .idea/caches/build_file_checksums.ser 71 | 72 | ### Java template 73 | # Compiled class file 74 | *.class 75 | 76 | # Log file 77 | *.log 78 | 79 | # BlueJ files 80 | *.ctxt 81 | 82 | # Mobile Tools for Java (J2ME) 83 | .mtj.tmp/ 84 | 85 | # Package Files # 86 | *.jar 87 | *.war 88 | *.nar 89 | *.ear 90 | *.zip 91 | *.tar.gz 92 | *.rar 93 | 94 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 95 | hs_err_pid* 96 | 97 | /.idea/ 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # planar_algorithm 2 |  3 |  4 | #### 介绍 5 | 平面算法 6 | 7 | 关于 二维点 二维线的基础算法 8 | 9 | - 坐标转换算法 10 | 11 | - 反距离加权插值 12 | 13 | - 利用构建规则网格(GRID) 计算体积 14 | 15 | - 最短路径 16 | 17 | - 纵断面计算 18 | 19 | - [根据K-means 分割多边形](https://blog.csdn.net/staHuri/article/details/86482967) 20 |  21 | 22 | - [最小外接矩形](#) 23 |  24 | - [凹点切割](https://blog.csdn.net/staHuri/article/details/88057017) 25 |  26 |  27 | 28 | - 最大内接圆 29 |  30 | - 最小外接圆 31 |  32 | 33 |  34 | - 拟合球体 35 | - 拟合球体 36 |  37 | - 拟合椭球 38 |  39 | 40 | - 多边形选择 41 | - 根据结点选择 42 |  43 | - 根据线段选择 44 |  45 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /pic/1555286763223.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/1555286763223.png -------------------------------------------------------------------------------- /pic/Kmean.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/Kmean.PNG -------------------------------------------------------------------------------- /pic/凹点切割1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/凹点切割1.png -------------------------------------------------------------------------------- /pic/凹点切割2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/凹点切割2.jpg -------------------------------------------------------------------------------- /pic/凹点切割流程示意图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/凹点切割流程示意图.jpg -------------------------------------------------------------------------------- /pic/凹点延长线1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/凹点延长线1.png -------------------------------------------------------------------------------- /pic/凹点延长线2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/凹点延长线2.png -------------------------------------------------------------------------------- /pic/凹点计算.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/凹点计算.png -------------------------------------------------------------------------------- /pic/拟合球体.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/拟合球体.png -------------------------------------------------------------------------------- /pic/最.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/最.png -------------------------------------------------------------------------------- /pic/最大内接圆.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/最大内接圆.jpg -------------------------------------------------------------------------------- /pic/最小外接圆.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/最小外接圆.png -------------------------------------------------------------------------------- /pic/最小外接面.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/最小外接面.gif -------------------------------------------------------------------------------- /pic/面选择_线段.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/面选择_线段.png -------------------------------------------------------------------------------- /pic/面选择_结点.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huifer/planar_algorithm/884760e4768dc6d426c99bded29a6da45c172a0c/pic/面选择_结点.png -------------------------------------------------------------------------------- /python-planar-algorithm/拟合球体.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # __file__: 拟合球体 4 | # __date__: 5 | # __author__: huifer 6 | import numpy as np 7 | import math 8 | from matplotlib import pyplot as plt 9 | from mpl_toolkits.mplot3d import Axes3D 10 | import csv 11 | 12 | 13 | def qiuti(x_list, y_list, z_list): 14 | """ 15 | 球体计算 16 | :param x_list: 17 | :param y_list: 18 | :param z_list: 19 | :return: 20 | """ 21 | # 右侧矩阵 22 | x_list = np.array(x_list) 23 | y_list = np.array(y_list) 24 | z_list = np.array(z_list) 25 | 26 | right_mat = np.zeros((len(x_list), 4)) 27 | right_mat[:, 0] = x_list * 2 28 | right_mat[:, 1] = y_list * 2 29 | right_mat[:, 2] = z_list * 2 30 | right_mat[:, 3] = 1 31 | 32 | # 等号左侧 33 | left_mat = np.zeros((len(x_list), 1)) 34 | left_mat[:, 0] = (x_list * x_list) + (y_list * y_list) + (z_list * z_list) 35 | 36 | C, residules, rank, singval = np.linalg.lstsq(right_mat, left_mat) 37 | 38 | # 求半径 39 | t = (C[0] * C[0]) + (C[1] * C[1]) + (C[2] * C[2]) + C[3] 40 | radius = math.sqrt(t) 41 | return radius, C[0], C[1], C[2] 42 | 43 | 44 | def show_qiut(x_list, y_list, z_list): 45 | """ 46 | 三维展示球体 47 | :param x_list: 48 | :param y_list: 49 | :param z_list: 50 | :return: 51 | """ 52 | 53 | fig = plt.figure() 54 | ax = plt.axes(projection='3d') 55 | 56 | # 计算拟合 57 | r, x0, y0, z0 = qiuti(x_list, y_list, z_list) 58 | print("圆心:", [x0[0], y0[0], z0[0]]) 59 | print("半径:", r) 60 | 61 | u, v = np.mgrid[0:2 * np.pi:20j, 0:np.pi:10j] 62 | 63 | x = np.cos(u) * np.sin(v) * r 64 | y = np.sin(u) * np.sin(v) * r 65 | z = np.cos(v) * r 66 | 67 | x = x + x0 68 | y = y + y0 69 | z = z + z0 70 | 71 | # 三维展示 72 | 73 | ax.scatter(x_list, y_list, z_list, zdir='z', s=20, c='b', rasterized=True) 74 | ax.plot_wireframe(x, y, z, color="r") 75 | 76 | ax.set_aspect('equal') 77 | 78 | plt.show() 79 | 80 | 81 | def write_csv(x, y, z): 82 | r, x0, y0, z0 = qiuti(x, y, z) 83 | 84 | with open('qiuti.csv', "w") as csv_file: 85 | csv_file.write("x,y,z,r\n") 86 | for x_, y_, z_ in zip(x, y, z): 87 | csv_file.write("{},{},{},{}\n".format(x_, y_, z_, 0.5)) 88 | 89 | csv_file.write("{},{},{},{}\n".format(x0[0], y0[0], z0[0], r)) 90 | pass 91 | 92 | 93 | if __name__ == '__main__': 94 | random_x = np.random.randint(0, 10, 30) 95 | random_y = np.random.randint(0, 10, 30) 96 | random_z = np.random.randint(0, 10, 30) 97 | 98 | show_qiut(x_list=random_x, y_list=random_y, z_list=random_z) 99 | write_csv(random_x, random_y, random_z) 100 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/AverageWidthAverageLength.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | /** 4 | *
Title : AverageWidthAverageLength
5 | *Description : 多边形(非回型)平均宽度 平均长度
6 | * 7 | * @author huifer 8 | * @date 2019-01-14 9 | */ 10 | public interface AverageWidthAverageLength { 11 | 12 | /** 13 | * 平均宽度 14 | * 15 | * @param count 分成多少分 16 | * @param wkt polygon wkt 描述 17 | * @return 平均宽度 18 | */ 19 | double calcAverageWidth(int count, String wkt); 20 | 21 | 22 | /** 23 | * 平均长度 24 | * 25 | * @param count 分成多少分 26 | * @param wkt polygon wkt 描述 27 | * @return 平均长度 28 | */ 29 | double calcAverageLength(int count, String wkt); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/CuttingConcavePolygon.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import com.huifer.planar.aset.algo.impl.concave.ConcaveSplit.TroughLineWithSort; 4 | import org.locationtech.jts.geom.Polygon; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | *Title : CuttingConcavePolygon
10 | *Description : 凹多边形的切割
11 | * 12 | * @author huifer 13 | * @date 2019-03-01 14 | */ 15 | public interface CuttingConcavePolygon { 16 | 17 | /** 18 | * 凹多边形的凸多边形拆分 19 | * 20 | * @param polygon 凹多边形 21 | * @return {@link TroughLineWithSort} 22 | * @throws Exception 23 | */ 24 | ListTitle : GraphInterface
11 | *Description : 点与线的关系
12 | * 13 | * @author huifer 14 | * @date 2018/12/12 15 | */ 16 | public interface GraphInterface { 17 | 18 | /** 19 | * 右手法则计算 线与点的关系 20 | * 21 | * @param point point 22 | * @param polyline polyline 23 | * @return {@link com.huifer.planar.aset.entity.OvlayerEnum} 24 | */ 25 | OvlayerEnum rightHandRule(MyPoint point, MyLine polyline); 26 | 27 | /** 28 | * 计算 两条线的交点 29 | * 30 | * @param linea 直线1 31 | * @param lineb 直线2 32 | * @return {@link com.huifer.planar.aset.entity.MyPoint} 33 | */ 34 | MyPoint getIntersectionPoint(MyLine linea, MyLine lineb); 35 | 36 | /** 37 | * 点和面的关系 38 | * 39 | * @param point point 40 | * @param polygon polygon 41 | * @return {@link com.huifer.planar.aset.entity.OvlayerEnum} 42 | */ 43 | OvlayerEnum pointWithPolygon(MyPoint point, MyPolygon polygon); 44 | 45 | /** 46 | * 线是否相交 47 | * 48 | * @param linea 直线1 49 | * @param lineb 直线2 50 | * @return int 51 | */ 52 | int lineWithLine(MyLine linea, MyLine lineb); 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/KmeanPolygonSplitInterface.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import com.huifer.planar.aset.entity.KmeanPolygonResult; 4 | import org.locationtech.jts.io.ParseException; 5 | 6 | /** 7 | *Title : KmeanPolygonSplitInterface
8 | *Description : kmean 切割面
9 | * 10 | * @author huifer 11 | * @date 2019-01-16 12 | */ 13 | public interface KmeanPolygonSplitInterface { 14 | 15 | /** 16 | * 切割面 17 | * 18 | * @param wkt polygon wkt描述 19 | * @param setp 随机点数量 20 | * @param k 切几个面 21 | * @return {@link com.huifer.planar.aset.entity.KmeanPolygonResult} 22 | * @throws ParseException 异常 23 | */ 24 | KmeanPolygonResult splitPolygon(String wkt, int setp, int k) throws ParseException; 25 | 26 | 27 | /** 28 | * shp 切割 29 | * 30 | * @param path 文件位置 31 | * @param splitFiled 切分字段 32 | * @return 切分结果 33 | * @throws Exception 异常 34 | */ 35 | Object splitPolygonWithShp(String path, String splitFiled) throws Exception; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/LineOverInterface.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import com.huifer.planar.aset.entity.MyLine; 4 | import com.huifer.planar.aset.entity.MyPoint; 5 | import com.huifer.planar.aset.entity.SortPoint; 6 | 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import java.util.Map; 10 | 11 | /** 12 | *Title : LineOverInterface
13 | *Description : 直线两侧排序
14 | * 15 | * @author huifer 16 | * @date 2018/12/17 17 | */ 18 | public interface LineOverInterface { 19 | 20 | /** 21 | * 直线两侧排序 22 | * 23 | * @param line 直线 24 | * @param points 点列表 25 | * @return 排序后结果 26 | */ 27 | MapTitle : MinimumEnclosingInterface
9 | *Description : 最小外接矩形
10 | * 11 | * @author huifer 12 | * @date 2019-02-25 13 | */ 14 | public interface MinimumEnclosingInterface { 15 | 16 | /** 17 | * 最小外接矩形 18 | * 19 | * @param polygon 需要计算的面 20 | * @return 最小外接矩形结果 21 | */ 22 | Polygon getMinRect(Geometry polygon); 23 | 24 | /** 25 | * 最大内接圆 26 | * 27 | * @param pg 面 28 | * @return 最大外接圆圆心 29 | */ 30 | Point getInCirclePoint(Polygon pg); 31 | 32 | /** 33 | * 最大内接圆 34 | * 35 | * @param pg 面 36 | * @return 最大外接圆 37 | */ 38 | Polygon getInCirclePolygon(Polygon pg); 39 | 40 | 41 | /** 42 | * 最小外接圆 43 | * 44 | * @param pg 面 45 | * @return 最小外接圆 46 | */ 47 | Polygon getMinimumCircumscribedCircle(Polygon pg); 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/MyRectangleOver.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import com.huifer.planar.aset.entity.MyRectangle; 4 | 5 | /** 6 | *Title : MyRectangleOver
7 | *Description : 矩阵拓扑
8 | * 9 | * @author huifer 10 | * @date 2018/12/20 11 | */ 12 | public interface MyRectangleOver { 13 | 14 | /** 15 | * 计算两个矩形相交面积 16 | * 17 | * @param r1 矩形1 18 | * @param r2 矩形2 19 | * @return 相交面积 20 | */ 21 | double calcAreaIntersectionRectangles(MyRectangle r1, MyRectangle r2); 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/NearbyInterface.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import org.locationtech.jts.geom.Point; 4 | import org.locationtech.jts.geom.Polygon; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 描述: 10 | * 邻近算法 11 | * 12 | * @author: huifer 13 | * @date: 2019-11-13 14 | */ 15 | public interface NearbyInterface { 16 | /** 17 | * 点附近的面 18 | * 19 | * @param point 点 20 | * @param polygonList 面集合 21 | * @return 最近的面 22 | */ 23 | Polygon pointNearbyPolygon(Point point, ListTitle : PolygonAngleInterface
8 | *Description : 面角度计算
9 | * 10 | * @author huifer 11 | * @date 2019-01-28 12 | */ 13 | public interface PolygonAngleInterface { 14 | 15 | 16 | /** 17 | * polygon每一个线段角度计算 18 | * 19 | * @param wkt polygon WKT描述 20 | * @return {@link PolygonAngleResult} 21 | * @throws ParseException 异常 22 | */ 23 | PolygonAngleResult polygonWktAngle(String wkt) throws ParseException; 24 | 25 | 26 | /** 27 | * 删除输入角度的值 28 | * 29 | * @param wkt polygon WKT描述 30 | * @param angle 角度 31 | * @return {@link PolygonAngleResult} 32 | * @throws ParseException 33 | */ 34 | PolygonAngleResult polygonWktAngleMerge(String wkt, Double angle) throws ParseException; 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/PolygonCenterOfGravityInterface.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import org.locationtech.jts.geom.Point; 4 | import org.locationtech.jts.geom.Polygon; 5 | 6 | /** 7 | *Title : PolygonCenterOfGravityInterface
8 | *Description : 多边形重心
9 | * 10 | * @author huifer 11 | * @date 2019-02-21 12 | */ 13 | public interface PolygonCenterOfGravityInterface { 14 | 15 | /** 16 | * 计算凸多边形重心 17 | * 18 | * @param covenPolygon 多边形 19 | * @return 重心点 20 | */ 21 | Point calcGravityPointOfCovenPolygon(Polygon covenPolygon); 22 | 23 | 24 | /** 25 | * 计算凹多边形中心 26 | * 27 | * @param concavePolygon 凹多边形 28 | * @return 重心点 29 | */ 30 | Point calcGravityPointOfConcavePolygon(Polygon concavePolygon); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/PolygonRemoveNodeInterface.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo; 2 | 3 | import com.huifer.planar.aset.entity.PolygonRemoveNodeResult; 4 | import org.locationtech.jts.geom.Geometry; 5 | import org.locationtech.jts.geom.Polygon; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 描述: 面上删除节点值 11 | * 12 | * @author huifer 13 | * @date 2019-02-13 14 | */ 15 | public interface PolygonRemoveNodeInterface { 16 | 17 | /** 18 | * 面上删除节点,根据节点间距 19 | * 20 | * @param geometryList polygon list 21 | * @param tolerance 容差 22 | * @return {@link Geometry} 删除点列表 23 | * @throws Exception 异常 24 | */ 25 | PolygonRemoveNodeResult polygonRemoveNodeByLength(ListTitle : RamerDouglasPeuckerInterfaceCore
7 | *Description : 拉默-道格拉斯-普克算法 rdp
8 | * 9 | * @author huifer 10 | * @date 2019-01-24 11 | */ 12 | public interface RamerDouglasPeuckerInterface { 13 | 14 | /** 15 | * dp算法 16 | * 17 | * @param list 点集合 18 | * @param threshold 容差 19 | * @return 压缩后结果 20 | */ 21 | ListTitle : RemoveNodesInterface
10 | *Description : 移除节点通用级别
11 | * 12 | * @author huifer 13 | * @date 2019-02-25 14 | */ 15 | public interface RemoveNodesInterface { 16 | 17 | /** 18 | * 移除节点 19 | * 20 | * @param geometry 需要移除节点的坐标 21 | * @param coordinate 移除节点坐标 22 | * @return 移除后geometry 23 | */ 24 | Geometry remove(Geometry geometry, Coordinate coordinate); 25 | 26 | 27 | /** 28 | * 几何图形删除节点组 29 | * 30 | * @param geometry 需要移除节点的坐标 31 | * @param coordinateList 移除节点坐标集合 32 | * @return 移除后geometry 33 | */ 34 | Geometry removeList(Geometry geometry, ListTitle : VoronoiInterface
12 | *Description : 泰森多边形相关
13 | * 14 | * @author huifer 15 | * @date 2019-01-16 16 | */ 17 | public interface VoronoiInterface { 18 | 19 | /** 20 | * 泰森多边形 21 | * 22 | * @param coords 坐标值 23 | * @return 泰森多边形面集合 24 | */ 25 | ListTitle : MinimumBoundingRectangle
11 | *Description : 最小外包矩形
12 | * 13 | * @author huifer 14 | * @date 2019-02-22 15 | */ 16 | public class MinimumBoundingRectangle { 17 | 18 | /** 19 | * 最小外接矩形的获取 20 | * 21 | * @param geom 需要计算的面 22 | * @param gf 构造器 23 | * @return 最小外接矩形结果 24 | */ 25 | public static Polygon get(Geometry geom, GeometryFactory gf) { 26 | Geometry hull = (new ConvexHull(geom)).getConvexHull(); 27 | if (!(hull instanceof Polygon)) { 28 | return null; 29 | } 30 | Polygon convexHull = (Polygon) hull; 31 | // System.out.println(convexHull); 32 | 33 | // 直接使用中心值 34 | Coordinate c = geom.getCentroid().getCoordinate(); 35 | // System.out.println("==============旋转基点=============="); 36 | // System.out.println(new GeometryFactory().createPoint(c)); 37 | // System.out.println("==============旋转基点=============="); 38 | Coordinate[] coords = convexHull.getExteriorRing().getCoordinates(); 39 | 40 | double minArea = Double.MAX_VALUE; 41 | double minAngle = 0; 42 | Polygon ssr = null; 43 | Coordinate ci = coords[0]; 44 | Coordinate cii; 45 | for (int i = 0; i < coords.length - 1; i++) { 46 | cii = coords[i + 1]; 47 | double angle = Math.atan2(cii.y - ci.y, cii.x - ci.x); 48 | Polygon rect = (Polygon) Rotation.get(convexHull, c, -1 * angle, gf).getEnvelope(); 49 | double area = rect.getArea(); 50 | // 此处可以将 rotationPolygon 放到list中求最小值 51 | // Polygon rotationPolygon = Rotation.delete(rect, c, angle, gf); 52 | // System.out.println(rotationPolygon); 53 | if (area < minArea) { 54 | minArea = area; 55 | ssr = rect; 56 | minAngle = angle; 57 | } 58 | ci = cii; 59 | } 60 | 61 | return Rotation.get(ssr, c, minAngle, gf); 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/impl/minrect/MinimumEnclosingCore.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo.impl.minrect; 2 | 3 | import com.huifer.planar.aset.algo.MinimumEnclosingInterface; 4 | import org.locationtech.jts.geom.*; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | *Title : MinimumEnclosingCore
11 | *Description : 最小外接矩形实现
12 | * 13 | * @author huifer 14 | * @date 2019-02-25 15 | */ 16 | public class MinimumEnclosingCore implements MinimumEnclosingInterface { 17 | 18 | 19 | /** 20 | * 最小外接矩形 21 | * 22 | * @param polygon 需要计算的面 23 | * @return 最小外接矩形结果 24 | */ 25 | @Override 26 | public Polygon getMinRect(Geometry polygon) { 27 | GeometryFactory gf = new GeometryFactory(); 28 | Polygon result = MinimumBoundingRectangle.get(polygon, gf); 29 | return result; 30 | } 31 | 32 | /** 33 | * 最大内接圆 34 | * 35 | * @param pg 面 36 | * @return 最大外接圆圆心 37 | */ 38 | @Override 39 | public Point getInCirclePoint(Polygon pg) { 40 | return MaximumInnerCircle.inCirclePoint(pg, 0.0001); 41 | } 42 | 43 | /** 44 | * 最大内接圆 45 | * 46 | * @param pg 面 47 | * @return 最大外接圆 48 | */ 49 | @Override 50 | public Polygon getInCirclePolygon(Polygon pg) { 51 | return MaximumInnerCircle.inCirclePolygon(pg, 0.0001); 52 | } 53 | 54 | /** 55 | * 最小外接圆 56 | * 57 | * @param pg 面 58 | * @return 最小外接圆 59 | */ 60 | @Override 61 | public Polygon getMinimumCircumscribedCircle(Polygon pg) { 62 | Coordinate[] cs = pg.getCoordinates(); 63 | ListTitle : WelzlAlgo
10 | *Description : 最小外接圆实现算法
11 | *https://en.wikipedia.org/wiki/Smallest-circle_problem
12 | * 13 | * @author huifer 14 | * @date 2019-03-13 15 | */ 16 | public class WelzlAlgo { 17 | 18 | 19 | /** 20 | * mec算法 21 | * 22 | * @param pointSet 点集合 23 | * @param maxId 最大ID 24 | * @return {@link MinCircle} 最小外接圆 25 | */ 26 | public static MinCircle mec(ListTitle : CuttingConcavePolygonImpl
12 | *Description :
13 | * 14 | * @author huifer 15 | * @date 2019-03-01 16 | */ 17 | public class CuttingConcavePolygonImpl implements CuttingConcavePolygon { 18 | 19 | @Override 20 | public ListTitle : MyRecatngleOverCore
10 | *Description : 矩形相交
11 | * 12 | * @author huifer 13 | * @date 2018/12/20 14 | */ 15 | public class MyRecatngleOverCore implements MyRectangleOver { 16 | 17 | LineOverInterface over = new LineOverCore(); 18 | 19 | 20 | /** 21 | * 计算两个矩形相交面积 22 | */ 23 | @Override 24 | public double calcAreaIntersectionRectangles(MyRectangle r1, MyRectangle r2) { 25 | if (r1 == null || r2 == null) { 26 | return -1; 27 | } 28 | double p1x = r1.getLowLeft().getX(); 29 | double p1y = r1.getLowLeft().getY(); 30 | 31 | double p2x = p1x + r1.getLength(); 32 | double p2y = p1y + r1.getWidth(); 33 | 34 | double p3x = r2.getLowLeft().getX(); 35 | double p3y = r2.getLowLeft().getY(); 36 | 37 | double p4x = p3x + r2.getLength(); 38 | double p4y = p3y + r2.getWidth(); 39 | if (p1x > p4x || p2x < p3x || p1y > p4y || p2y < p3y) { 40 | return 0; 41 | } 42 | double len = Math.min(p2x, p4x) - Math.max(p1x, p3x); 43 | double wid = Math.min(p2y, p4y) - Math.max(p1y, p3y); 44 | return len * wid; 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/algo/impl/polygon/RailCore.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.algo.impl.polygon; 2 | 3 | import com.huifer.planar.aset.algo.RailInterface; 4 | import com.huifer.planar.aset.entity.MyLine; 5 | import com.huifer.planar.aset.entity.MyPoint; 6 | import com.huifer.planar.aset.entity.MyPolygon; 7 | 8 | import java.util.ArrayList; 9 | 10 | /** 11 | *Title : RailCore
12 | *Description : 点面交集
13 | * 14 | * @author huifer 15 | * @date 2018/12/14 16 | */ 17 | public class RailCore implements RailInterface { 18 | 19 | @Override 20 | public boolean isInPolygon(MyPoint point, MyPolygon polygon) { 21 | boolean result = false; 22 | ArrayListTitle : ConcavePolygonCut
14 | *Description : 凹多边形切割结果类
15 | * 16 | * @author huifer 17 | * @date 2019-03-08 18 | */ 19 | @Data 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class ConcavePolygonCut { 23 | 24 | /** 25 | * 原始面 26 | */ 27 | private Polygon originalPolygon; 28 | /** 29 | * 凹点 30 | */ 31 | private ListTitle : FourBox
9 | *Description : 四至
10 | * 11 | * @author huifer 12 | * @date 2019-01-11 13 | */ 14 | @Data 15 | @NoArgsConstructor 16 | @AllArgsConstructor 17 | public class FourBox { 18 | 19 | private double leftX; 20 | private double leftY; 21 | private double rightX; 22 | private double rightY; 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/entity/KmeanPolygonResult.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | import org.locationtech.jts.geom.Geometry; 7 | import org.locationtech.jts.geom.Point; 8 | 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | *Title : KmeanPolygonResult
14 | *Description : Kmean+泰森多边形平分多边形结果
15 | * 16 | * @author huifer 17 | * @date 2019-01-16 18 | */ 19 | @Data 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class KmeanPolygonResult { 23 | 24 | /** 25 | * 原始平面 26 | */ 27 | private Geometry polygon; 28 | /** 29 | * 随机点集合 30 | */ 31 | private ArrayListTitle : Kmeans
8 | *Description : Kmeans 聚合
9 | * 10 | * @author huifer 11 | * @date 2019-01-15 12 | */ 13 | @Data 14 | public class Kmeans { 15 | 16 | /*** 17 | * 聚合总量 18 | */ 19 | private int n; 20 | /*** 21 | * 数据集合 22 | */ 23 | private double[][] points; 24 | /** 25 | * 簇族数量 26 | */ 27 | private int k; 28 | 29 | /** 30 | * 中心集合 31 | */ 32 | private double[][] centroids; 33 | /** 34 | * 分组后组id 35 | */ 36 | private int[] assignments; 37 | 38 | public Kmeans(double[][] points, int k) { 39 | this.n = points.length; 40 | this.points = points; 41 | this.k = k; 42 | this.centroids = new double[k][2]; 43 | init(); 44 | } 45 | 46 | /** 47 | * 求得分组数据 48 | */ 49 | public void init() { 50 | EKmeans eKmeans = new EKmeans(centroids, points); 51 | eKmeans.setIteration(128); 52 | eKmeans.setEqual(true); 53 | eKmeans.setDistanceFunction(EKmeans.EUCLIDEAN_DISTANCE_FUNCTION); 54 | eKmeans.run(); 55 | int[] assignments = eKmeans.getAssignments(); 56 | this.assignments = assignments; 57 | double[][] centroids = eKmeans.getCentroids(); 58 | this.centroids = centroids; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/entity/MyPolygon.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.entity; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.util.ArrayList; 8 | 9 | /** 10 | *Title : MyPolygon
11 | *Description : 平面
12 | * 13 | * @author huifer 14 | * @date 2018/12/11 15 | */ 16 | @Data 17 | @AllArgsConstructor 18 | @NoArgsConstructor 19 | public class MyPolygon { 20 | 21 | private ArrayListTitle : MyRectangle
13 | *Description : 矩形
14 | * 15 | * @author huifer 16 | * @date 2018/12/20 17 | */ 18 | @Data 19 | @ToString 20 | @NoArgsConstructor 21 | public class MyRectangle implements ComparableTitle : PolygonAngleResult
14 | *Description : polygon 角度计算结果
15 | * 16 | * @author huifer 17 | * @date 2019-01-28 18 | */ 19 | @Data 20 | @NoArgsConstructor 21 | @AllArgsConstructor 22 | public class PolygonAngleResult { 23 | 24 | 25 | private ListTitle : PolygonRemoveNodeResult
18 | *Description : 面移除节点结果接收类
19 | * 20 | * @author huifer 21 | * @date 2019-02-15 22 | */ 23 | @Data 24 | @NoArgsConstructor 25 | @AllArgsConstructor 26 | @ToString 27 | public class PolygonRemoveNodeResult { 28 | 29 | /** 30 | * 异常点集合 31 | */ 32 | private SetTitle : PublicRadial
10 | *Description : 射线
11 | * 12 | * @author huifer 13 | * @date 2019-03-11 14 | */ 15 | @Data 16 | @NoArgsConstructor 17 | @ToString 18 | public class PublicRadial { 19 | /** 20 | * 射线起点 21 | */ 22 | private Point startPoint; 23 | /** 24 | * 射线终点 25 | */ 26 | private Point endPoint; 27 | 28 | 29 | /** 30 | * 直线方程系数A 31 | */ 32 | private double A; 33 | /** 34 | * 直线方程系数B 35 | */ 36 | private double B; 37 | /** 38 | * 直线方程常量C 39 | */ 40 | private double C; 41 | 42 | 43 | public PublicRadial(Point startPoint, Point endPoint) { 44 | this.startPoint = startPoint; 45 | this.endPoint = endPoint; 46 | 47 | double AA = endPoint.getY() - startPoint.getY(); 48 | double BB = startPoint.getX() - endPoint.getX(); 49 | double CC = endPoint.getX() * startPoint.getY() - startPoint.getX() * endPoint.getY(); 50 | this.A = AA; 51 | this.B = BB; 52 | this.C = CC; 53 | } 54 | 55 | 56 | public double calcXX(double y) { 57 | return (-B * y - C) / A; 58 | } 59 | 60 | public double calcYY(double x) { 61 | return ((-A * x) - C) / B; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/entity/RefObject.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.entity; 2 | 3 | /** 4 | * 矩阵运算 结果 5 | * 6 | * @author huifer 7 | */ 8 | public final class RefObjectTitle : ResultShortestPath
10 | *Description : DijlstraInterface 结果集合
11 | * 12 | * @author huifer 13 | * @date 2018/12/12 14 | */ 15 | @Data 16 | @ToString 17 | public class ResultShortestPath { 18 | 19 | private double length; 20 | private ListTitle : SortPoint
8 | *Description : 排序点
9 | * 10 | * @author huifer 11 | * @date 2018/12/17 12 | */ 13 | @ToString 14 | @Data 15 | public class SortPoint extends MyPoint { 16 | 17 | private OvlayerEnum leftOrRight; 18 | /** 19 | * 点编号 20 | */ 21 | private int leftOrRightCode; 22 | /** 23 | * 投影点 24 | */ 25 | private MyPoint projectivePoint; 26 | /** 27 | * 到第一个点的距离 28 | */ 29 | private double distanceWithP1; 30 | 31 | public SortPoint() { 32 | } 33 | 34 | public SortPoint(double x, double y) { 35 | super(x, y); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/factory/MyGeoFactory.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.factory; 2 | 3 | import com.huifer.planar.aset.entity.MyLine; 4 | import com.huifer.planar.aset.entity.MyPoint; 5 | 6 | /** 7 | *Title : MyGeoFactory
8 | *Description : geo工厂
9 | * 10 | * @author huifer 11 | * @date 2018/12/14 12 | */ 13 | public class MyGeoFactory { 14 | 15 | public MyPoint createPoint(double x, double y) { 16 | return new MyPoint(x, y); 17 | } 18 | 19 | public MyLine createLine(MyPoint p1, MyPoint p2) { 20 | return new MyLine(p1, p2); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/coortrans/lib/AllData.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.coortrans.lib; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | *Title : AllData
8 | *Description : 数据整合
9 | * 10 | * @author huifer 11 | * @date 2018/11/12 12 | */ 13 | public class AllData { 14 | 15 | public Ellipsoid ellipsoid; 16 | public double l0; 17 | public ListTitle : Ellipsoid
5 | *Description : 椭球
6 | * 7 | * @author huifer 8 | * @date 2018/11/12 9 | */ 10 | public class Ellipsoid { 11 | 12 | 13 | /** 14 | * 长半轴 15 | */ 16 | public double a; 17 | 18 | /*** 19 | * 扁率 20 | */ 21 | public double f; 22 | 23 | /** 24 | * 第一偏心率的平方 25 | */ 26 | public double eccSq; 27 | 28 | /** 29 | * 第二偏心率的平方 30 | */ 31 | public double ecc2Sq; 32 | 33 | /** 34 | * m0 35 | */ 36 | public double m0; 37 | 38 | 39 | public Ellipsoid() { 40 | a = 6378137.0; 41 | f = 0.335281066475e-2; 42 | } 43 | 44 | /*** 45 | * 椭球构造 46 | * @param a 长半轴 47 | * @param invf f 48 | */ 49 | public Ellipsoid(double a, double invf) { 50 | this.a = a; 51 | f = 1 / invf; 52 | init(); 53 | } 54 | 55 | void init() { 56 | double b = a * (1 - f); 57 | eccSq = (a * a - b * b) / a / a; 58 | ecc2Sq = (a * a - b * b) / b / b; 59 | m0 = a * (1 - eccSq); 60 | } 61 | 62 | /*** 63 | * 计算W 64 | * @param b 纬度(以弧度为单位) 65 | * @return 66 | */ 67 | public double w(double b) { 68 | double w = Math.sqrt(1 - eccSq * Math.pow(Math.sin(b), 2)); 69 | return w; 70 | } 71 | 72 | /*** 73 | * 计算eta 74 | * @param b 纬度(以弧度为单位) 75 | * @return 76 | */ 77 | public double eta(double b) { 78 | double eta = Math.sqrt((ecc2Sq * Math.pow(Math.cos(b), 2))); 79 | return eta; 80 | } 81 | 82 | 83 | /*** 84 | * 计算tan 85 | * @param b 纬度(以弧度为单位) 86 | * @return 87 | */ 88 | public double tan(double b) { 89 | return Math.tan(b); 90 | } 91 | 92 | /*** 93 | * 计算 卯酉圈的曲率半径N 94 | * @param b 纬度(以弧度为单位) 95 | * @return 96 | */ 97 | public double n(double b) { 98 | double w = w(b); 99 | return a / w; 100 | } 101 | 102 | /*** 103 | * 子午圈曲率半径 m 104 | * @param b 105 | * @return 106 | */ 107 | public double m(double b) { 108 | double over = a * (1 - eccSq); 109 | double w = w(b); 110 | return over / (w * w * w); 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/coortrans/lib/PointInfo.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.coortrans.lib; 2 | 3 | /** 4 | *Title : PointInfo
5 | *Description : 点信息
6 | * 7 | * @author huifer 8 | * @date 2018/11/12 9 | */ 10 | public class PointInfo { 11 | 12 | public String name; 13 | /** 14 | * 大地坐标系b 15 | */ 16 | public double b; 17 | /** 18 | * 大地坐标系l 19 | */ 20 | public double l; 21 | /** 22 | * 大地坐标系h 23 | */ 24 | public double h; 25 | /** 26 | * 空间直角坐标系 x 27 | */ 28 | public double x; 29 | /** 30 | * 空间直角坐标系 y 31 | */ 32 | public double y; 33 | /** 34 | * 空间直角坐标系 z 35 | */ 36 | public double z; 37 | /** 38 | * 高斯平面直角坐标系 x 39 | */ 40 | public double gsx; 41 | /** 42 | * 高斯平面直角坐标系 y 43 | */ 44 | public double gsy; 45 | 46 | 47 | @Override 48 | public String toString() { 49 | return "PointInfo{" + 50 | "name='" + name + '\'' + 51 | ", b=" + b + 52 | ", l=" + l + 53 | ", h=" + h + 54 | ", x=" + x + 55 | ", y=" + y + 56 | ", z=" + z + 57 | ", gsx=" + gsx + 58 | ", gsy=" + gsy + 59 | '}'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/coortrans/lib/Position.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.coortrans.lib; 2 | 3 | /** 4 | *Title : Position
5 | *Description : 三维坐标转换
6 | * 7 | * @author huifer 8 | * @date 2018/11/12 9 | */ 10 | public class Position { 11 | 12 | private Ellipsoid ellipsoid; 13 | 14 | public Position(Ellipsoid ellipsoid) { 15 | this.ellipsoid = ellipsoid; 16 | } 17 | 18 | 19 | /*** 20 | * 大地测量转换为笛卡尔坐标 21 | * @param lat 纬度 22 | * @param lon 经度 23 | * @param height 高度 24 | * @return 笛卡尔坐标系 xyz 25 | */ 26 | public double[] geodetic2Cartesian(double lat, double lon, double height) { 27 | double x, y, z; 28 | 29 | double n = ellipsoid.n(lat); 30 | double slat = Math.sin(lat); 31 | double clat = Math.cos(lat); 32 | x = (n + height) * clat * Math.cos(lon); 33 | y = (n + height) * clat * Math.sin(lon); 34 | z = (n * (1 - ellipsoid.eccSq) + height) * slat; 35 | return new double[]{x, y, z}; 36 | } 37 | 38 | /** 39 | * 笛卡尔坐标系转换 大地坐标系 40 | * 41 | * @param x x 42 | * @param y y 43 | * @param z z 44 | * @return 大地坐标系值 45 | */ 46 | public double[] cartesian2Geodetic(double x, double y, double z) { 47 | double lat = 0; 48 | double lon = 0; 49 | double height = 0; 50 | double positionTolerance = 0.0001; 51 | 52 | double p, slat, n, htold, latold; 53 | 54 | p = Math.sqrt(x * x + y * y); 55 | if (p < positionTolerance) { 56 | lat = (z > 0 ? 90.0 : -90.0); 57 | lon = 0; 58 | height = Math.abs(z - ellipsoid.a * Math.sqrt(1 - ellipsoid.eccSq)); 59 | } else { 60 | lat = Math.atan2(z, p); 61 | height = 0; 62 | for (int i = 0; i < 5; i++) { 63 | slat = Math.sin(lat); 64 | n = ellipsoid.n(lat); 65 | htold = height; 66 | height = p / Math.cos(lat) - n; 67 | latold = lat; 68 | lat = Math.atan2(z + n * ellipsoid.eccSq * slat, p); 69 | if (Math.abs(lat - latold) < 1.0e-9 70 | && Math.abs(height - htold) < 1.0e-9 * ellipsoid.a) { 71 | break; 72 | } 73 | lon = Math.atan2(y, x); 74 | { 75 | if (lon < 0.0) { 76 | lon += 2 * Math.PI; 77 | } 78 | } 79 | } 80 | } 81 | return new double[]{lat, lon, height}; 82 | } 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/coortrans/lib/Rad2Dms.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.coortrans.lib; 2 | 3 | /** 4 | *Title : Rad2Dms
5 | *Description : rad dms 互相转换
6 | * 7 | * @author huifer 8 | * @date 2018/11/12 9 | */ 10 | public class Rad2Dms { 11 | 12 | /*** 13 | * rad 转 dms 14 | * @param rad 15 | * @return double 16 | */ 17 | public static double rad2dms(double rad) { 18 | double dms = 0; 19 | double sec = 0; 20 | int deg = 0; 21 | int minu = 0; 22 | int sign = 1; 23 | if (rad < 0) { 24 | sign = -1; 25 | rad = -rad; 26 | } 27 | dms = rad / Math.PI * 180; 28 | deg = (int) Math.floor(dms); 29 | minu = (int) Math.floor((dms - deg) * 60.0); 30 | 31 | sec = (dms - deg - minu / 60.0) * 3600.0; 32 | dms = deg + minu / 100.0 + sec / 10000.0; 33 | dms = sign * dms; 34 | 35 | return dms; 36 | } 37 | 38 | 39 | /*** 40 | * dms 转 rad 41 | * @param dms 42 | * @return double 43 | */ 44 | public static double dms2rad(double dms) { 45 | int sign = 1; 46 | double rad = 0; 47 | double sec = 0; 48 | int deg = 0; 49 | int minu = 0; 50 | if (dms < 0) { 51 | sign = -1; 52 | dms = -dms; 53 | } 54 | deg = (int) Math.floor(dms); 55 | minu = (int) Math.floor((dms - deg) * 100.0); 56 | 57 | sec = (dms - deg - minu / 100.0) * 10000; 58 | rad = deg + minu / 60.0 + sec / 3600.0; 59 | rad = rad / 180.0 * Math.PI; 60 | rad = rad * sign; 61 | return rad; 62 | } 63 | 64 | /** 65 | * rad 转 dms 字符串 66 | * 67 | * @return str 68 | */ 69 | public static String rad2Str(double rad) { 70 | String res = ""; 71 | double d = rad / Math.PI * 180; 72 | String sign = ""; 73 | if (d < 0) { 74 | sign = "-"; 75 | } 76 | d = Math.abs(d); 77 | double dd, mm, ss; 78 | dd = Math.floor(d); 79 | mm = Math.floor((d - dd) * 60.0); 80 | ss = (d - dd - mm / 60.0) * 3600.0; 81 | res = sign + dd + "°" + mm + "′" + ss + "″"; 82 | return res; 83 | } 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/coortrans/坐标数据.txt: -------------------------------------------------------------------------------- 1 | a,6378137.000 2 | 1/f,298.3 3 | L0,111 4 | 5 | Q71,36.082771,109.191366,5533.025 6 | P91,33.445550,110.154237,4785.906 7 | Q42,38.372964,108.023609,5453.323 8 | Q34,39.305664,111.361612,5800.386 9 | B99,37.264007,108.385066,5557.617 10 | A89,37.371094,112.321633,5282.713 11 | P90,36.035483,111.145753,5550.860 12 | P60,33.334965,109.295619,5496.801 13 | Q89,35.411290,112.303315,5625.113 14 | P72,36.456890,112.47257,4566.878 15 | A05,38.085189,109.182573,4712.183 16 | A46,35.221248,110.24663,5220.175 17 | Q03,36.182447,112.254924,5426.659 -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/fanjuli/InverseDistanceCore.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.fanjuli; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Comparator; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | 10 | /** 11 | *Title : InverseDistanceCore
12 | *Description : 运行工具
13 | * 14 | * @author huifer 15 | * @date 2018/11/12 16 | */ 17 | @Slf4j 18 | public class InverseDistanceCore { 19 | 20 | public static void main(String[] args) { 21 | ReadHelper readHelper = new ReadHelper( 22 | "E:\\mck\\planar_algorithm\\src\\main\\java\\com\\huifer\\planar\\aset\\mappingalgo\\fanjuli\\测站坐标.txt"); 23 | ListTitle : MyPoint
5 | *Description : 测站坐标点
6 | * 7 | * @author huifer 8 | * @date 2018/11/12 9 | */ 10 | public class MyPoint { 11 | 12 | private String id; 13 | private double x; 14 | private double y; 15 | private double z; 16 | private double dist; 17 | 18 | public MyPoint(String id, double x, double y, double z) { 19 | this.id = id; 20 | this.x = x; 21 | this.y = y; 22 | this.z = z; 23 | } 24 | 25 | public MyPoint() { 26 | x = y = z = dist = 0; 27 | } 28 | 29 | public String getId() { 30 | return id; 31 | } 32 | 33 | public double getX() { 34 | return x; 35 | } 36 | 37 | public double getY() { 38 | return y; 39 | } 40 | 41 | public double getZ() { 42 | return z; 43 | } 44 | 45 | public void setZ(double z) { 46 | this.z = z; 47 | } 48 | 49 | public double getDist() { 50 | return dist; 51 | } 52 | 53 | public void setDist(double dist) { 54 | this.dist = dist; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "MyPoint{" + 60 | "id='" + id + '\'' + 61 | ", x=" + x + 62 | ", y=" + y + 63 | ", z=" + z + 64 | ", dist=" + dist + 65 | '}'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/fanjuli/ReadHelper.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.fanjuli; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.FileInputStream; 5 | import java.io.InputStreamReader; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | /** 10 | *Title : ReadHelper
11 | *Description : 读文件工具
12 | * 13 | * @author huifer 14 | * @date 2018/11/12 15 | */ 16 | public class ReadHelper { 17 | 18 | 19 | private ListTitle : GeoCalc
5 | *Description : 坐标计算
6 | * 7 | * @author huifer 8 | * @date 2018/11/14 9 | */ 10 | public class GeoCalc { 11 | 12 | /** 13 | * 叉积 14 | */ 15 | public static double crossMul(Vector v1, Vector v2) { 16 | return v1.x * v2.y - v1.y * v2.x; 17 | } 18 | 19 | /*** 20 | * 点乘 21 | * @param v1 22 | * @param v2 23 | * @return 24 | */ 25 | public static double dotMul(Vector v1, Vector v2) { 26 | return v1.x * v2.x + v1.y * v2.y; 27 | } 28 | 29 | /** 30 | * 取模 31 | * 32 | * @param vector 33 | * @return 34 | */ 35 | public static double model(Vector vector) { 36 | return Math.sqrt(Math.pow(vector.x, 2) + Math.pow(vector.y, 2)); 37 | } 38 | 39 | /** 40 | * 计算体积 41 | * 42 | * @param grid 网格 43 | * @param baseHeight 基准高度 44 | * @return 体积 45 | */ 46 | public static double calcVolumn(Grid grid, double baseHeight) { 47 | double voumnSum = 0; 48 | for (int row = 0; row < grid.height; row++) { 49 | for (int col = 0; col < grid.width; col++) { 50 | GridCell cell = grid.gridCells[row][col]; 51 | if (cell.isInSide) { 52 | // double vol = (cell.Height - baseheight) * cell.SideLength * cell.SideLength; 53 | double vol = (cell.height - baseHeight) * cell.sideLength * cell.sideLength; 54 | voumnSum += vol; 55 | } 56 | } 57 | 58 | } 59 | 60 | return voumnSum; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/grid/lib/GridCell.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.grid.lib; 2 | 3 | /** 4 | *Title : GridCell
5 | *Description : 单元网格 矩阵
6 | * 7 | * @author huifer 8 | * @date 2018/11/14 9 | */ 10 | public class GridCell { 11 | 12 | /** 13 | * 左上角 14 | */ 15 | public PointInfo upLeft; 16 | /** 17 | * 右上角 18 | */ 19 | public PointInfo upRight; 20 | /** 21 | * 左下角 22 | */ 23 | public PointInfo downLeft; 24 | /** 25 | * 右下角 26 | */ 27 | public PointInfo downRight; 28 | 29 | /** 30 | * 边长 31 | */ 32 | public double sideLength; 33 | 34 | /** 35 | * 高 36 | */ 37 | public double height; 38 | 39 | /** 40 | * 是否在内部 41 | */ 42 | public boolean isInSide; 43 | 44 | @Override 45 | public String toString() { 46 | return "GridCell{" + 47 | "upLeft=" + upLeft + 48 | ", upRight=" + upRight + 49 | ", downLeft=" + downLeft + 50 | ", downRight=" + downRight + 51 | ", sideLength=" + sideLength + 52 | ", height=" + height + 53 | ", isInSide=" + isInSide + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/grid/lib/HeightCalc.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.grid.lib; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | *Title : HeightCalc
7 | *Description : 高度计算
8 | * 9 | * @author huifer 10 | * @date 2018/11/15 11 | */ 12 | public class HeightCalc { 13 | 14 | private Grid grid; 15 | private ListTitle : PointInfo
5 | *Description : 单点信息
6 | * 7 | * @author huifer 8 | * @date 2018/11/14 9 | */ 10 | public class PointInfo { 11 | 12 | /** 13 | * 点名 14 | */ 15 | public String name; 16 | /** 17 | * x 18 | */ 19 | public double x; 20 | /** 21 | * y 22 | */ 23 | public double y; 24 | /** 25 | * z 26 | */ 27 | public double h; 28 | /** 29 | * 角度 30 | */ 31 | public double angle; 32 | 33 | 34 | @Override 35 | public String toString() { 36 | return "PointInfo{" + 37 | "name='" + name + '\'' + 38 | ", x=" + x + 39 | ", y=" + y + 40 | ", h=" + h + 41 | ", angle=" + angle + 42 | '}'; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/grid/lib/ResultData.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.grid.lib; 2 | 3 | /** 4 | *Title : ResultData
5 | *Description : 结果数据
6 | * 7 | * @author huifer 8 | * @date 2018/11/15 9 | */ 10 | public class ResultData { 11 | 12 | /** 13 | * 基准高程 14 | */ 15 | public double baseHeight; 16 | 17 | /** 18 | * 领域比例 19 | */ 20 | public double neighbor; 21 | 22 | /** 23 | * 间距 24 | */ 25 | public double inteval; 26 | 27 | /** 28 | * 凸包 29 | */ 30 | public Convex convex; 31 | 32 | /** 33 | * 网格 34 | */ 35 | public Grid grid; 36 | 37 | /** 38 | * 体积 39 | */ 40 | public double volumn; 41 | 42 | /** 43 | * 列 44 | */ 45 | public Integer col; 46 | 47 | /** 48 | * 行 49 | */ 50 | public Integer row; 51 | 52 | 53 | @Override 54 | public String toString() { 55 | return "ResultData{" + 56 | "baseHeight=" + baseHeight + 57 | ", neighbor=" + neighbor + 58 | ", inteval=" + inteval + 59 | ", convex=" + convex + 60 | ", grid=" + grid + 61 | ", volumn=" + volumn + 62 | ", col=" + col + 63 | ", row=" + row + 64 | '}'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/grid/lib/Stack.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.grid.lib; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | *Title : Stack
8 | *Description : 堆
9 | * 10 | * @author huifer 11 | * @date 2018/11/14 12 | */ 13 | public class Stack { 14 | 15 | public ListTitle : Vector
5 | *Description : 节点数据
6 | * 7 | * @author huifer 8 | * @date 2018/11/14 9 | */ 10 | public class Vector { 11 | 12 | public double x; 13 | public double y; 14 | 15 | @Override 16 | public String toString() { 17 | return "Vector{" + 18 | "x=" + x + 19 | ", y=" + y + 20 | '}'; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/sortpath/Edge.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.sortpath; 2 | 3 | /** 4 | *Title : Edge
5 | *Description : 起点 , 终点 , 长度
6 | * 7 | * @author huifer 8 | * @date 2018/11/08 9 | */ 10 | public class Edge { 11 | 12 | /** 13 | * 起点 14 | */ 15 | public String start; 16 | /*** 17 | * 终点 18 | */ 19 | public String end; 20 | /*** 21 | * 距离 22 | */ 23 | public double length; 24 | 25 | 26 | public Edge(String line) { 27 | String[] split = line.split(","); 28 | start = split[0]; 29 | end = split[1]; 30 | length = Double.parseDouble(split[2]); 31 | } 32 | 33 | @Override 34 | public String toString() { 35 | return "Edge{" + 36 | "start='" + start + '\'' + 37 | ", end='" + end + '\'' + 38 | ", length=" + length + 39 | '}'; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/sortpath/Graph.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.sortpath; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | *Title : Digraph
8 | *Description : 图
9 | * 10 | * @author huifer 11 | * @date 2018/11/08 12 | */ 13 | public class Graph { 14 | 15 | public ListTitle : InverseDistanceCore
15 | *Description : sortpath 运行测试
16 | * 17 | * @author huifer 18 | * @date 2018/11/08 19 | */ 20 | @Slf4j 21 | public class SortPathRunt { 22 | 23 | public static void main(String[] args) throws Exception { 24 | 25 | /////////////// 读文件 26 | 27 | ListTitle : Vertex
7 | *Description : 顶点
8 | * 9 | * @author huifer 10 | * @date 2018/11/08 11 | */ 12 | public class Vertex { 13 | 14 | public String name; 15 | public double weight = 100000; 16 | 17 | 18 | public Vertex(String newName) { 19 | this.name = newName; 20 | } 21 | 22 | @Override 23 | public boolean equals(Object o) { 24 | if (this == o) { 25 | return true; 26 | } 27 | if (o == null || getClass() != o.getClass()) { 28 | return false; 29 | } 30 | Vertex vertex = (Vertex) o; 31 | return Double.compare(vertex.weight, weight) == 0 && 32 | Objects.equals(name, vertex.name); 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | return Objects.hash(name, weight); 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "Vertex{" + 43 | "name='" + name + '\'' + 44 | ", weight=" + weight + 45 | '}'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/sortpath/路径数据.txt: -------------------------------------------------------------------------------- 1 | 武大,地大,6 2 | 武大,光谷,11 3 | 武大,图书城,24 4 | 地大,光谷,4 5 | 地大,华科,8 6 | 光谷,地大,5 7 | 光谷,图书城,9 8 | 光谷,华科,7 9 | 图书城,光谷,11 10 | 华科,光谷,9 -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/trajectorycompression/Point.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.trajectorycompression; 2 | 3 | /** 4 | *Title : Point
5 | *Description : point
6 | * 7 | * @author huifer 8 | * @date 2018/10/19 9 | */ 10 | public class Point { 11 | 12 | private double id; 13 | private double x; 14 | private double y; 15 | 16 | public Point(Double id, double x, double y) { 17 | this.id = id; 18 | this.x = x; 19 | this.y = y; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return "Point{" + 25 | "id='" + id + '\'' + 26 | ", x=" + x + 27 | ", y=" + y + 28 | '}'; 29 | } 30 | 31 | public double getId() { 32 | return id; 33 | } 34 | 35 | public void setId(double id) { 36 | this.id = id; 37 | } 38 | 39 | public double getX() { 40 | return x; 41 | } 42 | 43 | public void setX(double x) { 44 | this.x = x; 45 | } 46 | 47 | public double getY() { 48 | return y; 49 | } 50 | 51 | public void setY(double y) { 52 | this.y = y; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/trajectorycompression/ReadText.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.trajectorycompression; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.InputStreamReader; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | /** 11 | *Title : ReadText
12 | *Description : 读文件
13 | * 14 | * @author huifer 15 | * @date 2018/10/19 16 | */ 17 | public class ReadText { 18 | 19 | public static void main(String[] argv) { 20 | String filePath = "E:\\mck\\planar_algorithm\\src\\main\\java\\com\\huifer\\planar\\aset\\mappingalgo\\trajectorycompression\\read.txt"; 21 | } 22 | 23 | public ListTitle : Zongduanmian
11 | *Description : Zongduanmian 运行测试
12 | * 13 | * @author huifer 14 | * @date 2018/11/13 15 | */ 16 | @Slf4j 17 | public class Zongduanmian { 18 | 19 | public static void main(String[] args) { 20 | ReadHelper readHelper = new ReadHelper( 21 | "E:\\mck\\planar_algorithm\\src\\main\\java\\com\\huifer\\planar\\aset\\mappingalgo\\Zongduanmian\\断面数据.txt"); 22 | AllData allData = readHelper.getAllData(); 23 | 24 | HeightCal heightCal = new HeightCal(allData.pointInfoList); 25 | 26 | allData.verticleSection.calcVerticleSection(heightCal, allData.h0); 27 | PointInfo p1 = allData.verticleSection.kPoint.get(0); 28 | PointInfo p2 = allData.verticleSection.kPoint.get(1); 29 | PointInfo p3 = allData.verticleSection.kPoint.get(2); 30 | 31 | CrossSection c1 = new CrossSection(p1, p2, allData.verticleSection.direction1); 32 | CrossSection c2 = new CrossSection(p2, p3, allData.verticleSection.direction2); 33 | 34 | c1.calcDataForCrossSection(heightCal, allData.h0); 35 | c2.calcDataForCrossSection(heightCal, allData.h0); 36 | 37 | c1.kPoint.name = "m"; 38 | c2.kPoint.name = "n"; 39 | allData.crossSections.add(c1); 40 | allData.crossSections.add(c2); 41 | // System.out.println(allData); 42 | log.info("纵断面 = {}", allData); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/zongduanmian/lib/AllData.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.zongduanmian.lib; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | *Title : AllData
8 | *Description : 数据集
9 | * 10 | * @author huifer 11 | * @date 2018/11/13 12 | */ 13 | public class AllData { 14 | 15 | /** 16 | * 离散点集合 17 | * {@link com.huifer.planar.aset.mappingalgo.zongduanmian.lib.PointInfo} 18 | */ 19 | public ListTitle : Dwh
5 | *Description : 距离\ 宽度\ 高度
6 | * 7 | * @author huifer 8 | * @date 2018/11/13 9 | */ 10 | public class Dwh { 11 | 12 | /*** 13 | * 距离 14 | */ 15 | private double distance; 16 | /** 17 | * 宽度 18 | */ 19 | private double weight; 20 | /*** 21 | * 高度 22 | */ 23 | private double height; 24 | 25 | public Dwh(double distance, double weight, double height) { 26 | this.distance = distance; 27 | this.weight = weight; 28 | this.height = height; 29 | } 30 | 31 | public Dwh() { 32 | } 33 | 34 | @Override 35 | public String toString() { 36 | return "Dwh{" + 37 | "distance=" + distance + 38 | ", weight=" + weight + 39 | ", height=" + height + 40 | '}'; 41 | } 42 | 43 | public double getDistance() { 44 | return distance; 45 | } 46 | 47 | public void setDistance(double distance) { 48 | this.distance = distance; 49 | } 50 | 51 | public double getWeight() { 52 | return weight; 53 | } 54 | 55 | public void setWeight(double weight) { 56 | this.weight = weight; 57 | } 58 | 59 | public double getHeight() { 60 | return height; 61 | } 62 | 63 | public void setHeight(double height) { 64 | this.height = height; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/zongduanmian/lib/HeightCal.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.mappingalgo.zongduanmian.lib; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | *Title : HeightCal
8 | *Description : 高度计算工具
9 | * 10 | * @author huifer 11 | * @date 2018/11/13 12 | */ 13 | public class HeightCal { 14 | 15 | /** 16 | * 点集 17 | */ 18 | ListTitle : PointInfo
7 | *Description : 离散点
8 | * 9 | * @author huifer 10 | * @date 2018/11/13 11 | */ 12 | public class PointInfo { 13 | 14 | public String name; 15 | public double xx; 16 | 17 | public double yy; 18 | public double hh; 19 | public double k; 20 | public String tag; 21 | 22 | @Override 23 | public boolean equals(Object o) { 24 | if (this == o) { 25 | return true; 26 | } 27 | if (o == null || getClass() != o.getClass()) { 28 | return false; 29 | } 30 | PointInfo pointInfo = (PointInfo) o; 31 | return Double.compare(pointInfo.xx, xx) == 0 && 32 | Double.compare(pointInfo.yy, yy) == 0 && 33 | Double.compare(pointInfo.hh, hh) == 0 && 34 | Double.compare(pointInfo.k, k) == 0 && 35 | Objects.equals(name, pointInfo.name) && 36 | Objects.equals(tag, pointInfo.tag); 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "PointInfo{" + 42 | "name='" + name + '\'' + 43 | ", x=" + xx + 44 | ", y=" + yy + 45 | ", h=" + hh + 46 | ", k=" + k + 47 | ", tag='" + tag + '\'' + 48 | '}'; 49 | } 50 | 51 | @Override 52 | public int hashCode() { 53 | return Objects.hash(name, xx, yy, hh, k, tag); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/mappingalgo/zongduanmian/断面数据.txt: -------------------------------------------------------------------------------- 1 | H0,10.000 2 | K0,K1,K2 3 | 4 | K0,4574.012 ,3358.300 ,12.922 5 | P01,4570.355 ,3382.210 ,10.558 6 | P02,4571.827 ,3372.090 ,10.619 7 | P03,4570.907 ,3362.574 ,10.771 8 | P04,4569.494 ,3355.660 ,14.233 9 | P05,4556.682 ,3361.789 ,16.660 10 | P06,4547.554 ,3364.421 ,17.352 11 | P07,4534.086 ,3370.041 ,17.158 12 | P08,4517.549 ,3376.080 ,17.345 13 | P09,4505.572 ,3383.182 ,15.637 14 | P10,4498.562 ,3390.196 ,13.033 15 | P11,4494.457 ,3390.748 ,10.963 16 | P12,4500.501 ,3391.959 ,13.085 17 | P13,4510.753 ,3382.485 ,14.083 18 | P14,4522.092 ,3378.296 ,14.356 19 | P15,4531.567 ,3373.371 ,15.047 20 | P16,4546.386 ,3367.159 ,15.794 21 | P17,4556.219 ,3362.776 ,16.082 22 | P18,4559.558 ,3362.461 ,15.678 23 | P19,4554.746 ,3366.571 ,17.609 24 | P20,4545.254 ,3372.596 ,19.024 25 | P21,4540.860 ,3376.395 ,19.223 26 | P22,4536.141 ,3378.766 ,19.502 27 | K1,4534.227 ,3380.195 ,19.925 28 | P23,4525.945 ,3383.019 ,18.152 29 | P24,4519.592 ,3385.587 ,18.060 30 | P25,4513.249 ,3391.514 ,18.302 31 | P26,4523.724 ,3389.414 ,18.811 32 | P27,4537.846 ,3387.734 ,18.239 33 | P28,4540.773 ,3379.044 ,18.344 34 | P29,4549.894 ,3382.932 ,16.482 35 | P30,4543.390 ,3387.292 ,16.594 36 | P31,4546.992 ,3381.416 ,16.637 37 | P32,4558.964 ,3370.594 ,16.666 38 | P33,4565.741 ,3367.802 ,13.835 39 | P34,4561.203 ,3375.941 ,13.732 40 | P35,4561.762 ,3385.330 ,13.068 41 | P36,4569.250 ,3376.133 ,12.032 42 | P37,4572.318 ,3372.975 ,10.908 43 | P38,4568.279 ,3386.945 ,11.014 44 | P39,4550.913 ,3394.728 ,10.462 45 | P40,4537.754 ,3400.079 ,10.427 46 | P41,4509.525 ,3411.290 ,10.478 47 | K2,4497.844 ,3403.422 ,10.836 48 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/DijkstraUtil.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils; 2 | 3 | import com.huifer.planar.aset.entity.MyLine; 4 | import com.huifer.planar.aset.entity.MyPoint; 5 | 6 | import java.util.ArrayList; 7 | 8 | /** 9 | *Title : DijkstraUtil
10 | *Description : dijkstra 邻接矩阵构造器
11 | * 12 | * @author huifer 13 | * @date 2018/12/14 14 | */ 15 | public class DijkstraUtil { 16 | 17 | 18 | /** 19 | * 构造邻接矩阵 20 | * 21 | * @param points 点集合 22 | * @param polylines 线集合 23 | * @return 邻接矩阵 24 | */ 25 | public static ArrayListTitle : Miact
10 | *Description :
11 | * 12 | * @author huifer 13 | * @date 2019-03-05 14 | */ 15 | public class Miact { 16 | 17 | /** 18 | * 构造邻接矩阵 19 | * 20 | * @param points 点集合 21 | * @param polylines 线集合 22 | * @return 邻接矩阵 23 | */ 24 | public static ArrayListTitle : PolygonUtils
15 | *Description : polygon 工具
16 | * 17 | * @author huifer 18 | * @date 2019-02-27 19 | */ 20 | public class PolygonUtils { 21 | 22 | public static Geometry polygonize(Geometry geometry) { 23 | List lines = LineStringExtracter.getLines(geometry); 24 | Polygonizer polygonizer = new Polygonizer(); 25 | polygonizer.add(lines); 26 | Collection polys = polygonizer.getPolygons(); 27 | Polygon[] polyArray = GeometryFactory.toPolygonArray(polys); 28 | return geometry.getFactory().createGeometryCollection(polyArray); 29 | } 30 | 31 | public static Geometry splitPolygon(Geometry poly, Geometry line) { 32 | Geometry nodedLinework = poly.getBoundary().union(line); 33 | Geometry polys = polygonize(nodedLinework); 34 | 35 | // Only keep polygons which are inside the input 36 | List output = new ArrayList(); 37 | for (int i = 0; i < polys.getNumGeometries(); i++) { 38 | Polygon candpoly = (Polygon) polys.getGeometryN(i); 39 | if (poly.contains(candpoly.getInteriorPoint())) { 40 | output.add(candpoly); 41 | } 42 | } 43 | return poly.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(output)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/Project.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils; 2 | 3 | import org.geotools.geometry.jts.JTS; 4 | import org.geotools.referencing.CRS; 5 | import org.locationtech.jts.geom.Coordinate; 6 | import org.locationtech.jts.geom.GeometryFactory; 7 | import org.locationtech.jts.geom.Point; 8 | import org.locationtech.jts.geom.util.AffineTransformation; 9 | import org.locationtech.jts.geom.util.AffineTransformationBuilder; 10 | import org.opengis.geometry.MismatchedDimensionException; 11 | import org.opengis.referencing.FactoryException; 12 | import org.opengis.referencing.crs.CoordinateReferenceSystem; 13 | import org.opengis.referencing.operation.MathTransform; 14 | import org.opengis.referencing.operation.TransformException; 15 | 16 | /** 17 | *Title : Project
18 | *Description : 投影
19 | * 20 | * @author huifer 21 | * @date 2019-02-27 22 | */ 23 | public class Project { 24 | 25 | /** 26 | * 仿射转换 27 | * 28 | * @param lon 经度 29 | * @param lat 纬度 30 | */ 31 | public static void affine(double lon, double lat) { 32 | Coordinate st1 = new Coordinate(); 33 | Coordinate st2 = new Coordinate(); 34 | Coordinate st3 = new Coordinate(); 35 | 36 | Coordinate end1 = new Coordinate(); 37 | Coordinate end2 = new Coordinate(); 38 | Coordinate end3 = new Coordinate(); 39 | AffineTransformationBuilder affineTransformationBuilder = new AffineTransformationBuilder( 40 | st1, st2, st3, end1, end2, end3); 41 | AffineTransformation afm = affineTransformationBuilder.getTransformation(); 42 | 43 | Point sourcePoint = new GeometryFactory().createPoint(new Coordinate(lat, lon)); 44 | sourcePoint.apply(afm); 45 | 46 | } 47 | 48 | /*** 49 | * 投影转换 50 | * @param lon 经度 51 | * @param lat 纬度 52 | * @param epsgSource EPSG:xxx 输入坐标系 53 | * @param epsgTarget EPSG:xxx 输出坐标系 54 | * @return 55 | * @throws FactoryException 56 | * @throws MismatchedDimensionException 57 | * @throws TransformException 58 | */ 59 | public static Point projectTransform(double lon, double lat, 60 | String epsgSource, String epsgTarget) throws FactoryException, 61 | MismatchedDimensionException, TransformException { 62 | 63 | Point sourcePoint = new GeometryFactory().createPoint(new Coordinate(lat, lon)); 64 | 65 | CoordinateReferenceSystem crsSource = CRS.decode(epsgSource); 66 | CoordinateReferenceSystem crsTarget = CRS.decode(epsgTarget); 67 | MathTransform transform = CRS.findMathTransform(crsSource, crsTarget); 68 | Point pointTarget = (Point) JTS.transform(sourcePoint, transform); 69 | 70 | return pointTarget; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/geo/ColorUtil.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils.geo; 2 | 3 | import java.awt.*; 4 | 5 | /** 6 | *Title : ColorUtil
7 | *Description : 颜色转换器
8 | * 9 | * @author huifer 10 | * @date 2019-01-18 11 | */ 12 | public class ColorUtil { 13 | 14 | /** 15 | * color 转换 16进制颜色字符串 16 | * 17 | * @param color 颜色 18 | * @return 16进制颜色字符串 19 | */ 20 | public static String colorToHexColor(Color color) { 21 | String r, b, g; 22 | StringBuilder hexColor = new StringBuilder(); 23 | r = Integer.toHexString(color.getRed()); 24 | g = Integer.toHexString(color.getGreen()); 25 | b = Integer.toHexString(color.getBlue()); 26 | r = r.length() == 1 ? "0" + r : r; 27 | g = g.length() == 1 ? "0" + g : g; 28 | b = b.length() == 1 ? "0" + b : b; 29 | r = r.toUpperCase(); 30 | g = g.toUpperCase(); 31 | b = b.toUpperCase(); 32 | hexColor.append("0x"); 33 | hexColor.append(r); 34 | hexColor.append(g); 35 | hexColor.append(b); 36 | return hexColor.toString(); 37 | } 38 | 39 | /** 40 | * 16进制颜色字符串 转换 color 41 | * 42 | * @param hexColor 16进制颜色字符串 43 | * @return 颜色 44 | */ 45 | public static Color hexColorToColor(String hexColor) { 46 | if (hexColor.contains("0x") || hexColor.contains("0X")) { 47 | hexColor = hexColor.substring(2); 48 | } else if (hexColor.contains("#")) { 49 | hexColor = hexColor.substring(1); 50 | } 51 | Color color = new Color(Integer.parseInt(hexColor, 16)); 52 | return color; 53 | } 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/geo/GeoMapContentUtil.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils.geo; 2 | 3 | import org.geotools.data.simple.SimpleFeatureCollection; 4 | import org.geotools.feature.DefaultFeatureCollection; 5 | import org.geotools.feature.simple.SimpleFeatureBuilder; 6 | import org.geotools.feature.simple.SimpleFeatureTypeBuilder; 7 | import org.geotools.geometry.jts.JTSFactoryFinder; 8 | import org.geotools.map.FeatureLayer; 9 | import org.geotools.map.Layer; 10 | import org.geotools.map.MapContent; 11 | import org.geotools.styling.Style; 12 | import org.locationtech.jts.geom.Coordinate; 13 | import org.locationtech.jts.geom.GeometryFactory; 14 | import org.locationtech.jts.geom.Point; 15 | import org.opengis.feature.simple.SimpleFeature; 16 | import org.opengis.feature.simple.SimpleFeatureType; 17 | 18 | /** 19 | *Title : GeoMapContentUtil
20 | *Description : 地图框
21 | * 22 | * @author huifer 23 | * @date 2019-01-23 24 | */ 25 | public class GeoMapContentUtil { 26 | 27 | 28 | /** 29 | * 追加layers 30 | * 31 | * @param content mapContent 32 | * @param features 要素 33 | * @param style 样式 34 | */ 35 | public static void addLayer(MapContent content, SimpleFeatureCollection features, Style style) { 36 | Layer layer = new FeatureLayer(features, style); 37 | content.addLayer(layer); 38 | } 39 | 40 | /** 41 | * 获取地图实例 42 | */ 43 | public static MapContent getMapContent(String title) { 44 | 45 | MapContent mapContent = new MapContent(); 46 | mapContent.setTitle(title); 47 | return mapContent; 48 | } 49 | 50 | public static Layer getFlickrLayer() { 51 | SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); 52 | builder.setName("MyFeatureType"); 53 | // set crs 54 | builder.setCRS(null); 55 | // add geometry 56 | builder.add("location", Point.class); 57 | 58 | // build the type 59 | SimpleFeatureType type = builder.buildFeatureType(); 60 | 61 | // create features using the type defined 62 | SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type); 63 | GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); 64 | org.locationtech.jts.geom.Point point = geometryFactory.createPoint(new Coordinate(5, 5)); 65 | featureBuilder.add(point); 66 | SimpleFeature feature = featureBuilder.buildFeature("FeaturePoint"); 67 | DefaultFeatureCollection featureCollection = new DefaultFeatureCollection("internal", type); 68 | featureCollection.add(feature); // Add feature 1, 2, 3, etc 69 | 70 | Style style = GeoStyleUtil.pointStyle(null, "0xffffff", "30000", "0xffffff", "1", 5000); 71 | Layer layer = new FeatureLayer(featureCollection, style); 72 | // layer.setTitle("NewPointLayer"); 73 | return layer; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/kriging/Kpoint.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils.kriging; 2 | 3 | /** 4 | *Title : Kpoint
5 | *Description : xyz
6 | * 7 | * @author huifer 8 | * @date 2019-04-19 9 | */ 10 | public class Kpoint { 11 | 12 | 13 | private double x; 14 | private double y; 15 | private double z; 16 | 17 | public Kpoint() { 18 | } 19 | 20 | public Kpoint(double x, double y, double z) { 21 | this.x = x; 22 | this.y = y; 23 | this.z = z; 24 | } 25 | 26 | public Kpoint(double x, double y) { 27 | this.x = x; 28 | this.y = y; 29 | } 30 | 31 | public double getX() { 32 | return x; 33 | } 34 | 35 | public void setX(double x) { 36 | this.x = x; 37 | } 38 | 39 | public double getY() { 40 | return y; 41 | } 42 | 43 | public void setY(double y) { 44 | this.y = y; 45 | } 46 | 47 | public double getZ() { 48 | return z; 49 | } 50 | 51 | public void setZ(double z) { 52 | this.z = z; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/kriging/ReadFile.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils.kriging; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.IOException; 7 | import java.util.ArrayList; 8 | 9 | /** 10 | *Title : ReadFile
11 | *Description : 读文件
12 | * 13 | * @author huifer 14 | * @date 2019-04-19 15 | */ 16 | public class ReadFile { 17 | 18 | private static final String TEST_PATH = "E:\\mck\\bg\\data_status\\src\\main\\java\\com\\huifer\\data\\idw\\text.txt"; 19 | 20 | public static void main(String[] args) { 21 | ArrayListTitle : TocePoint
13 | *Description : 面上的线段
14 | * 15 | * @author huifer 16 | * @date 2019-04-26 17 | */ 18 | @Data 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @EqualsAndHashCode 22 | public class ToceLineString { 23 | 24 | private String polygonID; 25 | private ListTitle : TocePoint
13 | *Description : 面上的点
14 | * 15 | * @author huifer 16 | * @date 2019-04-26 17 | */ 18 | @Data 19 | @NoArgsConstructor 20 | @AllArgsConstructor 21 | @EqualsAndHashCode 22 | public class TocePoint { 23 | 24 | private String polygonID; 25 | private ListTitle : TocePolygon
11 | *Description : 单个面属性
12 | * 13 | * @author huifer 14 | * @date 2019-04-26 15 | */ 16 | @Data 17 | @NoArgsConstructor 18 | @AllArgsConstructor 19 | @EqualsAndHashCode 20 | public class TocePolygon { 21 | private String id; 22 | private Geometry geom; 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/shptools/Shp2Wkt.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils.shptools; 2 | 3 | import org.geotools.data.FileDataStore; 4 | import org.geotools.data.FileDataStoreFinder; 5 | import org.geotools.data.shapefile.ShapefileDataStore; 6 | import org.geotools.data.simple.SimpleFeatureCollection; 7 | import org.geotools.data.simple.SimpleFeatureIterator; 8 | import org.geotools.data.simple.SimpleFeatureSource; 9 | import org.opengis.feature.simple.SimpleFeature; 10 | import org.opengis.filter.Filter; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.nio.charset.Charset; 15 | 16 | /** 17 | * shp 2 wkt 18 | * 19 | * @author huifer 20 | * @date 2019年1月17日 21 | */ 22 | public class Shp2Wkt { 23 | 24 | public static void main(String[] args) { 25 | String path1 = "D:\\testdata\\2019年1月16日\\11111.shp"; 26 | SimpleFeatureCollection colls1 = readShp(path1); 27 | SimpleFeatureIterator iters = colls1.features(); 28 | while (iters.hasNext()) { 29 | SimpleFeature sf = iters.next(); 30 | System.out.println("wkt: " + sf.getAttributes()); 31 | } 32 | } 33 | 34 | public static SimpleFeatureCollection readShp(String path) { 35 | return readShp(path, null); 36 | 37 | } 38 | 39 | public static SimpleFeatureCollection readShp(String path, Filter filter) { 40 | SimpleFeatureSource featureSource = readStoreByShp(path); 41 | if (featureSource == null) { 42 | return null; 43 | } 44 | try { 45 | return filter != null ? featureSource.getFeatures(filter) : featureSource.getFeatures(); 46 | } catch (IOException e) { 47 | e.printStackTrace(); 48 | } 49 | return null; 50 | } 51 | 52 | public static SimpleFeatureSource readStoreByShp(String path) { 53 | File file = new File(path); 54 | FileDataStore store; 55 | SimpleFeatureSource featureSource = null; 56 | try { 57 | store = FileDataStoreFinder.getDataStore(file); 58 | ((ShapefileDataStore) store).setCharset(Charset.forName("UTF-8")); 59 | featureSource = store.getFeatureSource(); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | return featureSource; 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/main/java/com/huifer/planar/aset/utils/shptools/polygontools/ForTest.java: -------------------------------------------------------------------------------- 1 | package com.huifer.planar.aset.utils.shptools.polygontools; 2 | 3 | 4 | import com.huifer.planar.aset.utils.shptools.polygontools.entity.LatLngEntity; 5 | import com.huifer.planar.aset.utils.shptools.polygontools.geometry.ConvexHull; 6 | import com.huifer.planar.aset.utils.shptools.polygontools.geometry.Polygon; 7 | 8 | import java.util.ArrayList; 9 | 10 | 11 | /** 12 | * ForTest 测试类 13 | * 14 | * @author huifer 15 | */ 16 | public class ForTest { 17 | 18 | /** 19 | * @param args 20 | */ 21 | public static void main(String[] args) { 22 | ConvexHull convexHull = new ConvexHull(); 23 | 24 | ArrayList