[GEOT-5502] First implementation of Pole of inaccessibility. #1287

Merged
merged 3 commits into from Aug 28, 2016

Conversation

Projects
None yet
4 participants
@chau-intl
Contributor

chau-intl commented Aug 27, 2016

Vladimir Agafonkin came up with an algorithm for calculating poles of inaccessibility to give good labelling points for odd shaped polygons.

See https://www.mapbox.com/blog/polygon-center/ for a discussion of algorithm

This implements this functionality and makes it available as a function so it could be added to GeoServer SLD files.

+ *
+ */
+public class PolyLabeller {
+ private static final Logger LOGGER = Logging.getLogger(PolyLabeller.class.getName());

This comment has been minimized.

@smithkm

smithkm Aug 27, 2016

Member

Using tabs, should be spaces.

@smithkm

smithkm Aug 27, 2016

Member

Using tabs, should be spaces.

+ super(Text.text("PolygonLabelProcess"), "polygonlabelprocess", PolygonLabelProcess.class);
+ }
+
+ @DescribeProcess(title = "Polygon label process", description = "Calculate the the Pole of accessibility, the most distant interior point i a polygon.")

This comment has been minimized.

@smithkm

smithkm Aug 27, 2016

Member

Typo, 'i a polygon' Should be 'in'?

@smithkm

smithkm Aug 27, 2016

Member

Typo, 'i a polygon' Should be 'in'?

+ // outside)
+ private double pointToPolygonDist(Point point, MultiPolygon polygon) {
+ boolean inside = polygon.contains(point);
+/* double minDistSq = Double.POSITIVE_INFINITY;

This comment has been minimized.

@smithkm

smithkm Aug 27, 2016

Member

Best to remove commented out code before submitting. If it's really important that it be retained, use a comment to explain why.

@smithkm

smithkm Aug 27, 2016

Member

Best to remove commented out code before submitting. If it's really important that it be retained, use a comment to explain why.

+ private double d;
+ private double max;
+
+ Cell(double x, double y, double h, MultiPolygon polygon) {

This comment has been minimized.

@smithkm

smithkm Aug 27, 2016

Member

Comment explaining the class would be nice. Even if it's only meant for implementation, it will help with maintaining.

@smithkm

smithkm Aug 27, 2016

Member

Comment explaining the class would be nice. Even if it's only meant for implementation, it will help with maintaining.

@ianturton

This comment has been minimized.

Show comment
Hide comment
@ianturton

ianturton Aug 27, 2016

Member

Casper will sign CLA on Monday when he has checked his contract

Member

ianturton commented Aug 27, 2016

Casper will sign CLA on Monday when he has checked his contract

@aaime

This comment has been minimized.

Show comment
Hide comment
@aaime

aaime Aug 27, 2016

Member

Thinking out loud and without having checked the pull request.... is this worth turning into a text symbolizer vendor option too? If it's fast enough it could become the default poly center implementation, with the vendor option still allowing it to turn it off and get the old behavior, but most of the people would get the benefit without needing to alter all their SLDs.

Member

aaime commented Aug 27, 2016

Thinking out loud and without having checked the pull request.... is this worth turning into a text symbolizer vendor option too? If it's fast enough it could become the default poly center implementation, with the vendor option still allowing it to turn it off and get the old behavior, but most of the people would get the benefit without needing to alter all their SLDs.

@ianturton

This comment has been minimized.

Show comment
Hide comment
@ianturton

ianturton Aug 27, 2016

Member

Once we've tried this out on a some realistic polygons we could consider moving it into the main styling package and making it the default.

Member

ianturton commented Aug 27, 2016

Once we've tried this out on a some realistic polygons we could consider moving it into the main styling package and making it the default.

@smithkm

This comment has been minimized.

Show comment
Hide comment
@smithkm

smithkm Aug 27, 2016

Member

OK nitpicks addressed. Looks good.

Member

smithkm commented Aug 27, 2016

OK nitpicks addressed. Looks good.

@smithkm smithkm merged commit 30ccc3b into geotools:master Aug 28, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment