Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public ActionResult Create()
        {
            var model = new AchsenSegmentModel();

            PrepareViewBag(true, model);
            return(PartialView("EditAchse", model));
        }
Exemplo n.º 3
0
        private void UpdateAchsenSegmentModel(AchsenSegmentModel achsenSegmentModel)
        {
            achsenSegmentModel = PrepareAchsenSegmentModel(achsenSegmentModel);

            achsenReferenzUpdateService.UpdateAchsenReferenzen(achsenSegmentModel, true);
            achsensegmentService.UpdateEntity(achsenSegmentModel);
        }
Exemplo n.º 4
0
 public ActionResult Insert(AchsenSegmentModel achsenSegmentModel)
 {
     if (ModelState.IsValid)
     {
         CreateAchsenSegmentModel(achsenSegmentModel);
         return(new EmsgEmptyResult());
     }
     PrepareViewBag(true, achsenSegmentModel);
     return(PartialView("EditAchse", achsenSegmentModel));
 }
Exemplo n.º 5
0
 public ActionResult ApplyUpdate(AchsenSegmentModel achsenSegmentModel)
 {
     if (ModelState.IsValid)
     {
         UpdateAchsenSegmentModel(achsenSegmentModel);
         ModelState.Clear();
     }
     PrepareViewBag(false, achsenSegmentModel);
     return(PartialView("EditAchse", achsenSegmentModel));
 }
Exemplo n.º 6
0
 public ActionResult Update(AchsenSegmentModel achsenSegmentModel)
 {
     if (ModelState.IsValid)
     {
         UpdateAchsenSegmentModel(achsenSegmentModel);
         return(new EmsgEmptyResult());
     }
     PrepareViewBag(false, achsenSegmentModel);
     return(PartialView("EditAchse", achsenSegmentModel));
 }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public ActionResult ApplyInsert(AchsenSegmentModel achsenSegmentModel)
        {
            var isInNewMode = true;

            if (ModelState.IsValid)
            {
                CreateAchsenSegmentModel(achsenSegmentModel);
                ModelState.Clear();
                isInNewMode = false;
            }
            PrepareViewBag(isInNewMode, achsenSegmentModel);
            return(PartialView("EditAchse", achsenSegmentModel));
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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);
         }
     }
 }
Exemplo n.º 11
0
        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));
        }
Exemplo n.º 12
0
 public IList <Guid> GetModifiedEntities(AchsenSegment currententity, AchsenSegmentModel newmodel)
 {
     return(this.UpdateAchsenReferenzen(currententity, newmodel.Shape, false));
 }
Exemplo n.º 13
0
        public IList <Guid> GetModifiedEntities(AchsenSegmentModel model)
        {
            AchsenSegment entity = this.achsenSegmentService.GetCurrentEntities().Where(e => e.Id == model.Id).Single();

            return(this.GetModifiedEntities(entity, model));
        }
Exemplo n.º 14
0
        public void DeleteAchsenReferenzen(AchsenSegmentModel model)
        {
            AchsenSegment segment = this.achsenSegmentService.GetCurrentEntities().Where(s => s.Id == model.Id).Single();

            this.DeleteAchsenReferenzen(segment);
        }
Exemplo n.º 15
0
        private void CreateAchsenSegmentModel(AchsenSegmentModel achsenSegmentModel)
        {
            achsenSegmentModel = PrepareAchsenSegmentModel(achsenSegmentModel);

            achsensegmentService.CreateEntity(achsenSegmentModel);
        }