public static async Task <MapPoint> GetOpenJawReplacementPointAsync(
            [NotNull] ReshapeGrpc.ReshapeGrpcClient rpcClient,
            [NotNull] Feature polylineFeature,
            [NotNull] Polyline reshapeLine,
            bool useNonDefaultReshapeSide)
        {
            var request = new OpenJawReshapeLineReplacementRequest()
            {
                UseNonDefaultReshapeSide = useNonDefaultReshapeSide
            };

            SpatialReference sr =
                await QueuedTaskUtils.Run(
                    () =>
            {
                Geometry geometryToReshape = polylineFeature.GetShape();

                request.Feature = ProtobufConversionUtils.ToGdbObjectMsg(
                    polylineFeature, geometryToReshape, true);

                request.ReshapePath = ProtobufConversionUtils.ToShapeMsg(reshapeLine);

                return(geometryToReshape.SpatialReference);
            });

            // Not in a queued task (but it is still called multiple times because...)
            ShapeMsg pointMsg = rpcClient.GetOpenJawReshapeLineReplaceEndPoint(request);

            return(await QueuedTaskUtils.Run(
                       () => (MapPoint)ProtobufConversionUtils.FromShapeMsg(pointMsg, sr)));
        }
        public static ShapeMsg GetOpenJawReshapeReplaceEndPoint(
            [NotNull] OpenJawReshapeLineReplacementRequest request,
            [CanBeNull] ITrackCancel trackCancel = null)
        {
            var polylineToReshape =
                (IPolyline)ProtobufGeometryUtils.FromShapeMsg(request.Feature.Shape);
            var reshapeLine =
                (IPolyline)ProtobufGeometryUtils.FromShapeMsg(request.ReshapePath);

            IPoint endPoint = null;

            if (polylineToReshape != null && reshapeLine != null)
            {
                endPoint = ReshapeUtils.GetOpenJawReshapeLineReplaceEndPoint(
                    polylineToReshape, reshapeLine, request.UseNonDefaultReshapeSide);
            }

            if (endPoint == null)
            {
                return(new ShapeMsg());
            }

            ShapeMsg result = ProtobufGeometryUtils.ToShapeMsg(endPoint);

            return(result);
        }
Exemple #3
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));
        }
        public override async Task <ShapeMsg> GetOpenJawReshapeLineReplaceEndPoint(
            OpenJawReshapeLineReplacementRequest request,
            ServerCallContext context)
        {
            Func <ITrackCancel, ShapeMsg> func =
                trackCancel => AdvancedReshapeServiceUtils.GetOpenJawReshapeReplaceEndPoint(
                    request, trackCancel);

            ShapeMsg response =
                await GrpcServerUtils.ExecuteServiceCall(func, context, _staTaskScheduler, true) ??
                new ShapeMsg();

            return(response);
        }