mirror of https://gitlab.com/bashrc2/epicyon
Include latitude and longitude for place if available
parent
2418bfc349
commit
b19349eae5
18
posts.py
18
posts.py
|
|
@ -1371,6 +1371,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
elif location.get('name'):
|
elif location.get('name'):
|
||||||
# check if the location url looks like a map url
|
# check if the location url looks like a map url
|
||||||
locn_url2 = locn_url
|
locn_url2 = locn_url
|
||||||
|
latitude = longitude = None
|
||||||
if locn_url2:
|
if locn_url2:
|
||||||
_, latitude, longitude = \
|
_, latitude, longitude = \
|
||||||
geocoords_from_map_link(locn_url2, 'openstreetmap.org',
|
geocoords_from_map_link(locn_url2, 'openstreetmap.org',
|
||||||
|
|
@ -1379,6 +1380,14 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
locn_url2 = None
|
locn_url2 = None
|
||||||
|
|
||||||
if not locn_url2 or location.get('address'):
|
if not locn_url2 or location.get('address'):
|
||||||
|
if latitude and longitude:
|
||||||
|
new_post['object']['location'] = {
|
||||||
|
'type': 'Place',
|
||||||
|
'name': location['name'],
|
||||||
|
'longitude': longitude,
|
||||||
|
'latitude': latitude
|
||||||
|
}
|
||||||
|
else:
|
||||||
new_post['object']['location'] = {
|
new_post['object']['location'] = {
|
||||||
'type': 'Place',
|
'type': 'Place',
|
||||||
'name': location['name']
|
'name': location['name']
|
||||||
|
|
@ -1528,6 +1537,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
elif location.get('name'):
|
elif location.get('name'):
|
||||||
# check if the location url looks like a map url
|
# check if the location url looks like a map url
|
||||||
locn_url2 = locn_url
|
locn_url2 = locn_url
|
||||||
|
latitude = longitude = None
|
||||||
if locn_url2:
|
if locn_url2:
|
||||||
_, latitude, longitude = \
|
_, latitude, longitude = \
|
||||||
geocoords_from_map_link(locn_url2, 'openstreetmap.org',
|
geocoords_from_map_link(locn_url2, 'openstreetmap.org',
|
||||||
|
|
@ -1536,6 +1546,14 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
locn_url2 = None
|
locn_url2 = None
|
||||||
|
|
||||||
if not locn_url2 or location.get('address'):
|
if not locn_url2 or location.get('address'):
|
||||||
|
if latitude and longitude:
|
||||||
|
new_post['location'] = {
|
||||||
|
'type': 'Place',
|
||||||
|
'name': location['name'],
|
||||||
|
'longitude': longitude,
|
||||||
|
'latitude': latitude
|
||||||
|
}
|
||||||
|
else:
|
||||||
new_post['location'] = {
|
new_post['location'] = {
|
||||||
'type': 'Place',
|
'type': 'Place',
|
||||||
'name': location['name']
|
'name': location['name']
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue