Skip to content

Commit

Permalink
Implementation of point infos in subjective 3d
Browse files Browse the repository at this point in the history
  • Loading branch information
PCigales authored May 30, 2022
1 parent e7b4d84 commit 325108c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
13 changes: 13 additions & 0 deletions GPXTweaker.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,19 @@ User_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Fi
Alias: OSM_NOMINATIM
#Json_key: display_name

[Handling]
Key:
Referer:
User_agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0


[[ReverseGeocodingAPI Google Maps]]

[Infos]
Alias: GOOGLE_MAPS_FR
#Source: https://www.google.fr/maps/place/{lat},{lon}
#Html_regex: <[^<]*?· (.*?). itemprop="name">

[Handling]
Key:
Referer:
Expand Down
23 changes: 16 additions & 7 deletions GPXTweaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2539,10 +2539,11 @@ def RequestItinerary(self, infos, points, key=None, referer=None, user_agent='GP

class WGS84ReverseGeocoding():

AS_IGN_LOOK4_50 = {'alias': 'IGN_LOOK4', 'source': 'https://geocodage.ign.fr/look4/poi/reverse?searchGeom={{"type":"Circle","coordinates":[{lon},{lat}],"radius":50}}&lonlat={lon},{lat}','key': ('features', 'properties', 'extraFields', 'names')}
AS_IGN_LOOK4 = AS_IGN_LOOK4_150 = {'alias': 'IGN_LOOK4', 'source': 'https://geocodage.ign.fr/look4/poi/reverse?searchGeom={{"type":"Circle","coordinates":[{lon},{lat}],"radius":150}}&lonlat={lon},{lat}','key': ('features', 'properties', 'extraFields', 'names')}
AS_IGN_LOOK4_250 = {'alias': 'IGN_LOOK4', 'source': 'https://geocodage.ign.fr/look4/poi/reverse?searchGeom={{"type":"Circle","coordinates":[{lon},{lat}],"radius":250}}&lonlat={lon},{lat}','key': ('features', 'properties', 'extraFields', 'names')}
AS_IGN_LOOK4_50 = {'alias': 'IGN_LOOK4_50', 'source': 'https://geocodage.ign.fr/look4/poi/reverse?searchGeom={{"type":"Circle","coordinates":[{lon},{lat}],"radius":50}}&lonlat={lon},{lat}','key': ('features', 'properties', 'extraFields', 'names')}
AS_IGN_LOOK4 = AS_IGN_LOOK4_150 = {'alias': 'IGN_LOOK4_150', 'source': 'https://geocodage.ign.fr/look4/poi/reverse?searchGeom={{"type":"Circle","coordinates":[{lon},{lat}],"radius":150}}&lonlat={lon},{lat}','key': ('features', 'properties', 'extraFields', 'names')}
AS_IGN_LOOK4_250 = {'alias': 'IGN_LOOK4_250', 'source': 'https://geocodage.ign.fr/look4/poi/reverse?searchGeom={{"type":"Circle","coordinates":[{lon},{lat}],"radius":250}}&lonlat={lon},{lat}','key': ('features', 'properties', 'extraFields', 'names')}
AS_OSM_NOMINATIM = {'alias': 'OSM_NOMINATIM', 'source': 'https://nominatim.openstreetmap.org/reverse?lat={lat}&lon={lon}&format=jsonv2','key': ('display_name',)}
AS_GOOGLE_MAPS_FR = {'alias': 'GOOGLE_MAPS_FR', 'source': 'https://www.google.fr/maps/place/{lat},{lon}','regex': '<[^<]*?· (.*?). itemprop="name">'}

@classmethod
def ASAlias(cls, name):
Expand Down Expand Up @@ -2578,14 +2579,20 @@ def RequestDescription(self, infos, point, key=None, referer=None, user_agent='G
uri = infos['source'].format_map({'key': key or '', 'lat': point[0], 'lon': point[1]})
try:
rep = HTTPRequest(uri, 'GET', headers, pconnection=pconnection)
print(rep.code)
if rep.code != '200':
return None
if not rep.body:
return None
jdesc = json.loads(rep.body)
return WGS84ReverseGeocoding._parse_json(jdesc, infos['key'])
if 'key' in infos:
jdesc = json.loads(rep.body)
return WGS84ReverseGeocoding._parse_json(jdesc, infos['key'])
elif 'regex' in infos:
return re.search(infos['regex'],rep.body.decode('utf-8')).group(1)
else:
return None
except:
return None
return None


class XMLNode():
Expand Down Expand Up @@ -13480,7 +13487,9 @@ def _load_config(self, uri=os.path.dirname(os.path.abspath(__file__)) + '\GPXTwe
return False
elif field == 'json_key':
s[1]['key'] = value if hcur[:13] == 'elevationapi ' else tuple(map(str.strip, value.split(',')))
elif field in ('source',) + (('separator', 'nodata') if hcur[:13] == 'elevationapi ' else ()):
elif field == 'html_regex' and hcur[:20] == 'reversegeocodingapi ':
s[1]['regex'] = value
elif field == 'source' or (field in ('separator', 'nodata') and hcur[:13] == 'elevationapi '):
s[1][field] = value
if field == 'nodata':
try:
Expand Down

0 comments on commit 325108c

Please sign in to comment.