I'm new to postGIS, and am looking to use a spatial database with my Rails app (specifically, to retrieve points from the database that are within the bounding box of a Google Maps viewport). I posted a question on Stack Overflow with a few more details ( https://stackoverflow.com/questions/3555840/constucting-a-postgis-query-with-rails ), before coming across this site. I was following the tutorial at http://railsonpostgresql.com/2009/11/05/intro-to-postgis, but my implementation doesn't really seem to work - when zoomed in, the points don't appear as expected (but some appear when zoomed further out, although not those near the international date line). I'm using the spatial_adapter and GeoRuby gems at the moment - are there any good tutorials out there on how to begin integrating postGIS with Rails? From what I've read, it seems like using the geography type would be a good start for my project, but unfortunately I don't believe GeoRuby supports it. Any help/suggestions would be greatly appreciated!

  • I don't know whether you have seen it, but there is a really in depth 9 part series of blog posts by Daniel Azuma, author of the RGeo gem starting at daniel-azuma.com/blog/archives/60 – Kelso May 10 '12 at 0:53

The answer on Stackoverflow echos my thoughts: first, determine if the issue is in the google maps implementation or with the database results. I'd try installing QGIS, and point it at your PostGIS database -- if all the data shows up there fine, and zooming works as expected, the data is correct in the database.

From your example query, here's a quick map of the bounding box: bbox example

That is consistent with the parameters you're sending, so try another one that fails, check the logs and try the query directly against the database to see if its sending the results you want. Step backward from there till you've isolated the component that's failed. Hope that helps!

  • Thanks for your help - once I got my database on QGIS I spotted the problem immediately - I had the x/y and lng/lat correlation mixed up. Massive n00b error - it works perfectly now!! – Budgie Aug 25 '10 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.