net开源GIS组件NetTopologySuite,计算闭合线到点距离

 

using NetTopologySuite.Geometries;
using NetTopologySuite.IO;
using NetTopologySuite.Operation.Distance;
  
  public double FindClosestPoint(string wktA, string wktB)
        {
            double distance = 0;
            var fact = new GeometryFactory();
            var wktRdr = new WKTReader(fact);
            Debug.WriteLine("-------------------------------------");
            try
            {
                var A = wktRdr.Read(wktA);
                var B = wktRdr.Read(wktB);
                Debug.WriteLine("Geometry A: " + A);
                Debug.WriteLine("Geometry B: " + B);
                var distOp = new DistanceOp(A, B);

                distance = distOp.Distance();
                Debug.WriteLine($"Distance = {distance}");

                //var closestPt = distOp.NearestPoints();
                //var closestPtLine = fact.CreateLineString(closestPt);
                //Debug.WriteLine("Closest points: " + closestPtLine + " (distance = " + closestPtLine.Length + ")");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return distance;
        }

 

net开源GIS组件NetTopologySuite,计算闭合线到点距离

上一篇:性能监控平台部署关注点(jmeter+grafana+influxDB)


下一篇:AUTOSAR-Implicit Communication Mode