Beispiel #1
0
        public static Feature ToGeoJSON(this VectorTileFeature vectortileFeature, int x, int y, int z)
        {
            IGeometryObject geom = null;

            switch (vectortileFeature.GeometryType)
            {
            case Tile.GeomType.Point:
                var projectedPoints = ProjectPoints(vectortileFeature.Geometry, x, y, z, vectortileFeature.Extent);
                geom = GetPointGeometry(projectedPoints);
                break;

            case Tile.GeomType.LineString:
                var projectedLines = ProjectLines(vectortileFeature.Geometry, x, y, z, vectortileFeature.Extent);
                geom = GetLineGeometry(projectedLines);
                break;

            case Tile.GeomType.Polygon:
                var rings             = ClassifyRings.Classify(vectortileFeature.Geometry);
                var projectedPolygons = ProjectPolygons(rings, x, y, z, vectortileFeature.Extent);
                geom = GetPolygonGeometry(projectedPolygons);
                break;
            }

            var result = new Feature(geom, id: vectortileFeature.Id);

            // add attributes
            foreach (var item in vectortileFeature.Attributes)
            {
                result.Properties.Add(item.Key, item.Value);
            }
            return(result);
        }
Beispiel #2
0
        public static VectorTileFeature Parse(Tile.Feature feature, List <string> keys, List <Tile.Value> values, uint extent)
        {
            var result = new VectorTileFeature();
            var id     = feature.Id;

            var geom = GeometryParser.ParseGeometry(feature.Geometry, feature.Type);

            result.GeometryType = feature.Type;

            // add the geometry
            result.Geometry = geom;
            result.Extent   = extent;

            // now add the attributes
            result.Id         = id.ToString(CultureInfo.InvariantCulture);
            result.Attributes = AttributesParser.Parse(keys, values, feature.Tags);
            return(result);
        }