private List <Polygon> ReadPolygon(int shxLength, byte[] shpArray, byte[] shxArray) { int count = (shxLength - 100) / 8; int offset = 0; List <Polygon> polyList = new List <Polygon> (); CoordConversion cc = new CoordConversion(); for (int i = 0; i < count; i++) { if ((i % 100) == 0) { EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", i, count)); } offset = BitConverter.ToInt32(shxArray, 100 + 8 * i); offset = Swap(offset) * 2 + 8; // BigEndian, Word(16bit) 단위 // SHP 파일의 컨텐츠 위치 int shapeType = BitConverter.ToInt32(shpArray, offset); int nParts = BitConverter.ToInt32(shpArray, offset + 36); int nPoints = BitConverter.ToInt32(shpArray, offset + 40); if (shapeType != 0) { Polygon poly = new Polygon(nParts, nPoints); poly.shapeType = BitConverter.ToInt32(shpArray, offset); poly.box[0].x = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 0); poly.box[0].y = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 1); poly.box[0].xy2ll(); poly.box[1].x = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 2); poly.box[1].y = BitConverter.ToDouble(shpArray, offset + 4 + 8 * 3); poly.box[1].xy2ll(); for (int j = 0; j < nParts; j++) // Parts { poly.parts[j] = BitConverter.ToInt32(shpArray, offset + 44 + 4 * j); } for (int j = 0; j < nPoints; j++) { poly.points[j].x = BitConverter.ToDouble(shpArray, offset + 44 + 4 * nParts + 16 * j); poly.points[j].y = BitConverter.ToDouble(shpArray, offset + 44 + 4 * nParts + 16 * j + 8); poly.points[j].xy2ll(); } poly.CalcCenter(); polyList.Add(poly); } } ////// 폴리곤 읽기 끝 EventControl.Instance().SendEvent(new ProgressEventArgs(null, "PB_OPER", count, count)); return(polyList); }
public void xy2ll() { CoordConversion cc = new CoordConversion(); LatLon coordi = cc.Tm2Geo(x, y); this.lat = coordi.lat * 180.0 / Math.PI;; this.lon = coordi.lon * 180.0 / Math.PI;; }