public static LinearUnit Meters {get;}
Public Shared ReadOnly Property Meters As LinearUnit
public static LinearUnit Meters {get;}
Public Shared ReadOnly Property Meters As LinearUnit
{
GeodesicEllipseParameter param = new()
{
AxisDirection = 4 * Math.PI / 3,
Center = new Coordinate2D(-120, 60),
LinearUnit = LinearUnit.Meters,
OutGeometryType = GeometryType.Polyline,
SemiAxis1Length = 6500000,
SemiAxis2Length = 1500000,
VertexCount = 800
};
Geometry geometry = GeometryEngine.Instance.GeodesicEllipse(param, SpatialReferences.WGS84);
// geometry.IsEmpty = false
polyline = geometry as Polyline;
// polyline.PointCount = 801
// polyline.PartCount = 1
}
{
GeodesicSectorParameter param = new()
{
ArcVertexCount = 50,
AxisDirection = Math.PI / 4,
Center = new Coordinate2D(0, 0),
LinearUnit = LinearUnit.Meters,
OutGeometryType = GeometryType.Polygon,
RadiusVertexCount = 10,
SectorAngle = 5 * Math.PI / 3,
SemiAxis1Length = 100000,
SemiAxis2Length = 20000,
StartDirection = 11 * Math.PI / 6
};
Geometry geometry = GeometryEngine.Instance.GeodesicSector(param, SpatialReferences.WGS84);
// geometry.IsEmpty = false
polygon = geometry as Polygon;
// polygon.PointCount = 68
// polygon.PartCount = 1
}
{
List<Coordinate2D> coords =
[
new Coordinate2D(-80, 0),
new Coordinate2D(-20, 60),
new Coordinate2D(40, 20),
new Coordinate2D(0, -20),
new Coordinate2D(-80, 0)
];
SpatialReference sr = SpatialReferences.WGS84;
// create a polyline
polyline = PolylineBuilderEx.CreatePolyline(coords, sr);
// densify in km
Polyline geodesicPolyline = GeometryEngine.Instance.GeodeticDensifyByDeviation(polyline, 200, LinearUnit.Kilometers, GeodeticCurveType.Geodesic) as Polyline;
// densify in m
geodesicPolyline = GeometryEngine.Instance.GeodeticDensifyByDeviation(polyline, 200, LinearUnit.Meters, GeodeticCurveType.Geodesic) as Polyline;
// Change curve type to Loxodrome
Polyline loxodromePolyline = GeometryEngine.Instance.GeodeticDensifyByDeviation(polyline, 200, LinearUnit.Meters, GeodeticCurveType.Loxodrome) as Polyline;
}
{
List<Coordinate2D> coords =
[
new Coordinate2D(-80, 0),
new Coordinate2D(-20, 60),
new Coordinate2D(40, 20),
new Coordinate2D(0, -20),
new Coordinate2D(-80, 0)
];
SpatialReference sr = SpatialReferences.WGS84;
// create a polygon
polygon = PolygonBuilderEx.CreatePolygon(coords, sr);
// get the geodesic lengths of the polygon segments
ReadOnlySegmentCollection segments = polygon.Parts[0];
List<double> geoLengths = new(segments.Count);
foreach (Segment s in segments)
{
Polyline line = PolylineBuilderEx.CreatePolyline(s, sr);
double geoLen = GeometryEngine.Instance.GeodesicLength(line);
geoLengths.Add(geoLen);
}
// find the max length
geoLengths.Sort();
double maxLen = geoLengths[^1];
// densify the polygon (in meters)
Polygon densifiedPoly = GeometryEngine.Instance.GeodeticDensifyByLength(polygon, maxLen, LinearUnit.Meters, GeodeticCurveType.Geodesic) as Polygon;
// densify the polygon (in km)
double maxSegmentLength = maxLen / 10000;
densifiedPoly = GeometryEngine.Instance.GeodeticDensifyByLength(polygon, maxSegmentLength, LinearUnit.Kilometers, GeodeticCurveType.Geodesic) as Polygon;
}
{
SpatialReference sr = SpatialReferences.WebMercator;
var points = new[] { MapPointBuilderEx.CreateMapPoint(0, 0, sr) };
double distance = 10;
double azimuth = Math.PI / 2;
var resultPoints = GeometryEngine.Instance.GeodeticMove(points, sr, distance, LinearUnit.Meters, azimuth, GeodeticCurveType.Geodesic);
// resultPoints.First().X = 10
// resultPoints.First().Y = 0
// resultPoints.First().SpatialReference.Wkid = sr.Wkid
// Change LinearUnit to Miles
resultPoints = GeometryEngine.Instance.GeodeticMove(points, sr, distance, LinearUnit.Miles, azimuth, GeodeticCurveType.Geodesic);
// resultPoints.First().X = 16093.44
// resultPoints.First().Y = 0
// Change curve type
resultPoints = GeometryEngine.Instance.GeodeticMove(points, sr, distance, LinearUnit.Miles, azimuth, GeodeticCurveType.Loxodrome);
// resultPoints.First().X = 16093.44
// resultPoints.First().Y = 0
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)