Ejemplo n.º 1
0
 public RoadSegmentSurfaceAttribute(
     AttributeId temporaryId,
     RoadSegmentSurfaceType type,
     RoadSegmentPosition from,
     RoadSegmentPosition to
     ) : base(temporaryId, from, to)
 {
     Type = type;
 }
 public RoadSegmentWidthAttribute(
     AttributeId temporaryId,
     RoadSegmentWidth width,
     RoadSegmentPosition from,
     RoadSegmentPosition to
     ) : base(temporaryId, from, to)
 {
     Width = width;
 }
Ejemplo n.º 3
0
 public Problems RoadSegmentLaneAttributeFromPositionNotEqualToZero(AttributeId attributeId,
                                                                    RoadSegmentPosition fromPosition)
 {
     return(new Problems(
                _problems.Add(
                    new Error(nameof(RoadSegmentLaneAttributeFromPositionNotEqualToZero),
                              new ProblemParameter("AttributeId", attributeId.ToInt32().ToString()),
                              new ProblemParameter("FromPosition", fromPosition.ToString())))));
 }
Ejemplo n.º 4
0
 public Problems RoadSegmentLaneAttributeToPositionNotEqualToLength(AttributeId attributeId,
                                                                    RoadSegmentPosition toPosition, double length)
 {
     return(new Problems(
                _problems.Add(
                    new Error(nameof(RoadSegmentLaneAttributeToPositionNotEqualToLength),
                              new ProblemParameter("AttributeId", attributeId.ToInt32().ToString()),
                              new ProblemParameter("ToPosition", toPosition.ToString()),
                              new ProblemParameter("Length", length.ToString(CultureInfo.InvariantCulture))))));
 }
Ejemplo n.º 5
0
 public RoadSegmentSurfaceAttribute(
     AttributeId id,
     AttributeId temporaryId,
     RoadSegmentSurfaceType type,
     RoadSegmentPosition from,
     RoadSegmentPosition to,
     GeometryVersion asOfGeometryVersion
     ) : base(id, temporaryId, from, to, asOfGeometryVersion)
 {
     Type = type;
 }
Ejemplo n.º 6
0
 public RoadSegmentWidthAttribute(
     AttributeId id,
     AttributeId temporaryId,
     RoadSegmentWidth width,
     RoadSegmentPosition from,
     RoadSegmentPosition to,
     GeometryVersion asOfGeometryVersion
     ) : base(id, temporaryId, from, to, asOfGeometryVersion)
 {
     Width = width;
 }
 public RoadSegmentLaneAttribute(
     AttributeId temporaryId,
     RoadSegmentLaneCount count,
     RoadSegmentLaneDirection direction,
     RoadSegmentPosition from,
     RoadSegmentPosition to
     ) : base(temporaryId, from, to)
 {
     Count     = count;
     Direction = direction;
 }
 public RoadSegmentLaneAttribute(
     AttributeId id,
     AttributeId temporaryId,
     RoadSegmentLaneCount count,
     RoadSegmentLaneDirection direction,
     RoadSegmentPosition from,
     RoadSegmentPosition to,
     GeometryVersion asOfGeometryVersion
     ) : base(id, temporaryId, from, to, asOfGeometryVersion)
 {
     Count     = count;
     Direction = direction;
 }
Ejemplo n.º 9
0
        protected DynamicRoadSegmentAttribute(
            AttributeId temporaryId,
            RoadSegmentPosition from,
            RoadSegmentPosition to
            )
        {
            if (from >= to)
            {
                throw new ArgumentException(nameof(From),
                                            $"The from position ({from.ToDecimal()}) must be less than the to position ({to.ToDecimal()}).");
            }

            TemporaryId = temporaryId;
            From        = from;
            To          = to;
        }
Ejemplo n.º 10
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentLaneChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.EqualIdentifier:
                    case RecordType.AddedIdentifier:
                    case RecordType.ModifiedIdentifier:
                        var segmentId = new RoadSegmentId(record.WS_OIDN.Value);
                        if (changes.TryFindAddRoadSegment(segmentId, out var change))
                        {
                            var lane = new RoadSegmentLaneAttribute(
                                new AttributeId(record.RS_OIDN.Value),
                                new RoadSegmentLaneCount(record.AANTAL.Value),
                                RoadSegmentLaneDirection.ByIdentifier[record.RICHTING.Value],
                                RoadSegmentPosition.FromDouble(record.VANPOSITIE.Value),
                                RoadSegmentPosition.FromDouble(record.TOTPOSITIE.Value)
                                );
                            changes = changes.Replace(change, change.WithLane(lane));
                        }
                        break;
                    }
                }
            }

            return(changes);
        }
Ejemplo n.º 11
0
        public TranslatedChanges Translate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentWidthChangeDbaseRecord> records, TranslatedChanges changes)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }
            if (changes == null)
            {
                throw new ArgumentNullException(nameof(changes));
            }

            while (records.MoveNext())
            {
                var record = records.Current;
                if (record != null)
                {
                    switch (record.RECORDTYPE.Value)
                    {
                    case RecordType.EqualIdentifier:
                    case RecordType.AddedIdentifier:
                    case RecordType.ModifiedIdentifier:
                        var segmentId = new RoadSegmentId(record.WS_OIDN.Value);
                        if (changes.TryFindAddRoadSegment(segmentId, out var before))
                        {
                            var width = new RoadSegmentWidthAttribute(
                                new AttributeId(record.WB_OIDN.Value),
                                new RoadSegmentWidth(record.BREEDTE.Value),
                                RoadSegmentPosition.FromDouble(record.VANPOSITIE.Value),
                                RoadSegmentPosition.FromDouble(record.TOTPOSITIE.Value)
                                );
                            changes = changes.Replace(before, before.WithWidth(width));
                        }
                        break;
                    }
                }
            }

            return(changes);
        }
Ejemplo n.º 12
0
        public RoadSegmentWidthAttributes(IReadOnlyCollection <RoadSegmentWidthAttribute> attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }
            var position = new RoadSegmentPosition(0);
            var index    = 0;

            foreach (var attribute in attributes)
            {
                if (attribute.From != position)
                {
                    throw new ArgumentException(
                              $"The road segment width attributes are not adjacent. The attribute at index {index} was expected to start from {position} but actually starts from {attribute.From}.",
                              nameof(attributes));
                }
                position = attribute.To;
                index++;
            }
            _attributes = attributes;
        }
        public ZipArchiveProblems Validate(ZipArchiveEntry entry, IDbaseRecordEnumerator <RoadSegmentLaneChangeDbaseRecord> records)
        {
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }
            if (records == null)
            {
                throw new ArgumentNullException(nameof(records));
            }

            var problems = ZipArchiveProblems.None;

            try
            {
                var identifiers = new Dictionary <AttributeId, RecordNumber>();
                var moved       = records.MoveNext();
                if (moved)
                {
                    while (moved)
                    {
                        var recordContext = entry.AtDbaseRecord(records.CurrentRecordNumber);
                        var record        = records.Current;
                        if (record != null)
                        {
                            if (!record.RECORDTYPE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RECORDTYPE.Field);
                            }
                            else
                            {
                                if (!RecordType.ByIdentifier.ContainsKey(record.RECORDTYPE.Value))
                                {
                                    problems += recordContext.RecordTypeMismatch(record.RECORDTYPE.Value);
                                }
                            }
                            if (record.RS_OIDN.HasValue)
                            {
                                if (record.RS_OIDN.Value == 0)
                                {
                                    problems += recordContext.IdentifierZero();
                                }
                                else
                                {
                                    var identifier = new AttributeId(record.RS_OIDN.Value);
                                    if (identifiers.TryGetValue(identifier, out var takenByRecordNumber))
                                    {
                                        problems += recordContext.IdentifierNotUnique(
                                            identifier,
                                            takenByRecordNumber
                                            );
                                    }
                                    else
                                    {
                                        identifiers.Add(identifier, records.CurrentRecordNumber);
                                    }
                                }
                            }
                            else
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RS_OIDN.Field);
                            }

                            if (!record.AANTAL.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.AANTAL.Field);
                            }
                            else if (!RoadSegmentLaneCount.Accepts(record.AANTAL.Value))
                            {
                                problems += recordContext.LaneCountOutOfRange(record.AANTAL.Value);
                            }

                            if (!record.RICHTING.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.RICHTING.Field);
                            }
                            else if (!RoadSegmentLaneDirection.ByIdentifier.ContainsKey(record.RICHTING.Value))
                            {
                                problems += recordContext.LaneDirectionMismatch(record.RICHTING.Value);
                            }

                            if (!record.VANPOSITIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.VANPOSITIE.Field);
                            }
                            else if (!RoadSegmentPosition.Accepts(record.VANPOSITIE.Value))
                            {
                                problems += recordContext.FromPositionOutOfRange(record.VANPOSITIE.Value);
                            }

                            if (!record.TOTPOSITIE.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.TOTPOSITIE.Field);
                            }
                            else if (!RoadSegmentPosition.Accepts(record.TOTPOSITIE.Value))
                            {
                                problems += recordContext.ToPositionOutOfRange(record.TOTPOSITIE.Value);
                            }

                            if (!record.WS_OIDN.HasValue)
                            {
                                problems += recordContext.RequiredFieldIsNull(record.WS_OIDN.Field);
                            }
                            else if (!RoadSegmentId.Accepts(record.WS_OIDN.Value))
                            {
                                problems += recordContext.RoadSegmentIdOutOfRange(record.WS_OIDN.Value);
                            }
                        }
                        moved = records.MoveNext();
                    }
                }
                else
                {
                    problems += entry.HasNoDbaseRecords(false);
                }
            }
            catch (Exception exception)
            {
                problems += entry.AtDbaseRecord(records.CurrentRecordNumber).HasDbaseRecordFormatError(exception);
            }

            return(problems);
        }
Ejemplo n.º 14
0
 public Problems RoadSegmentSurfaceAttributesNotAdjacent(AttributeId attributeId1, RoadSegmentPosition toPosition, AttributeId attributeId2, RoadSegmentPosition fromPosition)
 {
     return(new Problems(
                _problems.Add(
                    new Error(nameof(RoadSegmentSurfaceAttributesNotAdjacent),
                              new ProblemParameter("AttributeId", attributeId1.ToInt32().ToString()),
                              new ProblemParameter("ToPosition", toPosition.ToString()),
                              new ProblemParameter("AttributeId", attributeId2.ToInt32().ToString()),
                              new ProblemParameter("FromPosition", fromPosition.ToString())))));
 }