Ejemplo n.º 1
0
        public static WKSEnvelope GetEnvelope([NotNull] IIndexedSegments baseGeometry,
                                              int part, int startSegmentIndex,
                                              double startFraction,
                                              int endSegmentIndex, double endFraction)
        {
            SegmentProxy segment  = baseGeometry.GetSegment(part, startSegmentIndex);
            double       startEnd = 1;

            if (startSegmentIndex == endSegmentIndex)
            {
                startEnd = endFraction;
            }

            WKSEnvelope box = segment.GetSubCurveBox(startFraction, startEnd);

            for (int i = startSegmentIndex + 1; i < endSegmentIndex - 1; i++)
            {
                segment = baseGeometry.GetSegment(part, i);
                box     = GetUnion(box, segment.GetSubCurveBox(0, 1));
            }

            if (endSegmentIndex > startSegmentIndex && endFraction > 0)
            {
                segment = baseGeometry.GetSegment(part, endSegmentIndex);
                box     = GetUnion(box, segment.GetSubCurveBox(0, endFraction));
            }

            return(box);
        }
Ejemplo n.º 2
0
        internal static double GetLength([NotNull] IIndexedSegments baseGeometry,
                                         int partIndex,
                                         int startSegmentIndex, double startFraction,
                                         int endSegmentIndex, double endFraction)
        {
            double length = 0;

            for (int i = startSegmentIndex; i <= endSegmentIndex; i++)
            {
                SegmentProxy seg = baseGeometry.GetSegment(partIndex, i);

                double segLength = seg.Length;
                double addLength = segLength;

                if (i == startSegmentIndex)
                {
                    addLength -= segLength * startFraction;
                }

                if (i == endSegmentIndex)
                {
                    addLength -= segLength * (1 - endFraction);
                }

                length += addLength;
            }

            return(length);
        }
Ejemplo n.º 3
0
            private IGeometry GetGeometry(int partIndex)
            {
                IGeometry geometry;

                if (!_perPart)
                {
                    geometry = GeometryFactory.Clone(_baseGeometry);
                }
                else if (_baseGeometry is ICurve)
                {
                    var geometryCollection = _baseGeometry as IGeometryCollection;
                    if (geometryCollection == null || geometryCollection.GeometryCount == 1)
                    {
                        geometry = GetErrorGeometry((ICurve)_baseGeometry);
                    }
                    else
                    {
                        var curve = (ICurve)geometryCollection.get_Geometry(partIndex);
                        geometry = GetErrorGeometry(curve);
                    }

                    return(geometry);
                }
                else
                {
                    IGeometryCollection geometryCollection;
                    if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                        geometryCollection = QaGeometryUtils.CreatePolygon(_baseGeometry);
                    }
                    else if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        geometryCollection = QaGeometryUtils.CreatePolyline(_baseGeometry);
                    }
                    else if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryMultiPatch)
                    {
                        geometryCollection = new MultiPatchClass();
                    }
                    else
                    {
                        throw new InvalidOperationException("unhandled geometry type " +
                                                            _baseGeometry.GeometryType);
                    }

                    int segmentCount = _indexedSegments.GetPartSegmentCount(partIndex);
                    var partSegments = new List <SegmentProxy>(segmentCount);
                    for (int iSegment = 0; iSegment < segmentCount; iSegment++)
                    {
                        partSegments.Add(_indexedSegments.GetSegment(partIndex, iSegment));
                    }

                    SegmentUtils.CreateGeometry(geometryCollection, partSegments);
                    geometry = (IGeometry)geometryCollection;
                }

                return(geometry);
            }
Ejemplo n.º 4
0
        private static void GetClosePart([NotNull] SegmentProxy neighbor,
                                         [NotNull] IIndexedSegments geom,
                                         [NotNull] SegmentPart segPart,
                                         double searchDistanceSquared, bool is3D,
                                         out double min, out double max)
        {
            SegmentProxy part = geom.GetSegment(segPart.PartIndex, segPart.SegmentIndex);
            IPnt         start = part.GetPointAt(segPart.MinFraction);
            double       minStart, maxStart;

            GetClosePart(neighbor, start, searchDistanceSquared, is3D, out minStart,
                         out maxStart);

            IPnt   end = part.GetPointAt(segPart.MaxFraction);
            double minEnd, maxEnd;

            GetClosePart(neighbor, end, searchDistanceSquared, is3D, out minEnd, out maxEnd);

            min = Math.Min(minStart, minEnd);
            max = Math.Max(maxStart, maxEnd);
        }
Ejemplo n.º 5
0
        private static WKSPointZ[] GetWksPointZs(
            [NotNull] IIndexedSegments indexedSegments,
            int partIndex)
        {
            int partSegmentCount = indexedSegments.GetPartSegmentCount(partIndex);

            var segments = new List <SegmentProxy>(partSegmentCount);

            for (int segmentIndex = 0; segmentIndex < partSegmentCount; segmentIndex++)
            {
                segments.Add(indexedSegments.GetSegment(partIndex, segmentIndex));
            }

            var wksPoints = new List <WKSPointZ>(partSegmentCount + 1);

            foreach (Pnt point in QaGeometryUtils.GetPoints(segments))
            {
                wksPoints.Add(QaGeometryUtils.GetWksPoint(point));
            }

            return(wksPoints.ToArray());
        }
Ejemplo n.º 6
0
        private void CompleteJunctions()
        {
            foreach (KeyValuePair <RowKey, SegmentNeighbors> pair in ProcessedList)
            {
                RowKey key = pair.Key;
                if (_conflictTables.ContainsKey(key.TableIndex))
                {
                    continue;
                }

                // --> junction was not searched
                var thisFeature           = (IFeature)key.Row;
                var thisCurve             = (IGeometryCollection)thisFeature.Shape;
                IIndexedSegments thisGeom =
                    IndexedSegmentUtils.GetIndexedGeometry(thisFeature, false);
                Dictionary <int, SegmentPart> handledParts = new Dictionary <int, SegmentPart>();

                foreach (KeyValuePair <SegmentPart, SegmentParts> segmentPair in pair.Value)
                {
                    if (segmentPair.Value.Count == 0)
                    {
                        continue;
                    }

                    SegmentPart segment = segmentPair.Key;
                    if (handledParts.ContainsKey(segment.PartIndex))
                    {
                        continue;
                    }

                    int segmentsCount = thisGeom.GetPartSegmentCount(segment.PartIndex);

                    IEnvelope searchBox = thisCurve.Geometry[segment.PartIndex].Envelope;

                    double tolerance = UsedJunctionCoincidenceTolerance;
                    searchBox.Expand(tolerance, tolerance, asRatio: false);

                    Pnt  start    = thisGeom.GetSegment(segment.PartIndex, 0).GetStart(false);
                    IBox startBox = new Box(new Pnt2D(start.X - tolerance, start.Y - tolerance),
                                            new Pnt2D(start.X + tolerance, start.Y + tolerance));

                    Pnt end = thisGeom.GetSegment(segment.PartIndex, segmentsCount - 1)
                              .GetEnd(false);
                    IBox endBox = new Box(new Pnt2D(end.X - tolerance, end.Y - tolerance),
                                          new Pnt2D(end.X + tolerance, end.Y + tolerance));

                    foreach (KeyValuePair <int, IFeatureClass> topoPair in _topoTables)
                    {
                        int            neighborTableIdx = topoPair.Key;
                        ISpatialFilter filter           = _topoFilters[neighborTableIdx];
                        filter.Geometry = searchBox;
                        QueryFilterHelper helper = _topoHelpers[neighborTableIdx];

                        foreach (IRow neighborRow in Search((ITable)topoPair.Value, filter, helper)
                                 )
                        {
                            if (neighborRow.OID == key.Row.OID &&
                                neighborTableIdx == key.TableIndex)
                            {
                                continue;
                            }

                            var neighborFeature           = (IFeature)neighborRow;
                            IIndexedSegments neighborGeom =
                                IndexedSegmentUtils.GetIndexedGeometry(neighborFeature, false);

                            int connectedPart;
                            int connectedFraction;
                            if (IsConnected(neighborGeom, startBox, start,
                                            JunctionCoincidenceToleranceSquare,
                                            out connectedPart, out connectedFraction))
                            {
                                var jct =
                                    new Junction(thisFeature, key.TableIndex, segment.PartIndex, 0,
                                                 neighborFeature, neighborTableIdx, connectedPart,
                                                 connectedFraction);
                                _junctions.Add(jct);
                            }

                            if (IsConnected(neighborGeom, endBox, end,
                                            JunctionCoincidenceToleranceSquare,
                                            out connectedPart, out connectedFraction))
                            {
                                var jct = new Junction(
                                    thisFeature, key.TableIndex, segment.PartIndex, segmentsCount,
                                    neighborFeature, neighborTableIdx, connectedPart,
                                    connectedFraction);
                                _junctions.Add(jct);
                            }

                            if (ConnectionMode == ConnectionMode.VertexOnVertex)
                            {
                                for (int iSegment = 1; iSegment < segmentsCount; iSegment++)
                                {
                                    Pnt vertex = thisGeom
                                                 .GetSegment(segment.PartIndex, iSegment)
                                                 .GetStart(false);
                                    IBox vertexBox =
                                        new Box(
                                            new Pnt2D(vertex.X - tolerance, vertex.Y - tolerance),
                                            new Pnt2D(vertex.X + tolerance, vertex.Y + tolerance));

                                    if (IsConnected(neighborGeom, vertexBox, vertex,
                                                    JunctionCoincidenceToleranceSquare,
                                                    out connectedPart, out connectedFraction))
                                    {
                                        var jct = new Junction(
                                            thisFeature, key.TableIndex, segment.PartIndex,
                                            iSegment,
                                            neighborFeature, neighborTableIdx, connectedPart,
                                            connectedFraction);
                                        _junctions.Add(jct);
                                    }
                                }
                            }
                        }
                    }

                    handledParts.Add(segment.PartIndex, segment);
                }
            }
        }