Пример #1
0
        private static IGeometry TryGetIntersection([NotNull] IGeometry sourceGeometry,
                                                    [NotNull] IGeometry targetGeometry)
        {
            IGeometry targetToIntersect =
                targetGeometry.GeometryType == esriGeometryType.esriGeometryMultiPatch
                                        ? GeometryFactory.CreatePolygon(targetGeometry)
                                        : targetGeometry;

            esriGeometryDimension dimension =
                sourceGeometry is IPolygon
                                        ? esriGeometryDimension.esriGeometry2Dimension
                                        : esriGeometryDimension.esriGeometry1Dimension;

            IGeometry intersection = IntersectionUtils.Intersect(
                sourceGeometry, targetToIntersect, dimension);

            _msg.VerboseDebug("Simplifying...");

            GeometryUtils.Simplify(intersection);

            Marshal.ReleaseComObject(targetToIntersect);

            if (!intersection.IsEmpty)
            {
                return(intersection);
            }

            return(null);
        }
Пример #2
0
        private bool BelongsToLargeGap([NotNull] IPolygon crossingGap)
        {
            Assert.ArgumentNotNull(crossingGap, nameof(crossingGap));

            var gapRelOp  = (IRelationalOperator)crossingGap;
            var gapTopoOp = (ITopologicalOperator)crossingGap;

            foreach (IPolyline intersection in _largeGapCuttingEdgeIntersections)
            {
                if (gapRelOp.Disjoint(intersection))
                {
                    continue;
                }

                IGeometry linearIntersection = IntersectionUtils.Intersect(
                    gapTopoOp, intersection, esriGeometryDimension.esriGeometry1Dimension);

                try
                {
                    if (!linearIntersection.IsEmpty)
                    {
                        return(true);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(linearIntersection);
                }
            }

            return(false);
        }
Пример #3
0
        public static IPolyline GetLinearIntersection([NotNull] IPolyline line,
                                                      [NotNull] IGeometry geometry,
                                                      double?xyTolerance = null)
        {
            // the lines are often very short and close to each other --> xy cluster tolerance workaround is used far too often
            // --> test for IRelationalOperator.Equals at least if lines are very short?
            // --> if equal, return a clone of 'line'?

            if (xyTolerance != null)
            {
                double maxLengthWorkaround = xyTolerance.Value * 6;

                if (line.Length <= maxLengthWorkaround)
                {
                    var otherLine = geometry as IPolyline;

                    if (otherLine != null && otherLine.Length < maxLengthWorkaround)
                    {
                        if (((IRelationalOperator)line).Equals(otherLine))
                        {
                            return(GeometryFactory.Clone(line));
                        }
                    }
                }
            }

            return((IPolyline)IntersectionUtils.Intersect(
                       line, geometry,
                       esriGeometryDimension.esriGeometry1Dimension));
        }
Пример #4
0
        protected static IPolyline GetGeometryAlongBorder(
            [NotNull] IFeature borderFeature,
            [NotNull] IPolyline line)
        {
            IGeometry border = borderFeature.Shape;

            if (border.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                border = ((ITopologicalOperator)border).Boundary;
            }

            return((IPolyline)IntersectionUtils.Intersect(
                       line, border,
                       esriGeometryDimension.esriGeometry1Dimension));
        }
Пример #5
0
        private static IPolyline GetLinearIntersection(
            [NotNull] IPolygon polygon,
            [NotNull] IPolyline polyline)
        {
            var polygonTopoOp = (ITopologicalOperator)polygon;

            var result = (IPolyline)IntersectionUtils.Intersect(
                polygonTopoOp, polyline, esriGeometryDimension.esriGeometry1Dimension);

            if (result.IsEmpty)
            {
                return(null);
            }

            const bool allowReorder = true;
            const bool allowPathSplitAtIntersections = false;

            GeometryUtils.Simplify(result, allowReorder, allowPathSplitAtIntersections);

            GeometryUtils.AllowIndexing(result);

            return(result);
        }