Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changes to code

  • Loading branch information...
commit 39b838e31d20e72d7bdbe0051e2655349314b1e9 1 parent 13806f0
jordan authored
2  gis/mysql/distance.sql
@@ -5,7 +5,7 @@ DROP FUNCTION IF EXISTS `distance` $$
5 5 CREATE FUNCTION distance(a POINT, b POINT) RETURNS double
6 6 DETERMINISTIC
7 7 COMMENT 'Spatial distance function using the great-circle distance formula (in km)'
8   -RETURN ( 6378
  8 +RETURN ( 6378.7
9 9 * acos(
10 10 sin( radians(X(a)) ) * sin( radians(X(b)) )
11 11 + cos( radians(X(a)) ) * cos( radians(X(b)) )
10 management/commands/geonames_import.py
@@ -78,7 +78,7 @@ def fetch(self):
78 78 print 'Error fetching %s' % os.path.basename(f)
79 79 sys.exit(1)
80 80
81   - for f in ('cities5000.zip', 'alternateNames.zip'):
  81 + for f in ('allCountries.zip', 'alternateNames.zip'):
82 82 if os.system('unzip %s' % f) != 0:
83 83 print 'Error unzipping %s' % f
84 84 sys.exit(1)
@@ -272,7 +272,7 @@ def import_second_level_adm(self):
272 272
273 273 def import_third_level_adm(self):
274 274 print 'Importing third level administrative divisions'
275   - fd = open('cities5000.txt')
  275 + fd = open('allCountries.txt')
276 276 line = fd.readline()[:-1]
277 277 while line:
278 278 fields = line.split('\t')
@@ -318,7 +318,7 @@ def import_third_level_adm(self):
318 318
319 319 def import_fourth_level_adm(self):
320 320 print 'Importing fourth level administrative divisions'
321   - fd = open('cities5000.txt')
  321 + fd = open('allCountries.txt')
322 322 line = fd.readline()[:-1]
323 323 while line:
324 324 fields = line.split('\t')
@@ -372,13 +372,15 @@ def import_fourth_level_adm(self):
372 372
373 373 def import_geonames(self):
374 374 print 'Importing geonames (this is going to take a while)'
375   - fd = open('cities5000.txt')
  375 + fd = open('allCountries.txt')
376 376 line = fd.readline()[:-1]
377 377 while line:
378 378 fields = line.split('\t')
379 379 id, name, ascii_name = fields[:3]
380 380 latitude, longitude, fclass, fcode, country_id, cc2 = fields[4:10]
381 381 population, elevation, gtopo30 = fields[14:17]
  382 + if fclass != 'P': #only import populated places!
  383 + continue
382 384 moddate = fields[18]
383 385 if elevation == '':
384 386 elevation = 0

0 comments on commit 39b838e

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