Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AoSegmentProxy"/> class.
        /// </summary>
        /// <param name="segment">The segment (must be a copy, i.e. not straight from a recycling segment enumerator).</param>
        /// <param name="partIndex">Index of the part.</param>
        /// <param name="segmentIndex">Index of the segment.</param>
        public AoSegmentProxy([NotNull] ISegment segment, int partIndex, int segmentIndex)
            : base(partIndex, segmentIndex)
        {
            Assert.ArgumentNotNull(segment, nameof(segment));

            InnerSegment = segment;
            _extent      = QaGeometryUtils.CreateBox(segment);
        }
Esempio n. 3
0
        public IndexedPolycurve([NotNull] IPointCollection4 baseGeometry)
        {
            Assert.ArgumentNotNull(baseGeometry, nameof(baseGeometry));

            const bool @dynamic  = true;
            const int  dimension = 2;
            const int  maxElementCountPerTile = 4;            //  was: 64;

            _boxTree = new BoxTree <SegmentProxy>(dimension, maxElementCountPerTile, @dynamic);

            var geometry = (IGeometry)baseGeometry;

            _envelope = geometry.Envelope;
            double tolerance = GeometryUtils.GetXyTolerance(geometry);

            Box extent = QaGeometryUtils.CreateBox(_envelope);

            Expand(extent, tolerance);

            _boxTree.InitSize(new IGmtry[] { extent });

            var geometryCollection = baseGeometry as IGeometryCollection;

            if (geometryCollection != null)
            {
                int partCount = geometryCollection.GeometryCount;

                if (partCount > 1)
                {
                    // unpack and add individual parts
                    _partProxies = new List <PartProxy>(partCount);

                    for (int partIndex = 0; partIndex < partCount; partIndex++)
                    {
                        var part = (IPointCollection4)geometryCollection.Geometry[partIndex];

                        var partProxy = new PartProxy(_boxTree, partIndex, part);

                        _partProxies.Add(partProxy);

                        Marshal.ReleaseComObject(part);
                    }
                }
                else
                {
                    // single part in collection
                    _partProxies = AddSinglePartProxy(baseGeometry);
                }
            }
            else
            {
                // no geometry collection
                _partProxies = AddSinglePartProxy(baseGeometry);
            }
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
 private static Pnt CreatePoint([NotNull] IPoint p, bool as3D)
 {
     return(as3D
                                ? QaGeometryUtils.CreatePoint3D(p)
                                : QaGeometryUtils.CreatePoint2D(p));
 }
Esempio n. 8
0
 public IndexedMultiPatch([NotNull] IMultiPatch baseGeometry)
 {
     BaseGeometry  = baseGeometry;
     _envelope     = baseGeometry.Envelope;
     _patchProxies = QaGeometryUtils.GetPatchProxies(baseGeometry).ToList();
 }
Esempio n. 9
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);
        }