Exemplo n.º 1
0
 static MapService()
 {
     /// <summary>
     /// 修正地址区域
     /// </summary>
     string AreaPoints1 = "22.56613,114.29093;22.58912,114.26713;22.58198,114.26093;22.56651,114.27473";
     //修正地址
     LocationInfo TempLocationInfo1 = new LocationInfo()
     {
         Area = "洪安路",
         City = "深圳市",
         Dist = "盐田区",
         Point = "深圳盐田国际集装箱码头",
         Province = "广东省",
         RoadName = "洪安路"
     };
     string AreaPoints2 = "22.67133,113.91344;22.67133,113.92008;22.66776,113.92008;22.66776,113.91344";
     LocationInfo TempLocationInfo2 = new LocationInfo()
     {
         Area = "二五三乡道",
         City = "深圳市",
         Dist = "宝安区",
         Point = "山城工业区",
         Province = "广东省",
         RoadName = "山城路"
     };
     string AreaPoints3 = "22.52039,113.92137;22.51914,113.9204;22.51843,113.92059;22.51806,113.92194;22.52011,113.92268;22.52041,113.92137";
     LocationInfo TempLocationInfo3 = new LocationInfo()
     {
         Area = "创业路",
         City = "深圳市",
         Dist = "南山区",
         Point = "海王大厦",
         Province = "广东省",
         RoadName = "创业路"
     };
     ltPToL.Add(new PointsToLocationInfo(AreaPoints1, TempLocationInfo1));
     ltPToL.Add(new PointsToLocationInfo(AreaPoints2, TempLocationInfo2));
     ltPToL.Add(new PointsToLocationInfo(AreaPoints3, TempLocationInfo3));
 }
Exemplo n.º 2
0
 private bool InArea(string latitude, string longitude, out LocationInfo locationInfo)
 {
     locationInfo = null;
     try
     {
         double lat = Convert.ToDouble(latitude);
         double lon = Convert.ToDouble(longitude);
         return InArea(lat, lon, out locationInfo);
     }
     catch
     {
         return false;
     }
 }
Exemplo n.º 3
0
 private bool InArea(Double lat, Double lon, out LocationInfo locationInfo)
 {
     locationInfo = null;
     foreach (var item in ltPToL)
     {
         Polygon polygon = new Polygon(item.Points);
         double x = Convert.ToDouble(lat);
         double y = Convert.ToDouble(lon);
         Point point = new Point(x, y);
         bool isIn = Polygon.PointInPolygon(point, polygon);
         if (isIn)
         {
             locationInfo = item.LocationInfo;
             return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
 public PointsToLocationInfo(string points, LocationInfo locationInfo)
 {
     Points = points;
     LocationInfo = locationInfo;
 }