# Geographical Services?

**URL:** <https://www.ruby-forum.com/t/geographical-services/174252>\
**Category:** Rails\
**Created:** [August 23, 2009, 1:54pm UTC](https://www.ruby-forum.com/t/geographical-services/174252 "2009-08-23T13:54:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 1:54pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/1 "2009-08-23T13:54:52Z")

</div>

This is a broad question to get me started in the right direction:

I would like to provide a location-based service so that users can tag  
articles with a location (the place where the article took place), and  
search (or list) articles by location.

This raises some questions:

- Presumably best practice is to allow the user not to type free-form  
locations, but to help them pick a location from a list?

- Are there any frameworks that handle geographical hierarchies? For  
example, an article may be tagged with a city name, and a user may want  
to list all articles for a county, we’d need to know all of the cities  
in each county or we’d return nothing.

The simplest thing may be to just have a flat list of places, with no  
hierarchy, a list of cities and major towns for example?

Any broad advice on what’s out there to provide any  
geographical/location services would be much appreciated!

Thanks!

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 2:17pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/2 "2009-08-23T14:17:41Z")

</div>

Peter L. wrote:

> 

I’m not going to be able to help this yet, but just to add to it. What  
level of granularity do you want to provide? Can people search by the  
places within a city? How about different shops/ outlets within a  
city? Does it matter which branch generated the document?

Cheers,  
Mohit.  
8/23/2009 | 8:08 PM.

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 3:13pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/3 "2009-08-23T15:13:17Z")

</div>

are you looking to connect with something like: [www.geonames.org](http://www.geonames.org)

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 2:45pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/4 "2009-08-23T14:45:23Z")

</div>

> I’m not going to be able to help this yet, but just to add to it. What  
> level of granularity do you want to provide?

For me, I could really get away with a flat list of worldwide cities,  
which I guess would be the least level of granularity possible. However,  
a 2-level service would be good so we would have a hierarchy of  
county/parish\<-\>city. Of course, for very large cities such as London,  
it would be good to be able to split them further.

So in a nutshell, for my needs I think I could get by with a sensible  
worldwide flat list, but if there’s a good, easy to integrate, worldwide  
2-level service/framework, that would be great for me.

As for shops and outlets, that level of granularity would be a bit too  
much for me, but actually, thinking about it, might be interesting!

I guess I was fishing around for clues on what was available.

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 3:24pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/5 "2009-08-23T15:24:30Z")

</div>

Marion Taylor wrote:

> are you looking to connect with something like: [www.geonames.org](http://www.geonames.org)

That is pretty good!

There appear to be some basic ways of digging through the hierarchy too  
(e.g. finding the country for a city etc.).

This looks like what I needed, thanks.

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 3:33pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/6 "2009-08-23T15:33:12Z")

</div>

Peter  
if [www.geonames.org](http://www.geonames.org) is what you need, also check out:  
[www.gis.com](http://www.gis.com)  
GNIS Feature Search (which seems to be an application using  
[geonames.org](http://geonames.org))

and others via google: geographical database

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 24, 2009, 3:59pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/7 "2009-08-24T15:59:30Z")

</div>

You may or may not have seen this too, but it is a big part of every  
geocoding Rails app I build:

[http://geokit.rubyforge.org/](http://geokit.rubyforge.org/)

It adds a number of geocode-specific methods to ActiveRecord which  
allow you to query records based on their proximity to a location  
(e.g. @locations = Location.find(:all, :origin =\> @address, :within =\>  
@within, :order =\> ‘distance’)). It can also automatically geocode a  
location upon create using either Google, Yahoo, or GeoNames. You  
provide your API key and GeoKit handles the grunt work. Very handy  
tool. 🙂

Good luck with your project.

On Aug 23, 7:54 am, Peter L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 23, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/8 "2009-08-23T22:12:18Z")

</div>

PS you might want to also check out:

> **[野花在线观看免费高清完整版,野花视频官网手机免费观看,野花韩国中文版免费观看](http://www.extonrails.com)**
>
> 野花在线观看免费高清完整版，少妇的诱惑夫妻之间无需戴套一顿操全过程,少妇不带套直接进去全过程，爆裂黑丝高跟小骚货从浴室干到床上扛腿抽插爆射，野花视频官网手机免费观看，少妇下面又湿又滑又紧,精品在线视频，日本真人添下面视频免费，野花韩国中文版免费观看，偷拍窝棚里嫖老太视频,日本真人做爰无遮挡视频,色偷偷AV老熟女,国模冰莲自慰肥美胞极品人体图,翁熄粗大撞击娇嫩bd高清视频。

Country, region, city ruby wrapper for [geonames.org](http://geonames.org) | Ext on Rails

---

<div class="post-metadata">

**Author:** ![jazcyk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e56c9b/32.png) [@jazcyk](https://www.ruby-forum.com/u/jazcyk)\
**Post date:** [August 24, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/geographical-services/174252/9 "2009-08-24T17:57:10Z")

</div>

I second Geokit, I’ve used it in almost every application I’ve built.  
However, the main purpose of geokit is for getting the latitude and  
longitude of a location and then performing distance calculations  
between  
that location and other locations (such as finding all locations within  
a  
certain distance of another location).

If you want to do something such as list cities or counties, you’ll  
probably  
need to get something like a ‘location database’ and slice and dice it  
for  
your needs. Unfortunately they usually cost money.

An alternative solution to showing all the articles in the same county  
as a  
city would be to use geokit to show all the articles within a certain  
distance of a city. That could provide your users with a similar  
experience.

Hope that helps.
