ArcObjects Library Reference  (Geometry)    

IPointCollection.UpdatePoint Method

Changes the ith vertex or point to be a copy of the input point.

[Visual Basic 6.0]
Sub UpdatePoint(
    ByVal i As Long, _
    ByVal p As IPoint _
)
[Visual Basic .NET]
Public Sub UpdatePoint ( _
    ByVal i As Integer, _
    ByVal p As IPoint _
)
[C#]
public void UpdatePoint (
    int i,
    IPoint p
);
[Java]
public void updatePoint (
    int i,
    IPoint p
)
throws
    IOException,
    AutomationException
[C++]
HRESULT UpdatePoint(
  long i,
  IPoint* p
);
[C++]

Parameters

i

  i is a parameter of type long

p

  p is a parameter of type IPoint

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Updates the ith Point with a copy of the input Point.  Update replaces the reference to the indexed point with a reference to the input Point.

Remarks

For efficiency UpdatePoint does not check if the spatial reference of the input point is equal to the spatial reference of the PointCollection. Please make sure that the spatial reference of the input point is equal to the spatial reference of the PointCollection before you pass the point in.

Note : You can also explicitly check the spatial reference by using IClone::IsEqual

[C#]
            //Point to use in the UpdatePoint call
            IPoint point = new PointClass() as IPoint;
            //Point Collection to UpdatePoint
            IPointCollection ptCollection = new MultipointClass() as IPointCollection;
            //Set the spatial reference of the Point Collection usually it has already been set
            ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass() as ISpatialReferenceFactory;
            IGeometry geom = ptCollection as IGeometry;
            geom.SpatialReference = srFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983N_AmericaLambert);
            ISpatialReference sr = geom.SpatialReference;
            //This line does nothing if the two spatial references are already equal 
            point.Project(sr);
            //The integer is the number of point in the point collection you are updating 
            ptCollection.UpdatePoint(1, point);

[Visual Basic 6.0]

'How to check spatial refernce efficiently

Dim pointIn As IPoint
Dim ptColl As IPointCollection
Dim pSpatialReferenceOfCollection As ISpatialReference
'....
'The next line will not do anything if the two projections are equal
pointIn.Project pSpatialReferenceOfCollection
ptColl.UpdatePoint 1, pointIn

See Also

IPointCollection Interface

 


Feedback Send feedback on this page