コード例 #1
0
ファイル: SegmentUtils.cs プロジェクト: sungaoyong/ProSuite
        public static void CreateGeometry([NotNull] IGeometryCollection geometryCollection,
                                          [NotNull] IEnumerable <SegmentProxy> segments)
        {
            int lastPartIndex    = -1;
            ISpatialReference sr = null;

            var ringPoints = new List <WKSPointZ>();

            foreach (SegmentProxy segment in segments)
            {
                if (sr == null)
                {
                    sr = segment.SpatialReference;
                    ((IGeometry)geometryCollection).SpatialReference = sr;
                }

                if (lastPartIndex != segment.PartIndex)
                {
                    AddRing(geometryCollection, ringPoints);
                    ringPoints.Clear();
                    ringPoints.Add(QaGeometryUtils.GetWksPoint(segment.GetStart(true)));
                }

                lastPartIndex = segment.PartIndex;
                ringPoints.Add(QaGeometryUtils.GetWksPoint(segment.GetEnd(true)));
            }

            AddRing(geometryCollection, ringPoints);
        }
コード例 #2
0
        public override WKSEnvelope GetSubCurveBox(double fromRatio, double toRatio)
        {
            WKSPointZ from = fromRatio > 0
                                                 ? QaGeometryUtils.GetWksPoint(GetPointAt(fromRatio))
                                                 : FromPoint;
            WKSPointZ to = toRatio < 1
                                               ? QaGeometryUtils.GetWksPoint(GetPointAt(toRatio))
                                               : ToPoint;
            WKSEnvelope box = new WKSEnvelope
            {
                XMin = Math.Min(from.X, to.X),
                YMin = Math.Min(from.Y, to.Y),
                XMax = Math.Max(from.X, to.X),
                YMax = Math.Max(from.Y, to.Y)
            };

            return(box);
        }
コード例 #3
0
ファイル: PlaneProxy.cs プロジェクト: esride-jts/ProSuite
        public IPolyline GetSubpart(int startSegmentIndex, double startFraction,
                                    int endSegmentIndex, double endFraction)
        {
            IPointCollection4 subpart = new PolylineClass();

            ((IZAware)subpart).ZAware = true;

            var add = 2;

            if (endFraction == 0)
            {
                add = 1;
            }

            int pointCount = endSegmentIndex - startSegmentIndex + add;
            var points     = new WKSPointZ[pointCount];

            SegmentProxy seg0 = GetSegment(startSegmentIndex);
            IPnt         p    = seg0.GetPointAt(startFraction, true);

            points[0] = QaGeometryUtils.GetWksPoint(p);
            for (int i = startSegmentIndex + 1; i <= endSegmentIndex; i++)
            {
                points[i - startSegmentIndex] = GetPlanePoint(i);
            }

            if (endFraction > 0)
            {
                SegmentProxy seg1 = GetSegment(endSegmentIndex);
                IPnt         end  = seg1.GetPointAt(endFraction, true);
                points[pointCount - 1] = QaGeometryUtils.GetWksPoint(end);
            }

            GeometryUtils.SetWKSPointZs(subpart, points);
            return((IPolyline)subpart);
        }
コード例 #4
0
        private IPolyline GetLinearSubpart(int startSegmentIndex, double startFraction,
                                           int endSegmentIndex, double endFraction)
        {
            IPointCollection4 subpart = new PolylineClass();

            int add = 2;

            if (endFraction == 0)
            {
                add = 1;
            }

            int pointCount = endSegmentIndex - startSegmentIndex + add;
            var points     = new WKSPointZ[pointCount];

            SegmentProxy seg0 = GetSegment(startSegmentIndex);
            IPnt         p    = seg0.GetPointAt(startFraction, as3D: true);

            points[0] = QaGeometryUtils.GetWksPoint(p);
            for (int i = startSegmentIndex + 1; i <= endSegmentIndex; i++)
            {
                points[i - startSegmentIndex] = _points[i];
            }

            if (endFraction > 0)
            {
                SegmentProxy seg1 = GetSegment(endSegmentIndex);
                IPnt         end  = seg1.GetPointAt(endFraction, as3D: true);
                points[pointCount - 1] = QaGeometryUtils.GetWksPoint(end);
            }

            GeometryUtils.SetWKSPointZs(subpart, points);

            ((IPolyline)subpart).SpatialReference = SpatialReference;
            return((IPolyline)subpart);
        }
コード例 #5
0
        private IPolyline GetNonLinearSubpart(int startSegmentIndex, double startFraction,
                                              int endSegmentIndex, double endFraction)
        {
            var subpart = new PolylineClass();
            IPointCollection4  points = subpart;
            ISegmentCollection segs   = subpart;

            subpart.SpatialReference = SpatialReference;

            bool hasNonLinearParts = false;

            object         missing = Type.Missing;
            SegmentProxy   segProxy;
            AoSegmentProxy aoSegProxy;

            #region startSegment

            var currentWksPoints = new List <WKSPointZ>();
            if (_nonLinearSegments.TryGetValue(startSegmentIndex, out aoSegProxy))
            {
                hasNonLinearParts = true;
                ISegment seg = aoSegProxy.InnerSegment;
                ICurve   part;

                double end = 1;
                if (endSegmentIndex == startSegmentIndex)
                {
                    end = endFraction;
                }

                seg.GetSubcurve(startFraction, end, true, out part);

                segs.AddSegment((ISegment)part, ref missing, ref missing);
            }
            else
            {
                segProxy = GetSegment(startSegmentIndex);
                IPnt p = segProxy.GetPointAt(startFraction, as3D: true);
                currentWksPoints.Add(QaGeometryUtils.GetWksPoint(p));
            }

            #endregion

            #region segments

            for (int i = startSegmentIndex + 1; i < endSegmentIndex; i++)
            {
                if (_nonLinearSegments.TryGetValue(i, out aoSegProxy))
                {
                    hasNonLinearParts = true;

                    if (currentWksPoints.Count > 0)
                    {
                        currentWksPoints.Add(_points[i]);
                        WKSPointZ[] add = currentWksPoints.ToArray();
                        GeometryUtils.AddWKSPointZs(points, add);
                        currentWksPoints.Clear();
                    }

                    ISegment seg = GeometryFactory.Clone(aoSegProxy.InnerSegment);
                    segs.AddSegment(seg, ref missing, ref missing);
                }
                else
                {
                    currentWksPoints.Add(_points[i]);
                }
            }

            #endregion

            #region endsegment

            if (startSegmentIndex == endSegmentIndex)
            {
                if (currentWksPoints.Count > 0)
                {
                    segProxy = GetSegment(endSegmentIndex);
                    IPnt p = segProxy.GetPointAt(endFraction, as3D: true);
                    currentWksPoints.Add(QaGeometryUtils.GetWksPoint(p));
                    WKSPointZ[] add = currentWksPoints.ToArray();
                    GeometryUtils.AddWKSPointZs(points, add);
                }
            }
            else
            {
                if (_nonLinearSegments.TryGetValue(endSegmentIndex, out aoSegProxy))
                {
                    hasNonLinearParts = false;
                    if (currentWksPoints.Count > 0)
                    {
                        currentWksPoints.Add(_points[endSegmentIndex]);
                        WKSPointZ[] add = currentWksPoints.ToArray();
                        GeometryUtils.AddWKSPointZs(points, add);
                        currentWksPoints.Clear();
                    }

                    ISegment seg = aoSegProxy.InnerSegment;
                    ICurve   part;
                    seg.GetSubcurve(0, endFraction, true, out part);
                    segs.AddSegment((ISegment)part, ref missing, ref missing);
                }
                else
                {
                    currentWksPoints.Add(_points[endSegmentIndex]);
                    segProxy = GetSegment(endSegmentIndex);

                    IPnt p = segProxy.GetPointAt(endFraction, as3D: true);
                    currentWksPoints.Add(QaGeometryUtils.GetWksPoint(p));

                    WKSPointZ[] add = currentWksPoints.ToArray();
                    GeometryUtils.AddWKSPointZs(points, add);
                }
            }

            #endregion

            if (hasNonLinearParts)
            {
                var topoOp = (ITopologicalOperator2)subpart;
                topoOp.IsKnownSimple_2 = false;
                topoOp.Simplify();
            }

            return(subpart);
        }