Giter Site home page Giter Site logo

spatialassociations's Introduction

SpatialAssociations
===================

SpatialAssociations provides helper methods for ActiveRecord::Base that enable spatially constrained associations.

A Spatial Association is one where the coupling between models is determined by the result of a geometric function, rather than a relational key-based linking.

This plugin assumes that you are using PostGIS, and that your geometric columns are all named 'geometry'.


Helpers Available
=================

is_enclosed_by :model
	i.e. a city is_enclosed_by a state.
	
encloses :models
	i.e. a state encloses cities.


Example
=======

Say I have two spatial enabled models, City and State.

Add the helpers to the appropriate models:

	class City < ActiveRecord::Base
		is_enclosed_by :state
	end

	class State < ActiveRecord::Base
		encloses :cities
	end

I can now use these associations as follows:

@someCitysState = @someCityObject.state # => Returns a state object that spatially encloses the receiving city.

@someStatesCities = @someStateObject.cities # => Returns an array of City objects which are spatially enclosed by the receiving state.

Copyright (c) 2008 Bradley Spaulding, released under the MIT license

spatialassociations's People

Contributors

bspaulding avatar

Stargazers

Angus H. avatar  avatar Marcos Piccinini avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.