ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Geometry Namespace / MapPointBuilderEx Class / MapPointBuilderEx Constructor / MapPointBuilderEx Constructor(Double,Double,SpatialReference)
The X-value.
The Y-value.
(Optional) The SpatialReference. The default value is null.
Example

In This Topic
    MapPointBuilderEx Constructor(Double,Double,SpatialReference)
    In This Topic
    Creates a new MapPointBuilderEx instance with the given X and Y coordinates.
    Syntax
    public MapPointBuilderEx( 
       double x,
       double y,
       SpatialReference spatialReference
    )
    Public Function New( _
       ByVal x As Double, _
       ByVal y As Double, _
       Optional ByVal spatialReference As SpatialReference _
    )

    Parameters

    x
    The X-value.
    y
    The Y-value.
    spatialReference
    (Optional) The SpatialReference. The default value is null.
    Remarks
    No attribute awareness properties are set.
    Example
    Construct a MapPoint
    // Use a builder convenience method or use a builder constructor.
    
    // Create a 2D point without a spatial reference
    MapPoint point2D = MapPointBuilderEx.CreateMapPoint(1, 2);
    SpatialReference sr = point2D.SpatialReference; // sr = null
    bool hasZ = point2D.HasZ;   // hasZ = false
    bool hasM = point2D.HasM;   // hasM = false
    bool hasID = point2D.HasID; // hasID = false
    double x = point2D.X;   // x = 1
    double y = point2D.Y;   // y = 2
    double z = point2D.Z;   // z = 0 default value
    double m = point2D.M;   // m is NaN default value
    double id = point2D.ID; // id = 0 default value
    
    // Or use a builderEx which doesn't need to run on the MCT. 
    MapPointBuilderEx builderEx = new MapPointBuilderEx(1, 2);
    
    // do something with the builder
    builderEx.Y = 3;
    point2D = builderEx.ToGeometry();
    sr = point2D.SpatialReference; // sr = null
    hasZ = point2D.HasZ;   // hasZ = false
    hasM = point2D.HasM;   // hasM = false
    hasID = point2D.HasID; // hasID = false
    x = point2D.X;   // x = 1
    y = point2D.Y;   // y = 3
    z = point2D.Z;   // z = 0 default value
    m = point2D.M;   // m is NaN default value
    id = point2D.ID; // id = 0 default value
    
    // Create a 2D point with a spatial reference
    SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(4269);
    point2D = MapPointBuilderEx.CreateMapPoint(1, 2, spatialReference);
    sr = point2D.SpatialReference; // sr != null
    int wkid = sr.Wkid; // wkid = 4269
    
    // Or use a builder
    builderEx = new MapPointBuilderEx(1, 2, spatialReference);
    
    // Do something with the builder
    builderEx.SetValues(3, 5);
    point2D = builderEx.ToGeometry();
    sr = point2D.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 4269
    x = point2D.X; // x = 3
    y = point2D.Y; // y = 5
    
    // Change the spatial reference of the builder
    builderEx.SpatialReference = SpatialReferences.WGS84;
    point2D = builderEx.ToGeometry();
    sr = point2D.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 4326
    x = point2D.X; // x = 3
    y = point2D.Y; // y = 5
    
    // Create a 3D point with M
    MapPoint pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4);
    sr = pointZM.SpatialReference; // sr = null
    hasZ = pointZM.HasZ;   // hasZ = true
    hasM = pointZM.HasM;   // hasM = true
    hasID = pointZM.HasID; // hasID = false
    x = pointZM.X;   // x = 1
    y = pointZM.Y;   // y = 2
    z = pointZM.Z;   // z = 3
    m = pointZM.M;   // m = 4
    id = pointZM.ID; // id = 0 default value
    
    // Create a 3D point with M and a spatial reference
    pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, spatialReference);
    sr = pointZM.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 4269
    
    // Create a point from another point in three ways
    MapPoint clone = pointZM.Clone() as MapPoint; // Has the same values including the spatial reference as pointZM
    MapPoint anotherZM = MapPointBuilderEx.CreateMapPoint(pointZM);  // Has the same values including the spatial reference as pointZM
            
    builderEx = new MapPointBuilderEx(pointZM); // Has the same values including the spatial reference as pointZM
    // Do something with the builder
    builderEx.HasM = false;
    builderEx.ID = 7; // Setting the id also sets HasID = true
    MapPoint pointZId = builderEx.ToGeometry();
    sr = pointZId.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 4269
    hasZ = pointZId.HasZ;   // hasZ = true
    hasM = pointZId.HasM;   // hasM = false
    hasID = pointZId.HasID; // hasID = true
    x = pointZId.X;   // x = 1
    y = pointZId.Y;   // y = 2
    z = pointZId.Z;   // z = 3
    m = pointZId.M;   // m is NaN, default value
    id = pointZId.ID; // id = 7
    
    // Create a point with Z, M, and ID-values
    MapPoint pointZMId = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 5, spatialReference);
    sr = pointZMId.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 4269
    hasZ = pointZMId.HasZ;   // hasZ = true
    hasM = pointZMId.HasM;   // hasM = true
    hasID = pointZMId.HasID; // hasID = true
    x = pointZMId.X;   // x = 1
    y = pointZMId.Y;   // y = 2
    z = pointZMId.Z;   // z = 3
    m = pointZMId.M;   // m = 4
    id = pointZMId.ID; // id = 5
    
    // Pick and choose which attributes to include
    MapPoint point = MapPointBuilderEx.CreateMapPoint(1, 2, false, 3, true, 4, true, 5);
    sr = point.SpatialReference; // sr = null
    hasZ = point.HasZ;   // hasZ = false
    hasM = point.HasM;   // hasM = true
    hasID = point.HasID; // hasID = true
    x = point.X;   // x = 1
    y = point.Y;   // y = 2
    z = point.Z;   // z = 0, default value
    m = point.M;   // m = 4
    id = point.ID; // id = 5
    
    // Or use a builder
    builderEx = new(1, 2, true, 3, false, 4, true, 5);
    // Do something with the builder
    builderEx.ID = 7;
    builderEx.SpatialReference = SpatialReferences.WGS84;
    point = builderEx.ToGeometry();
    sr = point.SpatialReference; // sr != null
    wkid = sr.Wkid; // wkid = 4326
    hasZ = point.HasZ;   // hasZ = true
    hasM = point.HasM;   // hasM = false
    hasID = point.HasID; // hasID = true
    x = point.X;   // x = 1
    y = point.Y;   // y = 2
    z = point.Z;   // z = 0, default value
    m = point.M;   // m is NaN, default value
    id = point.ID; // id = 7
    
    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
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also