Parameters
- geometry1
- The first geometry.
- geometry2
- The second geometry.
Return Value
The distance between the two input geometries in the same unit as the spatial reference of the input geometries.
Exception | Description |
---|---|
System.ArgumentNullException | Either geometry1 or geometry2 or both are null or empty. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.InvalidOperationException | Incompatible spatial references between the input geometries. |
System.InvalidOperationException | Either geometry1 or geometry2 is not Z-Aware. |
// 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)
Target Platforms: Windows 10, Windows 8.1, Windows 7