示例#1
0
            private void ProcessFeature([NotNull] Feature feature)
            {
                var margin   = _maskMargin.DefineFields(feature.RowValues()).Evaluate <double>(0.0);
                var simplTol = _simplificationToleranceMu;

                var maskShape = CreateMask(feature, simplTol, margin, _maskOutlineType, _fillHoles);

                using (var buffer = _outputMaskDataset.FeatureClass.CreateRowBuffer())
                {
                    buffer[_outputMaskDataset.ShapeFieldName] = maskShape;

                    _maskAttributes.ForgetAll()
                    .DefineFields(feature, InputQualifier)
                    .Execute(buffer);

                    var maskFeature = _outputMaskDataset.FeatureClass.CreateRow(buffer);

                    Relate(feature, maskFeature);

                    MasksCreated += 1;
                }
            }
示例#2
0
            private void ProcessFeature([NotNull] Feature feature)
            {
                var shape = feature.GetShape();
                var point = Assert.NotNull(shape as MapPoint, "Input shape is not MapPoint");

                IDictionary <Feature, double> distanceByFeature =
                    GetNearFeatures(point, _referenceDatasets, _searchDistance);

                if (distanceByFeature.Count == 0)
                {
                    _msg.DebugFormat(
                        "Marker feature {0}: No reference feature found within search distance of {1}",
                        ProcessingUtils.Format(feature), _searchDistance);
                    return;
                }

                var nearest = distanceByFeature.OrderBy(f => f.Value).First();

                var referenceFeature = Assert.NotNull(nearest.Key, "Oops, bug");
                var distance         = nearest.Value;         // may be zero

                var referenceShape = referenceFeature.GetShape();
                var referenceCurve = Assert.NotNull(referenceShape as Multipart,
                                                    "Reference shape is not Multipart");

                double distanceAlongCurve = GeometryUtils.GetDistanceAlongCurve(referenceCurve, point);

                double normalLength = Math.Max(_inputDataset.XYTolerance, distance);
                var    normalPoly   = GeometryEngine.Instance.QueryNormal(
                    referenceCurve, SegmentExtension.NoExtension, distanceAlongCurve,
                    AsRatioOrLength.AsLength, normalLength);
                var normal = (LineSegment)normalPoly.Parts[0][0];                  // TODO safety guards

                double tangentLength = Math.Max(_inputDataset.XYTolerance, distance);
                var    tangentPoly   = GeometryEngine.Instance.QueryTangent(
                    referenceCurve, SegmentExtension.NoExtension, distanceAlongCurve,
                    AsRatioOrLength.AsLength, tangentLength);
                var tangent = (LineSegment)tangentPoly.Parts[0][0];                  // TODO safety guards

                // ILine.Angle is the angle between line and positive x axis,
                // but the Angle property of a representation marker has its
                // zero point at North: add 90° to ILine.Angle to fix:

                double normalOffset = MathUtils.ToDegrees(normal.Angle) - 90;
                double normalAngle  = ProcessingUtils.ToPositiveDegrees(normalOffset);

                double tangentOffset = MathUtils.ToDegrees(tangent.Angle) - 90;
                double tangentAngle  = ProcessingUtils.ToPositiveDegrees(tangentOffset);

                _markerFieldSetter.ForgetAll()
                .DefineFields(feature, InputQualifier)
                .DefineFields(referenceFeature, ReferenceQualifier)
                .DefineValue("normalAngle", normalAngle)
                .DefineValue("tangentAngle", tangentAngle)
                .DefineValue("distance", distance)
                .Execute(feature);

                feature.Store();

                FeaturesAligned += 1;

                _msg.DebugFormat(
                    "Marker feature {0}: aligned to {1} (normalAngle: {2}, tangentAngle: {3}, distance: {4})",
                    ProcessingUtils.Format(feature), ProcessingUtils.Format(referenceFeature),
                    normalAngle, tangentAngle, distance);

                // TODO need some mechanism to ensure disposal (required by Pro SDK documentation); see also OneNote
                foreach (var pair in distanceByFeature)
                {
                    pair.Key.Dispose();
                }
            }