-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathREADME
More file actions
75 lines (49 loc) · 2.29 KB
/
README
File metadata and controls
75 lines (49 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
Requirements
============
geo_regioning is packaged with geokit-rails and awesome_nested_set
Installation
============
Currently, geo_regioning is only packaged as a plugin.
> script/plugin install git://github.com/fuelxc/geo_regioning.git
Once installed the rake task will need to be ran. This creates the necessary tables for geo_regioning to work
> rake db:migrate:geo_regioning
Configuration
=============
There is a default configuration file in lib/config. You can copy this to your applications config directory and modify it.
Not all geokit options are passed to geokit. Currently it is hard coded, feel free to change this if you need to before I get to it.
Country definitions are completely arbitrary and up to you to define what you need. The level definitions are used to give you named accessors
eg:
country_definitions:
US:
1:
name: state
2:
name: county
exclude_from_geocode: true
3:
name: city
This will give you the methods state, county, city for the country code US. If you wish to add boroughs as a level below city add:
4:
name: boroughs
Setting the exclude_from_geocode option to true will not pass the value of that part of the field to the geocoding (which in turn means that level will geocode to the parent)
This is useful for any division that is not used in the postal address
Reason
======
This plugin was developed for use with geo based searches, such as real estate.
Example
=======
country = GeoRegioning::Country.find_by_iso_3166('US')
az = country.states.find_by_name('Arizona')
mesa = az.cities.find_by_name('Mesa')
#some other geokit model
Property.find_within(5, :origin => mesa.lat_long)
#non geokit model that uses addresses
cities = mesa.others_within(5) + [mesa]
#please don't actually use this. Great way to have sql injection attack
Property.all(:conditions => ["city IN (#{cities.collect(&:name).join(',')})")
Coming Soon
===========
Level strfmt - allow the passing of parameter much like strftime ie: mesa.strfmt("%s, %T %p") => "Mesa, AZ 85213"
Level Bounds - allow the addition of bounding boxes for regions. ie: Property.find(:all, :bounds => mesa.bounds)
Level By Ip - easily get the lowest subdivision closest to an IP address
Copyright (c) 2011 Eric Harrison, released under the MIT license