views:

42

answers:

2

Hello Friends,

i am developing a dating website, in which users can register from all over
the World. The Dating section is divided into cities from again, all over
the World.
The Problem i see here is, i do not have a database that covers all cities
around the Globe.
I am confirming every user by hand so this gives me the opportunity to review
the users city and country.
Main main approach is, giving each city a "city_id" in the Database.

It's like if a person joins from New York, i give it the id US_NEWYORK
If the person joins from Frankfurt they get the id DE_FRANKFURT

Both of those users still have their own City name in the Database and it's
written down the same as they wrote it. So for example,

"Frankfurt" instead of "Frankfurt am Main" for the right name or,
"NYC" instead of "New York" for the right name.

This way i can keep every users writing and can give the cities a special id
and run all queries through that ID.

This is my very own solution and i think it's not so bad. Do you might have
an Idea what i could do better?

I would like to kindly remember, that i would need every city from every country
i'm running this service, if you would like to recommend i would get a database
from somewhere :)

Thanks for reading.

+1  A: 

Why don't you use a geocoding servers like geonames.org or Google's geocoding API to find a canonical name for locations, and also a latitude/longitude. I assume you need the locations in some sort of canonical form so you can find closest matches, right? Well, latitude/longitude is the way to go there.

For instance, if you ask Google about "Frankfurt am Main", like so:

curl 'http://maps.googleapis.com/maps/api/geocode/xml?address=Frankfurt%20am%20Main&sensor=false'

You get back all this:

geocode/xml?address=Frankfurt%20am%20Main&sensor=false'
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>locality</type>
  <type>political</type>
  <formatted_address>Frankfurt, Germany</formatted_address>
  <address_component>
   <long_name>Frankfurt</long_name>
   <short_name>Frankfurt</short_name>
   <type>locality</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Frankfurt am Main</long_name>
   <short_name>Frankfurt am Main</short_name>
   <type>administrative_area_level_2</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Hesse</long_name>
   <short_name>HE</short_name>
   <type>administrative_area_level_1</type>
   <type>political</type>
  </address_component>
  <address_component>
   <long_name>Germany</long_name>
   <short_name>DE</short_name>
   <type>country</type>
   <type>political</type>
  </address_component>
  <geometry>
   <location>
    <lat>50.1115118</lat>
    <lng>8.6805059</lng>
   </location>
   <location_type>APPROXIMATE</location_type>
   <viewport>
    <southwest>
     <lat>49.9968858</lat>
     <lng>8.4243871</lng>
    </southwest>
    <northeast>
     <lat>50.2258641</lat>
     <lng>8.9366247</lng>
    </northeast>
   </viewport>
   <bounds>
    <southwest>
     <lat>50.0155200</lat>
     <lng>8.4727150</lng>
    </southwest>
    <northeast>
     <lat>50.2269512</lat>
     <lng>8.8004960</lng>
    </northeast>
   </bounds>
  </geometry>
 </result>
</GeocodeResponse>
Paul Tomblin
What i need is, i try to force people to chose their city from where they connect. Because the data on their dates will only appear for the city they are registered in or better say, they currently roam in. How could i do that? I would only have the user's ip or if it's possible, the location of their wireless card like skyhook? The problem is, for example i'm located in Berlin and want to sign up, how can the service know, that i'm actualy, in berlin? The name of the city would be enough already. Thanks by the way for your extended answer.
Herr Kaleun
ah and, unfortunately, if i ever exceed the rate of 2500 requests per day, i would need an extended license which is priced at 10.000 / Year, which i doubt i can afford now. Is there any affordable solution to this problem?
Herr Kaleun
Geonames.org has higher allowed rates - 3000 requests per hour.
Paul Tomblin
I assume that people will give you a true location. If they don't give you truthful information, they'll get lousy matches. That's their problem, not yours. Not much point in signing up for a dating service and asking for matches in Berlin if you're really in Des Moines, Iowa.
Paul Tomblin
+1  A: 

http://www.geonames.org/

looks quite comprehensive.

RisingSun