Exemplo n.º 1
0
        private FeatureCollection GetTestFeatureCollection()
        {
            var fc = new FeatureCollection();

            _testGeospatialObjects.ForEach(c =>
            {
                var geom = DbGeometry.FromText(c.Geometry, 4326);
                var f    = DbGeometryToGeoJsonHelper.FromDbGeometry(geom);
                f.Properties.Add("Name", c.Name);
                fc.Features.Add(f);
            });
            return(fc);
        }
Exemplo n.º 2
0
        private FeatureCollection GetTestFeatureCollection()
        {
            var fc = new FeatureCollection();

            _testGeospatialObjects.ForEach(c =>
            {
                var geom = DbGeometry.FromText(c.Geometry);
                var f    = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(geom);
                f.Id     = c.ID.ToString(CultureInfo.InvariantCulture);
                f.Properties.Add("Name", c.Name);
                fc.Features.Add(f);
            });
            return(fc);
        }
Exemplo n.º 3
0
        public static FeatureCollection FeatureCollectionFromDbGeometry(IEnumerable <DbGeometry> dbGeometries, string featurePropertyName, string featurePropertyValue)
        {
            var featureCollectionFromDbGeometry = new FeatureCollection();

            if (dbGeometries == null)
            {
                return(featureCollectionFromDbGeometry);
            }

            foreach (var dbGeometry in dbGeometries.Where(x => x != null))
            {
                var feature = DbGeometryToGeoJsonHelper.FromDbGeometry(dbGeometry);
                feature.Properties.Add(featurePropertyName, featurePropertyValue);
                featureCollectionFromDbGeometry.Features.Add(feature);
            }

            return(featureCollectionFromDbGeometry);
        }
Exemplo n.º 4
0
        public static string MakeDbGeometryIntoGeoJsonString(DbGeometry geometry, Formatting formatting)
        {
            var dbGeometryAsFeature = DbGeometryToGeoJsonHelper.FromDbGeometry(geometry);

            return(JsonTools.SerializeObject(dbGeometryAsFeature, formatting));
        }