No commit activity in last 3 years
No release in over 3 years
Adding support for PostGIS types and clean PostGIS querying extensions to ActiveRecord
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3.0
~> 1.3
>= 0
>= 0
> 0.13.2
~> 10.1.0

Runtime

 Project Readme

PostgresExt::Postgis

Installation

Add this line to your application's Gemfile:

gem 'postgres_ext-postgis'

And then execute:

$ bundle

Or install it yourself as:

$ gem install postgres_ext-postgis

Usage

Just require 'postgres_ext/postgis' and use ActiveRecord as you normally would! postgres\ext extends ActiveRecord's data type handling and query methods in both Arel and ActiveRecord.

Migrations

Adding a geomtry column to your table is simple! You can create a plain geometry column, or specify your spatial type and projection:

create_table :districts do |t|
  t.geometry :location
  t.geometry :district_boundries, spatial_type: :multipolygon, srid: 4326
end

Type Casting

PostGIS geometry types are converted to RGeo objects. You can set your PostGIS types in ActiveRecord using either the Extended Well-Known Binary (WKB) or Extended Well-Known Text (WKT) representation:

user.location = 'SRID=4623;POINT(1 1)'

Querying

Contains

Using the contains querying interface from postgres_ext that arrays utilize, we can query if geometry column contains the specified object

District.where.contains(district_boundries: user.location)

Authors

We are very thankful for the many contributors

Versioning

This gem follows Semantic Versioning

Want to help?

Please do! We are always looking to improve this gem. Please see our Contribution Guidelines on how to properly submit issues and pull requests.

Legal

DockYard, Inc. © 2014

@dockyard

Licensed under the MIT license