Exemplo n.º 1
0
        /// <summary>
        /// IGeometry转成JSON字符串
        /// </summary>
        public static string GeometryToJsonString(ZGeometry zGeo)
        {
            IGeometry   geometry   = zGeo.geometry;
            IJSONWriter jsonWriter = new JSONWriterClass();

            jsonWriter.WriteToString();
            JSONConverterGeometryClass jsonCon = new JSONConverterGeometryClass();

            jsonCon.WriteGeometry(jsonWriter, null, geometry, false);
            return(Encoding.UTF8.GetString(jsonWriter.GetStringBuffer()));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 分割多边形
        /// </summary>
        /// <param name="polygon"></param>
        /// <param name="polyline"></param>
        /// <returns></returns>
        public static List <ZGeometry> CutGeometry(ZGeometry polygon, ZGeometry polyline)
        {
            List <ZGeometry> geos = new List <ZGeometry>();

            try
            {
                IGeometry            pLeftGeo, pRightGeo;
                ITopologicalOperator pTopologBoundary = polygon.geometry as ITopologicalOperator;
                pTopologBoundary.Simplify();
                pTopologBoundary.Cut((IPolyline)polyline.geometry, out pLeftGeo, out pRightGeo);
                if (pLeftGeo != null && pRightGeo != null)
                {
                    geos.Add(new ZGeometry(pLeftGeo));
                    geos.Add(new ZGeometry(pRightGeo));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(geos);
        }