private void WritePoint(JsonWriter writer, EsriPoint point) { if (point == null) { writer.WriteNull(); return; } writer.WriteStartArray(); writer.WriteValue(point.X.Value); writer.WriteValue(point.Y.Value); if (point.Z.HasValue) { writer.WriteValue(point.Z.Value); } if (point.M.HasValue) { writer.WriteValue(point.Z.Value); } writer.WriteEndArray(); }
private static EsriPoint[] GetPoints(SqlGeometry geometry, Func <IPoint, IPoint> mapFunction) { if (geometry.IsNullOrEmpty()) { return(null); } int numberOfPoints = geometry.STNumPoints().Value; EsriPoint[] points = new EsriPoint[numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { int index = i + 1; //EsriPoint point = new EsriPoint(geometry.STPointN(index).STX.Value, geometry.STPointN(index).STY.Value); var point = geometry.STPointN(index).AsEsriPoint(); if (mapFunction == null) { points[i] = point; } else { points[i] = (EsriPoint)mapFunction(point); } } return(points); }
public static double GetSemiDistance(EsriPoint first, EsriPoint second) { var dx = first.X - second.X; var dy = first.Y - second.Y; return(dx * dx + dy * dy); }
private static void AppendPointText(EsriPoint coordinate, StringWriter writer) { if (coordinate == null) { writer.Write("Empty"); } else { writer.Write("("); AppendCoordinate(coordinate, writer); writer.Write(")"); } }
internal static EsriPoint[] GetPoints(ISimplePoints 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); }
public static byte[] ToWkbPoint(EsriPoint point) { byte[] result = new byte[21]; result[0] = (byte)IRI.Standards.OGC.SFA.WkbByteOrder.WkbNdr; Array.Copy(BitConverter.GetBytes((int)IRI.Standards.OGC.SFA.WkbGeometryType.Point), 0, result, 1, 4); Array.Copy(BitConverter.GetBytes(point.X), 0, result, 5, 8); Array.Copy(BitConverter.GetBytes(point.Y), 0, result, 13, 8); return(result); }
internal static EsriPoint[] ReadPoints(byte[] byteArray, int offset, int numberOfPoints) { EsriPoint[] result = new EsriPoint[numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { double tempX = BitConverter.ToDouble(byteArray, 2 * i * ShapeConstants.DoubleSize + offset); double tempY = BitConverter.ToDouble(byteArray, (2 * i + 1) * ShapeConstants.DoubleSize + offset); result[i] = new EsriPoint(tempX, tempY); } return(result); }
internal static EsriPoint[] ReadPoints(BinaryReader reader, int numberOfPoints) { EsriPoint[] result = new EsriPoint[numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { double tempX = reader.ReadDouble(); double tempY = reader.ReadDouble(); result[i] = new EsriPoint(tempX, tempY); } return(result); }
protected EsriPoint[] ReadPoints(int numberOfPoints) { EsriPoint[] result = new EsriPoint[numberOfPoints]; for (int i = 0; i < numberOfPoints; i++) { double tempX = shpReader.ReadDouble(); double tempY = shpReader.ReadDouble(); result[i] = new EsriPoint(tempX, tempY); } return(result); }
public static double GetCosineOfAngle(EsriPoint p1, EsriPoint p2, EsriPoint p3) { if (p1.Equals(p2) || p2.Equals(p3)) { return(1); } //cos(theta) = (A.B)/(|A|*|B|) var ax = p3.X - p2.X; var ay = p3.Y - p2.Y; var bx = p2.X - p1.X; var by = p2.Y - p1.Y; var dotProduct = ax * bx + ay * by; var result = dotProduct * dotProduct / ((ax * ax + ay * ay) * (bx * bx + by * by)); if (double.IsNaN(result)) { } return(result); }
private static void AppendPointTaggedText(EsriPoint coordinate, StringWriter writer) { writer.Write("POINT "); AppendPointText(coordinate, writer); }
public static double GetSignedArea(EsriPoint p1, EsriPoint p2, EsriPoint p3) { return((p1.X * (p2.Y - p3.Y) + p2.X * (p3.Y - p1.Y) + p3.X * (p1.Y - p2.Y)) / 2.0); }
public static double GetArea(EsriPoint p1, EsriPoint p2, EsriPoint p3) { return(Math.Abs(p1.X * (p2.Y - p3.Y) + p2.X * (p3.Y - p1.Y) + p3.X * (p1.Y - p2.Y)) / 2.0); }
private static void AppendCoordinate(EsriPoint coordinate, StringWriter writer) { writer.Write(coordinate.X + " " + coordinate.Y); }
internal static string PointZElementToWkt(EsriPoint point, double zValue, double measure) { return(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:G17} {1:G17} {2:G17} {3}", point.X, point.Y, zValue, measure == ShapeConstants.NoDataValue ? "NULL" : measure.ToString("G17"))); }
internal static string PointMElementToWkt(EsriPoint point, double measure) { return(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:G17} {1:G17} NULL {2:G17}", point.X, point.Y, measure)); }
internal static string SinglePointElementToWkt(EsriPoint point) { return(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:G17} {1:G17}", point.X, point.Y)); }