public void GetPoIbyExtent(Extent extent, string keyWords) { Coord topLeft = new Coord(extent.minX, extent.minY); topLeft = CoordHelper.WebMercator2lonLat(topLeft); Coord bottomRight = new Coord(extent.maxX, extent.maxY); bottomRight = CoordHelper.WebMercator2lonLat(bottomRight); double minx = topLeft.lon; double miny = topLeft.lat; double maxx = bottomRight.lon; double maxy = bottomRight.lat; int xCount = (int)Math.Ceiling((maxx - minx) / 0.01); int yCount = (int)Math.Ceiling((maxy - miny) / 0.01); int index = 0; keyWords = keyWords != "" ? keyWords : "汽车|摩托|餐饮|购物|生活|体育|医疗|住宿|风景|住宅|政府|科教|交通|金融|公司|行政地名|自然地名"; for (int i = 0; i < xCount; i++) { for (int j = 0; j < yCount; j++) { index++; double x1 = minx + i * 0.01; double x2 = minx + (i + 1) * 0.01; double y1 = miny + j * 0.01; double y2 = miny + (j + 1) * 0.01; if (i + 1 == xCount) { x2 = maxx; } if (j + 1 == yCount) { y2 = maxy; } this.DownPoIbyExtent(x1, y1, x2, y2, keyWords, index, xCount * yCount); } } if (this.DownEndEvent != null) { this.DownEndEvent("下载完成"); } }
/// <summary> /// 坐标转换 /// </summary> /// <param name="lonlat">格式[x,y]或者[x|y]</param> /// <param name="project"></param> /// <returns></returns> public static Coord ProjectChange(string lonlat, ProjectConvert project) { if (string.IsNullOrEmpty(lonlat)) { return(new Coord(0, 0)); } try { double x = double.Parse(lonlat.Split('|', ',')[0]); double y = double.Parse(lonlat.Split('|', ',')[1]); switch (project) { case ProjectConvert.NONE: return(new Coord(x, y)); case ProjectConvert.GCJ_WGS: case ProjectConvert.GAODE84_WGS: return(CoordHelper.Gcj2Wgs(x, y)); case ProjectConvert.BAIDU_WGS: var c = CoordHelper.BdDecrypt(y, x); return(CoordHelper.Gcj2Wgs(c.lon, c.lat)); case ProjectConvert.GAODE900913_WGS: var g = CoordHelper.WebMercator2lonLat(new Coord(x, y)); return(CoordHelper.Gcj2Wgs(g.lon, g.lat)); default: return(new Coord(0, 0)); } } catch (Exception) { Console.WriteLine(lonlat); return(new Coord()); } }