Exemplo n.º 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);
        }
        public static AgGateway.ADAPT.ApplicationDataModel.Shapes.MultiPolygon MapMultiPolygon(GeoJSON.Net.Geometry.MultiPolygon multiPolygonGeoJson, AffineTransformation affineTransformation = null)
        {
            var multiPolygon = new AgGateway.ADAPT.ApplicationDataModel.Shapes.MultiPolygon();

            foreach (var polygonGeoJson in multiPolygonGeoJson.Coordinates)
            {
                var polygon = PolygonMapper.MapPolygon(polygonGeoJson, affineTransformation);
                multiPolygon.Polygons.Add(polygon);
            }

            return(multiPolygon);
        }
        public static GeoJSON.Net.Geometry.MultiPolygon Map(AgGateway.ADAPT.ApplicationDataModel.Shapes.MultiPolygon multiPolygon, AffineTransformation affineTransformation = null)
        {
            var polygons = new List <GeoJSON.Net.Geometry.Polygon>();

            foreach (var adaptPolygon in multiPolygon.Polygons)
            {
                GeoJSON.Net.Geometry.Polygon polygon = PolygonMapper.MapPolygon(adaptPolygon, affineTransformation);
                if (polygon != null)
                {
                    polygons.Add(polygon);
                }
            }

            if (polygons.Count == 0)
            {
                return(null);
            }

            return(new GeoJSON.Net.Geometry.MultiPolygon(polygons));
        }