Thanks Sven, I will test the performance... some my objects have around 10000 points. Maybe I will reduce the amount of point and sacrifice some precision. I thought something like that was already available in SH. Best regards On Sat, Jul 25, 2015 at 4:31 AM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Arturo,
In Pharo itself, you could just do it yourself, like this:
T3GeoTools class>>#is: position inside: polygon "T3GeoTools is: 5.33732@50.92601 inside: { 5.48230@50.82249. 5.49523@50.81288. 5.50138@50.82008. 5.50228@50.82595. 5.49265@50.82560. 5.48230@50.82249 }"
"T3GeoTools is: 5.49007@50.82205 inside: { 5.48230@50.82249. 5.49523@50.81288. 5.50138@50.82008. 5.50228@50.82595. 5.49265@50.82560. 5.48230@50.82249 }"
"Point in polygon - ray casting algorithm - http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html"
| inside otherIndex | inside := false. otherIndex := polygon size. polygon doWithIndex: [ :each :index | | other | other := polygon at: otherIndex. (((each y > position y) ~= (other y > position y)) and: [ position x < (((other x - each x) * (position y - each y) / (other y - each y)) + each x) ]) ifTrue: [ inside := inside not ]. otherIndex := index ]. ^ inside
Inside circle, rectangle etc are trivial.
Sven
On 25 Jul 2015, at 01:19, Arturo Zambrano <arturo.zambrano@gmail.com> wrote:
Hi All, I would like to get some advice regarding which path I should take.
Problem: Given a coordinate I want to know to which geographical object it belongs to.
Path 1 Using Glorp to make a query to a Postgis instance containing the boundaries of the geobjects
Path 2 Use the data form GADM data (according to this thread).
I would avoid path 1 in order to avoid installation of postgi. From the thread mentioned above, I thing that it requires some development.
Regarding Path 2, I don't see which framework or library should I use to import and query the data contained in the KMZ from GADM.
Any advice is welcome.
Best regards. Art