better course country detecton
This commit is contained in:
@@ -73,7 +73,7 @@ def crewnerdcourse(doc):
|
||||
'description':description,
|
||||
'polygons':polygons
|
||||
})
|
||||
|
||||
|
||||
return courses
|
||||
|
||||
def get_polygons(polygonpms):
|
||||
@@ -103,7 +103,7 @@ def get_polygons(polygonpms):
|
||||
|
||||
|
||||
return polygons
|
||||
|
||||
|
||||
|
||||
def coursetokml(course):
|
||||
top = Element('kml')
|
||||
@@ -112,7 +112,7 @@ def coursetokml(course):
|
||||
top.attrib['xmlns:' + prefix] = uri
|
||||
else:
|
||||
top.attrib['xmlns'] = uri
|
||||
|
||||
|
||||
document = SubElement(top,'Document')
|
||||
name = SubElement(document, 'name')
|
||||
name.text = 'Courses.kml'
|
||||
@@ -124,11 +124,11 @@ def coursetokml(course):
|
||||
coursename.text = course.name
|
||||
open = SubElement(folder2,'open')
|
||||
open.text = '1'
|
||||
|
||||
|
||||
polygons = GeoPolygon.objects.filter(course=course).order_by("order_in_course")
|
||||
|
||||
polygonsxml = []
|
||||
|
||||
|
||||
for polygon in polygons:
|
||||
placemark = SubElement(folder2,'Placemark')
|
||||
polygonname = SubElement(placemark,'name')
|
||||
@@ -162,7 +162,7 @@ def kmltocourse(f):
|
||||
|
||||
if courses:
|
||||
return crewnerdcourse(courses)
|
||||
|
||||
|
||||
polygonpms = doc.findall('.//opengis:Placemark[opengis:Polygon]',ns)
|
||||
|
||||
return get_polygons(polygonpms)
|
||||
@@ -185,13 +185,9 @@ def createcourse(
|
||||
if i==0 and j==0:
|
||||
latitude = point['latitude']
|
||||
longitude = point['longitude']
|
||||
g = geocoder.google([latitude,longitude],method='reverse')
|
||||
g = geocoder.osm([latitude,longitude],method='reverse')
|
||||
if g.ok:
|
||||
address = g.raw['address_components']
|
||||
country = 'unknown'
|
||||
for a in address:
|
||||
if 'country' in a['types']:
|
||||
country = a['long_name']
|
||||
country = g.json['country']
|
||||
else:
|
||||
country = 'unknown'
|
||||
c.country = country
|
||||
@@ -251,13 +247,13 @@ def get_time_course(ws,course):
|
||||
paths.append(path)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(
|
||||
coursetimeseconds,
|
||||
coursemeters,
|
||||
coursecompleted,
|
||||
|
||||
|
||||
) = coursetime_paths(rowdata,paths)
|
||||
(
|
||||
coursetimefirst,
|
||||
@@ -268,7 +264,7 @@ def get_time_course(ws,course):
|
||||
|
||||
coursetimeseconds = coursetimeseconds-coursetimefirst
|
||||
coursemeters = coursemeters-coursemetersfirst
|
||||
|
||||
|
||||
return coursetimeseconds,coursemeters,coursecompleted
|
||||
|
||||
def replacecourse(course1,course2):
|
||||
|
||||
Reference in New Issue
Block a user