IPoint Interface

Provides access to members that define two dimensional points.

Description

A Point is a zero-dimensional object that represents a specific (X, Y) location in a the two-dimensional XY-Plane. A Point may also have Z, M, and ID attributes associated with it. Existence of attributes does not alter the dimensionality of a Point nor does it alter geometric calculations performed on the Point. Attributes are only considered for attribute calculations when the Point is ZAware, MAware, or PointIDAware. Points may be constructed using PutCoords, individually setting the X and Y properties, or using the IConstructPoint interface.

Members

Name Description
Method Compare Compares X, Y, M, Z, ID of this point (in that order) with that of the other point. Returns -1 if this point's value is less, 1 if greater, and 0 otherwise. Useful for sorting a group of points.
Method ConstrainAngle Projects this point to the point on the infinite line defined by anchor and angle (in radians). If allowOpposite is true, then the point can also snap to angle + pi radians.
Method ConstrainDistance Projects this point to the perimeter of the circle defined by radius and anchor.
Read-only property Dimension The topological dimension of this geometry.
Read-only property Envelope Creates a copy of this geometry's envelope and returns it.
Read-only property GeometryType The type of this geometry.
Method GeoNormalize Shifts longitudes, if need be, into a continuous range of 360 degrees.
Method GeoNormalizeFromLongitude Normalizes longitudes into a continuous range containing the longitude. This method is obsolete.
Read/write property ID The Point ID attribute.
Read-only property IsEmpty Indicates whether this geometry contains any points.
Read/write property M The measure attribute.
Method Project Projects this geometry into a new spatial reference.
Method PutCoords Sets the X and Y coordinates.
Method QueryCoords Returns the X and Y coordinates.
Method QueryEnvelope Copies this geometry's envelope properties into the specified envelope.
Method SetEmpty Removes all points from this geometry.
Method SnapToSpatialReference Moves points of this geometry so that they can be represented in the precision of the geometry's associated spatial reference system.
Read/write property SpatialReference The spatial reference associated with this geometry.
Read/write property VertexAttribute Any attribute (coordinate), except X or Y.
Read/write property X The X coordinate.
Read/write property Y The Y coordinate.
Read/write property Z The Z attribute.

IPoint.Compare Method

Compares X, Y, M, Z, ID of this point (in that order) with that of the other point. Returns -1 if this point's value is less, 1 if greater, and 0 otherwise. Useful for sorting a group of points.

Public Function Compare ( _
    ByVal otherPoint As IPoint _
) As Integer
public int Compare (
    IPoint otherPoint
);

Description

Compares the location and attributes of the base point with those of the input point to determine a relative ordering of the two points. Compares point properties in the following order: X, Y, M, Z, and ID. Returns 1 if the base point possesses the first greater property, and returns -1 if the input point possesses the first greater property. This method takes the resolution of the spatial reference into account.

Remarks

The method should not be used in order to determine equality of two points. Use IRelationalOperator::Equals or IClone::IsEqual. At 9.2, this method uses the resolution property of the point's spatial reference in order to determine (x,y) coordinate ordering. At 9.1, an untoleranced (exact) comparison was performed.

IPoint.ConstrainAngle Method

Projects this point to the point on the infinite line defined by anchor and angle (in radians). If allowOpposite is true, then the point can also snap to angle + pi radians.

Public Sub ConstrainAngle ( _
    ByVal constraintAngle As Double, _
    ByVal anchor As IPoint, _
    ByVal allowOpposite As Boolean _
)
public void ConstrainAngle (
    double constraintAngle,
    IPoint anchor,
    bool allowOpposite
);

Description

Projects the base Point to to the nearest point on the line defined by an input anchor point and input angle. ConstrainAngle is used by the editor to force a newly created Point to be on the line between a fixed point and a specified angle.

Remarks

ContrainAngle

//Finds the closes point to line from (0,0) with angles

//defined by steps of pi/4 (Note all angles in radians)

private void ConstrainAngle()

 {

   IPoint point = new PointClass();

   point.PutCoords(0, 0);





  IPoint newPoint = new PointClass();

   newPoint.PutCoords(1,0);



   for (int i = 0; i < 8; i++)

   {

     newPoint.ConstrainAngle(i * Math.PI / 4, point, true);

    System.Windows.Forms.MessageBox.Show(newPoint.X + ", " + newPoint.Y);

   }

 }
'Finds the closes point to line from (0,0) with angles

     'defined by steps of pi/4 (Note all angles in radians)

     '

     Sub TestConstrainAngle()

         Dim pApoint As ESRI.ArcGIS.Geometry.IPoint

         Dim pNpoint As ESRI.ArcGIS.Geometry.IPoint

         Dim pi As Double

         Dim dAngle As Double

         Dim i As Long

        pApoint = New ESRI.ArcGIS.Geometry.Point

         pi = 4 * Math.Atan(1)

         dAngle = 0

         pApoint.PutCoords(0, 0)

        pNpoint = New ESRI.ArcGIS.Geometry.Point

        For i = 0 To 7

             pNpoint.PutCoords(1, 0)

             dAngle = i * pi / 4

             pNpoint.ConstrainAngle(dAngle, pApoint, True)

             MsgBox("angle = " & i & "*pi/4" & vbCrLf & pNpoint.X & "," & pNpoint.Y)

         Next i

     End Sub

IPoint.ConstrainDistance Method

Projects this point to the perimeter of the circle defined by radius and anchor.

Public Sub ConstrainDistance ( _
    ByVal constraintRadius As Double, _
    ByVal anchor As IPoint _
)
public void ConstrainDistance (
    double constraintRadius,
    IPoint anchor
);

Description

Sets the base Point to a location a specified distance from the input anchor Point along the line between the two points. ConstrainDistance is used by the editor to fix the distance between an anchor point and an input Point. Thus, the input to be created must lie on the circumference defined by the anchor point and the fixed distance radius with the angle determined by the user.

Remarks

ConstrainDistance

private void ConstrainDistance()

{

  IPoint point = new PointClass();

  point.PutCoords(0, 0);

  IPoint newPoint = new PointClass();

  newPoint.PutCoords(2,2);

  newPoint.ConstrainDistance(Math.PI, point);

System.Windows.Forms.MessageBox.Show(newPoint.X + ", " + newPoint.Y);}
Public Sub ConstrainDistanceTest()

        Dim pPoint As ESRI.ArcGIS.Geometry.IPoint

        Dim pNPoint As ESRI.ArcGIS.Geometry.IPoint

        Dim dRadius As Double

        pPoint = New ESRI.ArcGIS.Geometry.Point

        pPoint.PutCoords(0, 0)

        pNPoint = New ESRI.ArcGIS.Geometry.Point

        pNPoint.PutCoords(2, 2)

        dRadius = 1.4142135623731

        pNPoint.ConstrainDistance(dRadius, pPoint)

        MsgBox("Radius = " & dRadius & " x,y = " & pNPoint.X & "," & pNPoint.Y)

    End Sub

IPoint.ID Property

The Point ID attribute.

Public Property ID As Integer
public int ID {get; set;}

Description

Returns or Sets the ID attribute of the Point. The ID attribute is a numeric label, but does not serve any computational purposes. The Point must be PointIDAware to make use of the ID attribute.

Remarks

To set the ID value for a point you need to define it to be ID aware.

The following C# code explains how to do it:    

IPoint pnt = new PointClass();

pnt.PutCoords(100, 100);

 

IPointIDAware pntIDA = pnt as IPointIDAware;

pntIDA.PointIDAware = true;

pnt.ID = 10;

IPoint.M Property

The measure attribute.

Public Property M As Double
public double M {get; set;}

Description

Returns or Sets the M attribute on the Point. The M attribute refers to the Point's measure (similar to an address). The point must be MAware to make use of the M attribute.

Remarks

// The following example shows how to set the x,y,z,m properties

    // for a point. Note that you need to tell the point to be

    // M- and Z-aware.

    public void DisplayCoordinates()

    {

        IPoint point = new PointClass();

        point.PutCoords(100, 100);

        IMAware mAware = point as IMAware;

        mAware.MAware = true;

        IZAware zAware = point as IZAware;

        zAware.ZAware = true;

        point.Z = 50;

        point.M = 10;

        System.Windows.Forms.MessageBox.Show(point.X + "," + point.Y + "," + point.Z + "," + point.M);

    }

IPoint.PutCoords Method

Sets the X and Y coordinates.

Public Sub PutCoords ( _
    ByVal X As Double, _
    ByVal Y As Double _
)
public void PutCoords (
    double X,
    double Y
);

Remarks

Use the IPoint::PutCoordsmethod to set the X,Y coordinates for a Point. The coordinates can also be set by updating the Xand Y properties for the point.

private void DefinePoint()

    {

        IPoint point = new PointClass();

        point.PutCoords(0, 0);

        System.Windows.Forms.MessageBox.Show(point.X + ", " + point.Y);

    }

IPoint.QueryCoords Method

Returns the X and Y coordinates.

Public Sub QueryCoords ( _
    ByRef X As Double, _
    ByRef Y As Double _
)
public void QueryCoords (
    ref double X,
    ref double Y
);
The following C# code shows how the IPoint interface exposes a method to get the X,Y values of a Point:

double x, y;

pnt.QueryCoords(out x, out y);

IPoint.VertexAttribute Property

Any attribute (coordinate), except X or Y.

Public Function get_VertexAttribute ( _
    ByVal attributeType As esriGeometryAttributes _
) As Double
Public Sub set_VertexAttribute ( _
    ByVal attributeType As esriGeometryAttributes, _
    ByVal attributeValue As Double _
)
public double get_VertexAttribute (
    esriGeometryAttributes attributeType
);
public void set_VertexAttribute (
    esriGeometryAttributes attributeType,
    double attributeValue
);

Description

Used to Get or Set a specific attribute (Z, M, or ID).

IPoint.X Property

The X coordinate.

Public Property X As Double
public double X {get; set;}

Description

Returns and Sets the X coordinate of the Point. The X coordinate is the horizontal position of the point.

// The following example shows how to set the x,y,z,m properties

    // for a point. Note that you need to tell the point to be

    // M- and Z-aware.

    public void DisplayCoordinates()

    {

        IPoint point = new PointClass();

        point.PutCoords(100, 100);

        IMAware mAware = point as IMAware;

        mAware.MAware = true;

        IZAware zAware = point as IZAware;

        zAware.ZAware = true;

        point.Z = 50;

        point.M = 10;

        System.Windows.Forms.MessageBox.Show(point.X + "," + point.Y + "," + point.Z + "," + point.M);

    }

IPoint.Y Property

The Y coordinate.

Public Property Y As Double
public double Y {get; set;}

Description

Returns and Sets the Y coordinate of the Point. The Y coordinate is the vertical position of the point.

Remarks

Point Y Coord Example

// The following example shows how to set the x,y,z,m properties

    // for a point. Note that you need to tell the point to be

    // M- and Z-aware.

    public void DisplayCoordinates()

    {

        IPoint point = new PointClass();

        point.PutCoords(100, 100);

        IMAware mAware = point as IMAware;

        mAware.MAware = true;

        IZAware zAware = point as IZAware;

        zAware.ZAware = true;

        point.Z = 50;

        point.M = 10;

        System.Windows.Forms.MessageBox.Show(point.X + "," + point.Y + "," + point.Z + "," + point.M);

    }

IPoint.Z Property

The Z attribute.

Public Property Z As Double
public double Z {get; set;}

Description

Returns or Sets the Z attribute on the Point. Although the Z attribute refers to the 3-Dimensional depth of the point, the point still spatially exists in only 2-Dimensions with a Z attribute. Further, the point must be ZAware to make use of the Z attribute.

// The following example shows how to set the x,y,z,m properties

    // for a point. Note that you need to tell the point to be

    // M- and Z-aware.

    public void DisplayCoordinates()

    {

        IPoint point = new PointClass();

        point.PutCoords(100, 100);

        IMAware mAware = point as IMAware;

        mAware.MAware = true;

        IZAware zAware = point as IZAware;

        zAware.ZAware = true;

        point.Z = 50;

        point.M = 10;

        System.Windows.Forms.MessageBox.Show(point.X + "," + point.Y + "," + point.Z + "," + point.M);

    }

Inherited Interfaces

Interfaces Description
IGeometry Provides access to members that describe properties and behavior of all geometric objects.

Classes that implement IPoint

Classes Description
Point A two dimensional point, optionally with measure, height, and ID attributes.

Remarks

Point Example

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.