private static string processMultiPointBuffer(MultiPointShapeBuffer buffer)
 {
     try
     {
         StringBuilder retval = new StringBuilder("{\"type\":\"MultiPoint\", \"coordinates\": [");
         bool hasZ = false;
         try
         {
             hasZ = (buffer.Zs != null);
         }
         catch
         {
             hasZ = false;
         }
         Point[] points = buffer.Points;
         List<string> coords = new List<string>();
         for (int i = 0; i < points.Length; i++)
         {
             string coord = hasZ ? getCoordinate(points[i].x, points[i].y, buffer.Zs[i]) : getCoordinate(points[i].x, points[i].y);
             coords.Add(coord);
         }
         string[] coordArray = coords.ToArray();
         string coordList = string.Join(",", coordArray);
         retval.Append(coordList);
         retval.Append("]}");
         return retval.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("Error processing multipoint buffer", ex);
     }
 }
示例#2
0
 private static string processMultiPointBuffer(MultiPointShapeBuffer buffer)
 {
     try
     {
         string retval = "MULTIPOINT ({0})";
         bool   hasZ   = false;
         try
         {
             hasZ = (buffer.Zs != null);
         }
         catch
         {
             hasZ = false;
         }
         Point[]       points = buffer.Points;
         List <string> coords = new List <string>();
         for (int i = 0; i < points.Length; i++)
         {
             string coord = hasZ ? getCoordinate(points[i].x, points[i].y, buffer.Zs[i]) : getCoordinate(points[i].x, points[i].y);
             coords.Add(coord);
         }
         string[] coordArray = coords.ToArray();
         string   coordList  = string.Join(",", coordArray);
         retval = string.Format(retval, coordList);
         return(retval);
     }
     catch (Exception ex)
     {
         throw new Exception("Error processing multipoint buffer", ex);
     }
 }
示例#3
0
        static void Main(string[] args)
        {
            Geodatabase geo = Geodatabase.Open("");

            List <Table> tables = new List <Table>();

            List <string> featureClasses = geo.GetChildDatasets("\\", "Feature Class").ToList();

            foreach (string featureClassName in featureClasses)
            {
                tables.Add(geo.OpenTable(featureClassName));
            }

            string createTableSqlCommand = CreateTableColumns(tables[0].FieldInformation);

            FieldInfo fieldInfo = tables[0].FieldInformation;
            var       fields    = new List <string>();

            for (int i = 0; i < fieldInfo.Count; i++)
            {
                fields.Add(fieldInfo.GetFieldName(i));
            }

            var           countStatements = $"SELECT * FROM VAULTSCOT_AUTH_POINT_OCT18";
            RowCollection rows            = geo.ExecuteSQL(countStatements);
            WKBReader     reader          = new WKBReader();

            foreach (Row row in rows)
            {
                MultiPointShapeBuffer geometry = row.GetGeometry();
                var point = geometry.Points;
                //MULTIPOINT (295512,712727,0) throwing format exception - Resolved in upcoming commit.
                var geometryWKT = processMultiPointBuffer(geometry);
            }

            var           countEnumerator = rows.GetEnumerator();
            List <object> fieldValues     = new List <object>();

            if (rows != null)
            {
                countEnumerator.MoveNext();
                var shape = countEnumerator.Current["Shape"];

                for (int i = 0; i < fieldInfo.Count - 1; i++)
                {
                    var count = countEnumerator.Current[fields[i]];
                    fieldValues.Add(count);
                }
            }

            InsertTableValues(fieldValues, fieldInfo);
        }
        private static ILineString ToGeneralMultiPoint(MultiPointShapeBuffer multiPoint)
        {
            var lineExtent = new GeometryFactory().CreateEnvelope(multiPoint.Extent.xMax, multiPoint.Extent.yMax, multiPoint.Extent.xMin, multiPoint.Extent.yMin);

            var lineGeo = new GeometryFactory().CreateLineString();
            lineGeo.Envelope = lineExtent;
            var vertices = lineGeo.Vertices;
            for (var i = 0; i < multiPoint.NumPoints; i++)
            {
                var mapPoint = new GeometryFactory().CreatePoint(multiPoint.Points[i].x, multiPoint.Points[i].y);
                vertices.Add(mapPoint);
            }

            return lineGeo;
        }
        private static ILineString ToGeneralMultiPoint(MultiPointShapeBuffer multiPoint)
        {
            var lineExtent = new GeometryFactory().CreateEnvelope(multiPoint.Extent.xMax, multiPoint.Extent.yMax, multiPoint.Extent.xMin, multiPoint.Extent.yMin);

            var lineGeo = new GeometryFactory().CreateLineString();

            lineGeo.Envelope = lineExtent;
            var vertices = lineGeo.Vertices;

            for (var i = 0; i < multiPoint.NumPoints; i++)
            {
                var mapPoint = new GeometryFactory().CreatePoint(multiPoint.Points[i].x, multiPoint.Points[i].y);
                vertices.Add(mapPoint);
            }

            return(lineGeo);
        }
示例#6
0
        public static string ToWKT(this Esri.FileGDB.ShapeBuffer geometry)
        {
            try
            {
                string retval    = "";
                var    shapeType = (ShapeType)geometry.shapeType;
                //note: "M" values are not really supported. Relevant geometries are handled to extract Z values, if present.
                switch (shapeType)
                {
                case ShapeType.Multipoint:
                case ShapeType.MultipointZ:
                case ShapeType.MultipointZM:
                    MultiPointShapeBuffer mptbuff = geometry;
                    retval = processMultiPointBuffer(mptbuff);
                    break;

                case ShapeType.Point:
                case ShapeType.PointZ:
                case ShapeType.PointZM:
                    PointShapeBuffer pt = geometry;
                    retval = processPointBuffer(geometry);
                    break;

                case ShapeType.Polyline:
                case ShapeType.PolylineZ:
                case ShapeType.PolylineZM:
                    MultiPartShapeBuffer lbuff = geometry;
                    retval = processMultiPartBuffer(lbuff, "MULTILINESTRING");
                    break;

                case ShapeType.Polygon:
                case ShapeType.PolygonZ:
                case ShapeType.PolygonZM:
                    MultiPartShapeBuffer pbuff = geometry;
                    retval = processMultiPartBuffer(pbuff, "MULTIPOLYGON");
                    break;
                }
                return(retval);
            }
            catch (Exception ex)
            {
                throw new Exception("Error processing geometry", ex);
            }
        }
 private static string processMultiPointBuffer(MultiPointShapeBuffer buffer)
 {
     try
     {
         string retval = "MULTIPOINT ({0})";
         bool hasZ = false;
         try
         {
             hasZ = (buffer.Zs != null);
         }
         catch
         {
             hasZ = false;
         }
         Point[] points = buffer.Points;
         List<string> coords = new List<string>();
         for (int i = 0; i < points.Length; i++)
         {
             string coord = hasZ ? getCoordinate(points[i].x, points[i].y, buffer.Zs[i]) : getCoordinate(points[i].x, points[i].y);
             coords.Add(coord);
         }
         string[] coordArray = coords.ToArray();
         string coordList = string.Join(",", coordArray);
         retval = string.Format(retval, coordList);
         return retval;
     }
     catch (Exception ex)
     {
         throw new Exception("Error processing multipoint buffer", ex);
     }
 }
 private static string processMultiPointBuffer(MultiPointShapeBuffer buffer)
 {
     string retval = "{\"type\":\"MultiPoint\", \"coordinates\": [";
     Point[] points = buffer.Points;
     List<string> coords = new List<string>();
     for (int i = 0; i < points.Length; i++)
     {
         coords.Add(getCoordinate(points[i].x, points[i].y));
     }
     string[] coordArray = coords.ToArray();
     string coordList = string.Join(",", coordArray);
     retval += coordList + "]}";
     return retval;
 }
 private static string processMultiPointBuffer(MultiPointShapeBuffer buffer)
 {
     try
     {
         StringBuilder retval = new StringBuilder("{\"type\":\"MultiPoint\", \"coordinates\": [");
         bool hasZ = false;
         try
         {
             hasZ = (buffer.Zs != null);
         }
         catch
         {
             hasZ = false;
         }
         Point[] points = buffer.Points;
         List<string> coords = new List<string>();
         for (int i = 0; i < points.Length; i++)
         {
             string coord = hasZ ? getCoordinate(points[i].x, points[i].y, buffer.Zs[i]) : getCoordinate(points[i].x, points[i].y);
             coords.Add(coord);
         }
         string[] coordArray = coords.ToArray();
         string coordList = string.Join(",", coordArray);
         retval.Append(coordList);
         retval.Append("]}");
         return retval.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("Error processing multipoint buffer", ex);
     }
 }