Ejemplo n.º 1
0
        public PartialViewResult EditProjectLocationDetailed(ProjectPrimaryKey projectPrimaryKey)
        {
            var project   = projectPrimaryKey.EntityObject;
            var viewModel = new ProjectLocationDetailViewModel();

            return(ViewEditProjectLocationDetailed(project, viewModel));
        }
Ejemplo n.º 2
0
        private PartialViewResult ViewEditProjectLocationDetailed(Project project, ProjectLocationDetailViewModel viewModel)
        {
            var mapDivID = $"project_{project.GetEntityID()}_EditDetailedMap";
            var detailedLocationGeoJsonFeatureCollection = project.DetailedLocationToGeoJsonFeatureCollection(true);
            var editableLayerGeoJson = new LayerGeoJson($"{FieldDefinitionEnum.ProjectLocation.ToType().GetFieldDefinitionLabel()} Detail", detailedLocationGeoJsonFeatureCollection, "red", 1, LayerInitialVisibility.LayerInitialVisibilityEnum.Show);

            var layers = MapInitJson.GetConfiguredGeospatialAreaMapLayers();
            var userCanViewPrivateLocations = CurrentFirmaSession.UserCanViewPrivateLocations(project);

            layers.AddRange(MapInitJson.GetProjectLocationSimpleMapLayer(project, userCanViewPrivateLocations));
            var boundingBox = ProjectLocationSummaryMapInitJson.GetProjectBoundingBox(project, userCanViewPrivateLocations);
            var mapInitJson = new MapInitJson(mapDivID, 10, layers, MapInitJson.GetExternalMapLayers(), boundingBox)
            {
                AllowFullScreen = false,
                DisablePopups   = true
            };

            var mapFormID        = GenerateEditProjectLocationFormID(project.GetEntityID());
            var uploadGisFileUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.ImportGdbFile(project.GetEntityID()));

            var saveFeatureCollectionUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(x => x.EditProjectLocationDetailed(project.GetEntityID(), null));

            var hasSimpleLocationPoint = project.HasProjectLocationPoint(userCanViewPrivateLocations);

            var viewData = new ProjectLocationDetailViewData(project.GetEntityID(), mapInitJson, editableLayerGeoJson, uploadGisFileUrl, mapFormID,
                                                             saveFeatureCollectionUrl, ProjectLocation.FieldLengths.Annotation, hasSimpleLocationPoint, project.LocationIsPrivate);

            return(RazorPartialView <ProjectLocationDetail, ProjectLocationDetailViewData, ProjectLocationDetailViewModel>(viewData, viewModel));
        }
Ejemplo n.º 3
0
        public ActionResult ApproveGisUpload(ProjectPrimaryKey projectPrimaryKey, ProjectLocationDetailViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewApproveGisUpload(project, viewModel));
            }
            SaveProjectDetailedLocations(viewModel, project, out bool hadToMakeValid, out bool atLeastOneCouldNotBeCorrected);
            if (hadToMakeValid && !atLeastOneCouldNotBeCorrected)
            {
                SetWarningForDisplay("One or more of your imported shapes had to be corrected in order to make it a valid geometry. Most likely this resulted in no noticeable changes, but please review the detailed location to verify.");
            }
            if (atLeastOneCouldNotBeCorrected && !hadToMakeValid)
            {
                SetWarningForDisplay("One or more of your imported shapes could not be made into a valid geometry and was not saved. All other shapes were saved. Please review the detailed location to verify.");
            }

            if (atLeastOneCouldNotBeCorrected && hadToMakeValid)
            {
                SetWarningForDisplay("One or more of your imported shapes had to be corrected in order to make it a valid geometry. Most likely this resulted in no noticeable changes." +
                                     " Additionally, one or more of your imported shapes could not be made into a valid geometry and was not saved. All other shapes were saved. Please review the detailed location to verify.");
            }
            DbSpatialHelper.Reduce(new List <IHaveSqlGeometry>(project.GetProjectLocationDetailed(true).ToList()));
            return(new ModalDialogFormJsonResult());
        }
Ejemplo n.º 4
0
        private PartialViewResult ViewEditProjectLocationDetailed(Project project, ProjectLocationDetailViewModel viewModel)
        {
            var mapDivID = $"project_{project.EntityID}_EditDetailedMap";
            var detailedLocationGeoJsonFeatureCollection = project.ProjectLocations.Where(pl => !pl.ArcGisObjectID.HasValue).ToGeoJsonFeatureCollection();
            var editableLayerGeoJson = new LayerGeoJson($"{FieldDefinition.ProjectLocation.GetFieldDefinitionLabel()} Detail", detailedLocationGeoJsonFeatureCollection, "red", 1, LayerInitialVisibility.Show);

            var arcGisLocationGeoJsonFeatureCollection = project.ProjectLocations.Where(pl => pl.ArcGisObjectID.HasValue).ToGeoJsonFeatureCollection();
            var arcGisLayerGeoJson = new LayerGeoJson($"{FieldDefinition.ProjectLocation.GetFieldDefinitionLabel()} Detail", arcGisLocationGeoJsonFeatureCollection, "red", 1, LayerInitialVisibility.Show);

            var layers = MapInitJson.GetAllGeospatialAreaMapLayers(LayerInitialVisibility.Show);

            layers.AddRange(MapInitJson.GetProjectLocationSimpleMapLayer(project));
            var boundingBox = ProjectLocationSummaryMapInitJson.GetProjectBoundingBox(project);
            var mapInitJson = new MapInitJson(mapDivID, 10, layers, boundingBox)
            {
                AllowFullScreen = false,
                DisablePopups   = true
            };

            var mapFormID        = GenerateEditProjectLocationFormID(project.EntityID);
            var uploadGisFileUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(c => c.ImportGdbFile(project.EntityID));

            var saveFeatureCollectionUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(x => x.EditProjectLocationDetailed(project.EntityID, null));

            var hasSimpleLocationPoint = project.ProjectLocationPoint != null;

            var viewData = new ProjectLocationDetailViewData(project.EntityID, mapInitJson, editableLayerGeoJson, arcGisLayerGeoJson, uploadGisFileUrl, mapFormID, saveFeatureCollectionUrl, ProjectLocation.FieldLengths.ProjectLocationNotes, hasSimpleLocationPoint);

            return(RazorPartialView <ProjectLocationDetail, ProjectLocationDetailViewData, ProjectLocationDetailViewModel>(viewData, viewModel));
        }
Ejemplo n.º 5
0
        private PartialViewResult ViewApproveGisUpload(Project project, ProjectLocationDetailViewModel viewModel)
        {
            var projectLocationStagings = project.ProjectLocationStagings.ToList();
            var layerGeoJsons           =
                projectLocationStagings.Select(
                    (projectLocationStaging, i) =>
                    new LayerGeoJson(projectLocationStaging.FeatureClassName,
                                     projectLocationStaging.ToGeoJsonFeatureCollection(),
                                     FirmaHelpers.DefaultColorRange[i],
                                     1,
                                     LayerInitialVisibility.LayerInitialVisibilityEnum.Show)).ToList();

            var showFeatureClassColumn = projectLocationStagings.Any(x => x.FeatureClassName.Length > 0);

            var boundingBox = BoundingBox.MakeBoundingBoxFromLayerGeoJsonList(layerGeoJsons);

            var mapInitJson = new MapInitJson($"project_{project.ProjectID}_PreviewMap", 10, layerGeoJsons, MapInitJson.GetExternalMapLayers(), boundingBox, false)
            {
                AllowFullScreen = false, DisablePopups = true
            };
            var mapFormID           = GenerateEditProjectLocationFormID(((IProject)project).GetEntityID());
            var approveGisUploadUrl = SitkaRoute <ProjectLocationController> .BuildUrlFromExpression(x => x.ApproveGisUpload(project, null));

            var viewData = new ApproveGisUploadViewData(new List <IProjectLocationStaging>(projectLocationStagings), mapInitJson, mapFormID, approveGisUploadUrl, showFeatureClassColumn);

            return(RazorPartialView <ApproveGisUpload, ApproveGisUploadViewData, ProjectLocationDetailViewModel>(viewData, viewModel));
        }
Ejemplo n.º 6
0
        private static void SaveProjectDetailedLocations(ProjectLocationDetailViewModel viewModel, Project project)
        {
            //update the editable ProjectLocations
            if (viewModel.ProjectLocationJsons != null)
            {
                foreach (var projectLocationJson in viewModel.ProjectLocationJsons.Where(x => !x.ArcGisObjectID.HasValue))
                {
                    var projectLocationGeometry =
                        DbGeometry.FromText(projectLocationJson.ProjectLocationGeometryWellKnownText,
                                            FirmaWebConfiguration.GeoSpatialReferenceID);
                    var projectLocation = new ProjectLocation(project, projectLocationJson.ProjectLocationName,
                                                              projectLocationGeometry, projectLocationJson.ProjectLocationTypeID,
                                                              projectLocationJson.ProjectLocationNotes);
                    project.ProjectLocations.Add(projectLocation);
                }
            }

            //update arcGIS ProjectLocations for the notes
            foreach (var matched in viewModel.ArcGisProjectLocationJsons.Where(x => x.ArcGisObjectID.HasValue)
                     .Join(project.ProjectLocations, plj => plj.ProjectLocationID, pl => pl.ProjectLocationID,
                           (lhs, rhs) => new { ProjectLocationJson = lhs, ProjectLocation = rhs }))
            {
                matched.ProjectLocation.ProjectLocationNotes = matched.ProjectLocationJson.ProjectLocationNotes;
            }
        }
Ejemplo n.º 7
0
        public PartialViewResult ApproveGisUpload(ProjectPrimaryKey projectPrimaryKey)
        {
            var project   = projectPrimaryKey.EntityObject;
            var viewModel = new ProjectLocationDetailViewModel(project.ProjectLocations);

            return(ViewApproveGisUpload(project, viewModel));
        }
Ejemplo n.º 8
0
        private static void SaveProjectDetailedLocationsWithDelete(ProjectLocationDetailViewModel viewModel, Project project)
        {
            var currentProjectLocationsThatAreEditable = project.ProjectLocations.Where(x => !x.ArcGisObjectID.HasValue).ToList();

            foreach (var currentProjectLocation in currentProjectLocationsThatAreEditable)
            {
                currentProjectLocation.DeleteFull(HttpRequestStorage.DatabaseEntities);
                project.ProjectLocations.Remove(currentProjectLocation);
            }
            SaveProjectDetailedLocations(viewModel, project);
        }
Ejemplo n.º 9
0
        public ActionResult ApproveGisUpload(ProjectPrimaryKey projectPrimaryKey, ProjectLocationDetailViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewApproveGisUpload(project, viewModel));
            }
            SaveProjectDetailedLocations(viewModel, project);
            DbSpatialHelper.Reduce(new List <IHaveSqlGeometry>(project.ProjectLocations.ToList()));
            return(EditProjectLocationDetailed(projectPrimaryKey));
        }
Ejemplo n.º 10
0
        private static void SaveProjectDetailedLocations(ProjectLocationDetailViewModel viewModel, Project project, out bool hadToMakeValid, out bool atLeastOneCouldNotBeCorrected)
        {
            foreach (var projectLocation in project.GetProjectLocationDetailedAsProjectLocations(true).ToList())
            {
                projectLocation.DeleteFull(HttpRequestStorage.DatabaseEntities);
            }

            hadToMakeValid = false;
            atLeastOneCouldNotBeCorrected = false;



            if (viewModel.WktAndAnnotations != null)
            {
                var dbGeomsToAdd =
                    ProjectCreateController.MakeValidDbGeometriesFromWellKnownTextAndAnnotations(
                        viewModel.WktAndAnnotations, out hadToMakeValid, out atLeastOneCouldNotBeCorrected);
                foreach (var dbGeomTuple in dbGeomsToAdd)
                {
                    project.ProjectLocations.Add(new ProjectLocation(project, dbGeomTuple.Item1, dbGeomTuple.Item2));
                }
            }
        }
Ejemplo n.º 11
0
        public ActionResult EditProjectLocationDetailed(ProjectPrimaryKey projectPrimaryKey, ProjectLocationDetailViewModel viewModel)
        {
            var project = projectPrimaryKey.EntityObject;

            if (!ModelState.IsValid)
            {
                return(ViewEditProjectLocationDetailed(project, viewModel));
            }
            SaveProjectDetailedLocationsWithDelete(viewModel, project);
            return(new ModalDialogFormJsonResult());
        }