示例#1
0
        /// <summary>
        ///     Gets the points on the geometry where the first and last M value occurs.
        /// </summary>
        /// <param name="source">The geometry.</param>
        /// <returns>Returns a <see cref="IEnumerable{T}" /> representing the points of M values.</returns>
        public static IEnumerable <IPoint> GetPointsAtMs(this IMSegmentation3 source)
        {
            double firstM, lastM;

            source.QueryFirstLastM(out firstM, out lastM);

            var collection = source.GetPointsAtM(firstM, 0);

            if (collection.GeometryCount == 1)
            {
                yield return((IPoint)collection.Geometry[0]);
            }

            collection = source.GetPointsAtM(lastM, 0);
            if (collection.GeometryCount == 1)
            {
                yield return((IPoint)collection.Geometry[0]);
            }
        }
        /// <summary>
        /// object polyline. Distance negative -> upstream
        /// </summary>
        /// <param name="geometricNetwork">object geometricNetwork</param>
        /// <param name="resultEdges">objects resultEdges</param>
        /// <param name="distance">value of distance</param>
        /// <param name="point">object point</param>
        /// <param name="offset">offset of polyline</param>
        /// <param name="messageInfo">info on result</param>
        /// <returns>object IGeometry (polyline or point)</returns>
        internal static IGeometry GetPolylinePosAlong(ESRI.ArcGIS.Geodatabase.IGeometricNetwork geometricNetwork, IEnumNetEID resultEdges, double distance, IPoint point, double?offset, ref string messageInfo)
        {
            IGeometry geometryBag = new GeometryBagClass();

            geometryBag.SpatialReference = point.SpatialReference;
            IGeometryCollection geometryCollection = geometryBag as IGeometryCollection;

            IEIDHelper eidHelper = new EIDHelperClass();

            eidHelper.GeometricNetwork = geometricNetwork;
            eidHelper.ReturnGeometries = true;
            eidHelper.ReturnFeatures   = false;

            IEnumEIDInfo enumEIDinfo = eidHelper.CreateEnumEIDInfo(resultEdges);

            enumEIDinfo.Reset();
            IEIDInfo eidInfo = enumEIDinfo.Next();

            while (eidInfo != null)
            {
                IGeometry geometry = eidInfo.Geometry;
                geometryCollection.AddGeometry(geometry);
                eidInfo = enumEIDinfo.Next();
            }

            ITopologicalOperator unionedPolyline = new PolylineClass();

            unionedPolyline.ConstructUnion(geometryBag as IEnumGeometry);

            IPolyline pl = unionedPolyline as IPolyline;

            if (distance < 0)
            {
                pl.ReverseOrientation();
                distance = Math.Abs(distance);
            }

            IMAware mAware = pl as IMAware;

            mAware.MAware = true;
            IMSegmentation3 mSegmentation = unionedPolyline as IMSegmentation3;

            mSegmentation.SetMsAsDistance(false);

            IPoint ptTmp             = new PointClass();
            double distanceAlong     = 0;
            double distanceFromCurve = 0;
            bool   rightSide         = false;

            pl.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, point, false, ptTmp, ref distanceAlong, ref distanceFromCurve, ref rightSide);
            object mStartArray = mSegmentation.GetMsAtDistance(distanceAlong, false);

            double[]  mStart             = mStartArray as double[];
            double    distanceDownStream = distanceAlong + distance;
            IPolyline resultPolyline     = mSegmentation.GetSubcurveBetweenMs(mStart[0], distanceDownStream) as IPolyline;

            if (resultPolyline.IsEmpty)
            {
                return(point);
            }

            if (mSegmentation.MMax < distanceDownStream)
            {
                messageInfo = "The set distance exceeds the length of network";
            }

            return(Helper.ConstructOffset(resultPolyline, offset));
        }