-
Notifications
You must be signed in to change notification settings - Fork 347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port MinimumDiameter::getMinimumRectangle algorithm from JTS #54
Conversation
|
I'm guessing the appveyor failure isn't related to this PR? |
|
Could you please remove CR from Out of curiosity, does "git show --check" warn you about those too ? Also please file a ticket on trac referencing this PR. Good work, btw ! :) |
|
The trac ticket is at https://trac.osgeo.org/geos/ticket/729 |
|
Thanks, please add a "Fixes #729" comment in the commit log
on next force-push.
|
|
@mloskot what happened to your appveyor branch ? Should you disable checking PRs until it works in a test branch ? |
0a33ceb
to
32d1008
Compare
|
@strk Thanks for the feedback - I've updated the PR to fix the whitespace issues & update the commit log message. And yes, |
|
Another thing, I've been adding "Last Port" headers to files to track when was a class last being updated. See an example here: https://github.com/libgeos/libgeos/blob/svn-trunk/include/geos/algorithm/CentroidArea.h#L16 It looks like the latest change in that file for JTS was adding static methods for getMinimumRectangle and getMinimumDiameter in the MinimumDiameter class with r966 (March 2015) and some Javadoc fixes were added with r705 (December 2012) The class was initially ported to GEOS in 2004 (JTS 1.4) - the JTS history for that file starts in 2010 (I guess it was lost in the CVS to SVN transition). What about taking a quick pass to the JTS class (is short) and adding the "Last port" item (in both .cpp and .h files) so we're in sync and don't have to check this again in the future ? Oh, and if you do this, could you also write the commit log to be complete within 70 cols in the first line by moving the detail (included ticket reference) to after a new line ? Ok, enough nitpicking :) |
|
MinimumDiameter.cpp:304:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] |
|
Another thing: the new testcases are not enabled, they need to be added to tests/unit/Makefile.am (and probably in some CMakeFile too but I usually don't do that part) |
|
FYI: I've pushed a "pull54" branch in my fork, if you want to pull from it :) The following changes since commit 32d1008: Port MinimumDiameter::getMinimumRectangle algorithm from JTS and add to C API. Fixes #729. (2015-11-12 22:03:35 +1100) are available in the git repository at: git://github.com/strk/libgeos.git pr/54 for you to fetch changes up to 66774e7: Enable unit tests (2015-11-12 12:43:58 +0100) Sandro Santilli (1): tests/unit/Makefile.am | 2 ++ |
32d1008
to
64933d2
Compare
|
@strk all done. I've resynced it to JTS r966 (just the new static methods + doc changes), fixed the warning and commit message, pulled your extra commit (no changes required for cmake, that's automatically handled), also fixed a few memory leaks (which probably could never actually happen, but better to be safe in case things change in future). |
64933d2
to
ca7d525
Compare
|
@strk I've added tests & protection against null/non polygon geometries |
|
Great, thanks ! Please also squash-rebase against current trunk and force-push here. |
|
I also think the name is badly chosen, but it's what JTS uses. Is there an issue if we change it for GEOS? |
ca7d525
to
790615a
Compare
|
@strk I've squashed & force pushed, with the original JTS name intact for now. So if you're happy with that we should be good to go. Otherwise, what do you think about "minimumRotatedRectangle" as an alternative name? |
|
+1 for "minimumRotatedRectangle".
JTS naming is of a method within a class which gives more context
(mentioning "diameter").
|
|
btw, exposing minimumDiameter would be also useful as it would allow PostGIS to use the GEOS implementation for its https://trac.osgeo.org/postgis/ticket/2996 \cc @dbaston |
Also add GEOSMinimumRotatedRectangle and GEOSMinimumDiameter to C API, and re-sync MinimumDiameter with JTS r966. Fixes libgeos#729.
790615a
to
22169c7
Compare
|
@strk how's this? I've:
|
|
This is great ! Committed as r4123 = 7061e93 (refs/remotes/trunk) I'm tempted to ask more as you're so good at it -- want to look at exposing these 2 new CAPI methods to the PHP binding ? :) |
|
Realize I'm a bit late on this one, but I would consider using a name other than GEOSMinimumDiameter, since "minimum diameter" could give the impression that this is somehow related to a minimum bounding circle (which it its not). GEOSMinimumWidth ? |
|
It is related to a minimum bounding circle, as far as I understood. |
|
The minimum diameter is described in JTS as
The key here is "with a single rotation," with LINESTRING (0 0, 0 1e6) being a good example of the difference. The diameter of its minimum bounding circle is 1e6, but the JTS "minimum diameter" is zero. |
|
Now I see it. I agree GEOSMinimumWidth would be better. Up for a patch ? It's not too late for it :) |
This commit ports the JTS MinimumDiameter::getMinimumRectangle algorithm and adds it to the c API.
I've tried to model the code as much as possible off the existing algorithms/unit tests, but this is my first contribution to GEOS (hopefully many more to come!) and I may be unaware of what's considered best-practice here.