<div dir="ltr">Convex hulls are not only needed as a performance boost. You would need some complicated "find next extreme point"-code in order for the algorithm to behave correctly as well.<div><br></div><div>Åsmund<br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 25, 2014 at 3:41 PM, Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">And if you do that on the convex hull rather than the original geometry, you will have less points to consider while doing the evaluation.<br>
<br>
-Steve<span class=""><br>
<br>
On 10/25/2014 8:52 AM, Rémi Cura wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
Found a python version here for minimal area enclosing rectangle<br>
<a href="http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#minarearect" target="_blank">http://docs.opencv.org/<u></u>modules/imgproc/doc/<u></u>structural_analysis_and_shape_<u></u>descriptors.html#minarearect</a><br>
It takes a numpy 2D array as point<br>
That means it is possible to use shapely to read postgis wkb geom, then<br>
convert it to numpy and use opencv afterward.<br>
<br>
There is also this implementation in python (iterate over all possible<br>
edge angle)<br>
<a href="https://github.com/dbworth/minimum-area-bounding-rectangle/blob/master/python/min_bounding_rect.py" target="_blank">https://github.com/dbworth/<u></u>minimum-area-bounding-<u></u>rectangle/blob/master/python/<u></u>min_bounding_rect.py</a><br>
<br>
To implement rotating caliper,<br>
I would need some functions like :<br>
- compute robust orientation of an edge (easy)<br>
- loop on points (should be provided)<br>
- area of a rectangle defined by 4 points and 1 angle (=2 caliper<br>
sets) (easy)<br>
<br>
I guess using only the geos_c.h api is not a good solution.<br>
Where should I look in the cpp geos jungle?<br>
<br>
Cheers,<br>
Rémi-C<br>
<br>
2014-10-25 2:23 GMT+02:00 Åsmund Tokheim <<a href="mailto:asmundto@gmail.com" target="_blank">asmundto@gmail.com</a><br></span>
<mailto:<a href="mailto:asmundto@gmail.com" target="_blank">asmundto@gmail.com</a>>>:<span class=""><br>
<br>
As far as I can tell, you shouldn't order and rotate, or you'll be<br>
looking at a O(n^2) implementation. During an iteration of<br>
<a href="http://cgm.cs.mcgill.ca/~orm/rotcal.html" target="_blank">http://cgm.cs.mcgill.ca/~orm/<u></u>rotcal.html</a><br></span>
<<a href="http://cgm.cs.mcgill.ca/%7Eorm/rotcal.html" target="_blank">http://cgm.cs.mcgill.ca/%<u></u>7Eorm/rotcal.html</a>>, it seems like you can<span class=""><br>
make the following assumptions:<br>
<br>
The next angle you should rotate to will be one of the four angles,<br>
given by the current extreme points and their next clockwise<br>
neighbour. So you should be able to find the next minimum clockwise<br>
rotation in O(1) time<br>
<br>
Also whenever you do a clockwise rotation to orient one of the<br>
support lines along a new edge, the extreme points for the other<br>
support lines stay the same. You only need to update the extreme<br>
point that was on the edge we now use as a support line, to its next<br>
clockwise point. Using the new extreme points and caliper's angle,<br>
you can calculate the bbox area in O(1) time as well.<br>
<br>
Regards<br>
Åsmund<br>
<br>
<br>
On Fri, Oct 24, 2014 at 7:09 PM, Rémi Cura <<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a><br></span><span class="">
<mailto:<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>>> wrote:<br>
<br>
Ok if I understand right,<br>
implementing it at the sql level would be :<br>
<br>
- compute convex envelop<br>
- order edges by angle<br>
- round angle to a given precision, keep distinct values<br>
- for each angle, rotate and compute bbox and area<br>
<br>
keep bbox and rotation giving the min area.<br>
<br>
Cheers,<br>
Rémi-C<br>
<br>
2014-10-23 18:46 GMT+02:00 Stephen V. Mather<br></span>
<<a href="mailto:svm@clevelandmetroparks.com" target="_blank">svm@clevelandmetroparks.com</a> <mailto:<a href="mailto:svm@clevelandmetroparks.com" target="_blank">svm@<u></u>clevelandmetroparks.com</a>>>:<span class=""><br>
<br>
That would be really cool. Could be a set of functions. It<br>
would be interesting to see if the triangulation<br>
optimizations listed at<br>
<a href="http://cgm.cs.mcgill.ca/~orm/rotcal.html" target="_blank">http://cgm.cs.mcgill.ca/~orm/<u></u>rotcal.html</a><br></span>
<<a href="http://cgm.cs.mcgill.ca/%7Eorm/rotcal.html" target="_blank">http://cgm.cs.mcgill.ca/%<u></u>7Eorm/rotcal.html</a>> are faster than<span class=""><br>
the JTS/GEOS equivalents.<br>
<br>
Stephen V. Mather<br>
GIS Manager<br></span>
<a href="tel:%28216%29%20635-3243" value="+12166353243" target="_blank">(216) 635-3243</a> <tel:%28216%29%20635-3243> (Work)<br>
<a href="http://clevelandmetroparks.com" target="_blank">clevelandmetroparks.com</a> <<a href="http://clevelandmetroparks.com" target="_blank">http://clevelandmetroparks.<u></u>com</a>><br>
<br>
<br>
<br>
<br>
______________________________<u></u>__________<br>
From: <a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.<u></u>osgeo.org</a><br>
<mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@<u></u>lists.osgeo.org</a>><br>
<<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.<u></u>osgeo.org</a><br>
<mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@<u></u>lists.osgeo.org</a>>> on behalf of<br>
Sandro Santilli <<a href="mailto:strk@keybit.net" target="_blank">strk@keybit.net</a> <mailto:<a href="mailto:strk@keybit.net" target="_blank">strk@keybit.net</a>>><span class=""><br>
Sent: Thursday, October 23, 2014 12:36 PM<br>
To: PostGIS Users Discussion<br>
Subject: Re: [postgis-users] Oriented BBox Efficient computing?<br>
<br>
On Thu, Oct 23, 2014 at 06:17:56PM +0200, Rémi Cura wrote:<br>
> Wov thanks everybody :<br>
> Seems it possible to do it fully geometrically :<br>
> <a href="http://cgm.cs.mcgill.ca/~orm/rotcal.html" target="_blank">http://cgm.cs.mcgill.ca/~orm/<u></u>rotcal.html</a><br></span>
<<a href="http://cgm.cs.mcgill.ca/%7Eorm/rotcal.html" target="_blank">http://cgm.cs.mcgill.ca/%<u></u>7Eorm/rotcal.html</a>><span class=""><br>
<br>
Nice, would be a good candidate for a new PostGIS function<br>
(possibly via JTS/GEOS)<br>
<br>
--strk;<br>
<br>
() Free GIS & Flash consultant/developer<br>
/\ <a href="http://strk.keybit.net/services.html" target="_blank">http://strk.keybit.net/<u></u>services.html</a><br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br></span>
<mailto:<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.<u></u>osgeo.org</a>><span class=""><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-<u></u>bin/mailman/listinfo/postgis-<u></u>users</a><br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br></span>
<mailto:<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.<u></u>osgeo.org</a>><span class=""><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-<u></u>bin/mailman/listinfo/postgis-<u></u>users</a><br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br></span>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a> <mailto:<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.<u></u>osgeo.org</a>><span class=""><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-<u></u>bin/mailman/listinfo/postgis-<u></u>users</a><br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br></span>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a> <mailto:<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.<u></u>osgeo.org</a>><span class=""><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-<u></u>bin/mailman/listinfo/postgis-<u></u>users</a><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-<u></u>bin/mailman/listinfo/postgis-<u></u>users</a><br>
<br>
</span></blockquote><div class="HOEnZb"><div class="h5">
<br>
______________________________<u></u>_________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-<u></u>bin/mailman/listinfo/postgis-<u></u>users</a><br>
</div></div></blockquote></div><br></div></div></div>