Parameters
- envelope
- An envelope to test for equality.
Return Value
Value to indicate if the two geometries are equal.
{
// use the convenience builders
Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84);
Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84);
Envelope env3 = env1.Union(env2);
double area = env3.Area;
double depth = env3.Depth;
double height = env3.Height;
double width = env3.Width;
double len = env3.Length;
MapPoint centerPt = env3.Center;
Coordinate2D coord = env3.CenterCoordinate;
bool isEmpty = env3.IsEmpty;
int pointCount = env3.PointCount;
// coordinates
//env3.XMin, env3.XMax, env3.YMin, env3.YMax
//env3.ZMin, env3.ZMax, env3.MMin, env3.MMax
bool isEqual = env1.IsEqual(env2); // false
// or use the builderEx constructors which don't need to run on the MCT.
EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84);
builderEx.Union(env2); // builder is updated to the result
depth = builderEx.Depth;
height = builderEx.Height;
width = builderEx.Width;
centerPt = builderEx.Center;
coord = builderEx.CenterCoordinate;
isEmpty = builderEx.IsEmpty;
env3 = builderEx.ToGeometry() as Envelope;
}
{
// methods need to be on the MCT
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
SpatialReference sr4267 = SpatialReferenceBuilder.CreateSpatialReference(4267);
SpatialReference sr4326 = SpatialReferences.WGS84;
SpatialReference sr3857 = SpatialReferences.WebMercator;
// Create transformation from 4267 -> 3857
ProjectionTransformation projTransFromSRs =
ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr4267, sr3857);
// create an envelope
Envelope env = EnvelopeBuilderEx.CreateEnvelope(
new Coordinate2D(2, 2), new Coordinate2D(3, 3), sr4267);
// Project with one geo transform 4267 -> 3857
Envelope projectedEnvEx = GeometryEngine.Instance.ProjectEx(
env, projTransFromSRs) as Envelope;
// Create inverse transformation, 3857 -> 4267
ProjectionTransformation projTransFromSRsInverse =
ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr3857, sr4267);
// Project the projected envelope back using the inverse transformation
Envelope projectedEnvBack =
GeometryEngine.Instance.ProjectEx(
projectedEnvEx, projTransFromSRsInverse) as Envelope;
bool isEqual = env.IsEqual(projectedEnvBack);
});
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)