Anyone know how to get the centroid of a "C", or "U" shape like polygon and the point need to be inside the polygon some where near the centre?
in most Arc* products this is referred to as a LabelPoint, so look for some incarnation of that term
ie
The point at which the label is located. The labelPoint is always located within or on a feature.
For the Java API, getLabelPointForPolygon in the GeometryEngine class.
like I said Joshua... they have to look for labelpoint stuff ... grief ![]()
In Feature to Point Tool, choose "INSIDE" as the point location.
I need to use ArcGis Runtime SDK for Java API to code it. Feature to point is not available for me. ![]()
Oops... My mistake. Didn't notice the Space where it's posted.
did you look for labelpoint or not? it would be in a polygon class or methods section for your api
protected boolean determineCentroid(Geometry polygon, Point centroid) {
if (polygon.getType() == Geometry.Type.POLYGON) {
Point tempCentroid;
//Get centroid of the polygon
Envelope env = new Envelope();
polygon.queryEnvelope(env);
tempCentroid = env.getCenter();
//If tempCentroid is within the polygon then centroid is valid, else look for nearest vertex
if (GeometryEngine.within(polygon, tempCentroid, featureServiceTable.getSpatialReference()))
centroid.setXY(tempCentroid.getX(), tempCentroid.getY());
else {
Proximity2DResult proximity2DResult = GeometryEngine.getNearestCoordinate(polygon, tempCentroid, true);
centroid.setXY(proximity2DResult.getCoordinate().getX(), proximity2DResult.getCoordinate().getY());
}
return true;
}
return false;
}I did something as shown above to look for the centroid of a polygon whereby the centre is empty. Although the result it is not really plotted at the "centre" of the polygon but it did solved my problem.