Skip to content

Commit

Permalink
Changes to code
Browse files Browse the repository at this point in the history
  • Loading branch information
jordan committed May 13, 2010
1 parent 13806f0 commit 39b838e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gis/mysql/distance.sql
Expand Up @@ -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)) )
Expand Down
10 changes: 6 additions & 4 deletions management/commands/geonames_import.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 39b838e

Please sign in to comment.