///
        /// 将ESRIGeometry转换为WKB 仅支持简单几何对象
        ///
        ///
        ///
        public static byte[] ConvertGeometryToWKB(IGeometry geometry)
        {
            IWkb wkb = geometry as IWkb;


            ITopologicalOperator6 oper = geometry as ITopologicalOperator6;

            oper.SimplifyAsFeature();
            IGeometryFactory3 factory = new GeometryEnvironment() as IGeometryFactory3;

            byte[] b = factory.CreateWkbVariantFromGeometry(geometry) as byte[];

            return(b);
        }
Пример #2
0
        public void InsertPointAtIntersection2(ref IPolyline pPolyline, IGeometry pOther, double hmgetal)
        {
            bool   SplitHappened   = false;
            int    newPartIndex    = 0;
            int    newSegmentIndex = 0;
            int    index           = 0;
            IPoint Point           = null;
            IPoint HitPoint        = new ESRI.ArcGIS.Geometry.Point();
            double hitDistance     = 0;
            int    hitPartIndex    = 0;
            int    hitSegmentIndex = 0;
            bool   bRightSide      = false;


            ITopologicalOperator5 pTopoOpOther = pOther as ITopologicalOperator5;

            pTopoOpOther.Simplify();

            ITopologicalOperator6 pTopoOpPolyline = pPolyline as ITopologicalOperator6;
            IGeometry             pGeomResult     = pTopoOpPolyline.IntersectEx(pOther, false, esriGeometryDimension.esriGeometry0Dimension);

            if ((pGeomResult is IPointCollection) && ((pGeomResult as IPointCollection).PointCount > 0))
            {
                for (int i = 0; i < (pGeomResult as IPointCollection).PointCount; i++)
                {
                    (pPolyline as IHitTest).HitTest(
                        (pGeomResult as IPointCollection).get_Point(i),
                        10,
                        esriGeometryHitPartType.esriGeometryPartBoundary,
                        HitPoint,
                        ref hitDistance,
                        ref hitPartIndex,
                        ref hitSegmentIndex,
                        ref bRightSide);

                    index = 0;
                    for (int j = 0; j < hitPartIndex; j++)
                    {
                        index += ((pPolyline as IGeometryCollection).get_Geometry(j) as IPointCollection).PointCount;
                    }
                    index += hitSegmentIndex;

                    HitPoint.M = hmgetal;
                    (pPolyline as IPointCollection).AddPoint(HitPoint, after: index);
                }
            }
            (pPolyline as ITopologicalOperator2).IsKnownSimple_2 = false;
            (pPolyline as IPolyline4).SimplifyEx(true);
        }