I've inherited an ArcSDE 9.3 Java app that needs some fixing. The basic task is to find the centroid of a polygon retrieved from an SDE geodatabase, but lately it's been returning the 0th vertex instead. This is how the code looks:
SeShape shape = sde.findShape(aPIN); // Get the geometry
SDEPoint sdePoint = null;
try {
if (null != shape) sdePoint = shape.generateLabelPoint(); // Find "centroid"
}
I'm not sure why generateLabelPoint was used -- it seems like a hack which worked for a while but has since stopped. According to this post generateLabelPoint() is the correct way to find the centroid of an SeShape, but our client app is still getting a vertex. We use the same shape shape elsewhere in the code and it works fine, so I don't think it's the geometry that's bad. If I could convert it to an SePolygon there's the centroid() method, but those appear to be two different libraries without any way of translating between the two. Does anyone have any insights on this?
The test shape I'm using is Los Angeles City Hall. In State Plane CA V Feet, the centroid (found via the Polygon.centroid
method in ArcPy) is 6488062.24483722, 1841966.80439753. generateLabelPoint
is returning 6488207.42375, 1842383.41312499, which is a vertex in the corner of the lot. The source of this data is an Oracle 11g database. I have a feeling that the architecture of the database is different than what the 9.3 API is expecting, but still looking into this...