Exemple #1
0
        /// <summary>
        /// Gets the data polygons from a feature.
        /// </summary>
        /// <param name="feature">The feature.</param>
        /// <returns>List with DataPolygons.</returns>
        private List <DataPolygon> GetDataPolygons(Feature feature)
        {
            GeoJSONObjectType  polygonType = feature.Geometry.Type;
            List <DataPolygon> polygons    = new List <DataPolygon>();

            if (!(polygonType == GeoJSONObjectType.MultiPolygon || polygonType == GeoJSONObjectType.Polygon))
            {
                return(polygons);
            }

            DataPolygon dataPolygon;

            if (polygonType == GeoJSONObjectType.MultiPolygon)
            {
                MultiPolygon multiPolygon = (MultiPolygon)feature.Geometry;
                foreach (Polygon polygon in multiPolygon.Coordinates)
                {
                    dataPolygon = DataPolygonConverter.ConvertToDataPolygon(polygon);
                    polygons.Add(dataPolygon);
                }
            }

            if (polygonType == GeoJSONObjectType.Polygon)
            {
                dataPolygon = DataPolygonConverter.ConvertToDataPolygon((Polygon)feature.Geometry);
                polygons.Add(dataPolygon);
            }

            return(polygons);
        }
        /// <summary>
        /// Updates the spatial filter. All coordinates will be converted to Google Mercator.
        /// </summary>
        /// <param name="featureCollection">The feature collection.</param>
        /// <param name="coordinateSystem">The coordinate system used in featureCollection.</param>
        public void UpdateSpatialFilter(FeatureCollection featureCollection, CoordinateSystem coordinateSystem)
        {
            List <DataPolygon> dataPolygons = DataPolygonConverter.ConvertToDataPolygons(featureCollection);

            if (coordinateSystem.Id != CoordinateSystemId.GoogleMercator)
            {
                DataContext     dataContext       = new DataContext(UserContext);
                List <IPolygon> polygons          = dataPolygons.ToPolygons(dataContext);
                List <IPolygon> convertedPolygons = GisTools.CoordinateConversionManager.GetConvertedPolygons(polygons, coordinateSystem, new CoordinateSystem(CoordinateSystemId.GoogleMercator));
                dataPolygons = DataPolygonConverter.ConvertToDataPolygons(convertedPolygons);
            }

            SpatialSetting.SetPolygons(dataPolygons);
        }
        public int AddPolygons(FeatureCollection featureCollection)
        {
            List <DataPolygon> dataPolygons = DataPolygonConverter.ConvertToDataPolygons(featureCollection);

            if (dataPolygons.Count > 0)
            {
                foreach (var dataPolygon in dataPolygons)
                {
                    SpatialSetting.Polygons.Add(dataPolygon);
                }
                SpatialSetting.IsActive = true;
            }
            return(dataPolygons.Count);
        }
        /// <summary>
        /// Updates the spatial filter.
        /// </summary>
        /// <param name="featureCollection">The feature collection.</param>
        public void UpdateSpatialFilter(FeatureCollection featureCollection)
        {
            List <DataPolygon> dataPolygons = DataPolygonConverter.ConvertToDataPolygons(featureCollection);

            SpatialSetting.SetPolygons(dataPolygons);
        }