public bool isAchsenSegmentModelValid(AchsenSegmentModel achsenSegmentModel, string geoJsonString) { AchsenSegmentModel model = GenerateAchsenSegmentModelFromGeoJsonString(achsenSegmentModel); var isValid = true; Envelope maxExtent = GisConstants.MaxExtent; foreach (Coordinate coord in model.Shape.Coordinates) { if (!(coord.X >= maxExtent.MinX && coord.X <= maxExtent.MaxX && coord.Y >= maxExtent.MinY && coord.Y <= maxExtent.MaxY)) { isValid = false; } } if (!model.Shape.IsSimple) { isValid = false; } CoordinateList list = new CoordinateList(model.Shape.Coordinates, false); if (list.Count <= 1) { isValid = false; } return(isValid); }
public ActionResult Create() { var model = new AchsenSegmentModel(); PrepareViewBag(true, model); return(PartialView("EditAchse", model)); }
private void UpdateAchsenSegmentModel(AchsenSegmentModel achsenSegmentModel) { achsenSegmentModel = PrepareAchsenSegmentModel(achsenSegmentModel); achsenReferenzUpdateService.UpdateAchsenReferenzen(achsenSegmentModel, true); achsensegmentService.UpdateEntity(achsenSegmentModel); }
public ActionResult Insert(AchsenSegmentModel achsenSegmentModel) { if (ModelState.IsValid) { CreateAchsenSegmentModel(achsenSegmentModel); return(new EmsgEmptyResult()); } PrepareViewBag(true, achsenSegmentModel); return(PartialView("EditAchse", achsenSegmentModel)); }
public ActionResult ApplyUpdate(AchsenSegmentModel achsenSegmentModel) { if (ModelState.IsValid) { UpdateAchsenSegmentModel(achsenSegmentModel); ModelState.Clear(); } PrepareViewBag(false, achsenSegmentModel); return(PartialView("EditAchse", achsenSegmentModel)); }
public ActionResult Update(AchsenSegmentModel achsenSegmentModel) { if (ModelState.IsValid) { UpdateAchsenSegmentModel(achsenSegmentModel); return(new EmsgEmptyResult()); } PrepareViewBag(false, achsenSegmentModel); return(PartialView("EditAchse", achsenSegmentModel)); }
public AchsenSegmentModel GenerateAchsenSegmentModelFromGeoJsonString(AchsenSegmentModel model) { string geoJSONString = model.FeatureGeoJSONString; FeatureWithID feature = GeoJSONReader.ReadFeatureWithID(new StringReader(model.FeatureGeoJSONString)); string invertedString = feature.Attributes[geoJSONAttribute_IsInverted] as string; bool? invertedbool = feature.Attributes[geoJSONAttribute_IsInverted] as bool?; model.IsInverted = (invertedString != null && invertedString.ToLower() == "true") || (invertedbool != null && invertedbool == true); //model.IsInverted = (bool)feature.Attributes[geoJSONAttribute_IsInverted]; model.Shape = feature.Geometry; model.Shape.SRID = GisConstants.SRID; return(model); }
public ActionResult ApplyInsert(AchsenSegmentModel achsenSegmentModel) { var isInNewMode = true; if (ModelState.IsValid) { CreateAchsenSegmentModel(achsenSegmentModel); ModelState.Clear(); isInNewMode = false; } PrepareViewBag(isInNewMode, achsenSegmentModel); return(PartialView("EditAchse", achsenSegmentModel)); }
private AchsenSegmentModel PrepareAchsenSegmentModel(AchsenSegmentModel achsenSegmentModel) { achsenSegmentModel = this.geoJSONParseService.GenerateAchsenSegmentModelFromGeoJsonString(achsenSegmentModel); //Snapping allows to easily create duplicates (by clicking the EXACT same spot twice) //this prevents duplicate coordinates (this should be prevented by the create tool but since duplicate Coordinates can cause problems another check here) CoordinateList list = new CoordinateList(achsenSegmentModel.Shape.Coordinates, false); if (list.Count > 1) { achsenSegmentModel.Shape = new LineString(new CoordinateArraySequence(list.ToCoordinateArray()), achsenSegmentModel.Shape.Factory); } return(achsenSegmentModel); }
private void PrepareViewBag(bool isCreateMode, AchsenSegmentModel model) { ViewBag.IsNew = isCreateMode; ViewBag.IsLocked = false; if (!isCreateMode) { var segment = achsensegmentService.GetCurrentEntities().FirstOrDefault(s => s.Id == model.Id); if (segment != null) { ViewBag.IsLocked = segment.AchsenReferenzen.Any(r => r.ReferenzGruppe != null && r.ReferenzGruppe.StrassenabschnittGIS != null && r.ReferenzGruppe.StrassenabschnittGIS.IsLocked); } } }
public IList <Guid> UpdateAchsenReferenzen(AchsenSegmentModel newmodel, bool persistChanges) { AchsenSegment entity = this.achsenSegmentService.GetCurrentEntities().Where(e => e.Id == newmodel.Id).Single(); return(this.UpdateAchsenReferenzen(entity, newmodel.Shape, persistChanges, newmodel.ModificationAction)); }
public IList <Guid> GetModifiedEntities(AchsenSegment currententity, AchsenSegmentModel newmodel) { return(this.UpdateAchsenReferenzen(currententity, newmodel.Shape, false)); }
public IList <Guid> GetModifiedEntities(AchsenSegmentModel model) { AchsenSegment entity = this.achsenSegmentService.GetCurrentEntities().Where(e => e.Id == model.Id).Single(); return(this.GetModifiedEntities(entity, model)); }
public void DeleteAchsenReferenzen(AchsenSegmentModel model) { AchsenSegment segment = this.achsenSegmentService.GetCurrentEntities().Where(s => s.Id == model.Id).Single(); this.DeleteAchsenReferenzen(segment); }
private void CreateAchsenSegmentModel(AchsenSegmentModel achsenSegmentModel) { achsenSegmentModel = PrepareAchsenSegmentModel(achsenSegmentModel); achsensegmentService.CreateEntity(achsenSegmentModel); }