示例#1
0
        /// <summary>
        ///     Преобразует в списки координат с инфрмацией о типе геометрии
        /// </summary>
        /// <param name="shape"></param>
        /// <returns></returns>
        private GeometryInstanceInfo GetGeometryInfo(SqlGeometry shape)
        {
            var result = new GeometryInstanceInfo();
            var type = (OpenGisGeometryType) Enum.Parse(typeof (OpenGisGeometryType), (string) shape.STGeometryType());
            result.ShapeType = type;
            //List<PointF> points = new List<PointF>();
            PointF[] points;
            List<GeometryPointSequence> pointSequenceList;
            var shapesPointsCollection = new List<List<GeometryPointSequence>>();
            switch (type)
            {
                case OpenGisGeometryType.Point:
                    points = new PointF[1];
                    SqlGeometry firstpoint = shape.STStartPoint();
                    points[0] = new PointF((float) firstpoint.STX, (float) firstpoint.STY);
                    pointSequenceList = new List<GeometryPointSequence>
                        {
                            new GeometryPointSequence {PointList = points, InnerRing = false}
                        };
                    shapesPointsCollection.Add(pointSequenceList);
                    break;

                case OpenGisGeometryType.LineString:
                    points = shape.ToPointsFArray();
                    pointSequenceList = new List<GeometryPointSequence> { new GeometryPointSequence { PointList = points, InnerRing = false } };

                    shapesPointsCollection.Add(pointSequenceList);
                    break;

                case OpenGisGeometryType.Polygon:
                    shapesPointsCollection = shape.ToGeometryPointsOfPolygon();
                    break;

                case OpenGisGeometryType.MultiPoint:
                case OpenGisGeometryType.MultiLineString:
                    shapesPointsCollection = shape.ToGeometryPointsOfMultiPointLineString();
                    break;

                case OpenGisGeometryType.MultiPolygon:
                    shapesPointsCollection = shape.ToGeometryPointsOfMultiPolygon();
                    break;

                case OpenGisGeometryType.GeometryCollection:
                    var geomNum = (int) shape.STNumGeometries();
                    var geometryList = new GeometryInstanceInfo[geomNum];
                    int i;
                    for ( i = 0; i < geomNum; i++)
                        geometryList[i] = GetGeometryInfo(shape.STGeometryN(i));
                    result.GeometryInstanceInfoCollection = geometryList;
                    break;
            }
            result.Points = shapesPointsCollection;
            return result;
        }
示例#2
0
        /// <summary>
        ///     Преобразует в списки координат с инфрмацией о типе геометрии
        /// </summary>
        /// <param name="shape"></param>
        /// <returns></returns>
        private GeometryInstanceInfo GetGeometryInfo(SqlGeometry shape)
        {
            var result = new GeometryInstanceInfo();
            var type = (OpenGisGeometryType) Enum.Parse(typeof (OpenGisGeometryType), (string) shape.STGeometryType());
            result.ShapeType = type;
            //List<PointF> points = new List<PointF>();
            PointF[] points;
            List<GeometryPointSequence> pointSequenceList;
            var shapesPointsCollection = new List<List<GeometryPointSequence>>();
            switch (type)
            {
                case OpenGisGeometryType.Point:
                    points = new PointF[1];
                    SqlGeometry firstpoint = shape.STStartPoint();
                    points[0] = new PointF((float) firstpoint.STX, (float) firstpoint.STY);
                    pointSequenceList = new List<GeometryPointSequence>
                        {
                            new GeometryPointSequence {PointList = points, InnerRing = false}
                        };
                    shapesPointsCollection.Add(pointSequenceList);
                    break;

                case OpenGisGeometryType.LineString:
                    points = shape.ToPointsFArray();
                    pointSequenceList = new List<GeometryPointSequence> { new GeometryPointSequence { PointList = points, InnerRing = false } };

                    shapesPointsCollection.Add(pointSequenceList);
                    break;

                case OpenGisGeometryType.Polygon:
                    shapesPointsCollection = shape.ToGeometryPointsOfPolygon();
                    break;

                case OpenGisGeometryType.MultiPoint:
                case OpenGisGeometryType.MultiLineString:
                    shapesPointsCollection = shape.ToGeometryPointsOfMultiPointLineString();
                    break;

                case OpenGisGeometryType.MultiPolygon:
                    shapesPointsCollection = shape.ToGeometryPointsOfMultiPolygon();
                    break;

                case OpenGisGeometryType.GeometryCollection:
                    var geomNum = (int) shape.STNumGeometries();
                    var geometryList = new GeometryInstanceInfo[geomNum];
                    int i;
                    for ( i = 0; i < geomNum; i++)
                        geometryList[i] = GetGeometryInfo(shape.STGeometryN(i));
                    result.GeometryInstanceInfoCollection = geometryList;
                    break;
            }
            result.Points = shapesPointsCollection;
            return result;
        }
示例#3
0
        /// <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;
        }
示例#4
0
        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;
        }