Skip to content
Browse files

Changes to code

  • Loading branch information...
1 parent 13806f0 commit 39b838e31d20e72d7bdbe0051e2655349314b1e9 jordan committed May 13, 2010
Showing with 7 additions and 5 deletions.
  1. +1 −1 gis/mysql/distance.sql
  2. +6 −4 management/commands/geonames_import.py
View
2 gis/mysql/distance.sql
@@ -5,7 +5,7 @@ DROP FUNCTION IF EXISTS `distance` $$
CREATE FUNCTION distance(a POINT, b POINT) RETURNS double
DETERMINISTIC
COMMENT 'Spatial distance function using the great-circle distance formula (in km)'
-RETURN ( 6378
+RETURN ( 6378.7
* acos(
sin( radians(X(a)) ) * sin( radians(X(b)) )
+ cos( radians(X(a)) ) * cos( radians(X(b)) )
View
10 management/commands/geonames_import.py
@@ -78,7 +78,7 @@ def fetch(self):
print 'Error fetching %s' % os.path.basename(f)
sys.exit(1)
- for f in ('cities5000.zip', 'alternateNames.zip'):
+ for f in ('allCountries.zip', 'alternateNames.zip'):
if os.system('unzip %s' % f) != 0:
print 'Error unzipping %s' % f
sys.exit(1)
@@ -272,7 +272,7 @@ def import_second_level_adm(self):
def import_third_level_adm(self):
print 'Importing third level administrative divisions'
- fd = open('cities5000.txt')
+ fd = open('allCountries.txt')
line = fd.readline()[:-1]
while line:
fields = line.split('\t')
@@ -318,7 +318,7 @@ def import_third_level_adm(self):
def import_fourth_level_adm(self):
print 'Importing fourth level administrative divisions'
- fd = open('cities5000.txt')
+ fd = open('allCountries.txt')
line = fd.readline()[:-1]
while line:
fields = line.split('\t')
@@ -372,13 +372,15 @@ def import_fourth_level_adm(self):
def import_geonames(self):
print 'Importing geonames (this is going to take a while)'
- fd = open('cities5000.txt')
+ fd = open('allCountries.txt')
line = fd.readline()[:-1]
while line:
fields = line.split('\t')
id, name, ascii_name = fields[:3]
latitude, longitude, fclass, fcode, country_id, cc2 = fields[4:10]
population, elevation, gtopo30 = fields[14:17]
+ if fclass != 'P': #only import populated places!
+ continue
moddate = fields[18]
if elevation == '':
elevation = 0

0 comments on commit 39b838e

Please sign in to comment.
Something went wrong with that request. Please try again.