private static CutSubcurve FromReshapeLineMsg([NotNull] ReshapeLineMsg reshapeLineMsg)
        {
            IPath path = Assert.NotNull(GetPath(reshapeLineMsg.Path), "Reshapeline's path is null");

            var result = new CutSubcurve(
                path, reshapeLineMsg.CanReshape,
                reshapeLineMsg.IsCandidate,
                reshapeLineMsg.IsFiltered,
                GetSegment(reshapeLineMsg.TargetSegmentAtFrom),
                GetSegment(reshapeLineMsg.TargetSegmentAtTo),
                PointsFromShapeMsg(reshapeLineMsg.ExtraTargetInsertPoints));

            if (reshapeLineMsg.Source != null)
            {
                result.Source = new GdbObjectReference(
                    reshapeLineMsg.Source.ClassHandle, reshapeLineMsg.Source.ObjectId);
            }

            return(result);
        }
Esempio n. 2
0
        public void CanReshapeNonLinearGeometry()
        {
            ISpatialReference spatialReference = SpatialReferenceUtils.CreateSpatialReference(
                WellKnownHorizontalCS.LV95, WellKnownVerticalCS.LHN95);

            IPoint    centerPoint       = GeometryFactory.CreatePoint(150, 150);
            IGeometry geometryToReshape =
                GeometryFactory.CreateCircleArcPolygon(centerPoint, 50, false);

            geometryToReshape.SpatialReference = spatialReference;

            double circleArea = ((IArea)geometryToReshape).Area;

            IGeometry reshapeLine =
                GeometryFactory.CreatePolyline(spatialReference,
                                               GeometryFactory.CreatePoint(175, 100),
                                               GeometryFactory.CreatePoint(175, 200));

            ReshapeInfo reshapeInfo = Reshape(GeometryFactory.Clone(geometryToReshape),
                                              reshapeLine, false);

            CutSubcurve cutReshapePath = reshapeInfo.CutReshapePath;

            Assert.NotNull(cutReshapePath);

            // s = 2* sqrt(r^2-(r-h)^2) = 2 * sqrt(2rh-h^2)
            Assert.AreEqual(86.60, Math.Round(cutReshapePath.Path.Length, 2));

            const double area = 6318.5222074138192;

            ExpectResult(reshapeInfo, RingReshapeSideOfLine.Left, area, 1, 1);

            const bool useNonDefaultSide = true;

            reshapeInfo = Reshape(GeometryFactory.Clone(geometryToReshape),
                                  reshapeLine, useNonDefaultSide);

            double otherSide = circleArea - area;

            ExpectResult(reshapeInfo, RingReshapeSideOfLine.Right, otherSide, 1, 1);
        }
        private static ReshapeLineMsg ToReshapeLineMsg([NotNull] CutSubcurve cutSubcurve)
        {
            var result = new ReshapeLineMsg();

            result.Path = ProtobufGeometryUtils.ToShapeMsg(cutSubcurve.Path);

            result.CanReshape  = cutSubcurve.CanReshape;
            result.IsCandidate = cutSubcurve.IsReshapeMemberCandidate;
            result.IsFiltered  = cutSubcurve.IsFiltered;

            result.TargetSegmentAtFrom =
                cutSubcurve.FromPointIsStitchPoint
                                        ? ProtobufGeometryUtils.ToShapeMsg(cutSubcurve.TargetSegmentAtFromPoint)
                                        : null;

            result.TargetSegmentAtTo =
                cutSubcurve.ToPointIsStitchPoint
                                        ? ProtobufGeometryUtils.ToShapeMsg(cutSubcurve.TargetSegmentAtToPoint)
                                        : null;

            if (cutSubcurve.ExtraTargetInsertPoints != null)
            {
                result.ExtraTargetInsertPoints =
                    ProtobufGeometryUtils.ToShapeMsg(
                        GeometryFactory.CreateMultipoint(cutSubcurve.ExtraTargetInsertPoints));
            }

            if (cutSubcurve.Source != null)
            {
                GdbObjectReference sourceObjRef = cutSubcurve.Source.Value;

                result.Source = new GdbObjRefMsg
                {
                    ClassHandle = sourceObjRef.ClassId,
                    ObjectId    = sourceObjRef.ObjectId
                };
            }

            return(result);
        }