Skip to content

Commit

Permalink
Merge pull request #32 from Skippern/none-object
Browse files Browse the repository at this point in the history
relation without shape -> None
  • Loading branch information
Skippern authored Sep 2, 2017
2 parents cc9a4d5 + 22face4 commit 70d4f62
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fetch_kml.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@
gpx_store.init_cache()


tags = gpx_data.load_tags(args.obj_id, args.obj_level)
try:
tags = gpx_data.load_tags(args.obj_id, args.obj_level)
except:
tags = dict({ 'name': 'unknown', })

name = str(args.obj_id)
if 'name:en' in tags:
name = tags['name:en']
else:
name = tags['name']
try:
name = tags['name']
except:
pass

geos = gpx_data.load_geo_shape(args.obj_id, args.obj_level, name)
gpx_store.store_kml(geos, args.obj_id, args.obj_level, name)
4 changes: 4 additions & 0 deletions gpx/gpx_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ def geojson_to_geometry(data, name):

###########################

if len(my_ways) == 0:
__LOG.critical("Relation have no shape: %s" % name )
return None

rings = []
lines = []

Expand Down
3 changes: 3 additions & 0 deletions gpx/gpx_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def store_wkb(obj, obj_id, admin_level):
:param int admin_level: The subdir (usually the administrative level)
:return: None
"""
if obj == None:
return None

filename = '%s/geos/%s/%s.wkb' % (cache_dir, admin_level, obj_id)

__LOG.info(u'store_wkb: storing a %s with size: %s ', obj.geom_type, obj.area)
Expand Down
2 changes: 2 additions & 0 deletions gpx/gpx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ def test_object(track, obj):
:param obj: The polygon object to test against.
:return bool: If the object
"""
if obj == None:
return False
if track.within(obj):
return True
if track.intersects(obj):
Expand Down

0 comments on commit 70d4f62

Please sign in to comment.