11import sys
22import requests
33import json
4- from shapely .geometry import mapping , Point
4+ from shapely .geometry import Point
55
66
77class API (object ):
@@ -44,7 +44,7 @@ def Get(self, query, asGeoJSON=False):
4444 response = json .loads (self ._GetFromOverpass (
4545 self ._ConstructQLQuery (query )))
4646 except OverpassException as oe :
47- print oe
47+ print ( oe )
4848 sys .exit (1 )
4949
5050 if "elements" not in response or len (response ["elements" ]) == 0 :
@@ -67,7 +67,7 @@ def _ConstructQLQuery(self, userquery):
6767
6868 complete_query = self ._QUERY_TEMPLATE .format (responseformat = self .responseformat , query = raw_query )
6969 if self .debug :
70- print complete_query
70+ print ( complete_query )
7171 return complete_query
7272
7373 def _GetFromOverpass (self , query ):
@@ -79,7 +79,7 @@ def _GetFromOverpass(self, query):
7979 try :
8080 r = requests .get (self .endpoint , params = payload , timeout = self .timeout )
8181 except requests .exceptions .Timeout :
82- raise OverpassException (408 ,
82+ raise OverpassException (408 ,
8383 'Query timed out. API instance is set to time out in {timeout} seconds. '
8484 'Try passing in a higher value when instantiating this API:'
8585 'api = Overpass.API(timeout=60)' .format (timeout = self .timeout ))
@@ -107,12 +107,14 @@ def _asGeoJSON(self, elements):
107107 "tags" : elem .get ("tags" ),
108108 "nodes" : elem .get ("nodes" )}
109109 for elem in elements if elem ["type" ] == "way" ]
110- print nodes
111- print ways
110+ print (nodes )
111+ print (ways )
112+
112113
113114class OverpassException (Exception ):
114115 def __init__ (self , status_code , message ):
115116 self .status_code = status_code
116117 self .message = message
118+
117119 def __str__ (self ):
118- return json .dumps ({'status' : self .status_code , 'message' : self .message })
120+ return json .dumps ({'status' : self .status_code , 'message' : self .message })
0 commit comments