internal static List <Point> GetPoints(IEsriSimplePoints shape, int startIndex) { int partNumber = Array.IndexOf(shape.Parts, startIndex); int lastIndex = (partNumber == shape.NumberOfParts - 1) ? shape.NumberOfPoints - 1 : shape.Parts[partNumber + 1] - 1; //do not add last point for polygon if (shape is EsriPolygon || shape is EsriPolygonM || shape is EsriPolygonZ) { lastIndex = lastIndex - 1; } var count = lastIndex - startIndex + 1; //Point[] result = new Point[lastIndex - startIndex + 1]; List <Point> result = new List <Point>(count); for (int i = 0; i < count; i++) { //result[i] = new Point(shape.Points[startIndex + i].X, shape.Points[startIndex + i].Y); result.Add(new Point(shape.Points[startIndex + i].X, shape.Points[startIndex + i].Y)); } return(result); }
private static void WriteEsriPolygon(SqlGeometryBuilder builder, IEsriSimplePoints points) { if (points.NumberOfParts == 1) { builder.BeginGeometry(OpenGisGeometryType.Polygon); WriteLineOrRing(builder, points.Points); builder.EndGeometry(); } else if (points.NumberOfParts > 1) { builder.BeginGeometry(OpenGisGeometryType.MultiPolygon); for (int i = 0; i < points.NumberOfParts; i++) { builder.BeginGeometry(OpenGisGeometryType.Polygon); WriteLineOrRing(builder, points.GetPart(i)); builder.EndGeometry(); } builder.EndGeometry(); } else { throw new NotImplementedException(); } }
private static void WriteEsriMultiPoint(SqlGeometryBuilder builder, IEsriSimplePoints points) { builder.BeginGeometry(OpenGisGeometryType.MultiPoint); foreach (var point in points.Points) { WriteEsriPoint(builder, point); } builder.EndGeometry(); }
internal static EsriPoint[] GetEsriPoints(IEsriSimplePoints shape, int startIndex) { int partNumber = Array.IndexOf(shape.Parts, startIndex); //int startIndex = shape.Parts[partNumber]; int lastIndex = (partNumber == shape.NumberOfParts - 1) ? shape.NumberOfPoints - 1 : shape.Parts[partNumber + 1] - 1; EsriPoint[] result = new EsriPoint[lastIndex - startIndex + 1]; Array.ConstrainedCopy(shape.Points, startIndex, result, 0, result.Length); return(result); }
internal static byte[] WriteBoundingBoxToByte(IEsriSimplePoints shape) { System.IO.MemoryStream result = new System.IO.MemoryStream(); result.Write(System.BitConverter.GetBytes(shape.MinimumBoundingBox.XMin), 0, ShapeConstants.DoubleSize); result.Write(System.BitConverter.GetBytes(shape.MinimumBoundingBox.YMin), 0, ShapeConstants.DoubleSize); result.Write(System.BitConverter.GetBytes(shape.MinimumBoundingBox.XMax), 0, ShapeConstants.DoubleSize); result.Write(System.BitConverter.GetBytes(shape.MinimumBoundingBox.YMax), 0, ShapeConstants.DoubleSize); return(result.ToArray()); }