Merge lp:~hloeung/ubuntu-geonames/add-country-continent into lp:ubuntu-geonames

Proposed by Haw Loeung
Status: Merged
Merged at revision: 33
Proposed branch: lp:~hloeung/ubuntu-geonames/add-country-continent
Merge into: lp:ubuntu-geonames
Diff against target: 50 lines (+5/-3)
2 files modified
geoname-modpython.py (+3/-1)
geoname.py (+2/-2)
To merge this branch: bzr merge lp:~hloeung/ubuntu-geonames/add-country-continent
Reviewer Review Type Date Requested Status
Paul Collins lgtm Approve
Ubuntu Geonames Hackers Pending
Review via email: mp+432157@code.launchpad.net

Description of the change

We're already importing continent from countryInfo.txt. Let's serve that up.

Per http://download.geonames.org/export/dump/readme.txt

Continent codes :
AF : Africa geonameId=6255146
AS : Asia geonameId=6255147
EU : Europe geonameId=6255148
NA : North America geonameId=6255149
OC : Oceania geonameId=6255151
SA : South America geonameId=6255150
AN : Antarctica geonameId=6255152

To post a comment you must log in.
Revision history for this message
Paul Collins (pjdc) :
review: Approve (lgtm)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'geoname-modpython.py'
2--- geoname-modpython.py 2015-12-16 22:26:11 +0000
3+++ geoname-modpython.py 2022-10-26 02:11:08 +0000
4@@ -13,6 +13,7 @@
5 admin1codes.name,
6 admin2codes.name,
7 countryInfo.name,
8+countryInfo.continent,
9 geoname.longitude,
10 geoname.latitude,
11 geoname.timezone,
12@@ -28,6 +29,7 @@
13 admin1codes.name,
14 admin2codes.name,
15 countryInfo.name,
16+countryInfo.continent,
17 geoname.longitude,
18 geoname.latitude,
19 geoname.timezone,
20@@ -43,7 +45,7 @@
21 """
22 jsonheader = '['
23 jsonfooter = ']'
24-jsonentry = '{"name" : "%s", "admin1" : "%s", "admin2" : "%s", "country" : "%s", ' \
25+jsonentry = '{"name" : "%s", "admin1" : "%s", "admin2" : "%s", "country" : "%s", "continent" : "%s", ' \
26 '"longitude" : "%F", "latitude" : "%F" , "timezone" : "%s" }'
27
28 def handler(req):
29
30=== modified file 'geoname.py'
31--- geoname.py 2011-04-05 19:00:42 +0000
32+++ geoname.py 2022-10-26 02:11:08 +0000
33@@ -1,7 +1,7 @@
34 import sphinxapi
35 import cherrypy
36 import psycopg2
37-statement = "SELECT geoname.name, admin1codes.name, countryInfo.name, \
38+statement = "SELECT geoname.name, admin1codes.name, countryInfo.name, countryInfo.continent, \
39 geoname.longitude, geoname.latitude FROM admin1codes, geoname, countryInfo \
40 WHERE code = geoname.country||'.'||geoname.admin1 AND \
41 countryInfo.iso_alpha2=geoname.country AND geoname.geonameid=%s;"
42@@ -14,7 +14,7 @@
43 testentry = '%s (%s, %s) <font size="-2">[%F, %F]</font><br />'
44 jsonheader = '['
45 jsonfooter = ']'
46-jsonentry = '{"name" : "%s", "admin1" : "%s", "country" : "%s", "longitude" : "%F", "latitude" : "%F" }'
47+jsonentry = '{"name" : "%s", "admin1" : "%s", "country" : "%s", "continent" : "%s", "longitude" : "%F", "latitude" : "%F" }'
48
49 class Geoname:
50 def index(self, query=""):

Subscribers

People subscribed via source and target branches

to all changes: