Пример #1
0
        // Needed?
        #endregion

        #region Import
        public static AgGateway.ADAPT.ApplicationDataModel.Shapes.Shape Map(Feature feature, AffineTransformation affineTransformation = null)
        {
            // ToDo: importing different GeoJSONObjectTypes
            switch (feature.Type)
            {
            case GeoJSON.Net.GeoJSONObjectType.Point:
                return(PointMapper.MapPosition(((GeoJSON.Net.Geometry.Point)feature.Geometry).Coordinates, affineTransformation));

            case GeoJSON.Net.GeoJSONObjectType.MultiPoint:
                break;

            case GeoJSON.Net.GeoJSONObjectType.LineString:
                return(LineStringMapper.MapLineString((GeoJSON.Net.Geometry.LineString)feature.Geometry, affineTransformation));

            case GeoJSON.Net.GeoJSONObjectType.MultiLineString:
                break;

            case GeoJSON.Net.GeoJSONObjectType.Polygon:
                return(PolygonMapper.MapPolygon((GeoJSON.Net.Geometry.Polygon)feature.Geometry, affineTransformation));

            case GeoJSON.Net.GeoJSONObjectType.MultiPolygon:
                return(MultiPolygonMapper.MapMultiPolygon((GeoJSON.Net.Geometry.MultiPolygon)feature.Geometry, affineTransformation));

            case GeoJSON.Net.GeoJSONObjectType.GeometryCollection:
                break;

            case GeoJSON.Net.GeoJSONObjectType.Feature:
                break;

            case GeoJSON.Net.GeoJSONObjectType.FeatureCollection:
                break;
            }
            return(null);
        }
Пример #2
0
        public static AgGateway.ADAPT.ApplicationDataModel.Shapes.Polygon MapPolygon(GeoJSON.Net.Geometry.Polygon polygonGeoJson, AffineTransformation affineTransformation = null)
        {
            var polygon = new AgGateway.ADAPT.ApplicationDataModel.Shapes.Polygon();

            // First LineString is ExteriorRing, see https://tools.ietf.org/html/rfc7946#section-3.1.6
            for (int i = 0; i < polygonGeoJson.Coordinates.Count; i++)
            {
                if (i == 0)
                {
                    polygon.ExteriorRing = LineStringMapper.MapLineString(polygonGeoJson.Coordinates[i], affineTransformation);
                }
                else
                {
                    polygon.InteriorRings.Add(LineStringMapper.MapLineString(polygonGeoJson.Coordinates[i], affineTransformation));
                }
            }

            return(polygon);
        }
Пример #3
0
        public static GeoJSON.Net.Geometry.Polygon MapBoundingBox(AgGateway.ADAPT.ApplicationDataModel.Shapes.BoundingBox adaptBBox, AffineTransformation affineTransformation = null)
        {
            var points = new List <AgGateway.ADAPT.ApplicationDataModel.Shapes.Point>();

            points.Add(new AgGateway.ADAPT.ApplicationDataModel.Shapes.Point()
            {
                X = adaptBBox.MinX.Value.Value, Y = adaptBBox.MinY.Value.Value
            });
            points.Add(new AgGateway.ADAPT.ApplicationDataModel.Shapes.Point()
            {
                X = adaptBBox.MinX.Value.Value, Y = adaptBBox.MaxY.Value.Value
            });
            points.Add(new AgGateway.ADAPT.ApplicationDataModel.Shapes.Point()
            {
                X = adaptBBox.MaxX.Value.Value, Y = adaptBBox.MaxY.Value.Value
            });
            points.Add(new AgGateway.ADAPT.ApplicationDataModel.Shapes.Point()
            {
                X = adaptBBox.MaxX.Value.Value, Y = adaptBBox.MinY.Value.Value
            });

            var linearRing = new AgGateway.ADAPT.ApplicationDataModel.Shapes.LinearRing();

            linearRing.Points = points;

            var lineString = LineStringMapper.MapLinearRing(linearRing, affineTransformation);

            if (lineString == null)
            {
                // Stopping here because ExteriorRing is needed, see https://tools.ietf.org/html/rfc7946#section-3.1.6
                return(null);
            }

            return(new GeoJSON.Net.Geometry.Polygon(new List <LineString>()
            {
                lineString
            }));
        }
Пример #4
0
        public static GeoJSON.Net.Geometry.Polygon MapPolygon(AgGateway.ADAPT.ApplicationDataModel.Shapes.Polygon adaptPolygon, AffineTransformation affineTransformation = null)
        {
            var lineStrings = new List <LineString>();
            // First LineString is ExteriorRing
            var lineString = LineStringMapper.MapLinearRing(adaptPolygon.ExteriorRing, affineTransformation);

            if (lineString == null)
            {
                // Stopping here because ExteriorRing is needed, see https://tools.ietf.org/html/rfc7946#section-3.1.6
                return(null);
            }
            lineStrings.Add(lineString);

            foreach (var adaptInteriorLinearRing in adaptPolygon.InteriorRings)
            {
                var interiorLineString = LineStringMapper.MapLinearRing(adaptInteriorLinearRing, affineTransformation);
                if (interiorLineString != null)
                {
                    lineStrings.Add(interiorLineString);
                }
            }

            return(new GeoJSON.Net.Geometry.Polygon(lineStrings));
        }