{
Coordinate2D coordinate = new Coordinate2D(10, 30);
double angle = SpatialReferences.WGS84.GetConvergenceAngle(coordinate);
// angle = 0
SpatialReference srUTM30N = SpatialReferenceBuilder.CreateSpatialReference(32630);
coordinate.X = 500000;
coordinate.Y = 550000;
angle = srUTM30N.GetConvergenceAngle(coordinate);
// angle = 0
MapPoint pointWGS84 = MapPointBuilderEx.CreateMapPoint(10, 50, SpatialReferences.WGS84);
MapPoint pointUTM30N = GeometryEngine.Instance.Project(
pointWGS84, srUTM30N) as MapPoint;
coordinate = (Coordinate2D)pointUTM30N;
// get convergence angle and convert to degrees
angle = srUTM30N.GetConvergenceAngle(coordinate) * 180 / Math.PI;
// angle = 10.03
}
{
// <summary>
// Create an N-sided regular polygon. A regular sided polygon is a polygon that is equiangular (all angles are equal in measure)
// and equilateral (all sides are equal in length). See https://en.wikipedia.org/wiki/Regular_polygon
// </summary>
// <param name="numSides">The number of sides in the polygon.</param>
// <param name="center">The center of the polygon.</param>
// <param name="radius">The distance from the center of the polygon to a vertex.</param>
// <param name="rotation">The rotation angle in radians of the start point of the polygon. The start point will be
// rotated counterclockwise from the positive x-axis.</param>
// <returns>N-sided regular polygon.</returns>
// <exception cref="ArgumentException">Number of sides is less than 3.</exception>
static Polygon CreateRegularPolygon(int numSides, Coordinate2D center, double radius, double rotation)
{
if (numSides < 3)
{
throw new ArgumentException();
}
Coordinate2D[] coords = new Coordinate2D[numSides + 1];
double centerX = center.X;
double centerY = center.Y;
double x = radius * Math.Cos(rotation) + centerX;
double y = radius * Math.Sin(rotation) + centerY;
Coordinate2D start = new Coordinate2D(x, y);
coords[0] = start;
double da = 2 * Math.PI / numSides;
for (int i = 1; i < numSides; i++)
{
x = radius * Math.Cos(i * da + rotation) + centerX;
y = radius * Math.Sin(i * da + rotation) + centerY;
coords[i] = new Coordinate2D(x, y);
}
coords[numSides] = start;
return PolygonBuilderEx.CreatePolygon(coords);
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)