public static LayerGeoJson GetTransectLineLayerGeoJson(this OnlandVisualTrashAssessment onlandVisualTrashAssessment)
        {
            LayerGeoJson transsectLineLayerGeoJson;

            if (onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea?.TransectLine != null)
            {
                transsectLineLayerGeoJson = onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea
                                            .GetTransectLineLayerGeoJson();
            }
            else
            {
                var featureCollection = new FeatureCollection();
                var dbGeometry        = onlandVisualTrashAssessment.GetTransect();
                if (dbGeometry == null)
                {
                    return(null);
                }

                var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(dbGeometry.ToSqlGeometry().MakeValid().ToDbGeometry());
                featureCollection.Features.AddRange(new List <Feature> {
                    feature
                });

                transsectLineLayerGeoJson = new LayerGeoJson("transectLine", featureCollection, "#000000",
                                                             1,
                                                             LayerInitialVisibility.Show);
            }

            return(transsectLineLayerGeoJson);
        }
예제 #2
0
        private static GeoJSON.Net.Feature.Feature MakeFeatureWithRelevantProperties(County county)
        {
            var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(county.CountyFeature);

            feature.Properties.Add("State", county.StateProvince.StateProvinceAbbreviation);
            feature.Properties.Add("County", county.CountyName);
            return(feature);
        }
예제 #3
0
        public static GeoJSON.Net.Feature.FeatureCollection ToGeoJsonFeatureCollection(this IEnumerable <DelineationGeometryStaging> delineationGeometryStagings)
        {
            var featureCollection = new GeoJSON.Net.Feature.FeatureCollection();

            featureCollection.Features.AddRange(delineationGeometryStagings.Select(x =>
            {
                var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(DbGeometry.FromText(""));

                feature.Properties.Add("FeatureWeight", 1);
                feature.Properties.Add("FillPolygon", true);
                feature.Properties.Add("FeatureColor", "#405d74");
                feature.Properties.Add("FillOpacity", "0.2");
                return(feature);
            }));
            return(featureCollection);
        }
예제 #4
0
        public static LayerGeoJson GetTransectLineLayerGeoJson(this Models.OnlandVisualTrashAssessmentArea onlandVisualTrashAssessmentArea)
        {
            if (onlandVisualTrashAssessmentArea.TransectLine != null)
            {
                var featureCollection = new FeatureCollection();
                var feature           = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(onlandVisualTrashAssessmentArea.TransectLine);
                featureCollection.Features.AddRange(new List <Feature> {
                    feature
                });

                LayerGeoJson transectLineLayerGeoJson = new LayerGeoJson("transectLine", featureCollection, "#000000",
                                                                         1,
                                                                         LayerInitialVisibility.Show);
                return(transectLineLayerGeoJson);
            }

            return(null);
        }
        public static LayerGeoJson GetAssessmentAreaLayerGeoJson(this OnlandVisualTrashAssessment onlandVisualTrashAssessment, bool reduce)
        {
            FeatureCollection geoJsonFeatureCollection;

            if (onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea != null)
            {
                geoJsonFeatureCollection =
                    new List <OnlandVisualTrashAssessmentArea> {
                    onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea
                }
                .ToGeoJsonFeatureCollection();
            }
            else if (onlandVisualTrashAssessment.DraftGeometry != null)
            {
                var draftGeometry = onlandVisualTrashAssessment.DraftGeometry;
                geoJsonFeatureCollection = new FeatureCollection();

                // Leaflet.Draw does not support multipolgyon editing because its dev team decided it wasn't necessary.
                // Unless https://github.com/Leaflet/Leaflet.draw/issues/268 is resolved, we have to break into separate polys.
                // On an unrelated note, DbGeometry.ElementAt is 1-indexed instead of 0-indexed, which is terrible.
                for (var i = 1; i <= draftGeometry.ElementCount.GetValueOrDefault(); i++)
                {
                    var dbGeometry = draftGeometry.ElementAt(i);
                    if (reduce)
                    {
                        // Reduce is SQL Server's implementation of the Douglas–Peucker downsampling algorithm
                        dbGeometry = dbGeometry.ToSqlGeometry().Reduce(.0000025).ToDbGeometry().FixSrid(CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID);
                    }
                    var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(dbGeometry);
                    geoJsonFeatureCollection.Features.Add(feature);
                }
            }
            else
            {
                geoJsonFeatureCollection = new FeatureCollection();
            }

            var assessmentAreaLayerGeoJson = new LayerGeoJson("parcels", geoJsonFeatureCollection,
                                                              "#ffff00", .5m,
                                                              LayerInitialVisibility.Show);

            return(assessmentAreaLayerGeoJson);
        }
        private ViewResult ViewDetail(RegionalSubbasinRevisionRequest regionalSubbasinRevisionRequest)
        {
            var geometry = regionalSubbasinRevisionRequest.RegionalSubbasinRevisionRequestGeometry;
            var feature  = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(geometry);

            var layerGeoJson = new LayerGeoJson("centralizedDelineationLayer",
                                                new FeatureCollection(new List <Feature> {
                feature
            }), "#ffff00", .5m, LayerInitialVisibility.Show);

            var mapInitJson = new RegionalSubbasinRevisionRequestMapInitJson("revisionRequestMap",
                                                                             MapInitJson.DefaultZoomLevel, new List <LayerGeoJson>(),
                                                                             new BoundingBox(new List <DbGeometry> {
                geometry
            }), layerGeoJson);

            var viewData = new DetailViewData(CurrentPerson, regionalSubbasinRevisionRequest, mapInitJson);

            return(RazorView <Detail, DetailViewData>(viewData));
        }
예제 #7
0
        public ContentResult Union(UnionOfParcelsViewModel viewModel)
        {
            var unionOfParcels = HttpRequestStorage.DatabaseEntities.Parcels
                                 .Where(x => viewModel.ParcelIDs.Contains(x.ParcelID)).Select(x => x.ParcelGeometry).ToList()
                                 .UnionListGeometries();

            var featureCollection = new FeatureCollection();

            // Leaflet.Draw does not support multipolgyon editing because its dev team decided it wasn't necessary.
            // Unless https://github.com/Leaflet/Leaflet.draw/issues/268 is resolved, we have to break into separate polys.
            // On an unrelated note, DbGeometry.ElementAt is 1-indexed instead of 0-indexed, which is terrible.
            for (var i = 1; i <= unionOfParcels.ElementCount.GetValueOrDefault(); i++)
            {
                var dbGeometry = unionOfParcels.ElementAt(i);
                // Reduce is SQL Server's implementation of the Douglas–Peucker downsampling algorithm
                dbGeometry = dbGeometry.ToSqlGeometry().Reduce(.0000025).ToDbGeometry();

                var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(dbGeometry);
                featureCollection.Features.Add(feature);
            }

            return(Content(JObject.FromObject(featureCollection).ToString(Formatting.None)));
        }