public void UpdateModel(Models.InteractionEvent interactionEvent) { if (InteractionEventLocationPointX != null && InteractionEventLocationPointY != null) { interactionEvent.InteractionEventLocationSimple = DbSpatialHelper.MakeDbGeometryFromCoordinates(InteractionEventLocationPointX.Value, InteractionEventLocationPointY.Value, MapInitJson.CoordinateSystemId); } }
public void UpdateModelBatch(ProjectUpdateBatch projectUpdateBatch) { var projectUpdate = projectUpdateBatch.ProjectUpdate; projectUpdate.ProjectLocationSimpleTypeID = ProjectFirmaModels.Models.ProjectLocationSimpleType.ToType(ProjectLocationSimpleType).ProjectLocationSimpleTypeID; switch (ProjectLocationSimpleType) { case ProjectLocationSimpleTypeEnum.PointOnMap: case ProjectLocationSimpleTypeEnum.LatLngInput: // Using ProjectLocationPoint here because the location is being updated projectUpdate.ProjectLocationPoint = ProjectLocationPointX.HasValue && ProjectLocationPointY.HasValue ? DbSpatialHelper.MakeDbGeometryFromCoordinates(ProjectLocationPointX.Value, ProjectLocationPointY.Value, LtInfoGeometryConfiguration.DefaultCoordinateSystemId) : null; break; case ProjectLocationSimpleTypeEnum.None: // Using ProjectLocationPoint here because the location is being updated projectUpdate.ProjectLocationPoint = null; break; default: throw new ArgumentOutOfRangeException(); } projectUpdate.ProjectLocationNotes = ProjectLocationNotes; projectUpdate.LocationIsPrivate = LocationIsPrivate; }
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()); }
public OnlandVisualTrashAssessmentObservation ToOnlandVisualTrashAssessmentObservation() { DbGeometry locationPoint4326 = DbSpatialHelper.MakeDbGeometryFromCoordinates(LocationX.GetValueOrDefault(), LocationY.GetValueOrDefault(), CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID); var locationPoint2771 = CoordinateSystemHelper.ProjectWebMercatorToCaliforniaStatePlaneVI(locationPoint4326); return(new OnlandVisualTrashAssessmentObservation(OnlandVisualTrashAssessmentObservationID, OnlandVisualTrashAssessmentID, locationPoint2771, Note, ObservationDateTime, locationPoint4326)); }
public ActionResult ImportGdbFile(ProjectPrimaryKey projectPrimaryKey, ImportGdbFileViewModel viewModel) { var project = projectPrimaryKey.EntityObject; if (!ModelState.IsValid) { return(ViewImportGdbFile(viewModel, project.ProjectID)); } var httpPostedFileBase = viewModel.FileResourceData; var isKml = httpPostedFileBase.FileName.EndsWith(".kml"); var isKmz = httpPostedFileBase.FileName.EndsWith(".kmz"); var fileEnding = isKml ? ".kml" : isKmz ? ".kmz" : ".gdb.zip"; using (var disposableTempFile = DisposableTempFile.MakeDisposableTempFileEndingIn(fileEnding)) { var disposableTempFileFileInfo = disposableTempFile.FileInfo; httpPostedFileBase.SaveAs(disposableTempFileFileInfo.FullName); foreach (var projectLocationStaging in project.ProjectLocationStagings.ToList()) { projectLocationStaging.DeleteFull(HttpRequestStorage.DatabaseEntities); } try { if (isKml) { ProjectLocationStagingModelExtensions.CreateProjectLocationStagingListFromKml( disposableTempFileFileInfo, httpPostedFileBase.FileName, project, CurrentFirmaSession); } else if (isKmz) { ProjectLocationStagingModelExtensions.CreateProjectLocationStagingListFromKmz( disposableTempFileFileInfo, httpPostedFileBase.FileName, project, CurrentFirmaSession); } else { ProjectLocationStagingModelExtensions.CreateProjectLocationStagingListFromGdb( disposableTempFileFileInfo, httpPostedFileBase.FileName, project, CurrentFirmaSession); } // Run a quick test to see if the uploaded geometries are going to be reducible later. // If they aren't, we can throw the SitkaGeometryDisplayErrorException to capture a record of the uploaded file. var mockGeometries = project.ProjectLocationStagings.SelectMany(x => x.ToGeoJsonFeatureCollection().Features.Select(y => y.ToSqlGeometry())).ToList(); Check.Assert(DbSpatialHelper.CanReduce(mockGeometries), new SitkaGeometryDisplayErrorException("Could not reduce the uploaded geometries.")); } catch (SitkaGeometryDisplayErrorException exception) { string preservedFilenameFullPath = ProjectLocationStagingModelExtensions.PreserveFailedLocationImportFile(httpPostedFileBase); throw new SitkaGeometryDisplayErrorException(exception.Message, preservedFilenameFullPath); } } return(ApproveGisUpload(project)); }
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)); }
public virtual void UpdateModel(Models.TreatmentBMP treatmentBMP, Person currentPerson) { // note that these nullables will never be null due to the Required attribute // this is coming FROM the browser, so it has to be reprojected to CA State Plane var locationPoint4326 = DbSpatialHelper.MakeDbGeometryFromCoordinates(TreatmentBMPPointX.GetValueOrDefault(), TreatmentBMPPointY.GetValueOrDefault(), CoordinateSystemHelper.WGS_1984_SRID); var locationPoint = CoordinateSystemHelper.ProjectWebMercatorToCaliforniaStatePlaneVI(locationPoint4326); treatmentBMP.LocationPoint = locationPoint; treatmentBMP.LocationPoint4326 = locationPoint4326; treatmentBMP.UpdateUpstreamBMPReferencesIfNecessary(); // associate watershed, lspc basin, precipitation zone treatmentBMP.SetTreatmentBMPPointInPolygonDataByLocationPoint(locationPoint); treatmentBMP.UpdatedCentralizedBMPDelineationIfPresent(); }
public virtual void UpdateModel(IProject project) { project.ProjectLocationSimpleTypeID = Models.ProjectLocationSimpleType.ToType(ProjectLocationSimpleType).ProjectLocationSimpleTypeID; switch (ProjectLocationSimpleType) { case ProjectLocationSimpleTypeEnum.PointOnMap: project.ProjectLocationPoint = DbSpatialHelper.MakeDbGeometryFromCoordinates(ProjectLocationPointX.Value, ProjectLocationPointY.Value, MapInitJson.CoordinateSystemId); break; case ProjectLocationSimpleTypeEnum.None: project.ProjectLocationPoint = null; break; default: throw new ArgumentOutOfRangeException(); } project.ProjectLocationNotes = ProjectLocationNotes; }
public virtual void UpdateModel(IProject iProject) { iProject.ProjectLocationSimpleTypeID = ProjectFirmaModels.Models.ProjectLocationSimpleType.ToType(ProjectLocationSimpleType).ProjectLocationSimpleTypeID; switch (ProjectLocationSimpleType) { case ProjectLocationSimpleTypeEnum.PointOnMap: case ProjectLocationSimpleTypeEnum.LatLngInput: // Using ProjectLocationPoint here because location is being updated iProject.ProjectLocationPoint = DbSpatialHelper.MakeDbGeometryFromCoordinates(ProjectLocationPointX.Value, ProjectLocationPointY.Value, LtInfoGeometryConfiguration.DefaultCoordinateSystemId); break; case ProjectLocationSimpleTypeEnum.None: // Using ProjectLocationPoint here because location is being updated iProject.ProjectLocationPoint = null; break; default: throw new ArgumentOutOfRangeException(); } iProject.ProjectLocationNotes = ProjectLocationNotes; iProject.LocationIsPrivate = LocationIsPrivate; }
public void UpdateModelBatch(ProjectUpdateBatch projectUpdateBatch) { var project = projectUpdateBatch.ProjectUpdate; project.ProjectLocationSimpleTypeID = Models.ProjectLocationSimpleType.ToType(ProjectLocationSimpleType).ProjectLocationSimpleTypeID; switch (ProjectLocationSimpleType) { case ProjectLocationSimpleTypeEnum.PointOnMap: project.ProjectLocationPoint = ProjectLocationPointX.HasValue && ProjectLocationPointY.HasValue ? DbSpatialHelper.MakeDbGeometryFromCoordinates(ProjectLocationPointX.Value, ProjectLocationPointY.Value, MapInitJson.CoordinateSystemId) : null; break; case ProjectLocationSimpleTypeEnum.None: project.ProjectLocationPoint = null; break; default: throw new ArgumentOutOfRangeException(); } project.ProjectLocationNotes = ProjectLocationNotes; }