Пример #1
0
        private void GetSubcurves(IRow row,
                                  SortedDictionary <SegmentPart, SegmentParts> parts,
                                  double near,
                                  double connectedMinLength,
                                  out IList <SubClosedCurve> connected,
                                  out IList <SubClosedCurve> nearSelfConnected)
        {
            var feat = (IFeature)row;
            IIndexedSegments geom        = IndexedSegmentUtils.GetIndexedGeometry(feat, false);
            double           nearSquared = near * near;

            var curves         = new List <Subcurve>();
            var nearSelfCurves = new List <Subcurve>();

            foreach (SegmentParts segmentParts in parts.Values)
            {
                segmentParts.Sort(new SegmentPartComparer());
                foreach (SegmentPart part in segmentParts)
                {
                    AddSegment(feat, geom, curves, nearSelfCurves, part, connectedMinLength,
                               nearSquared);
                }
            }

            connected         = GetClosedCurves(curves);
            nearSelfConnected = GetClosedCurves(nearSelfCurves);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="row"></param>
        /// <param name="sortedParts">Each entry in sortedParts are lists of segmentparts of the same segment.
        /// sortedParts must be ordered by partIndex ASC, segmentIndex ASC.
        /// However, the entries of sortedParts will sorted in this method.</param>
        /// <param name="near">used for near self parts</param>
        /// <param name="connectedMinLength">used for near self parts</param>
        /// <param name="connected"></param>
        /// <param name="nearSelfConnected"></param>
        protected void GetSubcurves(IRow row,
                                    IEnumerable <SegmentParts> sortedParts,
                                    double near,
                                    double connectedMinLength,
                                    out IList <SubClosedCurve> connected,
                                    out IList <SubClosedCurve> nearSelfConnected)
        {
            var feat = (IFeature)row;
            IIndexedSegments geom = IndexedSegmentUtils.GetIndexedGeometry(feat, false);

            GetSubcurves(geom, sortedParts, near, connectedMinLength, Is3D, out connected,
                         out nearSelfConnected);
        }
Пример #3
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);
                }
            }
        }