-3

Here I want the midpoint of every polyline and add that point to List.

List<IPoint> pList = new ArrayList<IPoint>();
Polyline polyline = null;       
IPoint point = null;
for(int i=0;i<pFeatureLayerList.size();i++)
{
    IFeatureClass pFeatureClass = pFeatureLayerList.get(i).getFeatureClass();
    int numFeatures = pFeatureClass.featureCount(null);     
    if(pFeatureClass.getShapeType()==com.esri.arcgis.geometry.esriGeometryType.esriGeometryPolyline)
    {
        for(int j=0; j<numFeatures; j++)
        {
             IFeature pFeature = pFeatureClass.getFeature(j);
             polyline = (Polyline)pFeature.getShape();
             point = polyline.getCentroidEx();
             pList.add(point);
        }
    }
}
11
  • Do you mean the centre-point of your geometry or the point at the n / 2-position of the corresponding pointlist. If the latter how would you handle multipart-geometries? Commented Mar 31, 2016 at 10:24
  • Here I need Centre-point of line geometry, the output should be point variable.
    – mahesh
    Commented Mar 31, 2016 at 10:27
  • And where is the problem? It should work with that piece of code, as far as I can estimate. Commented Mar 31, 2016 at 10:29
  • 1
    is this a duplicate of: gis.stackexchange.com/questions/187415/… ?
    – nmtoken
    Commented Mar 31, 2016 at 10:33
  • I´d rather do not flag this as a duplicate because the mentioned question seems quite worse posted than this one, making it a duplicate of this one. I think the linked one is going to be deleted soon, so the duplicate would link to nothing. Commented Mar 31, 2016 at 10:35

1 Answer 1

1

Try ICurve.QueryPoint with asRatio = true, and distanceAlongCurve = 0.5:

Copies to outPoint the properties of a point on the curve at a specified distance from the beginning of the curve.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.