-
Notifications
You must be signed in to change notification settings - Fork 121
ProSnippets Geometry
arcgisprosdk edited this page Jan 16, 2018
·
23 revisions
Language: C#
Subject: Geometry
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: esri, http://www.esri.com
Date: 12/22/2017
ArcGIS Pro: 2.1
Visual Studio: 2015, 2017
.NET Target Framework: 4.6.1
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// use the builder constructor
SpatialReference sr3857 = null;
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
sr3857 = srBuilder.ToSpatialReference();
// or use the convenience method
SpatialReference sr_3857 = SpatialReferenceBuilder.CreateSpatialReference(3857);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
string wkt = "GEOGCS[\"MyGCS84\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Radian\",1.0]]";
// use the builder constructor
using (SpatialReferenceBuilder builder = new SpatialReferenceBuilder(wkt))
{
SpatialReference sr = builder.ToSpatialReference();
}
// or use the convenience method
SpatialReference anotherSR = SpatialReferenceBuilder.CreateSpatialReference(wkt);
});
SpatialReference wgs84 = SpatialReferences.WGS84;
bool isProjected = wgs84.IsProjected; // false
bool isGeographic = wgs84.IsGeographic; // true
// see a list of vertical coordinate systems at http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Vertical_coordinate_systems/02r3000000rn000000/
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// use the builder constructor
// 4326 = GCS_WGS_1984
// 115700 = vertical WGS_1984
using (SpatialReferenceBuilder sb = new SpatialReferenceBuilder(4326, 115700))
{
SpatialReference sr = sb.ToSpatialReference();
// spatialReferenceBuilder properties
int wkid = sb.Wkid;
string wkt = sb.Wkt;
string name = sb.Name;
int vcsWkid = sb.VcsWkid;
string vcsWkt = sb.VcsWkt;
}
// or use the convenience method
SpatialReference sr_4326 = SpatialReferenceBuilder.CreateSpatialReference(4326, 115700);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// custom VCS - use vertical shift of -1.23 instead of 0
string custom_vWkt = @"VERTCS[""SHD_height"",VDATUM[""Singapore_Height_Datum""],PARAMETER[""Vertical_Shift"",-1.23],PARAMETER[""Direction"",-1.0],UNIT[""Meter"",1.0]]";
using (SpatialReferenceBuilder sb = new SpatialReferenceBuilder(4326, custom_vWkt))
{
SpatialReference sr = sb.ToSpatialReference();
int wkid = sr.Wkid; // wkid = 4326
int vert_wkid = sr.VcsWkid; // vert_wkid = 0
string vert_wkt = sr.VcsWkt; // vert_wkt = custom_vWkt
bool hasVcs = sr.HasVcs;
}
// or use the convenience method
SpatialReference sr_4326 = SpatialReferenceBuilder.CreateSpatialReference(4326, custom_vWkt);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// use the builder constructor
using (SpatialReferenceBuilder srBuilder = new SpatialReferenceBuilder(3857))
{
// spatialReferenceBuilder properties
int wkid = srBuilder.Wkid;
string wkt = srBuilder.Wkt;
string name = srBuilder.Name;
double xyScale = srBuilder.XYScale;
double xyTolerance = srBuilder.XYTolerance;
double xyResolution = srBuilder.XYResolution;
Unit unit = srBuilder.Unit;
double zScale = srBuilder.ZScale;
double zTolerance = srBuilder.ZTolerance;
Unit zUnit = srBuilder.ZUnit;
double mScale = srBuilder.MScale;
double mTolerance = srBuilder.MTolerance;
double falseX = srBuilder.FalseX;
double falseY = srBuilder.FalseY;
double falseZ = srBuilder.FalseZ;
double falseM = srBuilder.FalseM;
// get the spatial reference
SpatialReference sr3857 = srBuilder.ToSpatialReference();
// spatial reference properties
wkid = sr3857.Wkid;
wkt = sr3857.Wkt;
name = sr3857.Name;
xyScale = sr3857.XYScale;
xyTolerance = sr3857.XYTolerance;
xyResolution = sr3857.XYResolution;
unit = sr3857.Unit;
zScale = sr3857.ZScale;
zTolerance = sr3857.ZTolerance;
zUnit = sr3857.ZUnit;
mScale = sr3857.MScale;
mTolerance = sr3857.MTolerance;
falseX = sr3857.FalseX;
falseY = sr3857.FalseY;
falseZ = sr3857.FalseZ;
falseM = sr3857.FalseM;
bool hasVcs = sr3857.HasVcs;
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReferenceBuilder sb = new SpatialReferenceBuilder(4326, 6916);
SpatialReference sr = sb.ToSpatialReference();
string xml = sr.ToXML();
SpatialReference importedSR = SpatialReferenceBuilder.FromXML(xml);
// importedSR.Wkid = 4326
// importedSR.VcsWkid = 6916
string json = sr.ToJson();
importedSR = SpatialReferenceBuilder.FromJson(json);
// importedSR.Wkid = 4326
// importedSR.VcsWkid = 6916
});
Coordinate3D polarVector = new Coordinate3D(0, 7, 0);
Tuple<double, double, double> polarComponents = polarVector.QueryPolarComponents();
// polarComponents.Item1 = 0 (azimuth)
// polarComponents.Item2 = 0 (inclination)
// polarComponents.Item3 = 7 (magnitude)
polarVector.SetPolarComponents(Math.PI / 4, Math.PI / 2, 8);
polarComponents = polarVector.QueryComponents();
// polarComponents.Item1 = 0 (x)
// polarComponents.Item2 = 0 (y)
// polarComponents.Item3 = 7 (z)
Coordinate3D v = new Coordinate3D(0, 0, 7);
double inclination = v.Inclination; // inclination = PI/2
v.SetComponents(-2, -3, 0);
inclination = v.Inclination; // inclination = 0
v.SetComponents(0, 0, -2);
inclination = v.Inclination; // inclination = -PI/2
Coordinate3D vector = new Coordinate3D(0, 7, 0);
double azimuth = vector.Azimuth; // azimuth = 0
vector.SetComponents(1, 1, 42);
azimuth = vector.Azimuth;
double degrees = AngularUnit.Degrees.ConvertFromRadians(azimuth); // degrees = 45
vector.SetComponents(-8, 8, 2);
azimuth = vector.Azimuth;
degrees = AngularUnit.Degrees.ConvertFromRadians(azimuth); // degrees = 315
// Easy 3D vectors
Coordinate3D v = new Coordinate3D(0, 1, 0);
// v.Magnitude = 1
Coordinate3D other = new Coordinate3D(-1, 0, 0);
// other.Magnitude = -1
double dotProduct = v.DotProduct(other); // dotProduct = 0
Coordinate3D crossProduct = v.CrossProduct(other);
// crossProduct.X = 0
// crossProduct.Y = 0
// crossProduct.Z = 1
Coordinate3D addVector = v.AddCoordinate3D(other);
// addVector.X = -1
// addVector.Y = 1
// addVector.Z = 0
// Rotate around x-axis
Coordinate3D w = v;
w.Rotate(Math.PI, other);
// w.X = 0
// w.Y = -1
// w.Z = 0
w.Scale(0.5);
// w.X = 0
// w.Y = -0.5
// w.Z = 0
w.Scale(-4);
// w.X = 0
// ww.Y = 2
// w.Z = 0
// w.Magnitude = 2
w.Move(3, 2, 0);
// w.X = 3
// w.Y = 4
// w.Z = 0
// w.Magnitude = 5
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// list of points
List<MapPoint> points = new List<MapPoint>
{
MapPointBuilder.CreateMapPoint(0, 0, 2, 3, 1),
MapPointBuilder.CreateMapPoint(1, 1, 5, 6),
MapPointBuilder.CreateMapPoint(2, 1, 6),
MapPointBuilder.CreateMapPoint(0, 0)
};
// will have attributes because it is created with convenience method
Polyline polylineWithAttrs = PolylineBuilder.CreatePolyline(points);
bool hasZ = polylineWithAttrs.HasZ; // hasZ = true
bool hasM = polylineWithAttrs.HasM; // hasM = true
bool hasID = polylineWithAttrs.HasID; // hasID = true
// will not have attributes because it is passed something other than an attributed polyline
using (PolylineBuilder polylineB = new PolylineBuilder(points))
{
hasZ = polylineB.HasZ; // hasZ = false
hasM = polylineB.HasM; // hasM = false
hasID = polylineB.HasID; // hasID = false
}
// will have attributes because it is passed an attributed polyline
using (PolylineBuilder polylineB = new PolylineBuilder(polylineWithAttrs))
{
hasZ = polylineB.HasZ; // hasZ = true
hasM = polylineB.HasM; // hasM = true
hasID = polylineB.HasID; // hasID = true
}
// will have attributes because it is created with convenience method
Polygon polygonWithAttrs = PolygonBuilder.CreatePolygon(points);
hasZ = polygonWithAttrs.HasZ; // hasZ = true
hasM = polygonWithAttrs.HasM; // hasM = true
hasID = polygonWithAttrs.HasID; // hasID = true
// will not have attributes because it is passed something other than an attributed polygon
using (PolygonBuilder polygonB = new PolygonBuilder(points))
{
hasZ = polygonB.HasZ; // hasZ = false
hasM = polygonB.HasM; // hasM = false
hasID = polygonB.HasID; // hasID = false
}
// will have attributes because it is passed an attributed polygon
using (PolygonBuilder polygonB = new PolygonBuilder(polygonWithAttrs))
{
hasZ = polygonB.HasZ; // hasZ = true
hasM = polygonB.HasM; // hasM = true
hasID = polygonB.HasID; // hasID = true
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a 3d point with M
// use the builder constructor
using (MapPointBuilder mb = new MapPointBuilder(1.0, 2.0, 3.0, 4.0))
{
MapPoint ptWithM = mb.ToGeometry();
MapPoint clone = ptWithM.Clone() as MapPoint;
// or use the convenience methods
MapPoint anotherPt = MapPointBuilder.CreateMapPoint(1.0, 2.0, 3.0, 4.0);
MapPoint anotherM = MapPointBuilder.CreateMapPoint(ptWithM);
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
using (MapPointBuilder mb = new MapPointBuilder(1.0, 2.0, 3.0))
{
bool hasZ = mb.HasZ; // hasZ = true
bool hasM = mb.HasM; // hasM = false
bool hasID = mb.HasID; // hasID = false
MapPoint pt = mb.ToGeometry();
double x = pt.X; // x = 1.0
double y = pt.Y; // y = 2.0
double z = pt.Z; // z = 3.0
double m = pt.M; // m = Nan
int ID = pt.ID; // ID = 0
hasZ = pt.HasZ; // hasZ = true
hasM = pt.HasM; // hasM = false
hasID = pt.HasID; // hasID = false
bool isEmpty = pt.IsEmpty; // isEmpty = false
MapPoint pt2 = MapPointBuilder.CreateMapPoint(pt);
x = pt.X; // x = 1.0
y = pt.Y; // y = 2.0
z = pt.Z; // z = 3.0
m = pt.M; // m = Nan
hasZ = pt2.HasZ; // hasZ = true
hasM = pt2.HasM; // hasM = false
hasID = pt2.HasID; // hasID = false
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, 5);
int ID = pt.ID; // ID = 5
bool hasID = pt.HasID; // hasID = true
MapPoint pt2 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, 0);
ID = pt2.ID; // ID = 0
hasID = pt2.HasID; // hasID = true
MapPoint pt3 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4);
ID = pt3.ID; // ID = 0
hasID = pt3.HasID; // hasID = false
MapPoint pt4 = MapPointBuilder.CreateMapPoint(1, 2, 3, 44);
ID = pt4.ID; // ID = 0
hasID = pt4.HasID; // hasID = false
bool hasM = pt4.HasM; // hasM = true
MapPoint pt5 = MapPointBuilder.CreateMapPoint(1, 2, 3);
ID = pt5.ID; // ID = 0
hasID = pt5.HasID; // hasID = false
hasM = pt5.HasM; // hasM = false
bool isEqual = pt.IsEqual(pt2); // isEqual = false // different IDs
isEqual = pt2.IsEqual(pt3); // isEqual = false // HasId is different
isEqual = pt4.IsEqual(pt3); // isEqual = false // different Ms
isEqual = pt.IsEqual(pt5); // isEqual = false // pt has M, id but pt5 does not.
});
// methods need to run on MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);
// use the builder constructor
using (PolylineBuilder pb = new PolylineBuilder(list))
{
pb.SpatialReference = SpatialReferences.WGS84;
Polyline polyline1 = pb.ToGeometry();
}
// or use the convenience method
Polyline polyline2 = PolylineBuilder.CreatePolyline(list, SpatialReferences.WGS84);
});
// get the points as a readonly Collection
ReadOnlyPointCollection pts = polyline.Points;
int numPts = polyline.PointCount;
// get an enumeration of the points
IEnumerator<MapPoint> enumPts = polyline.Points.GetEnumerator();
// get the point coordinates as a readonly list of Coordinate2D
IReadOnlyList<Coordinate2D> coordinates = polyline.Copy2DCoordinatesToList();
// get the point coordinates as a readonly list of Coordinate3D
IReadOnlyList<Coordinate3D> coordinates3D = polyline.Copy3DCoordinatesToList();
int numParts = polyline.PartCount;
// get the parts as a readonly collection
ReadOnlyPartCollection parts = polyline.Parts;
ReadOnlyPartCollection polylineParts = polyline.Parts;
// enumerate the segments to get the length
double len = 0;
IEnumerator<ReadOnlySegmentCollection> segments = polylineParts.GetEnumerator();
while (segments.MoveNext())
{
ReadOnlySegmentCollection seg = segments.Current;
foreach (Segment s in seg)
{
len += s.Length;
// perhaps do something specific per segment type
switch (s.SegmentType)
{
case SegmentType.Line:
break;
case SegmentType.Bezier:
break;
case SegmentType.EllipticArc:
break;
}
}
}
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
using (PolylineBuilder polylineBuilder = new PolylineBuilder(polyline))
{
polylineBuilder.ReverseOrientation();
Polyline reversedPolyline = polylineBuilder.ToGeometry();
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> firstPoints = new List<MapPoint>();
firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
List<MapPoint> nextPoints = new List<MapPoint>();
nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 1.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 2.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 2.0));
nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 1.0));
using (PolylineBuilder pBuilder = new PolylineBuilder(firstPoints))
{
pBuilder.AddPart(nextPoints);
Polyline p = pBuilder.ToGeometry();
// polyline p has 2 parts
pBuilder.RemovePart(0);
p = pBuilder.ToGeometry();
// polyline p has 1 part
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create list of points
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(startPt);
list.Add(endPt);
// use the PolylineBuilder as we wish to manipulate the geometry
using (PolylineBuilder polylineBuilder = new PolylineBuilder(list))
{
// split at a distance 0.75
polylineBuilder.SplitAtDistance(0.75, false);
// get the polyline
Polyline p = polylineBuilder.ToGeometry();
// polyline p should have 3 points (1,1), (1.75, 1), (2,1)
// add another path
MapPoint p1 = MapPointBuilder.CreateMapPoint(4.0, 1.0);
MapPoint p2 = MapPointBuilder.CreateMapPoint(6.0, 1.0);
MapPoint p3 = MapPointBuilder.CreateMapPoint(7.0, 1.0);
List<MapPoint> pts = new List<MapPoint>();
pts.Add(p1);
pts.Add(p2);
pts.Add(p3);
polylineBuilder.AddPart(pts);
p = polylineBuilder.ToGeometry();
// polyline p has 2 parts. Each part has 3 points
// split the 2nd path half way - dont create a new path
polylineBuilder.SplitPartAtDistance(1, 0.5, true, false);
p = polylineBuilder.ToGeometry();
// polyline p still has 2 parts; but now has 7 points
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(1.0, 2.0);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(2.0, 2.0);
MapPoint pt4 = MapPointBuilder.CreateMapPoint(2.0, 1.0);
List<MapPoint> list = new List<MapPoint>();
list.Add(pt1);
list.Add(pt2);
list.Add(pt3);
list.Add(pt4);
// use the builder constructor
using (PolygonBuilder pb = new PolygonBuilder(list))
{
pb.SpatialReference = SpatialReferences.WGS84;
Polygon polygon = pb.ToGeometry();
}
// or use the convenience method
Polygon anotherPolygon = PolygonBuilder.CreatePolygon(list, SpatialReferences.WGS84);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0);
// Create an envelope
Envelope env = EnvelopeBuilder.CreateEnvelope(minPt, maxPt);
// Create a polygon from the envelope
Polygon polygon = PolygonBuilder.CreatePolygon(env);
});
// get the points as a readonly Collection
ReadOnlyPointCollection pts = poly.Points;
// get an enumeration of the points
IEnumerator<MapPoint> enumPts = poly.Points.GetEnumerator();
// get the point coordinates as a readonly list of Coordinate3D
IReadOnlyList<Coordinate3D> coordinates = poly.Copy3DCoordinatesToList();
// get the parts as a readonly collection
ReadOnlyPartCollection parts = poly.Parts;
int numSegments = 0;
IEnumerator<ReadOnlySegmentCollection> segments = poly.Parts.GetEnumerator();
while (segments.MoveNext())
{
ReadOnlySegmentCollection seg = segments.Current;
numSegments += seg.Count;
foreach (Segment s in seg)
{
// do something with the segment
}
}
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> outerCoordinates = new List<Coordinate2D>();
outerCoordinates.Add(new Coordinate2D(10.0, 10.0));
outerCoordinates.Add(new Coordinate2D(10.0, 20.0));
outerCoordinates.Add(new Coordinate2D(20.0, 20.0));
outerCoordinates.Add(new Coordinate2D(20.0, 10.0));
// use the PolygonBuilder as we wish to manipulate the parts
using (PolygonBuilder pb = new PolygonBuilder(outerCoordinates))
{
Polygon donut = pb.ToGeometry();
double area = donut.Area; // area = 100
// define the inner polygon as anti-clockwise
List<Coordinate2D> innerCoordinates = new List<Coordinate2D>();
innerCoordinates.Add(new Coordinate2D(13.0, 13.0));
innerCoordinates.Add(new Coordinate2D(17.0, 13.0));
innerCoordinates.Add(new Coordinate2D(17.0, 17.0));
innerCoordinates.Add(new Coordinate2D(13.0, 17.0));
pb.AddPart(innerCoordinates);
donut = pb.ToGeometry();
area = donut.Area; // area = 84.0
area = GeometryEngine.Instance.Area(donut); // area = 84.0
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0);
using (EnvelopeBuilder ev = new EnvelopeBuilder(minPt, maxPt))
{
Envelope env = ev.ToGeometry();
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
string jsonString = "{ \"xmin\" : 1, \"ymin\" : 2,\"xmax\":3,\"ymax\":4,\"spatialReference\":{\"wkid\":4326}}";
Envelope envFromJson = EnvelopeBuilder.FromJson(jsonString);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Envelope env1 = EnvelopeBuilder.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84);
Envelope env2 = EnvelopeBuilder.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84);
Envelope env3 = env1.Union(env2);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Envelope envelope = EnvelopeBuilder.CreateEnvelope(100.0, 100.0, 500.0, 500.0);
// shrink the envelope by 50%
Envelope result = envelope.Expand(0.5, 0.5, true);
// or use the builder
using (EnvelopeBuilder eBuilder = new EnvelopeBuilder(100.0, 100.0, 500.0, 500.0))
{
// shrink by 50%
eBuilder.Expand(0.5, 0.5, true);
result = eBuilder.ToGeometry();
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
list.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
list.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
// use the builder constructor
using (MultipointBuilder mpb = new MultipointBuilder(list))
{
Multipoint mPt = mpb.ToGeometry();
}
// or use the convenience method
Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// assume a multiPoint has been built from 4 points
// the modified multiPoint will have the first point removed and the last point moved
using (MultipointBuilder mpb = new MultipointBuilder(multiPt))
{
// remove the first point
mpb.RemovePoint(0);
// modify the coordinates of the last point
MapPoint pt = mpb.GetMapPoint(mpb.PointCount - 1);
mpb.RemovePoint(mpb.PointCount - 1);
MapPoint newPt = MapPointBuilder.CreateMapPoint(pt.X + 1.0, pt.Y + 2.0);
mpb.Add(newPt);
Multipoint modifiedMultiPoint = mpb.ToGeometry();
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0);
// use the builder constructor
using (LineBuilder lb = new LineBuilder(startPt, endPt))
{
LineSegment line = lb.ToSegment();
}
// or use the convenience method
LineSegment anotherLine = LineBuilder.CreateLineSegment(startPt, endPt);
});
// builders need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, 3.0);
Coordinate2D ctrl1Pt = new Coordinate2D(1.0, 2.0);
Coordinate2D ctrl2Pt = new Coordinate2D(2.0, 1.0);
// use the builder constructor
using (CubicBezierBuilder cbb = new CubicBezierBuilder(startPt, ctrl1Pt, ctrl2Pt, endPt))
{
CubicBezierSegment bezier = cbb.ToSegment();
}
// or use the convenience method
CubicBezierSegment anotherBezier = CubicBezierBuilder.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt, SpatialReferences.WGS84);
});
// builders need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl1Pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl2Pt = MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84);
// use the builder constructor
using (CubicBezierBuilder cbb = new CubicBezierBuilder(startPt, ctrl1Pt, ctrl2Pt, endPt))
{
CubicBezierSegment bezier = cbb.ToSegment();
}
// or use the convenience method
CubicBezierSegment anotherBezier = CubicBezierBuilder.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt);
});
// builders need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl1Pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84);
MapPoint ctrl2Pt = MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84);
List<MapPoint> listMapPoints = new List<MapPoint>();
listMapPoints.Add(startPt);
listMapPoints.Add(ctrl1Pt);
listMapPoints.Add(ctrl2Pt);
listMapPoints.Add(endPt);
// use the builder constructor
using (CubicBezierBuilder cbb = new CubicBezierBuilder(listMapPoints))
{
CubicBezierSegment bezier = cbb.ToSegment();
}
// or use the convenience method
CubicBezierSegment anotherBezier = CubicBezierBuilder.CreateCubicBezierSegment(listMapPoints);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the bezier curve's control points
using (CubicBezierBuilder cbb = new CubicBezierBuilder(bezierSegment))
{
MapPoint startPt = cbb.StartPoint;
Coordinate2D ctrlPt1 = cbb.ControlPoint1;
Coordinate2D ctrlPt2 = cbb.ControlPoint2;
MapPoint endPt = cbb.EndPoint;
// or use the QueryCoords method
cbb.QueryCoords(out startPt, out ctrlPt1, out ctrlPt2, out endPt);
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the bezier curve's control points
CubicBezierSegment cb = CubicBezierBuilder.CreateCubicBezierSegment(bezierSegment);
MapPoint startPt = cb.StartPoint;
Coordinate2D ctrlPt1 = cb.ControlPoint1;
Coordinate2D ctrlPt2 = cb.ControlPoint2;
MapPoint endPt = cb.EndPoint;
bool isCurve = cb.IsCurve;
double len = cb.Length;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Polyline polyline = PolylineBuilder.CreatePolyline(bezierSegment);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circular arc from (2, 1) to (1, 2) with interior pt (1 + sqrt(2)/2, 1 + sqrt(2)/2).
MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1);
MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2);
Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);
// use the builder constructor
using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, toPt, interiorPt))
{
EllipticArcSegment circularArc = cab.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, toPt, interiorPt);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circular arc counterclockwise from (2, 1) to (1, 2) such that the embedded
// circle has center point at (1, 1) and radius = 1
MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1, SpatialReferences.WGS84);
double chordLength = Math.Sqrt(2);
double chordBearing = 3 * Math.PI / 4;
double radius = 1;
esriArcOrientation orientation = esriArcOrientation.esriArcCounterClockwise;
MinorOrMajor minorOrMajor = MinorOrMajor.Minor;
// use the builder constructor
using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor))
{
EllipticArcSegment circularArc = cab.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circular arc with center point at (0, 0), from angle = 0,
// central angle = pi/2, radius = 1
SpatialReference sr4326 = SpatialReferences.WGS84;
Coordinate2D centerPt = new Coordinate2D(0, 0);
double fromAngle = 0;
double centralAngle = Math.PI / 2;
double radius = 1;
// use the builder constructor
using (EllipticArcBuilder cab = new EllipticArcBuilder(fromAngle, centralAngle, centerPt, radius, sr4326))
{
EllipticArcSegment circularArc = cab.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromAngle, centralAngle, centerPt, radius, sr4326);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct an elliptic arc centered at (1,1), startAngle = 0, centralAngle = PI/2,
// rotationAngle = 0, semiMajorAxis = 1, minorMajorRatio = 0.5
Coordinate2D centerPt = new Coordinate2D(1, 1);
// use the builder constructor
using (EllipticArcBuilder cab = new EllipticArcBuilder(centerPt, 0, Math.PI / 2, 0, 1, 0.5))
{
EllipticArcSegment circularArc = cab.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(centerPt, 0, Math.PI / 2, 0, 1, 0.5);
double semiMajor;
double semiMinor;
anotherCircularArc.GetAxes(out semiMajor, out semiMinor);
// semiMajor = 1, semiMinor = 0.5
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circular arc from (2, 1) to (1, 2)
// with center point at (1, 1) and orientation counterclockwise.
MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1);
MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2);
Coordinate2D centerPtCoord = new Coordinate2D(1, 1);
// use the builder constructor
using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, toPt, centerPtCoord, esriArcOrientation.esriArcCounterClockwise))
{
EllipticArcSegment circularArc = cab.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, toPt, centerPtCoord, esriArcOrientation.esriArcCounterClockwise);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a segment from (100, 100) to (50, 50) and another segment from (100, 100) to (150, 50).
LineSegment segment1 = LineBuilder.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(50, 50));
LineSegment segment2 = LineBuilder.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(150, 50));
// Construct the hint point to determine where the arc will be constructed.
Coordinate2D hintPoint = new Coordinate2D(100, 75);
// Call QueryFilletRadius to get the minimum and maximum radii that can be used with these segments.
var minMaxRadii = EllipticArcBuilder.QueryFilletRadiusRange(segment1, segment2, hintPoint);
// Use the maximum radius to create the arc.
double maxRadius = minMaxRadii.Item2;
// use the builder constructor
using (EllipticArcBuilder cab = new EllipticArcBuilder(segment1, segment2, maxRadius, hintPoint))
{
EllipticArcSegment circularArc = cab.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherCircularArc = EllipticArcBuilder.CreateEllipticArcSegment(segment1, segment2, maxRadius, hintPoint);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct a circle with center at (-1,-1), radius = 2, and oriented clockwise.
Coordinate2D centerPtCoord = new Coordinate2D(-1, -1);
// use the builder constructor
using (EllipticArcBuilder builder = new EllipticArcBuilder(centerPtCoord, 2, esriArcOrientation.esriArcClockwise))
{
EllipticArcSegment circle = builder.ToSegment();
// circle.IsCircular = true
// circle.IsCounterClockwise = false
// circle.IsMinor = false
double startAngle, centralAngle, rotationAngle;
double semiMajor, semiMinor;
Coordinate2D actualCenterPt;
circle.QueryCoords(out actualCenterPt, out startAngle, out centralAngle, out rotationAngle, out semiMajor, out semiMinor);
// semiMajor = 2.0
// semiMinor = 2.0
// startAngle = PI/2
// centralAngle = -2*PI
// rotationAngle = 0
// endAngle = PI/2
}
// or use the convenience method
EllipticArcSegment anotherCircle = EllipticArcBuilder.CreateEllipticArcSegment(centerPtCoord, 2, esriArcOrientation.esriArcClockwise);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Construct an ellipse centered at (1, 2) with rotationAngle = -pi/6,
// semiMajorAxis = 5, minorMajorRatio = 0.2, oriented clockwise
Coordinate2D centerPt = new Coordinate2D(1, 2);
// use the builder constructor
using (EllipticArcBuilder builder = new EllipticArcBuilder(centerPt, -1 * Math.PI / 6, 5, 0.2, esriArcOrientation.esriArcClockwise))
{
EllipticArcSegment ellipse = builder.ToSegment();
}
// or use the convenience method
EllipticArcSegment anotherEllipse = EllipticArcBuilder.CreateEllipticArcSegment(centerPt, -1 * Math.PI / 6, 5, 0.2, esriArcOrientation.esriArcClockwise);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the curve's control points
using (EllipticArcBuilder builder = new EllipticArcBuilder(arcSegment))
{
MapPoint startPt = builder.StartPoint;
MapPoint endPt = builder.EndPoint;
Coordinate2D centerPt = builder.CenterPoint;
bool isCircular = builder.IsCircular;
bool isMinor = builder.IsMinor;
double startAngle = builder.StartAngle;
double endAngle = builder.EndAngle;
double centralAngle = builder.CentralAngle;
double rotationAngle = builder.RotationAngle;
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// retrieve the curve's control points
EllipticArcSegment arc = EllipticArcBuilder.CreateEllipticArcSegment(arcSegment);
MapPoint startPt = arc.StartPoint;
MapPoint endPt = arc.EndPoint;
Coordinate2D centerPt = arc.CenterPoint;
bool isCircular = arc.IsCircular;
bool isMinor = arc.IsMinor;
double startAngle, centralAngle, rotationAngle, semiMajorAxis, semiMinorAxis;
// or use QueryCoords
arc.QueryCoords(out centerPt, out startAngle, out centralAngle, out rotationAngle, out semiMajorAxis, out semiMinorAxis);
});
public IEnumerable<Geometry> MultipartToSinglePart(Geometry inputGeometry)
{
// list holding the part(s) of the input geometry
List<Geometry> singleParts = new List<Geometry>();
// check if the input is a null pointer or if the geometry is empty
if (inputGeometry == null || inputGeometry.IsEmpty)
return singleParts;
// based on the type of geometry, take the parts/points and add them individually into a list
switch (inputGeometry.GeometryType)
{
case GeometryType.Envelope:
singleParts.Add(inputGeometry.Clone() as Envelope);
break;
case GeometryType.Multipatch:
singleParts.Add(inputGeometry.Clone() as Multipatch);
break;
case GeometryType.Multipoint:
var multiPoint = inputGeometry as Multipoint;
foreach (var point in multiPoint.Points)
{
// add each point of collection as a standalone point into the list
singleParts.Add(point);
}
break;
case GeometryType.Point:
singleParts.Add(inputGeometry.Clone() as MapPoint);
break;
case GeometryType.Polygon:
var polygon = inputGeometry as Polygon;
foreach (var polygonPart in polygon.Parts)
{
// use the PolygonBuilder turning the segments into a standalone
// polygon instance
singleParts.Add(PolygonBuilder.CreatePolygon(polygonPart));
}
break;
case GeometryType.Polyline:
var polyline = inputGeometry as Polyline;
foreach (var polylinePart in polyline.Parts)
{
// use the PolylineBuilder turning the segments into a standalone
// polyline instance
singleParts.Add(PolylineBuilder.CreatePolyline(polylinePart));
}
break;
case GeometryType.Unknown:
break;
default:
break;
}
return singleParts;
}
public Polygon GetOutermostRings(Polygon inputPolygon)
{
if (inputPolygon == null || inputPolygon.IsEmpty)
return null;
List<Polygon> internalRings = new List<Polygon>();
// explode the parts of the polygon into a list of individual geometries
// see the "Get the individual parts of a multipart feature" snippet for MultipartToSinglePart method defintion
var parts = MultipartToSinglePart(inputPolygon);
// get an enumeration of clockwise geometries (area > 0) ordered by the area
var clockwiseParts = parts.Where(geom => ((Polygon)geom).Area > 0).OrderByDescending(geom => ((Polygon)geom).Area);
// for each of the exterior rings
foreach (var part in clockwiseParts)
{
// add the first (the largest) ring into the internal collection
if (internalRings.Count == 0)
internalRings.Add(part as Polygon);
// use flag to indicate if current part is within the already selection polygons
bool isWithin = false;
foreach (var item in internalRings)
{
if (GeometryEngine.Instance.Within(part, item))
isWithin = true;
}
// if the current polygon is not within any polygon of the internal collection
// then it is disjoint and needs to be added to
if (isWithin == false)
internalRings.Add(part as Polygon);
}
using (PolygonBuilder outerRings = new PolygonBuilder())
{
// now assemble a new polygon geometry based on the internal polygon collection
foreach (var ring in internalRings)
{
outerRings.AddParts(ring.Parts);
}
// return the final geometry of the outer rings
return outerRings.ToGeometry();
}
}
private void FindOrientationSimple(Polygon PolyToCheck)
{
foreach (var part in PolyToCheck.Parts)
{
// construct a list of ordered coordinate pairs
List<Coordinate2D> ringCoordinates = new List<Coordinate2D>(PolyToCheck.PointCount);
foreach (var segment in part)
{
ringCoordinates.Add(segment.StartCoordinate);
ringCoordinates.Add(segment.EndCoordinate);
}
// this is not the true area of the part
// a negative number indicates an outer ring and a positive number represents an inner ring
// (this is the opposite from the ArcGIS.Core.Geometry understanding)
double signedArea = 0;
// for all coordinates pairs compute the area
// the last coordinate needs to reach back to the starting coordinate to complete
for (int cIndex = 0; cIndex < ringCoordinates.Count - 1; cIndex++)
{
double x1 = ringCoordinates[cIndex].X;
double y1 = ringCoordinates[cIndex].Y;
double x2, y2;
if (cIndex == ringCoordinates.Count - 2)
{
x2 = ringCoordinates[0].X;
y2 = ringCoordinates[0].Y;
}
else
{
x2 = ringCoordinates[cIndex + 1].X;
y2 = ringCoordinates[cIndex + 1].Y;
}
signedArea += ((x1 * y2) - (x2 * y1));
}
// if signedArea is a negative number => indicates an outer ring
// if signedArea is a positive number => indicates an inner ring
// (this is the opposite from the ArcGIS.Core.Geometry understanding)
}
}
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
try
{
// open a gdb
using (ArcGIS.Core.Data.Geodatabase gdb = new ArcGIS.Core.Data.Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"c:\Temp\MyDatabase.gdb"))))
{
//Open a featureClass
using (ArcGIS.Core.Data.FeatureClass featureClass = gdb.OpenDataset<ArcGIS.Core.Data.FeatureClass>("Polygon"))
{
// find a field
ArcGIS.Core.Data.FeatureClassDefinition featureClassDefinition = featureClass.GetDefinition();
int fldIndex = featureClassDefinition.FindField("SomeField");
if (fldIndex == -1)
{
return;
}
ArcGIS.Core.Data.QueryFilter filter = new ArcGIS.Core.Data.QueryFilter
{
WhereClause = "OBJECTID = 6"
};
// get the row
using (ArcGIS.Core.Data.RowCursor rowCursor = featureClass.Search(filter, false))
{
while (rowCursor.MoveNext())
{
long oid = rowCursor.Current.GetObjectID();
// get the shape from the row
ArcGIS.Core.Data.Feature feature = rowCursor.Current as ArcGIS.Core.Data.Feature;
Polygon polygon = feature.GetShape() as Polygon;
// get the attribute from the row (assume it's a double field)
double value = (double)rowCursor.Current.GetOriginalValue(fldIndex);
// do something here
}
}
}
}
}
catch (Exception ex)
{
// error - handle appropriately
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a point with z, m
MapPoint point = MapPointBuilder.CreateMapPoint(100, 200, 300, 400, SpatialReferences.WebMercator);
// set the flags
WKTExportFlags exportFlags = WKTExportFlags.wktExportDefaults;
WKTImportFlags importFlags = WKTImportFlags.wktImportDefaults;
// export and import
string wktString = GeometryEngine.Instance.ExportToWKT(exportFlags, point);
MapPoint importPoint = GeometryEngine.Instance.ImportFromWKT(importFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
double x = importPoint.X; // x = 100
double y = importPoint.Y; // y = 200
bool hasZ = importPoint.HasZ; // hasZ = true
double z = importPoint.Z; // z = 300
bool hasM = importPoint.HasM; // hasM = true
double m = importPoint.M; // m = 400
// export without z
WKTExportFlags exportFlagsNoZ = WKTExportFlags.wktExportStripZs;
wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoZ, point);
importPoint = GeometryEngine.Instance.ImportFromWKT(importFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
x = importPoint.X; // x = 100
y = importPoint.Y; // y = 200
hasZ = importPoint.HasZ; // hasZ = false
z = importPoint.Z; // z = 0
hasM = importPoint.HasM; // hasM = true
m = importPoint.M; // m = 400
// export without m
WKTExportFlags exportFlagsNoM = WKTExportFlags.wktExportStripMs;
wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoM, point);
importPoint = GeometryEngine.Instance.ImportFromWKT(importFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
x = importPoint.X; // x = 100
y = importPoint.Y; // y = 200
hasZ = importPoint.HasZ; // hasZ = true
z = importPoint.Z; // z = 300
hasM = importPoint.HasM; // hasM = false
m = importPoint.M; // m = Nan
// export without z, m
wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoZ | exportFlagsNoM, point);
importPoint = GeometryEngine.Instance.ImportFromWKT(importFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
x = importPoint.X; // x = 100
y = importPoint.Y; // y = 200
hasZ = importPoint.HasZ; // hasZ = false
z = importPoint.Z; // z = 0
hasM = importPoint.HasM; // hasM = false
m = importPoint.M; // m = Nan
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a polyline
List<Coordinate2D> coords = new List<Coordinate2D>
{
new Coordinate2D(0, 0),
new Coordinate2D(0, 1),
new Coordinate2D(1, 1),
new Coordinate2D(1, 0)
};
Polyline polyline = PolylineBuilder.CreatePolyline(coords, SpatialReferences.WGS84);
WKBExportFlags exportFlags = WKBExportFlags.wkbExportDefaults;
WKBImportFlags importFlags = WKBImportFlags.wkbImportDefaults;
// export and import
byte[] buffer = GeometryEngine.Instance.ExportToWKB(exportFlags, polyline);
Geometry geometry = GeometryEngine.Instance.ImportFromWKB(importFlags, buffer, SpatialReferences.WGS84);
Polyline importPolyline = geometry as Polyline;
// alternatively, determine the size for the buffer
int bufferSize = GeometryEngine.Instance.GetWKBSize(exportFlags, polyline);
buffer = new byte[bufferSize];
// export
bufferSize = GeometryEngine.Instance.ExportToWKB(exportFlags, polyline, ref buffer);
// import
importPolyline = GeometryEngine.Instance.ImportFromWKB(importFlags, buffer, SpatialReferences.WGS84) as Polyline;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create an envelope
List<MapPoint> coordsZM = new List<MapPoint>
{
MapPointBuilder.CreateMapPoint(1001, 1002, 1003, 1004),
MapPointBuilder.CreateMapPoint(2001, 2002, Double.NaN, 2004),
MapPointBuilder.CreateMapPoint(3001, -3002, 3003, 3004),
MapPointBuilder.CreateMapPoint(1001, -4002, 4003, 4004)
};
Envelope envelope = EnvelopeBuilder.CreateEnvelope(coordsZM[0], coordsZM[2], SpatialReferences.WGS84);
// export and import
EsriShapeExportFlags exportFlags = EsriShapeExportFlags.esriShapeExportDefaults;
EsriShapeImportFlags importFlags = EsriShapeImportFlags.esriShapeImportDefaults;
byte[] buffer = GeometryEngine.Instance.ExportToEsriShape(exportFlags, envelope);
Polygon importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, envelope.SpatialReference) as Polygon;
Envelope importedEnvelope = importedPolygon.Extent;
// export without z,m
buffer = GeometryEngine.Instance.ExportToEsriShape(EsriShapeExportFlags.esriShapeExportStripZs | EsriShapeExportFlags.esriShapeExportStripMs, envelope);
importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, SpatialReferences.WGS84) as Polygon;
importedEnvelope = importedPolygon.Extent;
bool hasZ = importedEnvelope.HasZ; // hasZ = false
bool hasM = importedEnvelope.HasM; // hasM = false
// export with shapeSize
int bufferSize = GeometryEngine.Instance.GetEsriShapeSize(exportFlags, envelope);
buffer = new byte[bufferSize];
bufferSize = GeometryEngine.Instance.ExportToEsriShape(exportFlags, envelope, ref buffer);
importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, envelope.SpatialReference) as Polygon;
importedEnvelope = importedPolygon.Extent;
// or use the envelope and envelopeBuilder classes
buffer = envelope.ToEsriShape();
// buffer represents a polygon as there is not an envelope Esri shape buffer
// EnvelopeBuilder.FromEsriShape takes a polygon Esri shape buffer and returns the extent of the polygon.
importedEnvelope = EnvelopeBuilder.FromEsriShape(buffer);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// MapPoint
string inputString = "{\"x\":1,\"y\":2,\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}";
Geometry geometry = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, inputString);
MapPoint importPoint = geometry as MapPoint;
// importPoint = 1, 2
// importPoint.SpatialReference.WKid = 4326
// use the MapPointBuilder convenience method
MapPoint importPoint2 = MapPointBuilder.FromJson(inputString);
// importPoint2 = 1, 2
// impointPoint2.SpatialReference.Wkid = 4326
string outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportDefaults, importPoint);
// outputString = "{\"x\":1,\"y\":2,\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}"
string outputString2 = importPoint.ToJson();
inputString = "{\"spatialReference\":{\"wkid\":4326},\"z\":3,\"m\":4,\"x\":1,\"y\":2}";
importPoint = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, inputString) as MapPoint;
// importPoint.HasM = true
// importPoint.HasZ = true
// importPoint.X = 1
// importPoint.Y = 2
// importPoint.M = 4
// importPoint.Z = 3
importPoint2 = MapPointBuilder.FromJson(inputString);
// export to json - skip spatial reference
outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, importPoint);
// outputString = "{\"x\":1,\"y\":2,\"z\":3,\"m\":4}"
// export from mappoint, skipping the sr - same as GeometryEngine.Instance.ExportToJSON w JSONExportFlags.jsonExportSkipCRS
outputString2 = importPoint.ToJson(true);
//
// Multipoint
//
List<Coordinate2D> coords = new List<Coordinate2D>
{
new Coordinate2D(100, 200),
new Coordinate2D(201, 300),
new Coordinate2D(301, 400),
new Coordinate2D(401, 500)
};
Multipoint multipoint = MultipointBuilder.CreateMultipoint(coords, SpatialReferences.WebMercator);
inputString = "{\"points\":[[100,200],[201,300],[301,400],[401,500]],\"spatialReference\":{\"wkid\":3857}}";
Multipoint importMultipoint = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, inputString) as Multipoint;
// importMultipoint.IsEqual(multipoint) = true
ReadOnlyPointCollection points = importMultipoint.Points;
// points.Count = 4
// points[0] = 100, 200
// points[1] = 201, 300
// points[2] = 301, 400
// points[3] = 401, 500
// use the Multipointbuilder convenience method
Multipoint importMultipoint2 = MultipointBuilder.FromJson(inputString);
// importMultipoint2.IsEqual(multipoint) = true
// export to json
outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportDefaults, multipoint);
// outputString = inputString
// or use the multipoint itself
outputString2 = multipoint.ToJson();
//
// Polyline
//
Polyline polyline = PolylineBuilder.CreatePolyline(coords, SpatialReferences.WebMercator);
// export without the spatial reference
outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, polyline);
// import
geometry = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, outputString);
Polyline importPolyline = geometry as Polyline;
// importPolyline.SpatialReference = null
points = importPolyline.Points;
// points.Count = 4
// points[0] = 100, 200
// points[1] = 201, 300
// points[2] = 301, 400
// points[3] = 401, 500
// use the polylineBuilder convenience method
Polyline importPolyline2 = PolylineBuilder.FromJson(outputString);
// importPolyline2 = importPolyline
outputString2 = importPolyline2.ToJson();
// outputString2 = outputString
//
// Polygon
//
Polygon polygon = PolygonBuilder.CreatePolygon(coords, SpatialReferences.WebMercator);
// export without the spatial reference
outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, polygon);
// import
geometry = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, outputString);
Polygon importPolygon = geometry as Polygon;
// importPolygon.SpatialReference = null
points = importPolygon.Points;
// points.Count = 5
// polygonBuilder convenience method
Polygon importPolyon2 = PolygonBuilder.FromJson(outputString);
// importPolygon2 = importPolygon
// export from the polygon
outputString2 = importPolyon2.ToJson(true);
// Empty polygon
polygon = PolygonBuilder.CreatePolygon(SpatialReferences.WebMercator);
outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportDefaults, polygon);
importPolygon = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, outputString) as Polygon;
// importPolygon.IsEmpty = true
// importPolygon.SpatialReference.Wkid = 3857
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint minPoint = MapPointBuilder.CreateMapPoint(1, 1, 1, 1, 3);
MapPoint maxPoint = MapPointBuilder.CreateMapPoint(5, 5, 5);
//
// mapPoint
//
string xml = minPoint.ToXML();
MapPoint minPointImport = MapPointBuilder.FromXML(xml);
// minPointImport = minPoint
//
// envelope
//
Envelope envelopeWithID = EnvelopeBuilder.CreateEnvelope(minPoint, maxPoint);
// Envelopes don't have IDs
// envelopeWithID.HasID = false
// envelopeWithID.HasM = true
// envelopeWithID.HasZ = true
xml = envelopeWithID.ToXML();
Envelope envelopeImport = EnvelopeBuilder.FromXML(xml);
//
// multipoint
//
List<MapPoint> list = new List<MapPoint>();
list.Add(minPoint);
list.Add(maxPoint);
Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list);
xml = multiPoint.ToXML();
Multipoint multipointImport = MultipointBuilder.FromXML(xml);
// multipointImport.PointCount == 2
// multipointImport.HasID = true
// multipointImport.HasM = true
// multipointImport.HasZ= true
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
var g1 = PolygonBuilder.FromJson("{\"rings\": [ [ [0, 0], [10, 0], [10, 10], [0, 10] ] ] }");
double d = GeometryEngine.Instance.Area(g1);
// d = -100.0 //negative due to wrong ring orientation
d = GeometryEngine.Instance.Area(GeometryEngine.Instance.SimplifyAsFeature(g1));
// d = 100.0 // feature has been simplifed; ring orientation is correct
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a donut polygon. Must use the PolygonBuilder object
List<Coordinate2D> outerPts = new List<Coordinate2D>();
outerPts.Add(new Coordinate2D(10.0, 10.0));
outerPts.Add(new Coordinate2D(10.0, 20.0));
outerPts.Add(new Coordinate2D(20.0, 20.0));
outerPts.Add(new Coordinate2D(20.0, 10.0));
List<Coordinate2D> innerPts = new List<Coordinate2D>();
innerPts.Add(new Coordinate2D(13.0, 13.0));
innerPts.Add(new Coordinate2D(17.0, 13.0));
innerPts.Add(new Coordinate2D(17.0, 17.0));
innerPts.Add(new Coordinate2D(13.0, 17.0));
// add the outer points
using (PolygonBuilder pb = new PolygonBuilder(outerPts))
{
// add the inner points (note they are defined anticlockwise)
pb.AddPart(innerPts);
// get the polygon
Polygon donut = pb.ToGeometry();
// get the boundary
Geometry g = GeometryEngine.Instance.Boundary(donut);
Polyline boundary = g as Polyline;
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// buffer a point
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
Geometry ptBuffer = GeometryEngine.Instance.Buffer(pt, 5.0);
Polygon buffer = ptBuffer as Polygon;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create the circular arc
MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1);
MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2);
Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);
EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, toPt, interiorPt);
// buffer the arc
Polyline polyline = PolylineBuilder.CreatePolyline(circularArc);
Geometry lineBuffer = GeometryEngine.Instance.Buffer(polyline, 10);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// creates a buffer around each MapPoint
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
Geometry ptsBuffer = GeometryEngine.Instance.Buffer(pts, 0.25);
Polygon bufferResult = ptsBuffer as Polygon; // bufferResult will have 4 parts
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(1, 2), new Coordinate2D(3, 4), new Coordinate2D(4, 2),
new Coordinate2D(5, 6), new Coordinate2D(7, 8), new Coordinate2D(8, 4),
new Coordinate2D(9, 10), new Coordinate2D(11, 12), new Coordinate2D(12, 8),
new Coordinate2D(10, 8), new Coordinate2D(12, 12), new Coordinate2D(14, 10)
};
List<Geometry> manyGeometries = new List<Geometry>
{
MapPointBuilder.CreateMapPoint(coords[9]),
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84),
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[3], coords[4], coords[5]}),
PolygonBuilder.CreatePolygon(new List<Coordinate2D>(){coords[6], coords[7], coords[8]})
};
Geometry manyGeomBuffer = GeometryEngine.Instance.Buffer(manyGeometries, 0.25);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate3D> coords2 = new List<Coordinate3D>()
{
new Coordinate3D(0, 0, 0),
new Coordinate3D(0, 1000, double.NaN),
new Coordinate3D(1000, 1000, 50),
new Coordinate3D(1000, 1000, 76),
new Coordinate3D(0, 1000, double.NaN),
new Coordinate3D(0, 0, 0)
};
SpatialReference sr = SpatialReferences.WebMercator;
Polyline polyline = PolylineBuilder.CreatePolyline(coords2, sr);
// polyline.HasZ = true
// polyline.Points[1].HasZ = true
// polyline.Points[1].Z = NaN
// polyline.Points[4].HasZ = true
// polyline.Points[4].Z = NaN
Polyline polylineNoNaNZs = GeometryEngine.Instance.CalculateNonSimpleZs(polyline, 0) as Polyline;
// polylineNoNaNZs.Points[1].HasZ = true
// polylineNoNaNZs.Points[1].Z = 25 (halfway between 0 and 50)
// polylineNoNaNZs.Points[4].HasZ = true
// polylineNoNaNZs.Points[4].Z = 38 (halfway between 76 and 0)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> coords = new List<MapPoint>()
{
MapPointBuilder.CreateMapPoint(0, 0, 0, 0),
MapPointBuilder.CreateMapPoint(0, 1000),
MapPointBuilder.CreateMapPoint(1000, 1000, 10, 50)
};
SpatialReference sr2 = SpatialReferences.WebMercator;
Polygon polygon = PolygonBuilder.CreatePolygon(coords, sr2);
// polygon.HasM = true
// polygon.Points[1].HasM = true
// polygon.Points[1].M = NaN
Polygon polygonNoNaNMs = GeometryEngine.Instance.CalculateNonSimpleMs(polygon, 0) as Polygon;
// polygonNoNaNMs.Points[1].HasM = true
// polygonNoNaNMs.Points[1].M = 25 (halfway between 0 and 50)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Envelope env = EnvelopeBuilder.CreateEnvelope(1.0, 1.0, 5.0, 5.0);
Envelope centered = GeometryEngine.Instance.CenterAt(env, 2.0, 2.0);
// centered.Center.X = 2.0
// centered.Center.Y = 2.0
// centered.XMin = 0
// centered.YMin = 0
// centered.XMax = 4
// centered.YMax = 4
centered = env.CenterAt(4.0, 3.0);
// centered.Center.X == 4.0
// centered.Center.Y == 3.0
// centered.XMin == 2.0
// centered.YMin == 1.0
// centered.XMax == 6.0
// centered.YMax == 5.0
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// simple polygon
List<Coordinate2D> list2D = new List<Coordinate2D>();
list2D.Add(new Coordinate2D(0, 0));
list2D.Add(new Coordinate2D(0, 2));
list2D.Add(new Coordinate2D(2, 2));
list2D.Add(new Coordinate2D(2, 0));
Polygon polygon = PolygonBuilder.CreatePolygon(list2D, SpatialReferences.WGS84);
// verify it is simple
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon);
// find the centroid
MapPoint centroid = GeometryEngine.Instance.Centroid(polygon);
// centroid.X = 1
// centroid.Y = 1
// map Point
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, SpatialReferences.WGS84);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(5, 2, double.NaN, 7);
// pt1.HasZ = true
// pt1.HasM = true
centroid = GeometryEngine.Instance.Centroid(pt1);
// centroid.HasZ = true
// centroid.HasM = true
// pt1.IsEqual(centroid) = true
// multipoint
List<MapPoint> list = new List<MapPoint>() { pt1, pt2 };
Multipoint multipoint = MultipointBuilder.CreateMultipoint(list);
// multipoint.HasZ = true
// multipoint.HasM = true
centroid = GeometryEngine.Instance.Centroid(multipoint);
// centroid.X = 3
// centroid.Y = 2
// centroid.HasZ = false
// centroid.HasM = false
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// clip a polyline by an envelope
Envelope env = EnvelopeBuilder.CreateEnvelope(2.0, 2.0, 4.0, 4.0);
LineSegment line = LineBuilder.CreateLineSegment(new Coordinate2D(0, 3), new Coordinate2D(5.0, 3.0));
Polyline polyline = PolylineBuilder.CreatePolyline(line);
Geometry clipGeom = GeometryEngine.Instance.Clip(polyline, env);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// clip a polyline by a polygon
List<Coordinate2D> list = new List<Coordinate2D>();
list.Add(new Coordinate2D(1.0, 1.0));
list.Add(new Coordinate2D(1.0, 4.0));
list.Add(new Coordinate2D(4.0, 4.0));
list.Add(new Coordinate2D(4.0, 1.0));
Polygon polygon = PolygonBuilder.CreatePolygon(list, SpatialReferences.WGS84);
LineSegment crossingLine = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 3), MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline p = PolylineBuilder.CreatePolyline(crossingLine);
Geometry geometry = GeometryEngine.Instance.Clip(p, polygon.Extent);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// build a polygon
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
Polygon poly = PolygonBuilder.CreatePolygon(pts);
// test if an inner point is contained
MapPoint innerPt = MapPointBuilder.CreateMapPoint(1.5, 1.5);
bool contains = GeometryEngine.Instance.Contains(poly, innerPt); // contains = true
// test a point on a boundary
contains = GeometryEngine.Instance.Contains(poly, poly.Points[0]); // contains = false
// test an interior line
MapPoint innerPt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75);
List<MapPoint> innerLinePts = new List<MapPoint>();
innerLinePts.Add(innerPt);
innerLinePts.Add(innerPt2);
// test an inner polyline
Polyline polyline = PolylineBuilder.CreatePolyline(innerLinePts);
contains = GeometryEngine.Instance.Contains(poly, polyline); // contains = true
// test a line that crosses the boundary
MapPoint outerPt = MapPointBuilder.CreateMapPoint(3, 1.5);
List<MapPoint> crossingLinePts = new List<MapPoint>();
crossingLinePts.Add(innerPt);
crossingLinePts.Add(outerPt);
polyline = PolylineBuilder.CreatePolyline(crossingLinePts);
contains = GeometryEngine.Instance.Contains(poly, polyline); // contains = false
// test a polygon in polygon
Envelope env = EnvelopeBuilder.CreateEnvelope(innerPt, innerPt2);
contains = GeometryEngine.Instance.Contains(poly, env); // contains = true
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
//
// convex hull around a point - returns a point
//
MapPoint pt = MapPointBuilder.CreateMapPoint(2.0, 2.0);
Geometry hull = GeometryEngine.Instance.ConvexHull(pt);
MapPoint hullPt = hull as MapPoint;
// nullPt.X = 2
// hullPt.Y = 2
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
list.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
list.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
//
// convex hull around a multipoint - returns a polygon
//
// build a multiPoint
Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list);
hull = GeometryEngine.Instance.ConvexHull(multiPoint);
Polygon hullPoly = hull as Polygon;
// hullPoly.Area = 1
// hullPoly.PointCount = 5
//
// convex hull around a line - returns a polyline or polygon
//
List<MapPoint> polylineList = new List<MapPoint>();
polylineList.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
polylineList.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
// 2 point straight line
Polyline polyline = PolylineBuilder.CreatePolyline(polylineList);
hull = GeometryEngine.Instance.ConvexHull(polyline);
Polyline hullPolyline = hull as Polyline;
// hullPolyline.Length = Math.Sqrt(2)
// hullPolyline.PointCount = 2
// 3 point angular line
polylineList.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
polyline = PolylineBuilder.CreatePolyline(polylineList);
hull = GeometryEngine.Instance.ConvexHull(polyline);
hullPoly = hull as Polygon;
// hullPoly.Length = 2 + Math.Sqrt(2)
// hullPoly.Area = 0.5
// hullPoly.PointCount = 4
//
// convex hull around a polygon - returns a polygon
//
// simple polygon
Polygon poly = PolygonBuilder.CreatePolygon(list);
hull = GeometryEngine.Instance.ConvexHull(poly);
hullPoly = hull as Polygon;
// hullPoly.Length = 4.0
// hullPoly.Area = 1.0
// hullPoly.PointCount = 5
// polygon with concave angles
List<MapPoint> funkyList = new List<MapPoint>();
funkyList.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
funkyList.Add(MapPointBuilder.CreateMapPoint(1.5, 1.5));
funkyList.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
funkyList.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
funkyList.Add(MapPointBuilder.CreateMapPoint(1.5, 1.5));
funkyList.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
funkyList.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
Polygon funkyPoly = PolygonBuilder.CreatePolygon(funkyList);
hull = GeometryEngine.Instance.ConvexHull(funkyPoly);
hullPoly = hull as Polygon;
// hullPoly.Length = 4.0
// hullPoly.Area = 1.0
// hullPoly.PointCount = 5
// hullPoly.Points[0] = 1.0, 1.0
// hullPoly.Points[1] = 1.0, 2.0
// hullPoly.Points[2] = 2.0, 2.0
// hullPoly.Points[3] = 2.0, 1.0
// hullPoly.Points[4] = 1.0, 1.0
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
//
// pt on pt
//
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.0);
bool crosses = GeometryEngine.Instance.Crosses(pt, pt2); // crosses = false
crosses = GeometryEngine.Instance.Crosses(pt, pt); // crosses = false
//
// pt and line
//
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0));
list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0));
Polyline line1 = PolylineBuilder.CreatePolyline(list);
crosses = GeometryEngine.Instance.Crosses(line1, pt2); // crosses = false
crosses = GeometryEngine.Instance.Crosses(pt2, line1); // crosses = false
// end pt of line
crosses = GeometryEngine.Instance.Crosses(line1, pt); // crosses = false
//
// pt and polygon
//
List<MapPoint> polyPts = new List<MapPoint>();
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts);
crosses = GeometryEngine.Instance.Crosses(poly1, pt); // crosses = false
crosses = GeometryEngine.Instance.Crosses(pt, poly1); // crosses = false
//
// line and line
//
List<MapPoint> list2 = new List<MapPoint>();
list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0));
list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0));
list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline line2 = PolylineBuilder.CreatePolyline(list2);
crosses = GeometryEngine.Instance.Crosses(line1, line2); // crosses = true
//
// line and polygon
//
crosses = GeometryEngine.Instance.Crosses(poly1, line1); // crosses = true
//
// polygon and polygon
//
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4));
Polygon poly2 = PolygonBuilder.CreatePolygon(env);
crosses = GeometryEngine.Instance.Crosses(poly1, poly2); // crosses = false
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr = SpatialReferences.WGS84;
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, sr));
list.Add(MapPointBuilder.CreateMapPoint(1.0, 4.0, sr));
list.Add(MapPointBuilder.CreateMapPoint(4.0, 4.0, sr));
list.Add(MapPointBuilder.CreateMapPoint(4.0, 1.0, sr));
List<Geometry> cutGeometries;
LineSegment line = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 0, sr), MapPointBuilder.CreateMapPoint(3, 6, sr));
Polyline cutter = PolylineBuilder.CreatePolyline(line);
// polyline
Polyline polyline = PolylineBuilder.CreatePolyline(list);
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline);
cutGeometries = GeometryEngine.Instance.Cut(polyline, cutter) as List<Geometry>;
Polyline leftPolyline = cutGeometries[0] as Polyline;
Polyline rightPolyline = cutGeometries[1] as Polyline;
// leftPolyline.Points[0] = 1, 2
// leftPolyline.Points[1] = 1, 4
// leftPolyline.Points[2] = 2, 4
// rightPolyline.Points.Count = 5
// rightPolyline.Parts.Count = 2
ReadOnlySegmentCollection segments0 = rightPolyline.Parts[0];
// segments0[0].StartCoordinate = 1, 1
// segments0[0].EndCoordinate = 1, 2
ReadOnlySegmentCollection segments1 = rightPolyline.Parts[1];
// segments1.Count = 2
// segments1[0].StartCoordinate = 2, 4
// segments1[0].EndCoordinate = 4, 4
// segments1[1].StartCoordinate = 4, 4
// segments1[1].EndCoordinate = 4, 1
// polygon
Polygon polygon = PolygonBuilder.CreatePolygon(list);
isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon);
cutGeometries = GeometryEngine.Instance.Cut(polygon, cutter) as List<Geometry>;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// densify a line segment
MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint endPt = MapPointBuilder.CreateMapPoint(1, 21);
LineSegment line = LineBuilder.CreateLineSegment(startPt, endPt);
Polyline polyline = PolylineBuilder.CreatePolyline(line);
Geometry geom = GeometryEngine.Instance.DensifyByLength(polyline, 2);
Polyline result = geom as Polyline;
// densify a circular arc
MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1);
MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2);
Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);
using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, toPt, interiorPt))
{
EllipticArcSegment circularArc = cab.ToSegment();
polyline = PolylineBuilder.CreatePolyline(circularArc);
geom = GeometryEngine.Instance.DensifyByLength(polyline, 2);
result = geom as Polyline;
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> polyPts = new List<MapPoint>();
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts);
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4));
Polygon poly2 = PolygonBuilder.CreatePolygon(env);
Geometry result = GeometryEngine.Instance.Difference(poly1, poly2);
Polygon polyResult = result as Polygon;
// polyResult.Area = 10.0
result = GeometryEngine.Instance.Difference(poly2, poly1);
polyResult = result as Polygon;
// polyResult.Area = 7.0
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
//
// pt on pt
//
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5);
bool disjoint = GeometryEngine.Instance.Disjoint(pt, pt2); // result is true
using (MultipointBuilder mpb = new MultipointBuilder())
{
mpb.Add(pt);
mpb.Add(pt2);
Multipoint multiPoint = mpb.ToGeometry();
disjoint = GeometryEngine.Instance.Disjoint(multiPoint, pt); // result is false
}
//
// pt and line
//
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0));
list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0));
Polyline line1 = PolylineBuilder.CreatePolyline(list);
disjoint = GeometryEngine.Instance.Disjoint(line1, pt2); // result is true
disjoint = GeometryEngine.Instance.Disjoint(pt2, line1); // result is true
// end pt of line
disjoint = GeometryEngine.Instance.Disjoint(line1, pt); // result is false
//
// pt and polygon
//
List<MapPoint> polyPts = new List<MapPoint>();
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts);
disjoint = GeometryEngine.Instance.Disjoint(poly1, pt); // result is true
disjoint = GeometryEngine.Instance.Disjoint(pt, poly1); // result is true
//
// line and line
//
List<MapPoint> list2 = new List<MapPoint>();
list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0));
list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0));
list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline line2 = PolylineBuilder.CreatePolyline(list2);
disjoint = GeometryEngine.Instance.Disjoint(line1, line2); // result is false
//
// line and polygon
//
disjoint = GeometryEngine.Instance.Disjoint(poly1, line1); // result is false
disjoint = GeometryEngine.Instance.Disjoint(line1, poly1); // result is false
//
// polygon and polygon
//
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4));
Polygon poly2 = PolygonBuilder.CreatePolygon(env);
disjoint = GeometryEngine.Instance.Disjoint(poly1, poly2); // result is false
// disjoint3D
SpatialReference sr = SpatialReferences.WGS84;
MapPoint pt3D_1 = MapPointBuilder.CreateMapPoint(1, 1, 1, sr);
MapPoint pt3D_2 = MapPointBuilder.CreateMapPoint(2, 2, 2, sr);
MapPoint pt3D_3 = MapPointBuilder.CreateMapPoint(1, 1, 2, sr);
using (MultipointBuilder mpb = new MultipointBuilder())
{
mpb.Add(pt3D_1);
mpb.Add(pt3D_2);
mpb.HasZ = true;
Multipoint multiPoint = mpb.ToGeometry();
disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_2); // disjoint = false
disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_3); // disjoint = true
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.0);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(4.0, 2.0);
//
// pt and pt
//
double d = GeometryEngine.Instance.Distance(pt1, pt2); // d = Math.Sqrt(2)
//
// pt and multipoint
//
List<MapPoint> multiPts = new List<MapPoint>();
multiPts.Add(pt2);
multiPts.Add(pt3);
Multipoint multiPoint = MultipointBuilder.CreateMultipoint(multiPts);
d = GeometryEngine.Instance.Distance(pt1, multiPoint); // d = Math.Sqrt(2)
//
// pt and envelope
//
Envelope env = EnvelopeBuilder.CreateEnvelope(pt1, pt2);
d = GeometryEngine.Instance.Distance(pt1, env); // d = 0
//
// pt and polyline
//
List<MapPoint> polylinePts = new List<MapPoint>();
polylinePts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
polylinePts.Add(pt2);
Polyline polyline = PolylineBuilder.CreatePolyline(polylinePts);
d = GeometryEngine.Instance.Distance(pt1, polyline); // d = 1.0
//
// pt and polygon
//
Envelope env2 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(3.0, 3.0), MapPointBuilder.CreateMapPoint(5.0, 5.0));
Polygon poly = PolygonBuilder.CreatePolygon(env2);
d = GeometryEngine.Instance.Distance(pt1, poly); // d = Math.Sqrt(8)
//
// envelope and polyline
//
d = GeometryEngine.Instance.Distance(env, polyline); // d = 0
//
// polyline and polyline
//
List<MapPoint> polylineList = new List<MapPoint>();
polylineList.Add(MapPointBuilder.CreateMapPoint(4, 3));
polylineList.Add(MapPointBuilder.CreateMapPoint(4, 4));
Polyline polyline2 = PolylineBuilder.CreatePolyline(polylineList);
d = GeometryEngine.Instance.Distance(polyline, polyline2); // d = Math.Sqrt(5)
//
// polygon and polygon
//
Polygon poly2 = PolygonBuilder.CreatePolygon(env);
d = GeometryEngine.Instance.Distance(poly, poly2); // d = Math.Sqrt(2)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// between points
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 1, 1);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2, 2, 2);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(10, 2, 1);
// pt1 to pt2
double d = GeometryEngine.Instance.Distance3D(pt1, pt2); // d = Math.Sqrt(3)
// pt1 to pt3
d = GeometryEngine.Instance.Distance3D(pt1, pt3); // d = Math.Sqrt(82)
// pt2 to pt3
d = GeometryEngine.Instance.Distance3D(pt2, pt3); // d = Math.Sqrt(65)
// intersecting lines
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0, 1.0));
list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0, 1.0));
Polyline line1 = PolylineBuilder.CreatePolyline(list);
List<MapPoint> list2 = new List<MapPoint>();
list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 1.0));
list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 1.0));
list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0, 1.0));
Polyline line2 = PolylineBuilder.CreatePolyline(list2);
bool intersects = GeometryEngine.Instance.Intersects(line1, line2); // intersects = true
d = GeometryEngine.Instance.Distance3D(line1, line2); // d = 0 (distance is 0 when geomtries intersect)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
Envelope env = EnvelopeBuilder.CreateEnvelope(100.0, 100.0, 500.0, 500.0);
// env.HasZ = false
Envelope result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, true);
// result.Center = 300, 300
// result.XMin = 200
// result.YMin = 200
// result.XMax = 400
// result.YMax = 400
result = GeometryEngine.Instance.Expand(env, 100, 200, false);
// result.Center = 300, 300
// result.XMin = 0
// result.YMin = -100
// result.XMax = 600
// result.YMax = 700
try
{
// expand in 3 dimensions
result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, 0.5, true);
}
catch (InvalidOperationException e)
{
// the geometry is not Z-Aware
}
// expand a 3d envelope
MapPoint pt1 = MapPointBuilder.CreateMapPoint(100, 100, 100);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(200, 200, 200);
using (EnvelopeBuilder eb = new EnvelopeBuilder(pt1, pt2))
{
eb.HasZ = true;
env = eb.ToGeometry();
result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, 0.5, true);
// result.Center = 150, 150, 150
// result.XMin = 125
// result.YMin = 125
// result.ZMin = 125
// result.XMax = 175
// result.YMax = 175
// result.ZMax = 175
}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// build a polyline
var polyline = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint( 1, 1, 10, 20),
MapPointBuilder.CreateMapPoint( 0, 0, 10, 20),
MapPointBuilder.CreateMapPoint( 1, -1, 10, 20)
});
// build the extender line
var extender = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint( 2, 2),
MapPointBuilder.CreateMapPoint( 2,-2),
});
// extend
var result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes);
Polyline extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 10, 20
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// result.Parts[0].Points[4] = 2, -2, 10, 20
// change the flags
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.NoEndAttributes);
extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 0
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// result.Parts[0].Points[4] = 2, -2, 0
// extend
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes | ExtendFlags.NoExtendAtTo);
extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 10, 20
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// extend with no intersection
polyline = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint( 1, 1),
MapPointBuilder.CreateMapPoint( 3, 1),
});
extender = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint( 1, 4),
MapPointBuilder.CreateMapPoint( 3, 4),
});
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.Default);
// result = null
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// buffer a point
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84);
Polygon outPolygon = GeometryEngine.Instance.GeodesicBuffer(pt, 5) as Polygon;
double delta = SpatialReferences.WGS84.XYTolerance * 2 * Math.Sqrt(2);
ReadOnlyPointCollection points = outPolygon.Points;
foreach (MapPoint p in points)
{
double d = GeometryEngine.Instance.GeodesicDistance(pt, p);
// d = 5 (+- delta)
}
// buffer of 0 distance produces an empty geometry
Geometry g = GeometryEngine.Instance.GeodesicBuffer(pt, 0);
// g.IsEmpty = true
// buffer many points
List<MapPoint> list = new List<MapPoint>();
list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84));
list.Add(MapPointBuilder.CreateMapPoint(10.0, 20.0));
list.Add(MapPointBuilder.CreateMapPoint(40.0, 40.0));
list.Add(MapPointBuilder.CreateMapPoint(60.0, 60.0));
outPolygon = GeometryEngine.Instance.GeodesicBuffer(list, 10000) as Polygon;
// outPolygon.PartCount = 4
// buffer different geometry types
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(1, 2), new Coordinate2D(10, 20), new Coordinate2D(20, 30),
new Coordinate2D(50, 60), new Coordinate2D(70, 80), new Coordinate2D(80, 40),
new Coordinate2D(90, 10), new Coordinate2D(110, 15), new Coordinate2D(120, 30),
new Coordinate2D(10, 40), new Coordinate2D(-10, 40), new Coordinate2D(-10, 50)
};
List<Geometry> manyGeometries = new List<Geometry>
{
MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84),
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84),
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[3], coords[4], coords[5]}),
PolygonBuilder.CreatePolygon(new List<Coordinate2D>(){coords[9], coords[10], coords[11]})
};
outPolygon = GeometryEngine.Instance.GeodesicBuffer(manyGeometries, 20000) as Polygon;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> coords = new List<Coordinate2D>()
{
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 polyline = PolylineBuilder.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;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> coords = new List<Coordinate2D>()
{
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 polygon = PolygonBuilder.CreatePolygon(coords, sr);
// get the geodesic lengths of the polygon segments
ReadOnlySegmentCollection segments = polygon.Parts[0];
List<Double> geoLengths = new List<Double>(segments.Count);
foreach (Segment s in segments)
{
Polyline line = PolylineBuilder.CreatePolyline(s, sr);
double geoLen = GeometryEngine.Instance.GeodesicLength(line);
geoLengths.Add(geoLen);
}
// find the max length
geoLengths.Sort();
double maxLen = geoLengths[geoLengths.Count - 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;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
GeodesicEllipseParameter param = new GeodesicEllipseParameter();
param.AxisDirection = 4 * Math.PI / 3;
param.Center = new Coordinate2D(-120, 60);
param.LinearUnit = LinearUnit.Meters;
param.OutGeometryType = GeometryType.Polyline;
param.SemiAxis1Length = 6500000;
param.SemiAxis2Length = 1500000;
param.VertexCount = 800;
Geometry geometry = GeometryEngine.Instance.GeodesicEllipse(param, SpatialReferences.WGS84);
// geometry.IsEmpty = false
Polyline polyline = geometry as Polyline;
// polyline.PointCount = 801
// polyline.PartCount = 1
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr = SpatialReferences.WebMercator;
var points = new[] { MapPointBuilder.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
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
GeodesicSectorParameter param = new GeodesicSectorParameter();
param.ArcVertexCount = 50;
param.AxisDirection = Math.PI / 4;
param.Center = new Coordinate2D(0, 0);
param.LinearUnit = LinearUnit.Meters;
param.OutGeometryType = GeometryType.Polygon;
param.RadiusVertexCount = 10;
param.SectorAngle = 5 * Math.PI / 3;
param.SemiAxis1Length = 100000;
param.SemiAxis2Length = 20000;
param.StartDirection = 11 * Math.PI / 6;
Geometry geometry = GeometryEngine.Instance.GeodesicSector(param, SpatialReferences.WGS84);
// geometry.IsEmpty = false
Polygon polygon = geometry as Polygon;
// polygon.PointCount = 68
// polygon.PartCount = 1
});
// get all the geographic coordinate systems
IReadOnlyList<CoordinateSystemListEntry> gcs_list = GeometryEngine.Instance.GetPredefinedCoordinateSystemList(CoordinateSystemFilter.GeographicCoordinateSystem);
// get the projected coordinate systems
IReadOnlyList<CoordinateSystemListEntry> proj_list = GeometryEngine.Instance.GetPredefinedCoordinateSystemList(CoordinateSystemFilter.ProjectedCoordinateSystem);
// get the vertical coordinate systems
IReadOnlyList<CoordinateSystemListEntry> vert_list = GeometryEngine.Instance.GetPredefinedCoordinateSystemList(CoordinateSystemFilter.VerticalCoordinateSystem);
// get geographic and projected coordinate systems
IReadOnlyList<CoordinateSystemListEntry> combined_list = GeometryEngine.Instance.GetPredefinedCoordinateSystemList(CoordinateSystemFilter.GeographicCoordinateSystem | CoordinateSystemFilter.ProjectedCoordinateSystem);
// a geographic transformation is the definition of how to project from one spatial reference to another
IReadOnlyList<GeographicTransformationListEntry> list = GeometryEngine.Instance.GetPredefinedGeographicTransformationList();
// a GeographicTransformationListEntry consists of Name, Wkid, the From SpatialReference Wkid, the To SpatialReference Wkid
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr = SpatialReferences.WGS84;
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(-111, 72),
new Coordinate2D(-108, 68),
new Coordinate2D(-114, 68)
};
Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr);
Polyline subCurve = GeometryEngine.Instance.GetSubCurve(polyline, 0, 5, AsRatioOrLength.AsLength);
// subCurve.PartCount = 1
// subCurve.PointCount = 2
ReadOnlyPointCollection points = subCurve.Points;
// points[0] = -111, 72
// points[1] = -108, 68
subCurve = GeometryEngine.Instance.GetSubCurve(polyline, 0, 0.5, AsRatioOrLength.AsRatio);
// subCurve.PointCount = 3
points = subCurve.Points;
// points[0] = -111, 72
// points[1] = -108, 68
// points[2] = -108.5, 68
List<Coordinate3D> coords3D = new List<Coordinate3D>()
{
new Coordinate3D(0, 0, 0),
new Coordinate3D(0, 1, 1),
new Coordinate3D(1, 1, 2),
new Coordinate3D(1, 0, 3)
};
Polygon polygon = PolygonBuilder.CreatePolygon(coords3D, sr);
subCurve = GeometryEngine.Instance.GetSubCurve3D(polygon, 0, 1, AsRatioOrLength.AsLength);
// subCurve.HasZ = true
points = subCurve.Points;
// points.Count = 2
// points[0] = 0, 0, 0
// points[1] = 0, 0.70710678118654746, 0.70710678118654746
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// determine intersection between two polylines
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0));
Polyline line1 = PolylineBuilder.CreatePolyline(pts);
List<MapPoint> pts2 = new List<MapPoint>();
pts2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0));
pts2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0));
pts2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline line2 = PolylineBuilder.CreatePolyline(pts2);
bool intersects = GeometryEngine.Instance.Intersects(line1, line2); // intersects = true
Geometry g = GeometryEngine.Instance.Intersection(line1, line2, GeometryDimension.esriGeometry0Dimension);
Multipoint resultMultipoint = g as Multipoint;
// result is a multiPoint that intersects at (2,2) and (4,2)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// determine intersection between two polygons
Envelope env1 = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(3.0, 2.0), new Coordinate2D(6.0, 6.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(env1);
Envelope env2 = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(1.0, 1.0), new Coordinate2D(4.0, 4.0));
Polygon poly2 = PolygonBuilder.CreatePolygon(env2);
Polygon polyResult = GeometryEngine.Instance.Intersection(poly1, poly2) as Polygon;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create a polygon
List<Coordinate2D> list2D = new List<Coordinate2D>();
list2D.Add(new Coordinate2D(1.0, 1.0));
list2D.Add(new Coordinate2D(1.0, 2.0));
list2D.Add(new Coordinate2D(2.0, 2.0));
list2D.Add(new Coordinate2D(2.0, 1.0));
Polygon polygon = PolygonBuilder.CreatePolygon(list2D);
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon);
MapPoint pt = GeometryEngine.Instance.LabelPoint(polygon);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0);
MapPoint ptResult = GeometryEngine.Instance.Move(pt, -3.5, 2.5) as MapPoint;
// ptResult is (-2.5, 5.5)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint zPt = MapPointBuilder.CreateMapPoint(1.0, 3.0, 2.0);
MapPoint zPtResult = GeometryEngine.Instance.Move(zPt, 4, 0.25, 0.5) as MapPoint;
// zPtResult is (5.0, 3.25, 2.5);
});
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3, 2, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(4.0, 2.0, 3.0));
Polyline polyline = PolylineBuilder.CreatePolyline(pts);
Geometry g = GeometryEngine.Instance.Move(polyline, 3, 2);
Polyline polylineResult = g as Polyline;
// polylineResult.Points[0] = 4.0, 3.0, 3.0
// polylineResult.Points[1] = 6.0, 5.0, 3.0
// polylineResult.Points[2] = 6.0, 4.0, 3.0
// polylineResult.Points[3] = 7.0, 4.0, 3.0
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
LineSegment line = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 3), MapPointBuilder.CreateMapPoint(5.0, 3.0));
Polyline polyline = PolylineBuilder.CreatePolyline(line);
bool simple = GeometryEngine.Instance.IsSimpleAsFeature(polyline);
// ratio = false
MapPoint pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 0.0, SegmentExtension.NoExtension);
// pt = 1.0, 3.0
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, -1.0, SegmentExtension.NoExtension);
// pt = 1.0, 4.0
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 2.0, SegmentExtension.NoExtension);
// pt = 1.0, 1.0
// ratio = true
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtension.NoExtension);
// pt = 2.5, 3.0
// move past the line
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtension.NoExtension);
// pt = 5.0, 3.0
// move past the line with extension at "to" point
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtension.ExtendEmbeddedAtTo);
// pt = 7.0, 3.0
// negative distance with extension at "from" point
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, -2, false, 0, SegmentExtension.ExtendEmbeddedAtFrom);
// pt = -2.0, 3.0
// ratio = true
pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtension.NoExtension);
// pt = 2.5, 3.0
// line with Z
List<Coordinate3D> coords3D = new List<Coordinate3D> { new Coordinate3D(0, 0, 0), new Coordinate3D(1113195, 1118890, 5000) };
Polyline polylineZ = PolylineBuilder.CreatePolyline(coords3D, SpatialReferences.WebMercator);
// polylineZ.HasZ = true
// ratio = true, no offset
pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 0.5, true, 0, SegmentExtension.NoExtension);
// pt.X = 556597.5
// pt.Y = 559445
// pt.Z = 2500
// ratio = true, past the line with "to" extension, no offset
pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 1.5, true, 0, SegmentExtension.ExtendEmbeddedAtTo);
// pt.X = 1669792.5
// pt.Y = 1678335
// pt.Z = 7500
// ratio = true, negative distance past the line with no extension, no offset
pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, -1.5, true, 0, SegmentExtension.NoExtension);
// pt.X = 0
// pt.Y = 0
// pt.Z = -7500
// polyline with Z but 2d distance = 0
MapPoint pt3 = MapPointBuilder.CreateMapPoint(5, 5, 0);
MapPoint pt4 = MapPointBuilder.CreateMapPoint(5, 5, 10);
List<MapPoint> pts = new List<MapPoint>() { pt3, pt4 };
using (PolylineBuilder pb = new PolylineBuilder())
{
pb.SetEmpty();
pb.AddPart(pts);
pb.HasZ = true;
polyline = pb.ToGeometry();
// polyline.Length3D = 10
// polyline.Length = 0
MapPoint result = GeometryEngine.Instance.MovePointAlongLine(polyline, 2, false, 0, SegmentExtension.NoExtension);
// result = 5, 5, 2
// polyline with length2d = 0 and length3d = 0
MapPoint pt5 = MapPointBuilder.CreateMapPoint(5, 5, 10);
MapPoint pt6 = MapPointBuilder.CreateMapPoint(5, 5, 10);
pts.Clear();
pts.Add(pt5);
pts.Add(pt6);
pb.SetEmpty();
pb.AddPart(pts);
pb.HasZ = true;
polyline = pb.ToGeometry();
// polyline.Length3D = 0
// polyline.Length = 0
result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtension.NoExtension);
// result = 5, 5, 10
result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtension.ExtendEmbeddedAtFrom);
// result = 5, 5, 10
}
// polyline with Z and M
List<MapPoint> inputPoints = new List<MapPoint>()
{
MapPointBuilder.CreateMapPoint(1, 2, 3, 4),
MapPointBuilder.CreateMapPoint(1, 2, 33, 44),
};
Polyline polylineZM = PolylineBuilder.CreatePolyline(inputPoints, SpatialReferences.WGS84);
// polylineZM.HasZ = true
// polylineZM.HasM = true
// ratio = true, no offset
MapPoint pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.5, true, 0, SegmentExtension.NoExtension);
// pointAlong = 1, 2, 18, 24
// ratio = true with offset
pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.2, true, 2.23606797749979, SegmentExtension.NoExtension);
// pointAlong = 1, 2, 9, 12
});
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr = SpatialReferences.WGS84;
MapPoint pt = MapPointBuilder.CreateMapPoint(5, 5, sr);
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(10, 1),
new Coordinate2D(10, -4),
new Coordinate2D(0, -4),
new Coordinate2D(0, 1),
new Coordinate2D(10, 1)
};
Polygon polygon = PolygonBuilder.CreatePolygon(coords);
// find the nearest point in the polygon geomtry to the pt
ProximityResult result = GeometryEngine.Instance.NearestPoint(polygon, pt);
// result.Point = 5, 1
// result.SegmentIndex = 3
// result.PartIndex = 0
// result.PointIndex = null
//result.Distance = 4
//result.RightSide = false
// find the nearest vertex in the polgyon geometry to the pt
result = GeometryEngine.Instance.NearestVertex(polygon, pt);
// result.Point = 10, 1
// result.PointIndex = 0
// result.SegmentIndex = null
// result.PartIndex = 0
// result.Distance = Math.Sqrt(41)
// result.RightSide = false
});
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 1, 1);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2, 2, 2);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(10, 2, 1);
//
// test pt1 to pt2
//
ProximityResult result = GeometryEngine.Instance.NearestPoint3D(pt1, pt2);
// result.Point = 1,1,1
// result.Distance = Math.Sqrt(3)
// result.SegmentIndex = null
// result.PartIndex = 0
// result.PointIndex = 0
// result.RightSide = false
//
// multipoint built from pt1, pt2. should be closer to pt2
//
using (MultipointBuilder mpb = new MultipointBuilder(pt1))
{
mpb.Add(pt2);
mpb.HasZ = true;
Multipoint multipoint = mpb.ToGeometry();
result = GeometryEngine.Instance.NearestPoint3D(multipoint, pt3);
// result.Point = 2, 2, 2
// result.Distance = Math.Sqrt(65)
// result.SegmentIndex = null
// result.PartIndex = 1
// result.PointIndex = 1
// result.RightSide = false
}
});
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.5, 1.5);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75);
MapPoint pt3 = MapPointBuilder.CreateMapPoint(3, 1.5);
MapPoint pt4 = MapPointBuilder.CreateMapPoint(1.5, 2);
//
// point and point overlap
//
bool overlaps = GeometryEngine.Instance.Overlaps(pt1, pt2); // overlaps = false
overlaps = GeometryEngine.Instance.Overlaps(pt1, pt1); // overlaps = false
// Two geometries overlap if the region of their intersection is of the same dimension as the geometries involved and
// is not equivalent to either of the geometries.
List<MapPoint> pts = new List<MapPoint>();
pts.Add(pt1);
pts.Add(pt2);
pts.Add(pt3);
List<MapPoint> pts2 = new List<MapPoint>();
pts2.Add(pt2);
pts2.Add(pt3);
pts2.Add(pt4);
//
// pt and line overlap
//
Polyline polyline = PolylineBuilder.CreatePolyline(pts);
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline); // isSimple = true
overlaps = GeometryEngine.Instance.Overlaps(polyline, pt1); // overlaps = false
//
// line and line
//
Polyline polyline2 = PolylineBuilder.CreatePolyline(pts2);
isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline2); // isSimple = true
overlaps = GeometryEngine.Instance.Overlaps(polyline, polyline2); // overlaps = true
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WGS84);
Geometry result = GeometryEngine.Instance.Project(pt, SpatialReferences.WebMercator);
MapPoint projectedPt = result as MapPoint;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// create the polygon
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84));
Polygon polygon = PolygonBuilder.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 g = GeometryEngine.Instance.Project(polygon, northPole);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Horizontal line segment
List<MapPoint> linePts = new List<MapPoint>();
linePts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84));
linePts.Add(MapPointBuilder.CreateMapPoint(11.0, 1.0, SpatialReferences.WGS84));
Polyline polyline = PolylineBuilder.CreatePolyline(linePts);
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline);
// Don't extent the segment
SegmentExtension extension = SegmentExtension.NoExtension;
// A point on the line segment
MapPoint inPoint = MapPointBuilder.CreateMapPoint(2, 1, SpatialReferences.WGS84);
double distanceAlongCurve, distanceFromCurve;
LeftOrRightSide whichSide;
AsRatioOrLength asRatioOrLength = AsRatioOrLength.AsLength;
MapPoint outPoint = GeometryEngine.Instance.QueryPointAndDistance(polyline, extension, inPoint, asRatioOrLength, out distanceAlongCurve, out distanceFromCurve, out whichSide);
// outPoint = 2, 1
// distanceAlongCurve = 1
// distanceFromCurve = 0
// whichSide = GeometryEngine.Instance.LeftOrRightSide.LeftSide
// Extend infinitely in both directions
extension = SegmentExtension.ExtendTangents;
// A point on the left side
inPoint = MapPointBuilder.CreateMapPoint(16, 6, SpatialReferences.WGS84);
asRatioOrLength = AsRatioOrLength.AsRatio;
outPoint = GeometryEngine.Instance.QueryPointAndDistance(polyline, extension, inPoint, asRatioOrLength, out distanceAlongCurve, out distanceFromCurve, out whichSide);
// outPoint = 16, 1
// distanceAlongCurve = 1.5
// distanceFromCurve = 5
// whichSide = GeometryEngine.Instance.LeftOrRightSide.LeftSide
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// set up some geometries
// points
MapPoint point0 = MapPointBuilder.CreateMapPoint(0, 0, SpatialReferences.WGS84);
MapPoint point1 = MapPointBuilder.CreateMapPoint(1, 1, SpatialReferences.WGS84);
MapPoint point2 = MapPointBuilder.CreateMapPoint(-5, 5, SpatialReferences.WGS84);
// multipoint
List<MapPoint> points = new List<MapPoint>() { point0, point1, point2 };
Multipoint multipoint = MultipointBuilder.CreateMultipoint(points, SpatialReferences.WGS84);
// polygon
List<Coordinate2D> polygonCoords = new List<Coordinate2D>()
{
new Coordinate2D(-10, 0),
new Coordinate2D(0, 10),
new Coordinate2D(10, 0),
new Coordinate2D(-10, 0)
};
Polygon polygon = PolygonBuilder.CreatePolygon(polygonCoords, SpatialReferences.WGS84);
// polylines
Polyline polyline1 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(-9.1, 0.1), new Coordinate2D(0, 9)), SpatialReferences.WGS84);
Polyline polyline2 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(-5, 5), new Coordinate2D(0, 5)), SpatialReferences.WGS84);
Polyline polyline3 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(2.09, -2.04), new Coordinate2D(5, 10)), SpatialReferences.WGS84);
Polyline polyline4 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(10, -5), new Coordinate2D(10, 5)), SpatialReferences.WGS84);
List<Segment> segments = new List<Segment>()
{
LineBuilder.CreateLineSegment(new Coordinate2D(5.05, -2.87), new Coordinate2D(6.35, 1.57)),
LineBuilder.CreateLineSegment(new Coordinate2D(6.35, 1.57), new Coordinate2D(4.13, 2.59)),
LineBuilder.CreateLineSegment(new Coordinate2D(4.13, 2.59), new Coordinate2D(5, 5))
};
Polyline polyline5 = PolylineBuilder.CreatePolyline(segments, SpatialReferences.WGS84);
segments.Add(LineBuilder.CreateLineSegment(new Coordinate2D(5, 5), new Coordinate2D(10, 10)));
Polyline polyline6 = PolylineBuilder.CreatePolyline(segments, SpatialReferences.WGS84);
Polyline polyline7 = PolylineBuilder.CreatePolyline(polyline5);
Polyline polyline8 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(5, 5), new Coordinate2D(10, 10)), SpatialReferences.WGS84);
segments.Clear();
segments.Add(LineBuilder.CreateLineSegment(new Coordinate2D(0.6, 3.5), new Coordinate2D(0.7, 7)));
segments.Add(LineBuilder.CreateLineSegment(new Coordinate2D(0.7, 7), new Coordinate2D(3, 9)));
Polyline polyline9 = PolylineBuilder.CreatePolyline(segments, SpatialReferences.WGS84);
// now do the Related tests
// Interior/Interior Intersects
string scl = "T********";
bool related = GeometryEngine.Instance.Relate(polygon, polyline1, scl); // related = true
related = GeometryEngine.Instance.Relate(point0, point1, scl); // related = false
related = GeometryEngine.Instance.Relate(point0, multipoint, scl); // related = true
related = GeometryEngine.Instance.Relate(multipoint, polygon, scl); // related = true
related = GeometryEngine.Instance.Relate(multipoint, polyline1, scl); // related = false
related = GeometryEngine.Instance.Relate(polyline2, point2, scl); // related = false
related = GeometryEngine.Instance.Relate(point1, polygon, scl); // related = true
// Interior/Boundary Intersects
scl = "*T*******";
related = GeometryEngine.Instance.Relate(polygon, polyline2, scl); // related = true
related = GeometryEngine.Instance.Relate(polygon, polyline3, scl); // related = false
related = GeometryEngine.Instance.Relate(point1, polygon, scl); // related = false
// Boundary/Boundary Interior intersects
scl = "***T*****";
related = GeometryEngine.Instance.Relate(polygon, polyline4, scl); // related = true
// Overlaps Dim1
scl = "1*T***T**";
related = GeometryEngine.Instance.Relate(polygon, polyline5, scl); // related = true
// Crosses Area/Line (LineB crosses PolygonA)
scl = "1020F1102";
related = GeometryEngine.Instance.Relate(polygon, polyline6, scl); // related = false
related = GeometryEngine.Instance.Relate(polygon, polyline9, scl); // related = true
// Boundary/Boundary Touches
scl = "F***T****";
related = GeometryEngine.Instance.Relate(polygon, polyline7, scl); // related = false
related = GeometryEngine.Instance.Relate(polygon, polyline8, scl); // related = true
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate3D> coordsZ = new List<Coordinate3D>()
{
new Coordinate3D(1, 2, double.NaN),
new Coordinate3D(4, 5, 3),
new Coordinate3D(7, 8, double.NaN)
};
Polygon polygon = PolygonBuilder.CreatePolygon(coordsZ);
// polygon.HasZ = true
Polygon polygonZReplaced = GeometryEngine.Instance.ReplaceNaNZs(polygon, -1) as Polygon;
// polygonZReplaced.Points[0].Z = -1
// polygonZReplaced.Points[1].Z = 3
// polygonZReplaced.Points[2].Z = -1
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> list2D = new List<Coordinate2D>();
list2D.Add(new Coordinate2D(1.0, 1.0));
list2D.Add(new Coordinate2D(1.0, 2.0));
list2D.Add(new Coordinate2D(2.0, 2.0));
list2D.Add(new Coordinate2D(2.0, 1.0));
Polygon polygon = PolygonBuilder.CreatePolygon(list2D);
Geometry g = GeometryEngine.Instance.ReverseOrientation(polygon);
Polygon gPolygon = g as Polygon;
// gPolygon.Points[0] = 1.0, 1.0
// gPolygon.Points[1] = 2.0, 1.0
// gPolygon.Points[2] = 2.0, 2.0
// gPolygon.Points[3] = 1.0, 2.0
// gPolygon.Points[4] = 1.0, 1.0
// gPolygon.Area = -1 * polygon.Area
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0);
MapPoint rotatePt = MapPointBuilder.CreateMapPoint(3.0, 3.0);
Geometry result = GeometryEngine.Instance.Rotate(pt, rotatePt, Math.PI / 2);
// result point is (3, 1)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// rotate a polyline
MapPoint fixedPt = MapPointBuilder.CreateMapPoint(3.0, 3.0);
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 5.0));
pts.Add(MapPointBuilder.CreateMapPoint(5, 5));
pts.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0));
Polyline polyline = PolylineBuilder.CreatePolyline(pts);
Polyline rotated = GeometryEngine.Instance.Rotate(polyline, fixedPt, Math.PI / 4) as Polyline; // rotate 45 deg
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate3D> coordsZ = new List<Coordinate3D>()
{
new Coordinate3D(1, 2, 3),
new Coordinate3D(4, 5, 6),
new Coordinate3D(7, 8, double.NaN)
};
Polyline polyline = PolylineBuilder.CreatePolyline(coordsZ);
// polyline.HasZ = true
Polyline polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, -1) as Polyline;
// polylineSetZ.Points[0].Z = -1
// polylineSetZ.Points[1].Z = -1
// polylineSetZ.Points[2].Z = -1
polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, double.NaN) as Polyline;
// polyline.HasZ = true
// polylineSetZ.Points[0].HasZ = true
// polylineSetZ.Points[0].Z = NaN
// polylineSetZ.Points[1].HasZ = true
// polylineSetZ.Points[1].Z = NaN
// polylineSetZ.Points[2].HasZ = true
// polylineSetZ.Points[2].Z = NaN
polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, double.PositiveInfinity) as Polyline;
// polyline.HasZ = true
// polylineSetZ.Points[0].HasZ = true
// polylineSetZ.Points[0].Z = double.PositiveInfinity
// polylineSetZ.Points[1].HasZ = true
// polylineSetZ.Points[1].Z = double.PositiveInfinity
// polylineSetZ.Points[2].HasZ = true
// polylineSetZ.Points[2].Z = double.PositiveInfinity
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// pt
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator);
double area = GeometryEngine.Instance.ShapePreservingArea(pt); // area = 0
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3, 3, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 3.0));
// multipoint
Multipoint mPt = MultipointBuilder.CreateMultipoint(pts);
area = GeometryEngine.Instance.ShapePreservingArea(mPt); // area = 0
// polyline
Polyline polyline = PolylineBuilder.CreatePolyline(pts);
area = GeometryEngine.Instance.ShapePreservingArea(polyline); // area = 0
// polygon
Polygon polygon = PolygonBuilder.CreatePolygon(pts, SpatialReferences.WGS84);
area = GeometryEngine.Instance.ShapePreservingArea(polygon);
polygon = PolygonBuilder.CreatePolygon(pts, SpatialReferences.WebMercator);
area = GeometryEngine.Instance.ShapePreservingArea(polygon);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// pt
MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator);
double len = GeometryEngine.Instance.ShapePreservingLength(pt); // len = 0
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3, 3, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 3.0));
// multipoint
Multipoint mPt = MultipointBuilder.CreateMultipoint(pts);
len = GeometryEngine.Instance.ShapePreservingLength(mPt); // len = 0
// polyline
Polyline polyline = PolylineBuilder.CreatePolyline(pts, SpatialReferences.WGS84);
len = GeometryEngine.Instance.ShapePreservingLength(polyline);
// polygon
Polygon polygon = PolygonBuilder.CreatePolygon(pts, SpatialReferences.WGS84);
len = GeometryEngine.Instance.ShapePreservingLength(polygon);
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3, 3, 3.0));
pts.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 3.0));
MapPoint midPt = MapPointBuilder.CreateMapPoint(1.5, 1.5);
// polyline
Polyline polyline = PolylineBuilder.CreatePolyline(pts);
// polyline.Length = 6
// polyline.Length3D = 0
Geometry g = GeometryEngine.Instance.Scale(polyline, midPt, 0.5, 0.5);
Polyline resultPolyline = g as Polyline;
// resultPolyline.length = 3
// resultPolyline.Points[0] = 1.25, 1.25, 3
// resultPolyline.Points[1] = 1.25, 2.25, 3
// resultPolyline.Points[2] = 2.25, 2.25, 3
// resultPolyline.Points[3] = 2.25, 1.25, 3
// 3D point - scale in 3d
MapPoint midPtZ = MapPointBuilder.CreateMapPoint(1.5, 1.5, 1);
g = GeometryEngine.Instance.Scale(polyline, midPtZ, 0.5, 0.5, 0.25);
resultPolyline = g as Polyline;
// resultPolyline.Points[0] = 1.25, 1.25, 1.5
// resultPolyline.Points[1] = 1.25, 2.25, 1.5
// resultPolyline.Points[2] = 2.25, 2.25, 1.5
// resultPolyline.Points[3] = 2.25, 1.25, 1.5
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
var g1 = PolygonBuilder.FromJson("{\"rings\": [ [ [0, 0], [10, 0], [10, 10], [0, 10] ] ] }");
var result = GeometryEngine.Instance.Area(g1); // result = -100.0 - negative due to wrong ring orientation
// simplify it
var result2 = GeometryEngine.Instance.Area(GeometryEngine.Instance.SimplifyAsFeature(g1, true));
// result2 = 100.0 - positive due to correct ring orientation (clockwise)
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(8, 0),
new Coordinate2D(8, 4),
new Coordinate2D(6, 4),
new Coordinate2D(8, 4),
new Coordinate2D(10, 4),
new Coordinate2D(8, 4)
};
SpatialReference sr = SpatialReferences.WGS84;
// build a line that has segments that cross over each other
Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr);
// polyline.PartCount = 1
ReadOnlyPartCollection parts = polyline.Parts;
ReadOnlySegmentCollection segments = parts[0];
// segments.Count = 5
// note there is a difference between SimpleAsFeature (doesn't detect intersections and overlaps, determines if it's simple enough for gdb storage)
// and SimplifyPolyline (does detect intersections etc)
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline, false);
// isSimple = true
// simplify it (with force = false)
// because it has already been deemed 'simple' (previous IsSimpleAsFeature call) no detection of intersections, overlaps occur
Polyline simplePolyline = GeometryEngine.Instance.SimplifyPolyline(polyline, SimplifyType.Planar, false);
// simplePolyline.PartCount = 1
ReadOnlyPartCollection simpleParts = simplePolyline.Parts;
ReadOnlySegmentCollection simpleSegments = simpleParts[0];
// simpleSegments.Count = 5
// simplify it (with force = true)
// detection of intersections, overlaps occur
simplePolyline = GeometryEngine.Instance.SimplifyPolyline(polyline, SimplifyType.Planar, true);
// simplePolyline.PartCount = 3
simpleParts = simplePolyline.Parts;
simpleSegments = simpleParts[0];
// simpleSegments.Count = 1
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// two disjoint polygons
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8));
Polygon poly1 = PolygonBuilder.CreatePolygon(env);
Envelope env2 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(5, 5));
Polygon poly2 = PolygonBuilder.CreatePolygon(env2);
bool touches = GeometryEngine.Instance.Touches(poly1, poly2); // touches = false
// another polygon that touches the first
Envelope env3 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4));
Polygon poly3 = PolygonBuilder.CreatePolygon(env3);
touches = GeometryEngine.Instance.Touches(poly1, poly3); // touches = true
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Not all of the input points are transformed as some of them are outside of the GCS horizon.
Coordinate2D[] inCoords2D = new Coordinate2D[]
{
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}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// Not all of the input points are transformed as some of them are outside of the GCS horizon.
Coordinate3D[] inCoords3D = new Coordinate3D[]
{
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}
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5);
Geometry geometry = GeometryEngine.Instance.Union(pt1, pt2);
Multipoint multipoint = geometry as Multipoint; // multipoint has point count of 2
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// union two polygons
List<MapPoint> polyPts = new List<MapPoint>();
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0));
polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0));
Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts);
bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly1);
Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8));
Polygon poly2 = PolygonBuilder.CreatePolygon(env);
isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly2);
Geometry g = GeometryEngine.Instance.Union(poly1, poly2);
Polygon polyResult = g as Polygon;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// union many polylines
List<Coordinate2D> coords = new List<Coordinate2D>()
{
new Coordinate2D(1, 2), new Coordinate2D(3, 4), new Coordinate2D(4, 2),
new Coordinate2D(5, 6), new Coordinate2D(7, 8), new Coordinate2D(8, 4),
new Coordinate2D(9, 10), new Coordinate2D(11, 12), new Coordinate2D(12, 8),
new Coordinate2D(10, 8), new Coordinate2D(12, 12), new Coordinate2D(14, 10)
};
// create Disjoint lines
List<Polyline> manyLines = new List<Polyline>
{
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84),
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[3], coords[4], coords[5]}),
PolylineBuilder.CreatePolyline(new List<Coordinate2D>(){coords[6], coords[7], coords[8]})
};
Polyline polyline = GeometryEngine.Instance.Union(manyLines) as Polyline;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// union many polygons
List<Coordinate3D> coordsZ = new List<Coordinate3D>()
{
new Coordinate3D(1, 2, 0), new Coordinate3D(3, 4, 1), new Coordinate3D(4, 2, 2),
new Coordinate3D(5, 6, 3), new Coordinate3D(7, 8, 4), new Coordinate3D(8, 4, 5),
new Coordinate3D(9, 10, 6), new Coordinate3D(11, 12, 7), new Coordinate3D(12, 8, 8),
new Coordinate3D(10, 8, 9), new Coordinate3D(12, 12, 10), new Coordinate3D(14, 10, 11)
};
// create polygons
List<Polygon> manyPolygonsZ = new List<Polygon>
{
PolygonBuilder.CreatePolygon(new List<Coordinate3D>(){coordsZ[0], coordsZ[1], coordsZ[2]}, SpatialReferences.WGS84),
PolygonBuilder.CreatePolygon(new List<Coordinate3D>(){coordsZ[3], coordsZ[4], coordsZ[5]}),
PolygonBuilder.CreatePolygon(new List<Coordinate3D>(){coordsZ[6], coordsZ[7], coordsZ[8]})
};
Polygon polygon = GeometryEngine.Instance.Union(manyPolygonsZ) as Polygon;
});
// methods need to run on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
// build a polygon
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0));
pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0));
pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0));
Polygon poly = PolygonBuilder.CreatePolygon(pts);
// an inner point
MapPoint innerPt = MapPointBuilder.CreateMapPoint(1.5, 1.5);
bool within = GeometryEngine.Instance.Within(innerPt, poly); // within = true
// point on a boundary
within = GeometryEngine.Instance.Within(pts[0], poly); // within = false
// an interior line
MapPoint innerPt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75);
List<MapPoint> innerLinePts = new List<MapPoint>();
innerLinePts.Add(innerPt);
innerLinePts.Add(innerPt2);
Polyline polyline = PolylineBuilder.CreatePolyline(innerLinePts);
within = GeometryEngine.Instance.Within(polyline, poly); // within = true
// a line that crosses the boundary
MapPoint outerPt = MapPointBuilder.CreateMapPoint(3, 1.5);
List<MapPoint> crossingLinePts = new List<MapPoint>();
crossingLinePts.Add(innerPt);
crossingLinePts.Add(outerPt);
polyline = PolylineBuilder.CreatePolyline(crossingLinePts);
within = GeometryEngine.Instance.Within(polyline, poly); // within = false
// polygon in polygon
Envelope env = EnvelopeBuilder.CreateEnvelope(innerPt, innerPt2);
within = GeometryEngine.Instance.Within(env, poly); // within = true
});
// create from wkid
GeographicTransformation gt1478 = ArcGIS.Core.Geometry.GeographicTransformation.Create(1478);
string name = gt1478.Name;
string wkt = gt1478.Wkt;
// create from wkt
GeographicTransformation another_gt1478 = ArcGIS.Core.Geometry.GeographicTransformation.Create(wkt);
// inverse
GeographicTransformation inverse_gt148 = another_gt1478.GetInverse() as GeographicTransformation;
bool isForward = inverse_gt148.IsForward;
// Create singleton from wkid
CompositeGeographicTransformation cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(108272);
int count = cgt.Count; // count = 1
IList<GeographicTransformation> gts = cgt.Transformations as IList<GeographicTransformation>;
gts.Add(ArcGIS.Core.Geometry.GeographicTransformation.Create(1437, false));
count = cgt.Count; // count = 2
// create from an enumeration
CompositeGeographicTransformation another_cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(gts);
GeographicTransformation gt0 = another_cgt[0];
GeographicTransformation gt1 = another_cgt[1];
// get the inverse
CompositeGeographicTransformation inversed_cgt = another_cgt.GetInverse() as CompositeGeographicTransformation;
// inversed_cgt[0] is same as gt1
// inversed_cgt[1] is same as gt0
// methods need to be on the MCT
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 = EnvelopeBuilder.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);
});
// Create from wkid
HVDatumTransformation hv110018 = HVDatumTransformation.Create(110018);
int wkid = hv110018.Wkid;
bool isForward = hv110018.IsForward; // isForward = true
string name = hv110018.Name; // Name = WGS_1984_To_WGS_1984_EGM2008_1x1_Height
// Create from wkt
string wkt = hv110018.Wkt;
HVDatumTransformation hv110018FromWkt = HVDatumTransformation.Create(wkt);
// Get the inverse
HVDatumTransformation hv110018Inverse = hv110018.GetInverse() as HVDatumTransformation;
// hv110018Inverse.IsForward = false
HVDatumTransformation hv1 = HVDatumTransformation.Create(108034);
HVDatumTransformation hv2 = HVDatumTransformation.Create(108033, false);
List<HVDatumTransformation> hvs = new List<HVDatumTransformation>() { hv1, hv2 };
// create from enumeration
CompositeHVDatumTransformation compositehv = CompositeHVDatumTransformation.Create(hvs);
int count = compositehv.Count; // count = 2
List<HVDatumTransformation> transforms = compositehv.Transformations as List<HVDatumTransformation>;
HVDatumTransformation tranform = transforms[0];
// transform.Wkid = 108034
string xml = compositehv.ToXML();
// create from xml
CompositeHVDatumTransformation another_compositehv = CompositeHVDatumTransformation.CreateFromXML(xml);
// get inverse
CompositeHVDatumTransformation inverse_compositehv = another_compositehv.GetInverse() as CompositeHVDatumTransformation;
// methods need to run on the MCT
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 = EnvelopeBuilder.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
});
// methods need to be on the MCT
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr = SpatialReferences.WGS84;
SpatialReference sr2 = SpatialReferences.WebMercator;
// create some points
MapPoint point0 = MapPointBuilder.CreateMapPoint(0, 0, sr);
MapPoint point1 = MapPointBuilder.CreateMapPoint(10, 20, sr);
MapPoint point2 = GeometryEngine.Instance.Project(point1, sr2) as MapPoint;
MapPoint pointEmpty = MapPointBuilder.CreateMapPoint(sr);
MapPoint pointwithNoSR = MapPointBuilder.CreateMapPoint(1, 1);
MapPoint pointZM = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, sr);
// convert to MGRS
ToGeoCoordinateParameter mgrsParam = new ToGeoCoordinateParameter(GeoCoordinateType.MGRS);
string geoCoordString = point0.ToGeoCoordinateString(mgrsParam); // 31NAA6602100000
// use the builder to create a new point from the string. Coordinates are the same
MapPoint outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.x = 0; outPoint.Y = 0
geoCoordString = point1.ToGeoCoordinateString(mgrsParam); // 32QPH0460911794
outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.X = 10; outPoint.Y = 20
// z, m are not transformed
geoCoordString = pointZM.ToGeoCoordinateString(mgrsParam);
outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.X = 1; outPoint.Y = 2; outPoint.Z = Nan; outPoint.M = Nan;
// set the number of digits to 2 and convert
mgrsParam.NumDigits = 2;
geoCoordString = point1.ToGeoCoordinateString(mgrsParam); // 32QPH0512
outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.X = 10; outPoint.Y = 20
// convert to UTM
ToGeoCoordinateParameter utmParam = new ToGeoCoordinateParameter(GeoCoordinateType.UTM);
geoCoordString = point0.ToGeoCoordinateString(utmParam); // 31N 166021 0000000
geoCoordString = point1.ToGeoCoordinateString(utmParam); // 32Q 604609 2211793
// convert to DMS
ToGeoCoordinateParameter dmsParam = new ToGeoCoordinateParameter(GeoCoordinateType.DMS);
geoCoordString = point0.ToGeoCoordinateString(dmsParam); // 00 00 00.00N 000 00 00.00E
geoCoordString = point1.ToGeoCoordinateString(dmsParam); // 20 00 00.00N 010 00 00.00E
// convert to DDM
ToGeoCoordinateParameter ddmParam = new ToGeoCoordinateParameter(GeoCoordinateType.DDM);
geoCoordString = point0.ToGeoCoordinateString(ddmParam); // 00 00.0000N 000 00.0000E
geoCoordString = point1.ToGeoCoordinateString(ddmParam); // 20 00.0000N 010 00.0000E
// convert to DD
ToGeoCoordinateParameter ddParam = new ToGeoCoordinateParameter(GeoCoordinateType.DD);
geoCoordString = point0.ToGeoCoordinateString(ddParam); // 00.000000N 000.000000E
geoCoordString = point1.ToGeoCoordinateString(ddParam); // 20.000000N 010.000000E
});
// convert 45 degrees to radians
double radians = AngularUnit.Degrees.ConvertToRadians(45);
// convert PI to degrees
double degrees = AngularUnit.Degrees.ConvertFromRadians(Math.PI);
try
{
// create a Grad unit
var grad = AngularUnit.CreateAngularUnit(9105);
string unitName = grad.Name; // Grad
double conversionFactor = grad.ConversionFactor; // 0.015708
double radiansPerUnit = grad.RadiansPerUnit;
int factoryCode = grad.FactoryCode; // 9105
// convert 10 grads to degrees
double val = grad.ConvertTo(10, AngularUnit.Degrees);
// convert 10 radians to grads
val = grad.ConvertFromRadians(10);
}
catch (ArgumentException)
{
// ArgumentException will be thrown by CreateAngularUnit in the following scenarios
// - if the factory code used is a non-angular factory code (i.e. it corresponds to square meters which is an area unit code)
// - if the factory code used is invalid (i.e. it is negative or doesn't correspond to any factory code)
}
// custom unit - 3 radians per unit
var myAngularUnit = AngularUnit.CreateAngularUnit("myCustomAngularUnit", 3);
string Name = myAngularUnit.Name; // myCustomAngularUnit
double Factor = myAngularUnit.ConversionFactor; // 3
int Code = myAngularUnit.FactoryCode; // 0 because it is a custom angular unit
double radiansUnit = myAngularUnit.RadiansPerUnit; // 3
// convert 10 degrees to my unit
double converted = AngularUnit.Degrees.ConvertTo(10, myAngularUnit);
// convert it back to degrees
converted = myAngularUnit.ConvertTo(converted, AngularUnit.Degrees);
// convert 1 radian into my angular units
converted = myAngularUnit.ConvertFromRadians(1);
// convert 10 feet to meters
double metres = LinearUnit.Feet.ConvertToMeters(10);
// convert 20 meters to feet
double feet = LinearUnit.Feet.ConvertFromMeters(20.0);
// convert 11 centimeters to millimeters
double mm = LinearUnit.Centimeters.ConvertTo(11, LinearUnit.Millimeters);
// convert the result back to centimeters
double cm = LinearUnit.Millimeters.ConvertTo(mm, LinearUnit.Centimeters);
// convert the millimeter result back to meters
double meters = LinearUnit.Millimeters.ConvertToMeters(mm);
try
{
// create a british 1936 foot
var britFoot = LinearUnit.CreateLinearUnit(9095);
string unitName = britFoot.Name; // "Foot_British_1936"
double conversionFactor = britFoot.ConversionFactor; // 0.3048007491
double metersPerUnit = britFoot.MetersPerUnit;
int factoryCode = britFoot.FactoryCode; // 9095
// convert 10 british 1936 feet to centimeters
double val = britFoot.ConvertTo(10, LinearUnit.Centimeters);
// convert 10 m to british 1936 feet
val = britFoot.ConvertFromMeters(10);
}
catch (ArgumentException)
{
// ArgumentException will be thrown by CreateLinearUnit in the following scenarios
// - if the factory code used is a non-linear factory code (i.e. it corresponds to square meters which is an area unit code)
// - if the factory code used is invalid (i.e. it is negative or doesn't correspond to any factory code)
}
// create a custom linear unit - there are 0.33 meters per myLinearUnit
var myLinearUnit = LinearUnit.CreateLinearUnit("myCustomLinearUnit", 0.33);
string name = myLinearUnit.Name; // myCustomLinearUnit
double convFactor = myLinearUnit.ConversionFactor; // 0.33
int code = myLinearUnit.FactoryCode; // 0 for custom units
double metersUnit = myLinearUnit.MetersPerUnit; // 0.33
string toString = myLinearUnit.ToString(); // same as Name - myCustomLinearUnit
// convert 10 centimeters to myLinearUnit
double convertedVal = LinearUnit.Centimeters.ConvertTo(10, myLinearUnit);
// convert 700 square meters to square feet
double sqFeet = AreaUnit.SquareFeet.ConvertFromSquareMeters(700);
// convert 1100 square feet to square meters
double sqMeters = AreaUnit.SquareFeet.ConvertToSquareMeters(1000);
// convert 2 hectares to acres
double acres = AreaUnit.Hectares.ConvertTo(2, AreaUnit.Acres);
// convert 300 hectares to square miles
double sqMiles = AreaUnit.Hectares.ConvertTo(300, AreaUnit.SquareMiles);
double sqMetersPerUnit = AreaUnit.Acres.SquareMetersPerUnit;
sqMetersPerUnit = AreaUnit.Ares.SquareMetersPerUnit;
sqMetersPerUnit = AreaUnit.Hectares.SquareMetersPerUnit;
sqMetersPerUnit = AreaUnit.SquareKilometers.SquareMetersPerUnit;
sqMetersPerUnit = AreaUnit.SquareMiles.SquareMetersPerUnit;
sqMetersPerUnit = AreaUnit.SquareYards.SquareMetersPerUnit;
Home | API Reference | Requirements | Download | Samples
-
Construct a SpatialReference - from a well-known ID
-
Construct a SpatialReference - from a string
-
Use WGS84 SpatialReference
-
Construct a SpatialReference with a vertical coordinate system - from well-known IDs
-
Construct a SpatialReference with a vertical coordinate system - from a string
-
Construct a SpatialReference with a custom PCS - from a string
-
SpatialReference Properties
-
SpatialReference WKT2
-
Import and Export Spatial Reference
-
Determine grid convergence for a SpatialReference at a given point
-
Datum
-
SpatialReference Datum and datum properties
-
Vector Polar Coordinates
-
Getting vector inclination
-
Getting vector azimuth
-
Vector Operations
-
2D Vector Operations
-
Construct a Polyline - from an enumeration of MapPoints
-
Get the points of a Polyline
-
Get the parts of a Polyline
-
Enumerate the parts of a Polyline
-
Reverse the order of points in a Polyline
-
Get the segments of a Polyline
-
Build a multi-part Polyline
-
StartPoint of a Polyline
-
Construct a Clothoid by Angle
-
Construct a Clothoid by Length
-
Split Polyline at distance
-
Create 3D Polyline and set Z-values while preserving curve segments
-
Construct a Polygon - from an enumeration of MapPoints
-
Construct a Polygon - from an Envelope
-
Get the points of a Polygon
-
Get the parts of a Polygon
-
Enumerate the parts of a Polygon
-
Get the segments of a Polygon
-
Build a donut polygon
-
Create an N-sided regular polygon
-
Get the exterior rings of a polygon - polygon.GetExteriorRing
-
Construct an Envelope
-
Construct an Envelope - from a JSON string
-
Union two Envelopes
-
Intersect two Envelopes
-
Expand an Envelope
-
Update Coordinates of an Envelope
-
Construct a Multipoint - from an enumeration of MapPoints
-
Construct a Multipoint - using MultipointBuilderEx
-
Modify the points of a Multipoint
-
Retrieve Points, 2D Coordinates, 3D Coordinates from a multipoint
-
Construct a Cubic Bezier - from Coordinates
-
Construct a Cubic Bezier - from MapPoints
-
Construct a Cubic Bezier - from an enumeration of MapPoints
-
Cubic Bezier Builder Properties
-
Cubic Bezier Properties
-
Construct a Polyline - from a Cubic Bezier
-
Construct a Circular Arc - using an interior point
-
Construct a Circular Arc - using a chord length and bearing
-
Construct a Circular Arc - using a center point, angle and radius
-
Construct an Elliptic Arc - using a center point and rotation angle
-
Construct a Circular Arc - using a center point and orientation
-
Construct a Circular Arc - using two segments and radius
-
Construct a Circle
-
Construct an Ellipse
-
Elliptic Arc Builder Properties
-
Elliptic Arc Properties
-
Construct GeometryBag
-
Construct GeometryBag - from an enumeration of geometries
-
Construct GeometryBag - from JSON, Xml
-
Construct GeometryBag - adding or inserting an enumeration of geometries
-
Construct Multipatch via Extrusion of Polygon or Polyline
-
Multipatch Properties
-
Construct Multipatch
-
Construct Multipatch via MultipatchBuilderEx
-
Construct Multipatch from another Multipatch
-
Construct Multipatch from a 3D model file
-
Construct 3D special Multipatch shapes
-
Create BasicMaterial
-
Create BasicMaterial with JPEG texture
-
Create BasicMaterial with Uncompressed texture
-
Get the texture image of a multipatch
-
Get the normal coordinate of a multipatch
-
Get the normals of a multipatch
-
Get the material properties of a multipatch
-
Import and Export Geometries to well-known Text
-
Import and Export Geometries to well-known Binary
-
Import and Export Geometries to EsriShape
-
Import and Export Geometries to JSON
-
Import and Export Geometries to XML
-
Create Geographic Transformation
-
Create Composite Geographic Transformation
-
Create Projection Transformation
-
Create HV Datum Transformation
-
Create Composite HV Datum Transformation
-
Determine Transformations
-
AngularUnit - Convert between degrees and radians
-
AngularUnit - Create an AngularUnit with a factory code
-
AngularUnit - Create a Custom AngularUnit