private IGeometry GetGeometry(int partIndex)
            {
                IGeometry geometry;

                if (!_perPart)
                {
                    geometry = GeometryFactory.Clone(_baseGeometry);
                }
                else if (_baseGeometry is ICurve)
                {
                    var geometryCollection = _baseGeometry as IGeometryCollection;
                    if (geometryCollection == null || geometryCollection.GeometryCount == 1)
                    {
                        geometry = GetErrorGeometry((ICurve)_baseGeometry);
                    }
                    else
                    {
                        var curve = (ICurve)geometryCollection.get_Geometry(partIndex);
                        geometry = GetErrorGeometry(curve);
                    }

                    return(geometry);
                }
                else
                {
                    IGeometryCollection geometryCollection;
                    if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
                    {
                        geometryCollection = QaGeometryUtils.CreatePolygon(_baseGeometry);
                    }
                    else if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                    {
                        geometryCollection = QaGeometryUtils.CreatePolyline(_baseGeometry);
                    }
                    else if (_baseGeometry.GeometryType == esriGeometryType.esriGeometryMultiPatch)
                    {
                        geometryCollection = new MultiPatchClass();
                    }
                    else
                    {
                        throw new InvalidOperationException("unhandled geometry type " +
                                                            _baseGeometry.GeometryType);
                    }

                    int segmentCount = _indexedSegments.GetPartSegmentCount(partIndex);
                    var partSegments = new List <SegmentProxy>(segmentCount);
                    for (int iSegment = 0; iSegment < segmentCount; iSegment++)
                    {
                        partSegments.Add(_indexedSegments.GetSegment(partIndex, iSegment));
                    }

                    SegmentUtils.CreateGeometry(geometryCollection, partSegments);
                    geometry = (IGeometry)geometryCollection;
                }

                return(geometry);
            }
Exemple #2
0
        private static IGeometry GetErrorGeometry([NotNull] ISegment segment)
        {
            Assert.ArgumentNotNull(segment, nameof(segment));

            object missing = Type.Missing;

            PolylineClass result = QaGeometryUtils.CreatePolyline(segment);

            ((ISegmentCollection)result).AddSegment(segment, ref missing, ref missing);

            return(result);
        }
        IPolyline ITopologicalLine.GetLine()
        {
            if (PartIndex < 0)
            {
                return(FullLine);
            }

            if (((IGeometryCollection)FullLine).GeometryCount <= 1)
            {
                return(FullLine);
            }

            IPolyline line = QaGeometryUtils.CreatePolyline(Path);

            ((ISegmentCollection)line).AddSegmentCollection(
                (ISegmentCollection)GeometryFactory.Clone(Path));
            return(line);
        }
Exemple #4
0
        public static IPolyline GetErrorGeometry(
            [NotNull] ICollection <ISegment> invalidMSegments,
            bool cloneSegments)
        {
            Assert.ArgumentNotNull(invalidMSegments, nameof(invalidMSegments));

            IPolyline result = QaGeometryUtils.CreatePolyline(invalidMSegments);

            var segments = (ISegmentCollection)result;

            object emptyRef = Type.Missing;

            foreach (ISegment segment in invalidMSegments)
            {
                segments.AddSegment(cloneSegments
                                                            ? GeometryFactory.Clone(segment)
                                                            : segment,
                                    ref emptyRef, ref emptyRef);
            }

            return(result);
        }
Exemple #5
0
        public IPolyline GetSubpart(int part, int startSegmentIndex, double startFraction,
                                    int endSegmentIndex, double endFraction)
        {
            double l0 = IndexedSegmentUtils.GetLength(this, part, 0, 0, startSegmentIndex,
                                                      startFraction);
            double l1 = IndexedSegmentUtils.GetLength(this, part, startSegmentIndex,
                                                      startFraction,
                                                      endSegmentIndex, endFraction);

            IGeometry sourcePart  = ((IGeometryCollection)_segments).Geometry[part];
            var       sourceCurve = (ICurve)sourcePart;

            ICurve subcurve;

            sourceCurve.GetSubcurve(l0, l0 + l1, false, out subcurve);

            ISegmentCollection line = QaGeometryUtils.CreatePolyline(subcurve);

            ((IZAware)line).ZAware = ((IZAware)subcurve).ZAware;
            line.AddSegmentCollection((ISegmentCollection)subcurve);

            return((IPolyline)line);
        }