/// <summary> /// Converts a GeoJSON FeatureCollection to a list with data polygons. /// </summary> /// <param name="featureCollection">The GeoJSON FeatureCollection.</param> /// <returns>Converted polygons.</returns> public static List <DataPolygon> ConvertToDataPolygons(FeatureCollection featureCollection) { var dataPolygons = new List <DataPolygon>(); if (featureCollection.IsNull()) { return(dataPolygons); } foreach (Feature feature in featureCollection.Features) { ////if (feature.Type == GeoJSONObjectType.Polygon) if (feature.Geometry != null && feature.Geometry.GetType() == typeof(ArtDatabanken.GIS.GeoJSON.Net.Geometry.Polygon)) { ArtDatabanken.GIS.GeoJSON.Net.Geometry.Polygon polygon = (ArtDatabanken.GIS.GeoJSON.Net.Geometry.Polygon)feature.Geometry; DataPolygon dataPolygon = ConvertToDataPolygon(polygon); dataPolygons.Add(dataPolygon); } else if (feature.Geometry != null && feature.Geometry.GetType() == typeof(ArtDatabanken.GIS.GeoJSON.Net.Geometry.MultiPolygon)) { ArtDatabanken.GIS.GeoJSON.Net.Geometry.MultiPolygon multiPolygon = (ArtDatabanken.GIS.GeoJSON.Net.Geometry.MultiPolygon)feature.Geometry; foreach (ArtDatabanken.GIS.GeoJSON.Net.Geometry.Polygon polygon in multiPolygon.Coordinates) { DataPolygon dataPolygon = ConvertToDataPolygon(polygon); dataPolygons.Add(dataPolygon); } } } return(dataPolygons); }