コード例 #1
0
        public void CanReshapeMultipatch()
        {
            ISpatialReference lv95 = SpatialReferenceUtils.CreateSpatialReference(
                WellKnownHorizontalCS.LV95);

            IPolygon polygon = GeometryFactory.CreatePolygon(
                GeometryFactory.CreateEnvelope(2600000, 1200000, 500, 50, 20, lv95));

            IMultiPatch multiPatch = GeometryFactory.CreateMultiPatch(
                polygon);

            IPolyline cutLine = GeometryFactory.CreateLine(
                GeometryFactory.CreatePoint(2600000 - 100, 1200000),
                GeometryFactory.CreatePoint(2600000 + 100, 1200000));

            cutLine.SpatialReference = lv95;

            var reshapePath = (IPath)((IGeometryCollection)cutLine).Geometry[0];

            var reshapeInfo = new ReshapeInfo(multiPatch, reshapePath, null);

            IList <ReshapeInfo> singleReshapes;

            ReshapeUtils.ReshapeAllGeometryParts(reshapeInfo, reshapePath,
                                                 out singleReshapes);

            var reshapedRing = (IRing)((IGeometryCollection)multiPatch).Geometry[0];

            Assert.True(MathUtils.AreEqual(((IArea)reshapedRing).Area,
                                           ((IArea)polygon).Area / 2,
                                           0.1));
        }
コード例 #2
0
        private bool TryReshape([NotNull] IPath reshapePath,
                                bool tryReshapeRingNonDefaultSide,
                                [CanBeNull] NotificationCollection notifications,
                                out IGeometry geometryToReshape)
        {
            Assert.Null(TargetFeatures,
                        "Target features are set. This method does not support target feature updates.");

            geometryToReshape = ReshapeGeometryCloneByFeature[_feature];

            var reshapeInfo = new ReshapeInfo(geometryToReshape, reshapePath,
                                              notifications)
            {
                ReshapeResultFilter =
                    GetResultFilter(tryReshapeRingNonDefaultSide),
                AllowSimplifiedReshapeSideDetermination =
                    AllowSimplifiedReshapeSideDetermination,
                AllowOpenJawReshape = AllowOpenJawReshape
            };

            IList <ReshapeInfo> reshapeInfos;
            bool reshaped = ReshapeUtils.ReshapeAllGeometryParts(reshapeInfo, reshapePath,
                                                                 out reshapeInfos);

            if (reshaped)
            {
                reshaped = AreAllReshapesAllowed(reshapeInfos, notifications);
            }

            if (reshaped)
            {
                AddToRefreshArea(reshapeInfos);

                NotificationIsWarning = reshapeInfo.NotificationIsWarning;

                if (reshapeInfo.IsOpenJawReshape)
                {
                    OpenJawReshapeOcurred         = true;
                    OpenJawIntersectionPointCount =
                        reshapeInfo.IntersectionPoints.PointCount;
                }
            }

            foreach (ReshapeInfo singleReshape in reshapeInfos)
            {
                singleReshape.Dispose();
            }

            return(reshaped);
        }
コード例 #3
0
        public void CanReshapeVerticalTriangularRingInMultipatch()
        {
            ISpatialReference lv95 = SpatialReferenceUtils.CreateSpatialReference(
                WellKnownHorizontalCS.LV95);

            //IRing ring = GeometryFactory.CreateRing(
            //	GeometryFactory.CreatePath())
            var points = new WKSPointZ[4];

            points[0] = new WKSPointZ
            {
                X = 2600000,
                Y = 1200000,
                Z = 500
            };

            points[1] = new WKSPointZ
            {
                X = 2600100,
                Y = 1200000,
                Z = 500
            };

            points[2] = new WKSPointZ
            {
                X = 2600050,
                Y = 1200000,
                Z = 1000
            };

            points[3] = new WKSPointZ
            {
                X = 2600000,
                Y = 1200000,
                Z = 500
            };

            IRing ring = new RingClass();

            ((IGeometry)ring).SpatialReference = lv95;
            GeometryUtils.MakeZAware(ring);
            GeometryUtils.SetWKSPointZs((IPointCollection4)ring, points);

            IMultiPatch multipatch = new MultiPatchClass();

            ((IGeometry)multipatch).SpatialReference = lv95;

            GeometryUtils.MakeZAware(multipatch);
            GeometryUtils.MakeMAware(multipatch);

            GeometryUtils.MakePointIDAware(multipatch);

            GeometryFactory.AddRingToMultiPatch(ring, multipatch,
                                                esriMultiPatchRingType
                                                .esriMultiPatchOuterRing);

            var unReshaped = (IRing)((IGeometryCollection)multipatch).Geometry[0];

            int originalPointCount = ((IPointCollection)unReshaped).PointCount;

            IPolyline cutLine = GeometryFactory.CreateLine(
                GeometryFactory.CreatePoint(2600075, 1200000 - 100, 222),
                GeometryFactory.CreatePoint(2600075, 1200000 + 100, 222));

            cutLine.SpatialReference = lv95;

            GeometryUtils.MakeZAware(cutLine);

            var reshapePath = (IPath)((IGeometryCollection)cutLine).Geometry[0];

            Assert.IsTrue(((ICurve3D)unReshaped).IsClosed3D);

            var reshapeInfo = new ReshapeInfo(multipatch, reshapePath, null)
            {
                NonPlanar = true
            };

            IList <ReshapeInfo> singleReshapes;

            ReshapeUtils.ReshapeAllGeometryParts(reshapeInfo, reshapePath,
                                                 out singleReshapes);

            var reshapedRing = (IRing)((IGeometryCollection)multipatch).Geometry[0];

            Assert.AreEqual(originalPointCount + 1,
                            ((IPointCollection)reshapedRing).PointCount);

            Assert.IsTrue(((ICurve3D)reshapedRing).IsClosed3D);

            double expectedLength = Math.Sqrt(50 * 50 + 500 * 500) * 1.5 + 75 + 250;

            Assert.AreEqual(expectedLength, ((ICurve3D)reshapedRing).Length3D, 0.001);

            var newPoints = new WKSPointZ[5];

            GeometryUtils.QueryWKSPointZs((IPointCollection4)reshapedRing, newPoints);

            // first, fourth and last
            Assert.IsTrue(GeometryUtils.IsSamePoint(points[0], newPoints[0], 0, 0));
            Assert.IsTrue(GeometryUtils.IsSamePoint(points[2], newPoints[3], 0, 0));
            Assert.IsTrue(GeometryUtils.IsSamePoint(points[3], newPoints[4], 0, 0));

            // the new cut points
            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600075,
                Y = 1200000,
                Z = 500
            }, newPoints[1], 0, 0));

            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600075,
                Y = 1200000,
                Z = 750
            }, newPoints[2], 0, 0));

            // And now reshape right through the vertex at the top, this time reshape the left
            cutLine = GeometryFactory.CreateLine(
                GeometryFactory.CreatePoint(2600050, 1200000 - 100, 222),
                GeometryFactory.CreatePoint(2600050, 1200000 + 100, 222));
            cutLine.SpatialReference = lv95;

            GeometryUtils.MakeZAware(cutLine);

            reshapePath = (IPath)((IGeometryCollection)cutLine).Geometry[0];

            reshapeInfo = new ReshapeInfo(multipatch, reshapePath, null)
            {
                NonPlanar = true
            };

            // keep the right (small part)
            reshapeInfo.RingReshapeSide = RingReshapeSideOfLine.Right;

            ReshapeUtils.ReshapeAllGeometryParts(reshapeInfo, reshapePath,
                                                 out singleReshapes);

            reshapedRing = (IRing)((IGeometryCollection)multipatch).Geometry[0];

            Assert.AreEqual(5, ((IPointCollection)reshapedRing).PointCount);
            Assert.IsTrue(((ICurve3D)reshapedRing).IsClosed3D);

            expectedLength = Math.Sqrt(50 * 50 + 500 * 500) * 0.5 + 25 + 500 + 250;
            Assert.AreEqual(expectedLength, ((ICurve3D)reshapedRing).Length3D, 0.001);

            newPoints = new WKSPointZ[5];
            GeometryUtils.QueryWKSPointZs((IPointCollection4)reshapedRing, newPoints);

            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600050,
                Y = 1200000,
                Z = 500
            }, newPoints[0], 0, 0));

            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600075,
                Y = 1200000,
                Z = 500
            }, newPoints[1], 0, 0));

            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600075,
                Y = 1200000,
                Z = 750
            }, newPoints[2], 0, 0));

            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600050,
                Y = 1200000,
                Z = 1000
            }, newPoints[3], 0, 0));
        }
コード例 #4
0
        public void CanReshapeVerticalSquareRingInMultipatch()
        {
            ISpatialReference lv95 = SpatialReferenceUtils.CreateSpatialReference(
                WellKnownHorizontalCS.LV95);

            //IRing ring = GeometryFactory.CreateRing(
            //	GeometryFactory.CreatePath())
            var points = new WKSPointZ[5];

            points[0] = new WKSPointZ
            {
                X = 2600000,
                Y = 1200000,
                Z = 500
            };

            points[1] = new WKSPointZ
            {
                X = 2600100,
                Y = 1200000,
                Z = 500
            };

            points[2] = new WKSPointZ
            {
                X = 2600100,
                Y = 1200000,
                Z = 1000
            };

            points[3] = new WKSPointZ
            {
                X = 2600000,
                Y = 1200000,
                Z = 1000
            };

            points[4] = new WKSPointZ
            {
                X = 2600000,
                Y = 1200000,
                Z = 500
            };

            IRing ring = new RingClass();

            ((IGeometry)ring).SpatialReference = lv95;
            GeometryUtils.MakeZAware(ring);
            GeometryUtils.SetWKSPointZs((IPointCollection4)ring, points);

            IMultiPatch multipatch = new MultiPatchClass();

            ((IGeometry)multipatch).SpatialReference = lv95;

            GeometryUtils.MakeZAware(multipatch);
            GeometryUtils.MakeMAware(multipatch);

            GeometryUtils.MakePointIDAware(multipatch);

            GeometryFactory.AddRingToMultiPatch(ring, multipatch,
                                                esriMultiPatchRingType
                                                .esriMultiPatchOuterRing);

            var unReshaped = (IRing)((IGeometryCollection)multipatch).Geometry[0];

            int originalPointCount = ((IPointCollection)unReshaped).PointCount;

            // Left reshape is slightly larger -> vertical reshape side is determined by size only
            IPolyline cutLine = GeometryFactory.CreateLine(
                GeometryFactory.CreatePoint(2600051, 1200000 - 100, 222),
                GeometryFactory.CreatePoint(2600051, 1200000 + 100, 222));

            cutLine.SpatialReference = lv95;

            GeometryUtils.MakeZAware(cutLine);

            var reshapePath = (IPath)((IGeometryCollection)cutLine).Geometry[0];

            Assert.IsTrue(((ICurve3D)unReshaped).IsClosed3D);

            var reshapeInfo = new ReshapeInfo(multipatch, reshapePath, null)
            {
                NonPlanar = true
            };

            IList <ReshapeInfo> singleReshapes;

            ReshapeUtils.ReshapeAllGeometryParts(reshapeInfo, reshapePath,
                                                 out singleReshapes);

            var reshapedRing = (IRing)((IGeometryCollection)multipatch).Geometry[0];

            Assert.AreEqual(originalPointCount,
                            ((IPointCollection)reshapedRing).PointCount);

            Assert.IsTrue(((ICurve3D)reshapedRing).IsClosed3D);
            Assert.AreEqual(2 * 500 + 2 * 51, ((ICurve3D)reshapedRing).Length3D);

            var newPoints = new WKSPointZ[5];

            GeometryUtils.QueryWKSPointZs((IPointCollection4)reshapedRing, newPoints);

            // first, fourth and last
            Assert.IsTrue(GeometryUtils.IsSamePoint(points[0], newPoints[0], 0, 0));
            Assert.IsTrue(GeometryUtils.IsSamePoint(points[3], newPoints[3], 0, 0));
            Assert.IsTrue(GeometryUtils.IsSamePoint(points[4], newPoints[4], 0, 0));

            // the new cut points
            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600051,
                Y = 1200000,
                Z = 500
            }, newPoints[1], 0, 0));

            Assert.IsTrue(GeometryUtils.IsSamePoint(new WKSPointZ
            {
                X = 2600051,
                Y = 1200000,
                Z = 1000
            }, newPoints[2], 0, 0));
        }