コード例 #1
0
        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
        /// <summary>
        /// Creates a LayerGeoJson with features for each TreatmentBMP in treatmentBMPs.
        /// The FeatureCollection of the resultant LayerGeoJson will have some common properties,
        /// which can be extended with the onEachFeature parameter.
        /// </summary>
        /// <param name="treatmentBMPs"></param>
        /// <param name="onEachFeature"></param>
        /// <param name="enablePopups"></param>
        /// <returns></returns>
        public static LayerGeoJson MakeTreatmentBMPLayerGeoJson(IEnumerable <TreatmentBMP> treatmentBMPs, Action <Feature, TreatmentBMP> onEachFeature, bool enablePopups)
        {
            var featureCollection        = treatmentBMPs.ToGeoJsonFeatureCollectionGeneric(onEachFeature);
            var treatmentBMPLayerGeoJson = new LayerGeoJson("Treatment BMPs", featureCollection, "blue", 1, LayerInitialVisibility.Show)
            {
                EnablePopups = enablePopups
            };

            return(treatmentBMPLayerGeoJson);
        }
コード例 #3
0
        public static LayerGeoJson MakeDelineationLayerGeoJson(IEnumerable <Delineation> delineation)
        {
            var featureCollection = delineation.ToGeoJsonFeatureCollection();

            var catchmentLayerGeoJson = new LayerGeoJson("Delineation", featureCollection, "blue", 1, LayerInitialVisibility.Show)
            {
                EnablePopups = false
            };

            return(catchmentLayerGeoJson);
        }
コード例 #4
0
        public static LayerGeoJson MakeTreatmentBMPDelineationLayerGeoJson(TreatmentBMP treatmentBMP)
        {
            Check.Require(treatmentBMP.Delineation?.DelineationGeometry != null, "Tried to build delineation layer when delineation was null");
            var featureCollection = new FeatureCollection();
            var feature           = DbGeometryToGeoJsonHelper.FromDbGeometryWithNoReproject(treatmentBMP.Delineation?.DelineationGeometry4326);

            featureCollection.Features.Add(feature);

            var treatmentBMPLayerGeoJson = new LayerGeoJson("Delineation", featureCollection, "blue", 1, LayerInitialVisibility.Show)
            {
                EnablePopups = false
            };

            return(treatmentBMPLayerGeoJson);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public StormwaterSearchMapInitJson(string mapDivID, int zoomLevel, List <LayerGeoJson> layers, BoundingBox boundingBox, LayerGeoJson searchableLayerGeoJson)
     : base(mapDivID, zoomLevel, layers, boundingBox)
 {
     SearchableLayerGeoJson = searchableLayerGeoJson;
 }
コード例 #7
0
 public StormwaterSearchMapInitJson(string mapDivID, LayerGeoJson searchableLayerGeoJson)
     : base(mapDivID, DefaultZoomLevel, MapInitJsonHelpers.GetJurisdictionMapLayers().ToList(), BoundingBox.MakeNewDefaultBoundingBox())
 {
     SearchableLayerGeoJson = searchableLayerGeoJson;
 }