MeasureDistance() public method

根据地图名称、二维地理坐标点、量算单位进行距离量算。
public MeasureDistance ( string mapName, List point2Ds, Unit unit ) : MeasureDistanceResult
mapName string 地图名称。
point2Ds List 二维地理坐标点数组。
unit Unit 返回结果的单位。
return SuperMap.Connector.Utility.MeasureDistanceResult
Example #1
0
        public void MeasureDistanceTest_point2DsISNULL()
        {
            Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");

            MeasureDistanceResult result = null;
            try
            {
                result = map.MeasureDistance("世界地图", null, Unit.KILOMETER);
            }
            catch (ArgumentNullException e)
            {
                Assert.AreEqual(e.Message, "参数不能为空。\r\n参数名: point2Ds");
            }
        }
Example #2
0
        public void MeasureDistanceTest_mapNameISNULL()
        {
            Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");

            List<Point2D> point2Ds = new List<Point2D>();
            Point2D point1 = new Point2D(23.00, 34.00);
            Point2D point2 = new Point2D(53.55, 12.66);
            Point2D point3 = new Point2D(73.88, 12.6);
            point2Ds.Add(point1);
            point2Ds.Add(point2);
            point2Ds.Add(point3);
            MeasureDistanceResult result = null;
            try
            {
                result = map.MeasureDistance(string.Empty, point2Ds, Unit.KILOMETER);
            }
            catch (ArgumentNullException e)
            {
                Assert.AreEqual(e.Message, "参数不能为空。\r\n参数名: mapName");
            }
        }
Example #3
0
 public void MeasureDistanceTest_point2DsISEmply()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     List<Point2D> point2Ds = new List<Point2D>();
     MeasureDistanceResult result = null;
     try
     {
         result = map.MeasureDistance("世界地图", point2Ds, Unit.KILOMETER);
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual(e.Message, "参数 point2Ds 不合法,必须至少包含两个二维点。");
     }
 }
Example #4
0
 public void MeasureDistanceTest_KILOMETER()
 {
     Map map = new Map("http://" + ip + ":8090/iserver/services/map-world/rest");
     string mapName = "World Map";
     List<Point2D> point2Ds = new List<Point2D>();
     Point2D point1 = new Point2D(23.00, 34.00);
     Point2D point2 = new Point2D(53.55, 12.66);
     Point2D point3 = new Point2D(73.88, 12.6);
     point2Ds.Add(point1);
     point2Ds.Add(point2);
     point2Ds.Add(point3);
     MeasureDistanceResult result = map.MeasureDistance(mapName, point2Ds, Unit.KILOMETER);
     Assert.AreEqual(result.Distance, 6098.3555766137142);
     Assert.AreEqual(result.Unit.ToString(), "KILOMETER");
 }