public static SpatialReference CreateSpatialReference( int wkid )
Public Overloads Shared Function CreateSpatialReference( _ ByVal wkid As Integer _ ) As SpatialReference
Parameters
- wkid
- The well-known ID that represents the Spatial Reference.
public static SpatialReference CreateSpatialReference( int wkid )
Public Overloads Shared Function CreateSpatialReference( _ ByVal wkid As Integer _ ) As SpatialReference
{
// Use a builder convenience method or use a builder constructor.
// SpatialReferenceBuilder convenience methods don't need to run on the MCT.
SpatialReference sr3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
// SpatialReferenceBuilder constructors need to run on the MCT.
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
{
// do something with the builder
sr3857 = srBuilder.ToSpatialReference();
}
});
}
{
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
}
{
// Use a builder convenience method or use a builder constructor.
// Create a 2D point without a spatial reference
MapPoint point2D = MapPointBuilderEx.CreateMapPoint(1, 2);
SpatialReference sr = point2D.SpatialReference; // sr = null
bool hasZ = point2D.HasZ; // hasZ = false
bool hasM = point2D.HasM; // hasM = false
bool hasID = point2D.HasID; // hasID = false
double x = point2D.X; // x = 1
double y = point2D.Y; // y = 2
double z = point2D.Z; // z = 0 default value
double m = point2D.M; // m is NaN default value
double id = point2D.ID; // id = 0 default value
// Or use a builderEx which doesn't need to run on the MCT.
MapPointBuilderEx builderEx = new MapPointBuilderEx(1, 2);
// do something with the builder
builderEx.Y = 3;
point2D = builderEx.ToGeometry();
sr = point2D.SpatialReference; // sr = null
hasZ = point2D.HasZ; // hasZ = false
hasM = point2D.HasM; // hasM = false
hasID = point2D.HasID; // hasID = false
x = point2D.X; // x = 1
y = point2D.Y; // y = 3
z = point2D.Z; // z = 0 default value
m = point2D.M; // m is NaN default value
id = point2D.ID; // id = 0 default value
// Create a 2D point with a spatial reference
SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(4269);
point2D = MapPointBuilderEx.CreateMapPoint(1, 2, spatialReference);
sr = point2D.SpatialReference; // sr != null
int wkid = sr.Wkid; // wkid = 4269
// Or use a builder
builderEx = new MapPointBuilderEx(1, 2, spatialReference);
// Do something with the builder
builderEx.SetValues(3, 5);
point2D = builderEx.ToGeometry();
sr = point2D.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 4269
x = point2D.X; // x = 3
y = point2D.Y; // y = 5
// Change the spatial reference of the builder
builderEx.SpatialReference = SpatialReferences.WGS84;
point2D = builderEx.ToGeometry();
sr = point2D.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 4326
x = point2D.X; // x = 3
y = point2D.Y; // y = 5
// Create a 3D point with M
MapPoint pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4);
sr = pointZM.SpatialReference; // sr = null
hasZ = pointZM.HasZ; // hasZ = true
hasM = pointZM.HasM; // hasM = true
hasID = pointZM.HasID; // hasID = false
x = pointZM.X; // x = 1
y = pointZM.Y; // y = 2
z = pointZM.Z; // z = 3
m = pointZM.M; // m = 4
id = pointZM.ID; // id = 0 default value
// Create a 3D point with M and a spatial reference
pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, spatialReference);
sr = pointZM.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 4269
// Create a point from another point in three ways
MapPoint clone = pointZM.Clone() as MapPoint; // Has the same values including the spatial reference as pointZM
MapPoint anotherZM = MapPointBuilderEx.CreateMapPoint(pointZM); // Has the same values including the spatial reference as pointZM
builderEx = new MapPointBuilderEx(pointZM); // Has the same values including the spatial reference as pointZM
// Do something with the builder
builderEx.HasM = false;
builderEx.ID = 7; // Setting the id also sets HasID = true
MapPoint pointZId = builderEx.ToGeometry();
sr = pointZId.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 4269
hasZ = pointZId.HasZ; // hasZ = true
hasM = pointZId.HasM; // hasM = false
hasID = pointZId.HasID; // hasID = true
x = pointZId.X; // x = 1
y = pointZId.Y; // y = 2
z = pointZId.Z; // z = 3
m = pointZId.M; // m is NaN, default value
id = pointZId.ID; // id = 7
// Create a point with Z, M, and ID-values
MapPoint pointZMId = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 5, spatialReference);
sr = pointZMId.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 4269
hasZ = pointZMId.HasZ; // hasZ = true
hasM = pointZMId.HasM; // hasM = true
hasID = pointZMId.HasID; // hasID = true
x = pointZMId.X; // x = 1
y = pointZMId.Y; // y = 2
z = pointZMId.Z; // z = 3
m = pointZMId.M; // m = 4
id = pointZMId.ID; // id = 5
// Pick and choose which attributes to include
MapPoint point = MapPointBuilderEx.CreateMapPoint(1, 2, false, 3, true, 4, true, 5);
sr = point.SpatialReference; // sr = null
hasZ = point.HasZ; // hasZ = false
hasM = point.HasM; // hasM = true
hasID = point.HasID; // hasID = true
x = point.X; // x = 1
y = point.Y; // y = 2
z = point.Z; // z = 0, default value
m = point.M; // m = 4
id = point.ID; // id = 5
// Or use a builder
builderEx = new(1, 2, true, 3, false, 4, true, 5);
// Do something with the builder
builderEx.ID = 7;
builderEx.SpatialReference = SpatialReferences.WGS84;
point = builderEx.ToGeometry();
sr = point.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 4326
hasZ = point.HasZ; // hasZ = true
hasM = point.HasM; // hasM = false
hasID = point.HasID; // hasID = true
x = point.X; // x = 1
y = point.Y; // y = 2
z = point.Z; // z = 0, default value
m = point.M; // m is NaN, default value
id = point.ID; // id = 7
}
{
// MapPointBuilderEx constructors can run on any thread.
MapPoint point1 = null;
MapPoint point2 = null;
SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(54004);
MapPointBuilderEx mapPointBuilder = new MapPointBuilderEx(100, 200, spatialReference);
SpatialReference sr = mapPointBuilder.SpatialReference; // sr != null
int wkid = sr.Wkid; // wkid = 54004
bool hasZ = mapPointBuilder.HasZ; // hasZ = false
bool hasM = mapPointBuilder.HasM; // hasM = false
bool hasID = mapPointBuilder.HasID; // hasID = false
bool isEmpty = mapPointBuilder.IsEmpty; // isEmpty = false
double x = mapPointBuilder.X; // x = 100
double y = mapPointBuilder.Y; // y = 200
double z = mapPointBuilder.Z; // z = 0, default value
double m = mapPointBuilder.M; // m is NaN, default value
double id = mapPointBuilder.ID; // id = 0, default value
// Do something with the builder
mapPointBuilder.Z = 12; // Setting the z-value automatically sets HasZ property to true
point1 = mapPointBuilder.ToGeometry();
sr = point1.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 54004
hasZ = point1.HasZ; // hasZ = true
hasM = point1.HasM; // hasM = false
hasID = point1.HasID; // hasID = false
x = point1.X; // x = 100
y = point1.Y; // y = 200
z = point1.Z; // z = 12
m = point1.M; // m is NaN, default value
id = point1.ID; // id = 0, default value
// Change some of the builder properties
mapPointBuilder.SetValues(11, 22);
mapPointBuilder.HasZ = false;
mapPointBuilder.HasM = true;
mapPointBuilder.M = 44;
// Create another point
point2 = mapPointBuilder.ToGeometry();
bool isEqual = point1.IsEqual(point2); // isEqual = false
// Set the builder to empty
// Sets X and Y to NaN. Sets other attributes to the default values.
// Does not change the attribute awareness.
mapPointBuilder.SetEmpty();
MapPoint point3 = mapPointBuilder.ToGeometry();
sr = point3.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 54004
hasZ = point3.HasZ; // hasZ = false
hasM = point3.HasM; // hasM = true
hasID = point3.HasID; // hasID = false
isEmpty = point3.IsEmpty; // isEmpty = true
x = point3.X; // x is NaN
y = point3.Y; // y is NaN
z = point3.Z; // z = 0, default value
m = point3.M; // m is NaN, default value
id = point3.ID; // ID = 0, default value
// Create a builder from a point
mapPointBuilder = new MapPointBuilderEx(point2); // point1 = (11, 22, 0, 44, 0)
sr = mapPointBuilder.SpatialReference; // sr != null
wkid = sr.Wkid; // wkid = 54004
hasZ = mapPointBuilder.HasZ; // hasZ = false
hasM = mapPointBuilder.HasM; // hasM = true
hasID = mapPointBuilder.HasID; // hasID = false
isEmpty = mapPointBuilder.IsEmpty; // isEmpty = false
x = mapPointBuilder.X; // x = 11
y = mapPointBuilder.Y; // y = 22
z = mapPointBuilder.Z; // z = 0, default value
m = mapPointBuilder.M; // m = 44
id = mapPointBuilder.ID; // ID = 0, default value
// Setting attribute values automatically sets the corresponding flag to true
mapPointBuilder.Z = 150;
mapPointBuilder.ID = 2;
// Remove the spatial reference
mapPointBuilder.SpatialReference = null;
MapPoint point4 = mapPointBuilder.ToGeometry() as MapPoint;
sr = point3.SpatialReference; // sr = null
hasZ = point3.HasZ; // hasZ = true
hasM = point3.HasM; // hasM = true
hasID = point3.HasID; // hasID = true
isEmpty = point3.IsEmpty; // isEmpty = false
x = point3.X; // x = 11
y = point3.Y; // y = 22
z = point3.Z; // z = 150
m = point3.M; // m = 44
id = point3.ID; // ID = 2
}
{
double x = -122.45;
double y = 37.75;
double buffer_size = 0.1;
//Create a point
var pt = MapPointBuilderEx.CreateMapPoint(x, y,
SpatialReferenceBuilder.CreateSpatialReference(4326));
//Buffer it - for purpose of zoom
var poly = GeometryEngine.Instance.Buffer(pt, buffer_size);
//do we need to project the buffer polygon?
if (!MapView.Active.Map.SpatialReference.IsEqual(poly.SpatialReference))
{
//project the polygon
poly = GeometryEngine.Instance.Project(poly, MapView.Active.Map.SpatialReference);
}
// Must run on MCT.
var zoomMapView = MapView.Active;
if (zoomMapView == null)
return;
await QueuedTask.Run(() =>
{
//Zoom - add in a delay for animation effect
zoomMapView.ZoomTo(poly, new TimeSpan(0, 0, 0, 3));
});
}
{
// methods need to be on the MCT
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr4267 = SpatialReferenceBuilder.CreateSpatialReference(4267);
SpatialReference sr4326 = SpatialReferences.WGS84;
SpatialReference sr3857 = SpatialReferences.WebMercator;
// Create transformation from 4267 -> 3857
ProjectionTransformation projTransFromSRs =
ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr4267, sr3857);
// create an envelope
Envelope env = EnvelopeBuilderEx.CreateEnvelope(
new Coordinate2D(2, 2), new Coordinate2D(3, 3), sr4267);
// Project with one geo transform 4267 -> 3857
Envelope projectedEnvEx = GeometryEngine.Instance.ProjectEx(
env, projTransFromSRs) as Envelope;
// Create inverse transformation, 3857 -> 4267
ProjectionTransformation projTransFromSRsInverse =
ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr3857, sr4267);
// Project the projected envelope back using the inverse transformation
Envelope projectedEnvBack =
GeometryEngine.Instance.ProjectEx(
projectedEnvEx, projTransFromSRsInverse) as Envelope;
bool isEqual = env.IsEqual(projectedEnvBack);
});
}
{
// methods need to run on the MCT
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
//
// find the first transformation used between spatial references 4267 and 4326
//
SpatialReference sr4267 =
SpatialReferenceBuilder.CreateSpatialReference(4267);
SpatialReference sr4326 = SpatialReferences.WGS84;
List<ProjectionTransformation> transformations =
ProjectionTransformation.FindTransformations(sr4267, sr4326);
// transformations.Count = 1
ProjectionTransformation projTrans = transformations[0];
CompositeGeographicTransformation compositeGT =
projTrans.Transformation as CompositeGeographicTransformation;
GeographicTransformation gt = compositeGT[0];
// gt.Wkid = 15851
// gt.Name = "NAD_1927_To_WGS_1984_79_CONUS"
// gt.IsForward = true
//
// find the first five transformation used between spatial references 4267 and 4326
//
transformations = ProjectionTransformation.FindTransformations(
sr4267, sr4326, numResults: 5);
// transformations.Count = 5
projTrans = transformations[0];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 1
// compositeGT[0].Wkid = 15851
// compositeGT[0].Name = "NAD_1927_To_WGS_1984_79_CONUS"
// compositeGT[0].IsForward = true
projTrans = transformations[1];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 1
// compositeGT[0].Wkid = 1173
// compositeGT[0].Name = "NAD_1927_To_WGS_1984_4"
// compositeGT[0].IsForward = true
projTrans = transformations[2];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 1
// compositeGT[0].Wkid = 1172
// compositeGT[0].Name = "NAD_1927_To_WGS_1984_3"
// compositeGT[0].IsForward = true
projTrans = transformations[3];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 2
// compositeGT[0].Wkid = 1241
// compositeGT[0].Name = "NAD_1927_To_NAD_1983_NADCON"
// compositeGT[0].IsForward = true
// compositeGT[1].Wkid = 108190
// compositeGT[1].Name = "WGS_1984_(ITRF00)_To_NAD_1983"
// compositeGT[1].IsForward = false
projTrans = transformations[4];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 2
// compositeGT[0].Wkid = 1241
// compositeGT[0].Name = "NAD_1927_To_NAD_1983_NADCON"
// compositeGT[0].IsForward = true
// compositeGT[1].Wkid = 1515
// compositeGT[1].Name = "NAD_1983_To_WGS_1984_5"
// compositeGT[1].IsForward = true
//
// find the first transformation used between spatial
// references 4267 and 4326 within Alaska
//
// Alaska
Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(-161, 61, -145, 69);
transformations = ProjectionTransformation.FindTransformations(
sr4267, sr4326, envelope);
// transformations.Count = 1
projTrans = transformations[0];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 2
// compositeGT[0].Wkid = 1243
// compositeGT[0].Name = "NAD_1927_To_NAD_1983_Alaska"
// compositeGT[0].IsForward = true
// compositeGT[1].Wkid = 108190
// compositeGT[1].Name = "WGS_1984_(ITRF00)_To_NAD_1983"
// compositeGT[1].IsForward = false
//
// find the first geographic transformation used between two spatial references with VCS (use vertical = false)
//
SpatialReference inSR =
SpatialReferenceBuilder.CreateSpatialReference(4269, 115702);
SpatialReference outSR =
SpatialReferenceBuilder.CreateSpatialReference(4326, 3855);
// Even though each spatial reference has a VCS,
// vertical = false should return geographic transformations.
transformations = ProjectionTransformation.FindTransformations(inSR, outSR);
// transformations.Count = 1
projTrans = transformations[0];
compositeGT = projTrans.Transformation as CompositeGeographicTransformation;
// compositeGT.Count = 1
// compositeGT[0].Wkid = 108190
// compositeGT[0].Name = ""WGS_1984_(ITRF00)_To_NAD_1983"
// compositeGT[0].IsForward = false
//
// find the first vertical transformation used between two spatial references with VCS (use vertical = true)
//
transformations =
ProjectionTransformation.FindTransformations(
inSR, outSR, vertical: true);
// transformations.Count = 1
projTrans = transformations[0];
CompositeHVDatumTransformation compositeHV =
projTrans.Transformation as CompositeHVDatumTransformation;
// compositeHV.Count = 2
// compositeHV[0].Wkid = 1188
// compositeHV[0].Name = "NAD_1983_To_WGS_1984_1"
// compositeHV[0].IsForward = true
// compositeHV[1].Wkid = 110019
// compositeHV[1].Name = "WGS_1984_To_WGS_1984_EGM2008_2.5x2.5_Height"
// compositeHV[1].IsForward = true
});
}
{
var sr = SpatialReferenceBuilder.CreateSpatialReference(4326);
var mapPoint = MapPointBuilderEx.CreateMapPoint(15, 60, sr);
// calculate
var polylineGeodetic = GeometryEngine.Instance.ConstructGeodeticLineFromDistance(GeodeticCurveType.Loxodrome, mapPoint, 5000000, 45, null, CurveDensifyMethod.ByLength, 300000);
}
{
var sr = SpatialReferenceBuilder.CreateSpatialReference(4326);
var pt1 = MapPointBuilderEx.CreateMapPoint(60, 180, sr);
var pt2 = MapPointBuilderEx.CreateMapPoint(60, 0, sr);
// densify by length
var gl = GeometryEngine.Instance.ConstructGeodeticLineFromPoints(GeodeticCurveType.Geodesic, pt1, pt2, null, CurveDensifyMethod.ByLength, -3.356);
// densify by deviation
gl = GeometryEngine.Instance.ConstructGeodeticLineFromPoints(GeodeticCurveType.Geodesic, pt1, pt2, null, CurveDensifyMethod.ByDeviation, -0.0026);
}
{
// mitered join and butt caps
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(102010);
List<Coordinate2D> coords =
[
new Coordinate2D(1400,6200),
new Coordinate2D(1600,6300),
new Coordinate2D(1800,6200)
];
polyline = PolylineBuilderEx.CreatePolyline(coords, sr);
polygon = GeometryEngine.Instance.GraphicBuffer(polyline, 50, LineJoinType.Miter, LineCapType.Butt, 10, 0, -1) as Polygon;
// bevelled join and round caps
Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(0, 0, 10000, 10000, SpatialReferences.WebMercator);
Polygon outPolygon = GeometryEngine.Instance.GraphicBuffer(envelope, 1000, LineJoinType.Bevel, LineCapType.Round, 4, 0, 96) as Polygon;
}
{
// create the polygon
List<MapPoint> pts =
[
MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84),
MapPointBuilderEx.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84),
MapPointBuilderEx.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84),
MapPointBuilderEx.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84),
];
polygon = PolygonBuilderEx.CreatePolygon(pts);
// ensure it is simple
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon);
// create the spatial reference to project to
SpatialReference northPole = SpatialReferenceBuilder.CreateSpatialReference(102018); // north pole stereographic
// project
Geometry geometry = GeometryEngine.Instance.Project(polygon, northPole);
}
{
List<Coordinate2D> polygon1Coords =
[
new Coordinate2D(0, -11000),
new Coordinate2D(1000, -11000),
new Coordinate2D(1000, -12000),
new Coordinate2D(0, -12000),
new Coordinate2D(0, -11000)
];
// reshaper coordinates intersect the polygon
List<Coordinate2D> reshaperCoords =
[
new Coordinate2D(1500, -11800),
new Coordinate2D(-2600, -11800)
];
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(102010);
Polygon polygon1 = PolygonBuilderEx.CreatePolygon(polygon1Coords, sr);
Polyline reshaper = PolylineBuilderEx.CreatePolyline(reshaperCoords, sr);
Polygon outPolygon = GeometryEngine.Instance.Reshape(polygon1, reshaper) as Polygon;
// outPolygon.PartCount = 1
ReadOnlySegmentCollection segments = outPolygon.Parts[0];
// segments.Count = 4
// outPolygon.PointCount = 5
string json = GeometryEngine.Instance.ExportToJson(JsonExportFlags.JsonExportSkipCRS, outPolygon);
// json = "{\"rings\":[[[0,-11800],[0,-11000],[1000,-11000],[1000,-11800],[0,-11800]]]}";
// example where the Reshaper polyline doesn't intersect the input
reshaperCoords.Clear();
reshaperCoords.Add(new Coordinate2D(1000, 1000));
reshaperCoords.Add(new Coordinate2D(2000, 1000));
reshaper = PolylineBuilderEx.CreatePolyline(reshaperCoords, sr);
outPolygon = GeometryEngine.Instance.Reshape(polygon1, reshaper) as Polygon;
// outPolygon = null
}
{
// right side, round caps
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(102010);
List<Coordinate2D> coords =
[
new Coordinate2D(1200, 5800),
new Coordinate2D(1400, 5800),
new Coordinate2D(1400, 6000),
new Coordinate2D(1300, 6000),
new Coordinate2D(1300, 5700)
];
polyline = PolylineBuilderEx.CreatePolyline(coords, sr);
Polygon output = GeometryEngine.Instance.SideBuffer(polyline, 20, LeftOrRightSide.RightSide, LineCapType.Round) as Polygon;
}
{
SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(102010);
List<Coordinate2D> coordinates =
[
new Coordinate2D(1200, 5800),
new Coordinate2D(1400, 5800),
new Coordinate2D(1400, 6000),
new Coordinate2D(1300, 6000),
new Coordinate2D(1300, 5700)
];
Polyline polyline1 = PolylineBuilderEx.CreatePolyline(coordinates, spatialReference);
coordinates.Clear();
coordinates.Add(new Coordinate2D(1400, 6050));
coordinates.Add(new Coordinate2D(1600, 6150));
coordinates.Add(new Coordinate2D(1800, 6050));
Polyline polyline2 = PolylineBuilderEx.CreatePolyline(coordinates, spatialReference);
List<Polyline> polylines = [polyline1, polyline2];
IReadOnlyList<Geometry> outGeometries = GeometryEngine.Instance.SideBuffer(polylines, 10, LeftOrRightSide.RightSide, LineCapType.Round);
}
{
// Not all of the input points are transformed as some of them are outside of the GCS horizon.
Coordinate2D[] inCoords2D =
[
new Coordinate2D(-1, -1),
new Coordinate2D(-2, -5),
new Coordinate2D(-5, -11),
new Coordinate2D(-10, -19),
new Coordinate2D(-17, -29),
new Coordinate2D(-26, -41),
new Coordinate2D(-37, -5),
new Coordinate2D(-50, -21),
new Coordinate2D(-65, -39),
new Coordinate2D(-82, -9)
];
int arraySize = inCoords2D.Length;
ProjectionTransformation projTrans = ProjectionTransformation.Create(SpatialReferences.WGS84, SpatialReferenceBuilder.CreateSpatialReference(24891));
Coordinate2D[] outCoords2D = new Coordinate2D[arraySize];
// transform and choose to remove the clipped coordinates
int numPointsTransformed = GeometryEngine.Instance.Transform2D(inCoords2D, projTrans, ref outCoords2D, true);
// numPointsTransformed = 4
// outCoords2D.Length = 4
// outCoords2D[0] = {5580417.6876455201, 1328841.2376554986}
// outCoords2D[1] = {3508774.290814558, -568027.23444226268}
// outCoords2D[2] = {1568096.0886155984, -2343435.4394415971}
// outCoords2D[3] = {57325.827391741652, 1095146.8917508761}
// transform and don't remove the clipped coordinates
numPointsTransformed = GeometryEngine.Instance.Transform2D(inCoords2D, projTrans, ref outCoords2D, false);
// numPointsTransformed = 4
// outCoords2D.Length = 10
// outCoords2D[0] = {double.Nan, double.Nan}
// outCoords2D[1] = {double.Nan, double.Nan}
// outCoords2D[2] = {double.Nan, double.Nan}
// outCoords2D[3] = {double.Nan, double.Nan}
// outCoords2D[4] = {double.Nan, double.Nan}
// outCoords2D[5] = {double.Nan, double.Nan}
// outCoords2D[6] = {5580417.6876455201, 1328841.2376554986}
// outCoords2D[7] = {3508774.290814558, -568027.23444226268}
// outCoords2D[8] = {1568096.0886155984, -2343435.4394415971}
// outCoords2D[9] = {57325.827391741652, 1095146.8917508761}
}
{
// Not all of the input points are transformed as some of them are outside of the GCS horizon.
Coordinate3D[] inCoords3D =
[
new Coordinate3D(-1, -1, 0),
new Coordinate3D(-2, -5, 1),
new Coordinate3D(-5, -11, 2),
new Coordinate3D(-10, -19, 3),
new Coordinate3D(-17, -29, 4),
new Coordinate3D(-26, -41, 5),
new Coordinate3D(-37, -5, 6),
new Coordinate3D(-50, -21, 7),
new Coordinate3D(-65, -39, 8),
new Coordinate3D(-82, -9, 9)
];
int arraySize = inCoords3D.Length;
ProjectionTransformation projTrans = ProjectionTransformation.Create(SpatialReferences.WGS84, SpatialReferenceBuilder.CreateSpatialReference(24891));
Coordinate3D[] outCoords3D = new Coordinate3D[arraySize];
// transform and choose to remove the clipped coordinates
int numPointsTransformed = GeometryEngine.Instance.Transform3D(inCoords3D, projTrans, ref outCoords3D);
// numPointsTransformed = 4
// outCoords2D.Length = 4
// outCoords2D[0] = {5580417.6876455201, 1328841.2376554986, 7}
// outCoords2D[1] = {3508774.290814558, -568027.23444226268, 8}
// outCoords2D[2] = {1568096.0886155984, -2343435.4394415971, 9}
// outCoords2D[3] = {57325.827391741652, 1095146.8917508761, 10}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)