コード例 #1
0
        public void CanGetOpenJawReshapeLineReplaceEndPoint()
        {
            var fClass =
                new GdbFeatureClass(123, "TestFC", esriGeometryType.esriGeometryPolyline);

            var sr = SpatialReferenceUtils.CreateSpatialReference(
                WellKnownHorizontalCS.LV95,
                WellKnownVerticalCS.LN02);

            fClass.SpatialReference = sr;

            IPath sourcePath = GeometryFactory.CreatePath(
                GeometryFactory.CreatePoint(2600500, 1200000, sr),
                GeometryFactory.CreatePoint(2600500, 1200500, sr),
                GeometryFactory.CreatePoint(2601000, 1200500, sr));

            sourcePath.SpatialReference = sr;

            IPolyline sourcePolyline = GeometryFactory.CreatePolyline(sourcePath);

            GdbFeature sourceFeature = new GdbFeature(42, fClass)
            {
                Shape = sourcePolyline
            };

            IPath reshapePath = GeometryFactory.CreatePath(
                GeometryFactory.CreatePoint(2600500, 1200500, sr),
                GeometryFactory.CreatePoint(2600500, 1201000, sr));

            reshapePath.SpatialReference = sr;

            IPolyline reshapePolyline = GeometryFactory.CreatePolyline(reshapePath);

            var sourceFeatureMsg = ProtobufGdbUtils.ToGdbObjectMsg(sourceFeature);
            var reshapePathMsg   = ProtobufGeometryUtils.ToShapeMsg(reshapePolyline);

            var request = new OpenJawReshapeLineReplacementRequest
            {
                Feature     = sourceFeatureMsg,
                ReshapePath = reshapePathMsg
            };

            ShapeMsg response =
                AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(request);

            IPoint resultPoint = (IPoint)ProtobufGeometryUtils.FromShapeMsg(response);

            Assert.IsTrue(GeometryUtils.AreEqual(sourcePolyline.ToPoint, resultPoint));

            // Non-default side:
            request.UseNonDefaultReshapeSide = true;

            response =
                AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(request);
            resultPoint = (IPoint)ProtobufGeometryUtils.FromShapeMsg(response);

            Assert.IsTrue(GeometryUtils.AreEqual(sourcePolyline.FromPoint, resultPoint));
        }