Skip to content

WearyMonkey/rgeo

 
 

Repository files navigation

RGeo

RGeo is a geospatial data library for Ruby.

Summary

RGeo is a key component for writing location-aware applications in the Ruby programming language. At its core is an implementation of the industry standard OGC Simple Features Specification, which provides data representations of geometric objects such as points, lines, and polygons, along with a set of geometric analysis operations. This makes it ideal for modeling geolocation data. It also supports a suite of optional add-on modules that provide various geolocation-related services.

Use the core rgeo gem to:

  • Represent spatial and geolocation data objects such as points, lines, and polygons in your Ruby application.

  • Perform standard spatial analysis operations such as finding intersections, creating buffers, and computing lengths and areas.

  • Correctly handle spherical geometry, and compute geographic projections for map display and data analysis.

  • Read and write location data in the WKT and WKB representations used by spatial databases.

Several optional modules are currently available:

  • Generate and interpret GeoJSON data for communication with common location-based web services such as SimpleGeo, using the rgeo-geojson gem.

  • Read GIS datasets from ESRI shapefiles using the rgeo-shapefile gem.

  • Extend ActiveRecord to handle spatial data in MySQL Spatial, SpatiaLite, and PostGIS using RGeo’s spatial ActiveRecord adapters. These are available via the gems:

    • activerecord-mysqlspatial-adapter

    • activerecord-mysql2spatial-adapter

    • activerecord-spatialite-adapter

    • activerecord-postgis-adapter

  • and more to come…

Need help? Join the rgeo-users google group at: groups.google.com/group/rgeo-users

Dependencies

RGeo is known to work with the following Ruby implementations:

  • Standard “MRI” Ruby 1.8.7 or later. (1.9.2 or later preferred.)

  • Rubinius 1.1 or later.

  • Partial support for JRuby 1.6.3 or later. The FFI implementation of GEOS is available (ffi-geos gem is required) but CAPI is not. Proj4 support is expected in the future.

Some features also require the following:

  • GEOS 3.2 or later is highly recommended. Some functions will not be available without it. This C/C++ library may be available via your operating system’s package manager, or you can download it from trac.osgeo.org/geos

  • Proj 4.7 or later is also recommended. This library is needed if you want to translate coordinates between geographic projections. It also may be available via your operating system’s package manager, or from trac.osgeo.org/proj

Note: The build system assumes a unix-like environment. Windows builds may be possible, but not likely “out of the box”.

Installation

Install RGeo as a gem:

gem install rgeo

Note: By default, the gem installation looks for the GEOS library in the following locations: /usr/local, /usr/local/geos, /opt/local, /opt/geos, /opt, /usr, and /Library/Frameworks/GEOS.framework/unix. In other words, MacPorts, Homebrew, the Kyngchaos port, and building from source to /usr/local are supported out of the box.

If GEOS has been installed in a different location, you must provide its installation prefix directory using the “–with-geos-dir” option. This option must be preceded by “--” to separate it, as a build switch, from the switches interpreted by the gem command. For example:

gem install rgeo -- --with-geos-dir=/path/to/my/geos/installation

Similarly, the gem installation looks for the Proj4 library in the following locations by default: /usr/local, /usr/local/proj, /usr/local/proj4, /opt/local, /opt/proj, /opt/proj4, /opt, /usr, and /Library/Frameworks/PROJ.framework/unix.

If Proj4 is installed in a different location, you must provide its installation prefix directory using the “–with-proj-dir” option.

To-do list

The RGeo suite of tools is evolving rapidly. The current to-do list for the core library includes:

  • YAML and Marshal serialization support across all major entities.

  • Better JRuby support.

  • Ellipsoidal geography implementation, possibly utilizing geographiclib.

  • Windows build support.

Each of the current add-on modules also has its own feature roadmap, and we are planning on introducing more add-on modules, including:

  • GeoRSS and KML format support.

  • Integration with third-party APIs.

  • Possible additional ActiveRecord adapters.

Development and support

Documentation is available at virtuoso.rubyforge.org/rgeo/README_rdoc.html

Source code is hosted on Github at github.com/dazuma/rgeo

Contributions are welcome. Fork the project on Github.

Report bugs on Github issues at github.org/dazuma/rgeo/issues

Support available on the rgeo-users google group at groups.google.com/group/rgeo-users

Contact the author at dazuma at gmail dot com.

Acknowledgments

RGeo is written by Daniel Azuma (www.daniel-azuma.com).

Development of RGeo is sponsored by GeoPage, Inc. (www.geopage.com).

RGeo calls the GEOS library to handle most Cartesian geometric calculations, and the Proj4 library to handle projections and coordinate transformations. These libraries are maintained by the Open Source Geospatial Foundation; more information is available on OSGeo’s web site (www.osgeo.org).

JRuby support is made possible by the ffi-geos (and upcoming ffi-proj4) gems, by J Smith (github.com/dark-panda).

License

Copyright 2010-2011 Daniel Azuma

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the copyright holder, nor the names of any other contributors to this software, may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

About

Geospatial data library for Ruby

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 87.7%
  • C 12.3%