ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Geometry Namespace / MapPoint Class / IsEqual Method / IsEqual(MapPoint) Method
A MapPoint to test for equality.
Example

In This Topic
    IsEqual(MapPoint) Method
    In This Topic
    Compares two MapPoint for equality. This will check the SpatialReference, attribute awareness (HasZ, HasM, HasID), and coordinates for a match.
    Syntax
    public bool IsEqual( 
       MapPoint mapPoint
    )
    Public Overloads Function IsEqual( _
       ByVal mapPoint As MapPoint _
    ) As Boolean

    Parameters

    mapPoint
    A MapPoint to test for equality.

    Return Value

    True if the two geometries are equal.
    Example
    MapPoint Builder Properties
    // MapPointBuilderEx constructors can run on any thread.
    
    MapPoint point1 = null;
    MapPoint point2 = null;
    
    SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(54004);
            
    MapPointBuilderEx mapPointBuilder = new MapPointBuilderEx(100, 200, spatialReference);
    SpatialReference sr = mapPointBuilder.SpatialReference; // sr != null
    int wkid = sr.Wkid; // wkid = 54004
    bool hasZ = mapPointBuilder.HasZ;   // hasZ = false
    bool hasM = mapPointBuilder.HasM;   // hasM = false
    bool hasID = mapPointBuilder.HasID; // hasID = false
    bool isEmpty = mapPointBuilder.IsEmpty; // isEmpty = false
    double x = mapPointBuilder.X;   // x = 100
    double y = mapPointBuilder.Y;   // y = 200
    double z = mapPointBuilder.Z;   // z = 0, default value
    double m = mapPointBuilder.M;   // m is NaN, default value
    double id = mapPointBuilder.ID; // id = 0, default value
    
    // Do something with the builder
    mapPointBuilder.Z = 12; // Setting the z-value automatically sets HasZ property to true
    
    point1 = mapPointBuilder.ToGeometry();
    sr = point1.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 54004
    hasZ = point1.HasZ;   // hasZ = true
    hasM = point1.HasM;   // hasM = false
    hasID = point1.HasID; // hasID = false
    x = point1.X;   // x = 100
    y = point1.Y;   // y = 200
    z = point1.Z;   // z = 12
    m = point1.M;   // m is NaN, default value
    id = point1.ID; // id = 0, default value
    
    // Change some of the builder properties
    mapPointBuilder.SetValues(11, 22);
    mapPointBuilder.HasZ = false;
    mapPointBuilder.HasM = true;
    mapPointBuilder.M = 44;
            
    // Create another point
    point2 = mapPointBuilder.ToGeometry();
    
    bool isEqual = point1.IsEqual(point2); // isEqual = false
    
    // Set the builder to empty
    // Sets X and Y to NaN. Sets other attributes to the default values.
    // Does not change the attribute awareness.
    mapPointBuilder.SetEmpty();
    
    MapPoint point3 = mapPointBuilder.ToGeometry();
    sr = point3.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 54004
    hasZ = point3.HasZ;        // hasZ = false
    hasM = point3.HasM;        // hasM = true
    hasID = point3.HasID;      // hasID = false
    isEmpty = point3.IsEmpty;  // isEmpty = true
    x = point3.X;              // x is NaN
    y = point3.Y;              // y is NaN
    z = point3.Z;              // z = 0, default value
    m = point3.M;              // m is NaN, default value
    id = point3.ID;            // ID = 0, default value
    
    // Create a builder from a point
    mapPointBuilder = new MapPointBuilderEx(point2); // point1 = (11, 22, 0, 44, 0)
    sr = mapPointBuilder.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 54004
    hasZ = mapPointBuilder.HasZ;        // hasZ = false
    hasM = mapPointBuilder.HasM;        // hasM = true
    hasID = mapPointBuilder.HasID;      // hasID = false
    isEmpty = mapPointBuilder.IsEmpty;  // isEmpty = false
    x = mapPointBuilder.X;              // x = 11
    y = mapPointBuilder.Y;              // y = 22
    z = mapPointBuilder.Z;              // z = 0, default value
    m = mapPointBuilder.M;              // m = 44
    id = mapPointBuilder.ID;            // ID = 0, default value
    
    // Setting attribute values automatically sets the corresponding flag to true
    mapPointBuilder.Z = 150;
    mapPointBuilder.ID = 2;
    
    // Remove the spatial reference
    mapPointBuilder.SpatialReference = null;
            
    MapPoint point4 = mapPointBuilder.ToGeometry() as MapPoint;
    sr = point3.SpatialReference; // sr = null
    hasZ = point3.HasZ;        // hasZ = true
    hasM = point3.HasM;        // hasM = true
    hasID = point3.HasID;      // hasID = true
    isEmpty = point3.IsEmpty;  // isEmpty = false
    x = point3.X;              // x = 11
    y = point3.Y;              // y = 22
    z = point3.Z;              // z = 150
    m = point3.M;              // m = 44
    id = point3.ID;            // ID = 2
    
    MapPoint IsEqual
    MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 5);
    int ID = pt1.ID;           // ID = 5
    bool hasID = pt1.HasID;     // hasID = true
    
    MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 0);
    ID = pt2.ID;        // ID = 0
    hasID = pt2.HasID;  // hasID = true
    
    MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4);
    ID = pt3.ID;          // ID = 0
    hasID = pt3.HasID;    // hasID = false
    
    MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 44);
    ID = pt4.ID;          // ID = 0
    hasID = pt4.HasID;    // hasID = false
    bool hasM = pt4.HasM; // hasM = true
    
    MapPoint pt5 = MapPointBuilderEx.CreateMapPoint(1, 2, 3);
    ID = pt5.ID;          // ID = 0
    hasID = pt5.HasID;    // hasID = false
    hasM = pt5.HasM;      // hasM = false
    
    bool isEqual = pt1.IsEqual(pt2);   // isEqual = false, different IDs
    isEqual = pt2.IsEqual(pt3);        // isEqual = false, HasId is different
    isEqual = pt4.IsEqual(pt3);        // isEqual = false, different Ms
    isEqual = pt1.IsEqual(pt5);        // isEqual = false, pt has M, id but pt5 does not.  
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also