1

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...

2
  • 1
    Can you dump the coordinates and the location of the calculated label into the question? What is the source of the shape? Can you select the centroid directly from the database?
    – Vince
    Commented Nov 5, 2013 at 20:08
  • Vince, I've edited the question with some more details. Thanks in advance.
    – bertday
    Commented Nov 6, 2013 at 16:55

1 Answer 1

0

This is how you convert an SeShape to SeGeometry:

SeGeometry geometry = shape.toSeGeometry();

From there you can presumably cast it to the right geometry type:

if (geometry.geometryType().equals("Polygon") {
    SePolygon polygon = (SePolygon)geometry;
}

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.