private List<List<GeometryPixelCoords>> GetGeometryPixelCoordsShifted( List<List<GeometryPointSequence>> geomInstanceGeoPoints, int zoom, int shiftedX, int shiftedY) { var pixelCoordsListList = new List<List<GeometryPixelCoords>>(); var geomPixCoordsList = new List<GeometryPixelCoords>(); var coords = new GeometryPixelCoords(); foreach (var list in geomInstanceGeoPoints) foreach (GeometryPointSequence pointseq in list) { coords.PixelCoordList = GetPixelCoordsShifted(pointseq.PointList, zoom, shiftedX, shiftedY); coords.InnerRing = pointseq.InnerRing; geomPixCoordsList.Add(coords); } pixelCoordsListList.Add(geomPixCoordsList); return pixelCoordsListList; }
/// <summary> /// Converts to degree coordinates to pixels /// Shifts to tile with position numbers equals to zero /// </summary> /// <param name="info"></param> /// <param name="zoom"></param> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private GeometryZoomedPixelsInfo ConvertToGeometryZoomedPixelsZeroTileShiftedInfo(GeometryInstanceInfo info, int zoom, int x, int y) { int tilezeroshiftX = x*TILE_SIZE; int tilezeroshiftY = y*TILE_SIZE; var result = new GeometryZoomedPixelsInfo(); var pixelCoordsListList = new List<List<GeometryPixelCoords>>(); var geomPixCoordsList = new List<GeometryPixelCoords>(); var coords = new GeometryPixelCoords {InnerRing = false}; OpenGisGeometryType type = info.ShapeType; result.ShapeType = type; switch (type) { case OpenGisGeometryType.Point: PointF[] geopoints = info.Points[0][0].PointList; coords.PixelCoordList = new[] { new Point { X = _conv.FromLongitudeToXPixel(geopoints[0].X, zoom) - tilezeroshiftX, Y = _conv.FromLatitudeToYPixel(geopoints[0].Y, zoom) - tilezeroshiftY } }; geomPixCoordsList.Add(coords); pixelCoordsListList.Add(geomPixCoordsList); break; case OpenGisGeometryType.LineString: coords.PixelCoordList = GetPixelCoordsShifted(info.Points[0][0].PointList, zoom, tilezeroshiftX, tilezeroshiftY); geomPixCoordsList.Add(coords); pixelCoordsListList.Add(geomPixCoordsList); break; case OpenGisGeometryType.Polygon: foreach (var list in info.Points) foreach (GeometryPointSequence pointseq in list) { coords.PixelCoordList = GetPixelCoordsShifted(pointseq.PointList, zoom, tilezeroshiftX, tilezeroshiftY); coords.InnerRing = pointseq.InnerRing; geomPixCoordsList.Add(coords); } pixelCoordsListList.Add(geomPixCoordsList); break; case OpenGisGeometryType.MultiPoint: case OpenGisGeometryType.MultiLineString: case OpenGisGeometryType.MultiPolygon: pixelCoordsListList = GetGeometryPixelCoordsShifted(info.Points, zoom, tilezeroshiftX, tilezeroshiftY); break; case OpenGisGeometryType.GeometryCollection: GeometryInstanceInfo[] geomColl = info.GeometryInstanceInfoCollection; int n = info.GeometryInstanceInfoCollection.Length; var geomPixZoomInfoCollection = new GeometryZoomedPixelsInfo[n]; for (int i = 0; i < n; i++) { var geom = new GeometryZoomedPixelsInfo(); geom.ShapeType = geomColl[i].ShapeType; geom.Points = GetGeometryPixelCoordsShifted(geomColl[i].Points, zoom, tilezeroshiftX, tilezeroshiftY); geomPixZoomInfoCollection[i] = geom; } result.GeometryInstanceInfoCollection = geomPixZoomInfoCollection; break; } if (type != OpenGisGeometryType.GeometryCollection) result.Points = pixelCoordsListList; return result; }
private GeometryZoomedPixelsInfo ConvertToGeometryZoomedPixelsInfo(GeometryInstanceInfo info, int zoom) { var result = new GeometryZoomedPixelsInfo(); var pixelCoordsListList = new List<List<GeometryPixelCoords>>(); var geomPixCoordsList = new List<GeometryPixelCoords>(); var coords = new GeometryPixelCoords {InnerRing = false}; OpenGisGeometryType type = info.ShapeType; result.ShapeType = type; switch (type) { case OpenGisGeometryType.Point: PointF[] geopoints = info.Points[0][0].PointList; coords.PixelCoordList = new[] { new Point { X = _conv.FromLongitudeToXPixel(geopoints[0].X, zoom), Y = _conv.FromLatitudeToYPixel(geopoints[0].Y, zoom) } }; geomPixCoordsList.Add(coords); pixelCoordsListList.Add(geomPixCoordsList); break; case OpenGisGeometryType.LineString: coords.PixelCoordList = GetPixelCoords(info.Points[0][0].PointList, zoom); geomPixCoordsList.Add(coords); pixelCoordsListList.Add(geomPixCoordsList); break; case OpenGisGeometryType.Polygon: foreach (var list in info.Points) foreach (GeometryPointSequence pointseq in list) { coords.PixelCoordList = GetPixelCoords(pointseq.PointList, zoom); coords.InnerRing = pointseq.InnerRing; geomPixCoordsList.Add(coords); } pixelCoordsListList.Add(geomPixCoordsList); break; case OpenGisGeometryType.MultiPoint: case OpenGisGeometryType.MultiLineString: case OpenGisGeometryType.MultiPolygon: pixelCoordsListList = GetGeometryPixelcoords(info.Points, zoom); break; case OpenGisGeometryType.GeometryCollection: GeometryInstanceInfo[] geomColl = info.GeometryInstanceInfoCollection; int n = info.GeometryInstanceInfoCollection.Length; var geomPixZoomInfoCollection = new GeometryZoomedPixelsInfo[n]; for (int i = 0; i < n; i++) { var geom = new GeometryZoomedPixelsInfo { ShapeType = geomColl[i].ShapeType, Points = GetGeometryPixelcoords(geomColl[i].Points, zoom) }; geomPixZoomInfoCollection[i] = geom; } result.GeometryInstanceInfoCollection = geomPixZoomInfoCollection; break; } if (type != OpenGisGeometryType.GeometryCollection) result.Points = pixelCoordsListList; return result; }