public void DeleteAchsenReferenzen(AchsenSegment segment) { foreach (AchsenReferenz aref in segment.AchsenReferenzen.ToList()) { this.DeleteAchsenReferenz(aref); } }
public void AfterCreateSegment(AchsenSegment segment) { if (segment.ImpNr > 1) // incremental update, we suppress those warnings for full updates { AchsenUpdateConflict conflict = CreateConflict(AchsenUpdateConflict.CONFLICTTYPE_NEWSEGMENT, segment.Id, segment.Shape); conflict.ItemType = AchsenUpdateConflict.ITEMTYPE_SEGMENT; conflict.ItemId = segment.Id; conflict.Name = segment.Name; session.Persist(conflict); } }
public Feature CreateAchsenSegmentFeature(AchsenSegment achsensegment) { Feature feature = new Feature(); IAttributesTable attributes = new AttributesTable(); feature.Geometry = achsensegment.Shape; //ID attributes.AddAttribute(checkStringLengthforDBF(CheckOutGISDefaults.AchsensegmentID), achsensegment.Id.ToString()); feature.Attributes = attributes; return(feature); }
private Sektor findSektor(AchsenSegment achsenSegment, KopieSektor kopieSektor) { var list = achsenSegment.Sektoren.Where(o => o.BsId == kopieSektor.Id); if (list.Count() == 0) { list = achsenCache.SelectMany(a => a.Value.AchsenSegmente).SelectMany(s => s.Sektoren).Where(se => se.BsId == kopieSektor.Id); if (!list.Any()) { return(null); } } return(list.First()); }
public void AngenommenDieFolgendenStrassenabschnitteGUSExistieren(Table table) { using (var scope = new NHibernateSpecflowScope()) { foreach (var currentErfassungsperiod in scope.Session.Query <ErfassungsPeriod>()) { var achse = new Achse { VersionValidFrom = DateTime.Now, ErfassungsPeriod = currentErfassungsperiod }; var segment = new AchsenSegment(); segment.Achse = achse; segment.ErfassungsPeriod = currentErfassungsperiod; achse.AchsenSegmente.Add(segment); scope.Session.Save(segment); scope.Session.Save(achse); } } var reader = GetObjectReaderConfigurationFor <StrassenabschnittGIS>() .PropertyAliasFor(e => e.ErfassungsPeriod, "Jahr") .ConverterFor(e => e.Belastungskategorie, (s, p) => ScenarioContextWrapper.CurrentScope.Session.Query <Belastungskategorie>().ToArray().Single(i => i.Typ == s)) .ConverterFor(e => e.Mandant, (s, p) => new Mandant { MandantName = s }) .ConverterFor(e => e.ErfassungsPeriod, (s, p) => new ErfassungsPeriod { Erfassungsjahr = new DateTime(int.Parse(s), 1, 1) }); using (var nhScope = new NHibernateSpecflowScope()) { entitesProErfassungsmodus[NetzErfassungsmodus.Gis][typeof(StrassenabschnittGIS)] = reader.GetObjectReader().GetObjectList <StrassenabschnittGIS>(table); foreach (StrassenabschnittGIS strassenabschnitt in entitesProErfassungsmodus[NetzErfassungsmodus.Gis][typeof(StrassenabschnittGIS)]) { var segment = nhScope.Session.Query <AchsenSegment>().First(a => !a.ErfassungsPeriod.IsClosed && a.ErfassungsPeriod.Mandant.MandantName == strassenabschnitt.Mandant.MandantName); var achsenReferenz = new AchsenReferenz(); achsenReferenz.AchsenSegment = segment; var referenzGruppe = new ReferenzGruppe(); strassenabschnitt.ReferenzGruppe = referenzGruppe; referenzGruppe.StrassenabschnittGISList.Add(strassenabschnitt); achsenReferenz.ReferenzGruppe = referenzGruppe; referenzGruppe.AchsenReferenzen.Add(achsenReferenz); } } }
public void BeforeUpdateSegment(AchsenSegment targetSegment, KopieAchse kopieAchse, KopieAchsenSegment kopieSegment) { DateTime oldVersionValidFrom = oldAxisValidFromDict[targetSegment.Achse.BsId]; DateTime newVersionValidFrom = kopieAchse.VersionValidFrom; if (targetSegment.AchsenReferenzen.Count > 0) { foreach (AchsenReferenz achsRef in new List <AchsenReferenz>(targetSegment.AchsenReferenzen)) { ILineString oldRefGeometry = (ILineString)achsRef.Shape; ILineString newSegmentGeometry = GeometryUtils.ConvertMLineStringTo2D(gf, (MLineString)kopieSegment.Shape); GeometryTransformer gt = new GeometryTransformer(oldRefGeometry, newSegmentGeometry); GeometryTransformerResult result = gt.Transform(); switch (result.ResultState) { case GeometryTransformerResultState.Success: { achsRef.Shape = result.NewRefGeometry; Register(achsRef); statistics.UpdatedReferences++; break; } case GeometryTransformerResultState.FailedWouldBeOutside: { RegisterConflict(achsRef, CreateConflict(AchsenUpdateConflict.CONFLICTTYPE_PARTIAL_REFERENCE_OUTSIDE, targetSegment.Id, oldRefGeometry)); RemoveReference(achsRef); statistics.DeletedReferences++; break; } case GeometryTransformerResultState.FailedWouldBeTooShort: { RegisterConflict(achsRef, CreateConflict(AchsenUpdateConflict.CONFLICTTYPE_PARTIAL_REFERENCE_TOOSHORT, targetSegment.Id, oldRefGeometry)); RemoveReference(achsRef); statistics.DeletedReferences++; break; } } } } }
public void BeforeDeleteSegment(AchsenSegment segment) { if (segment.AchsenReferenzen.Count > 0) { // Delete References and Strabs and ZustandsAbs... foreach (AchsenReferenz achsRef in new List <AchsenReferenz>(segment.AchsenReferenzen)) { RegisterConflict(achsRef, CreateConflict(AchsenUpdateConflict.CONFLICTTYPE_PARTIAL_SEGMENT_DELETED, segment.Id, achsRef.Shape)); RemoveReference(achsRef); } } AchsenUpdateConflict conflict = CreateConflict(AchsenUpdateConflict.CONFLICTTYPE_PARTIAL_SEGMENT_DELETED, segment.Id, segment.Shape); conflict.ItemType = AchsenUpdateConflict.ITEMTYPE_SEGMENT; conflict.ItemId = segment.Id; conflict.Name = segment.Name; session.Persist(conflict); }
public void AngenommenFurMandantExistierenFolgendeNetzinformationen(string mandant, Table table) { using (NHibernateSpecflowScope scope = new NHibernateSpecflowScope()) { var strassenabschnittReader = GetStrassenabschnittGISReader(); var strassenabschnitten = strassenabschnittReader.GetObjectList <StrassenabschnittGIS>(table); ErfassungsPeriod currentErfassungsperiod = scope.GetCurrentErfassungsperiod(mandant); var achse = new Achse { VersionValidFrom = DateTime.Now, ErfassungsPeriod = currentErfassungsperiod }; var segment = new AchsenSegment(); segment.Achse = achse; segment.ErfassungsPeriod = currentErfassungsperiod; achse.AchsenSegmente.Add(segment); scope.Session.Save(segment); scope.Session.Save(achse); foreach (var strassenabschnitt in strassenabschnitten) { strassenabschnitt.Mandant = scope.GetMandant(mandant); strassenabschnitt.ErfassungsPeriod = currentErfassungsperiod; var achsenReferenz = new AchsenReferenz(); achsenReferenz.AchsenSegment = segment; segment.AchsenReferenzen.Add(achsenReferenz); scope.Session.Save(achsenReferenz); var referenzGruppe = new ReferenzGruppe(); strassenabschnitt.ReferenzGruppe = referenzGruppe; referenzGruppe.StrassenabschnittGISList.Add(strassenabschnitt); achsenReferenz.ReferenzGruppe = referenzGruppe; referenzGruppe.AchsenReferenzen.Add(achsenReferenz); scope.Session.Save(referenzGruppe); scope.Session.Save(strassenabschnitt); } } }
private Sektor UpdateSektor(AchsenSegment achsenSegment, KopieSektor kopieSektor, int operation) { if (kopieSektor.ImpNr <= lastImpNr) { return(null); } maxImpNr = Math.Max(maxImpNr, kopieSektor.ImpNr); switch (operation) { case AxisImportOperation.DELETE: { Sektor sektor = findSektor(achsenSegment, kopieSektor); if (sektor == null) { return(null); } achsenSegment.Sektoren.Remove(sektor); session.Delete(sektor); statistics.NumSector.Deletes++; return(null); } case AxisImportOperation.UPDATE: { Sektor sektor = findSektor(achsenSegment, kopieSektor); if (sektor == null) { return(UpdateSektor(achsenSegment, kopieSektor, AxisImportOperation.INSERT)); } sektor = gisKopieMappingEngine.Translate <KopieSektor, Sektor>(kopieSektor, sektor); statistics.NumSector.Updates++; return(sektor); } case AxisImportOperation.INSERT: { if (findSektor(achsenSegment, kopieSektor) != null) { throw new Exception("Cannot insert: KopieSektor " + kopieSektor.Id + " already exists in Sektor Table!"); } Sektor sektor = gisKopieMappingEngine.Translate <KopieSektor, Sektor>(kopieSektor); sektor.BsId = kopieSektor.Id; sektor.AchsenSegment = achsenSegment; achsenSegment.Sektoren.Add(sektor); statistics.NumSector.Inserts++; return(sektor); } } return(null); }
private AchsenSegment UpdateSegment(Achse achse, KopieAchse kopieAchse, KopieAchsenSegment kopieSegment, int operation) { if (kopieSegment.ImpNr <= lastImpNr) { return(null); } maxImpNr = Math.Max(maxImpNr, kopieSegment.ImpNr); switch (operation) { case AxisImportOperation.DELETE: { AchsenSegment segment = findSegment(achse, kopieSegment); if (segment == null) { return(null); } if (ReferenceUpdater != null) { ReferenceUpdater.BeforeDeleteSegment(segment); } foreach (KopieSektor kopieSektor in kopieSegmentToSektorDict[kopieSegment]) { UpdateSektor(segment, kopieSektor, kopieSektor.Operation); } achse.AchsenSegmente.Remove(segment); session.Delete(segment); statistics.NumSegment.Deletes++; return(null); } case AxisImportOperation.UPDATE: { AchsenSegment segment = findSegment(achse, kopieSegment); if (segment == null) { return(UpdateSegment(achse, kopieAchse, kopieSegment, AxisImportOperation.INSERT)); } if (ReferenceUpdater != null) { ReferenceUpdater.BeforeUpdateSegment(segment, kopieAchse, kopieSegment); } segment = gisKopieMappingEngine.Translate <KopieAchsenSegment, AchsenSegment>(kopieSegment, segment); segment.Shape4d = kopieSegment.Shape; if (segment.Mandant != mandant) { throw new Exception("segment.Mandant != mandant"); } foreach (KopieSektor kopieSektor in kopieSegmentToSektorDict[kopieSegment]) { UpdateSektor(segment, kopieSektor, kopieSektor.Operation); } statistics.NumSegment.Updates++; return(segment); } case AxisImportOperation.INSERT: { if (findSegment(achse, kopieSegment) != null) { throw new Exception("Cannot insert: KopieSegment " + kopieSegment.Id + " already exists in AchsenSegment table!"); } AchsenSegment segment = gisKopieMappingEngine.Translate <KopieAchsenSegment, AchsenSegment>(kopieSegment); segment.BsId = kopieSegment.Id; segment.Shape4d = kopieSegment.Shape; segment.Mandant = mandant; segment.ErfassungsPeriod = erfassungsPeriod; segment.Achse = achse; achse.AchsenSegmente.Add(segment); foreach (KopieSektor kopieSektor in kopieSegmentToSektorDict[kopieSegment]) { UpdateSektor(segment, kopieSektor, kopieSektor.Operation); } if (ReferenceUpdater != null) { ReferenceUpdater.AfterCreateSegment(segment); } statistics.NumSegment.Inserts++; return(segment); } } return(null); }
private IList <Guid> UpdateAchsenReferenzen(AchsenSegment currententity, IGeometry shape, bool persistChanges, AchseModificationAction modificationAction = AchseModificationAction.Change) { Dictionary <AchsenReferenz, GeometryTransformerResult> ret = new Dictionary <AchsenReferenz, GeometryTransformerResult>(); foreach (AchsenReferenz referenz in currententity.AchsenReferenzen.ToList()) { ILineString oldRefGeometry = (ILineString)referenz.Shape; ILineString newSegmentGeometry = (ILineString)shape; GeometryTransformer gt = new GeometryTransformer(oldRefGeometry, newSegmentGeometry); GeometryTransformerResult result = gt.Transform(); if (result.ResultState != GeometryTransformerResultState.Success || !result.NewRefGeometry.EqualsExact(oldRefGeometry)) { ret.Add(referenz, result); } } //check if strabs are overlapping other strabs foreach (var pair in ret.Where(p => p.Key.ReferenzGruppe.StrassenabschnittGIS != null && p.Value.ResultState == GeometryTransformerResultState.Success).ToList()) { IEnumerable <AchsenReferenz> strabsar = pair.Key.AchsenSegment.AchsenReferenzen.Where(ar => ar.Id != pair.Key.Id && ar.ReferenzGruppe.StrassenabschnittGIS != null); foreach (AchsenReferenz strabref in strabsar) { IGeometry currentstrabref = strabref.Shape; bool exists = true; KeyValuePair <AchsenReferenz, GeometryTransformerResult> newZabref = ret.Where(p => p.Key.Id.Equals(strabref.Id)).SingleOrDefault(); if (!newZabref.Equals(default(KeyValuePair <AchsenReferenz, GeometryTransformerResult>))) { currentstrabref = newZabref.Value.NewRefGeometry; exists = newZabref.Value.ResultState == GeometryTransformerResultState.Success; } if (exists) { if (!gisService.CheckOverlapp(new List <IGeometry>() { currentstrabref }, pair.Value.NewRefGeometry)) { ret[pair.Key] = new GeometryTransformerResult(GeometryTransformerResultState.FailedWouldBeOutside, pair.Value.NewRefGeometry); } } } } //check if zabs still within strabs and update results if not, ensure zabs are not overlapping others foreach (var pair in ret.Where(p => p.Key.ReferenzGruppe.ZustandsabschnittGIS != null && p.Value.ResultState == GeometryTransformerResultState.Success).ToList()) { ZustandsabschnittGIS zab = pair.Key.ReferenzGruppe.ZustandsabschnittGIS; if (zab != null && pair.Value.ResultState == GeometryTransformerResultState.Success) { IEnumerable <AchsenReferenz> strabrefs = ret.Where(p => p.Key.ReferenzGruppe.StrassenabschnittGIS != null && p.Key.ReferenzGruppe.StrassenabschnittGIS.Id == zab.StrassenabschnittGIS.Id && p.Value.ResultState == GeometryTransformerResultState.Success).Select(p => p.Key).ToList(); IList <IGeometry> zabrefs = new List <IGeometry>() { pair.Value.NewRefGeometry }; foreach (AchsenReferenz achsref in strabrefs) { bool isWithin = false; if (ret[achsref].ResultState == GeometryTransformerResultState.Success) { isWithin = isWithin || gisService.CheckGeometriesIsInControlGeometry(zabrefs, ret[achsref].NewRefGeometry); } if (!isWithin) { ret[pair.Key] = new GeometryTransformerResult(GeometryTransformerResultState.FailedWouldBeOutside, pair.Value.NewRefGeometry); } } IEnumerable <AchsenReferenz> allzabrefs = zab.StrassenabschnittGIS.Zustandsabschnitten.SelectMany(z => z.ReferenzGruppe.AchsenReferenzen).Where(ar => !ar.Id.Equals(pair.Key.Id)); foreach (AchsenReferenz zabref in allzabrefs) { IGeometry currentzabref = zabref.Shape; bool exists = true; KeyValuePair <AchsenReferenz, GeometryTransformerResult> newZabref = ret.Where(p => p.Key.Id.Equals(zabref.Id)).SingleOrDefault(); if (!newZabref.Equals(default(KeyValuePair <AchsenReferenz, GeometryTransformerResult>))) { currentzabref = newZabref.Value.NewRefGeometry; exists = newZabref.Value.ResultState == GeometryTransformerResultState.Success; } if (exists) { if (!gisService.CheckOverlapp(new List <IGeometry>() { currentzabref }, pair.Value.NewRefGeometry)) { ret[pair.Key] = new GeometryTransformerResult(GeometryTransformerResultState.FailedWouldBeOutside, pair.Value.NewRefGeometry); } } } } } if (persistChanges) { foreach (var pair in ret) { this.UpdateAchsenReferenz(pair.Key, pair.Value, modificationAction == AchseModificationAction.Delete); } } return(ret.Keys.Select(k => k.Id).ToList()); }
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(Guid id, IGeometry shape) { AchsenSegment entity = this.achsenSegmentService.GetCurrentEntities().Where(e => e.Id == id).Single(); return(this.UpdateAchsenReferenzen(entity, shape, false)); }
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(Guid id) { AchsenSegment segment = this.achsenSegmentService.GetCurrentEntities().Where(s => s.Id == id).Single(); this.DeleteAchsenReferenzen(segment); }