Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] Visual Center of Polygon

As it happens this request is quite timely, since I've been looking into labelling placement algorithms (which sounds like a similar requirement to the "visual centre").

There's nothing extra in JTS core yet.  But I have implemented an improved InteriorPoint implementation in the TestBuilder [1].  My intention is to replace the current core InteriorPoint with this, since it's faster and more robust.  One nice addition for labelling is that it supports constraining by a rectangle, to handle partially visible polygons  Actually this needs some further work, to ensure a label point is always found even if the clipped polygon has multiple pieces.

But there is an external port of a routine called PolyLabel, which finds the approximate centre of the Largest Inner Circle [2].  Actually there are two versions - one uses JTS indexing to speed up the computation (and does not appear to have any downside in terms of overhead).  I'm intending to enhance this with support for a rectangle constraint as well.

Feedback on suitability and performance would be welcome.

Martin



On Wed, Oct 24, 2018 at 8:43 AM Eric Angle <eric.lohner.angle@xxxxxxxxx> wrote:
I'm interested in calculating the visual center of a JTS Polygon. If the Polygon is convex, then the getCentroid() method works great. However, if the Polygon is non-convex, getCentroid() can return a Point outside the Polygon. Polygon does have a getInteriorPoint() method, however it doesn't always return what I would consider the visual center.

Is there any capability within JTS to calculate the visual center of a Polygon?

Some Googling suggests that I could triangulate the polygon (which JTS can definitely do) and then somehow use that to calculate the visual center (pole of inaccessibility and skeleton algorithms are terms that pop up).

Thank you for any input you can provide.

Eric Angle
_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.locationtech.org/mailman/listinfo/jts-dev

Back to the top