Rails Model Location functions

I put up some code snippets for a Location model in a Rails application. They include simple things like:

  • degree< ->radians conversions
  • distance between two locations
  • Min/Max latitude & longitudes given a location and radius
  • Database queries for locations in a given range from a center point

Essentially they're making up for not have a true GIS interface to the database running PostgreSQL and PostGIS.

Most of the functions actually came from another project, but I unfortunately lost the note, so if you can properly id the originator of some of the functions, please do!

About this article

written on
posted in ProgrammingGeolocationOpen-SourceRuby Back to Top

About the Author

Andrew Turner is an advocate of open standards and open data. He is actively involved in many organizations developing and supporting open standards, including OpenStreetMap, Open Geospatial Consortium, Open Web Foundation, OSGeo, and the World Wide Web Consortium. He co-founded CrisisCommons, a community of volunteers that, in coordination with government agencies and disaster response groups, build technology tools to help people in need during and after a crisis such as an earthquake, tsunami, tornado, hurricane, flood, or wildfire.