change reverse_geocoder for openmaps api call
This commit is contained in:
parent
ab20418a18
commit
106fe545fa
|
@ -7,7 +7,7 @@ import sys
|
|||
from typing import List, Union
|
||||
|
||||
import pyproj
|
||||
import reverse_geocoder as rg
|
||||
# import reverse_geocoder as rg
|
||||
from pyproj import Transformer
|
||||
|
||||
from city_model_structure.building import Building
|
||||
|
@ -31,6 +31,7 @@ class City:
|
|||
# todo: right now extracted at city level, in the future should be extracted also at building level if exist
|
||||
self._location = None
|
||||
|
||||
@property
|
||||
def _get_location(self):
|
||||
if self._location is None:
|
||||
gps = pyproj.CRS('EPSG:4326') # LatLon with WGS84 datum used by GPS units and Google Earth
|
||||
|
@ -41,7 +42,8 @@ class City:
|
|||
sys.exit()
|
||||
transformer = Transformer.from_crs(input_reference, gps)
|
||||
coordinates = transformer.transform(self.lower_corner[0], self.lower_corner[1])
|
||||
self._location = rg.search(coordinates)
|
||||
self._location = GeometryHelper.get_location(coordinates[0], coordinates[1])
|
||||
# rg.search(coordinates)
|
||||
return self._location
|
||||
|
||||
@property
|
||||
|
@ -50,7 +52,7 @@ class City:
|
|||
City country code
|
||||
:return: str
|
||||
"""
|
||||
return self._get_location()[0]['cc']
|
||||
return self._get_location[0]
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -58,9 +60,7 @@ class City:
|
|||
City name
|
||||
:return: str
|
||||
"""
|
||||
if self._name is None:
|
||||
self._name = self._get_location()[0]['name']
|
||||
return self._name
|
||||
return self._get_location[1]
|
||||
|
||||
@property
|
||||
def city_objects(self) -> Union[List[CityObject], None]:
|
||||
|
|
|
@ -7,6 +7,8 @@ import math
|
|||
|
||||
import numpy as np
|
||||
import open3d as o3d
|
||||
import requests
|
||||
import json
|
||||
from trimesh import Trimesh
|
||||
from trimesh import intersections
|
||||
from helpers.configuration_helper import ConfigurationHelper
|
||||
|
@ -187,3 +189,14 @@ class GeometryHelper:
|
|||
return 'Ground'
|
||||
else:
|
||||
return 'Roof'
|
||||
|
||||
@staticmethod
|
||||
def get_location(latitude, longitude):
|
||||
url = 'https://nominatim.openstreetmap.org/reverse?lat={latitude}&lon={longitude}&format=json'
|
||||
resp = requests.get(url.format(latitude=latitude, longitude=longitude))
|
||||
if resp.status_code != 200:
|
||||
# This means something went wrong.
|
||||
raise Exception('GET /tasks/ {}'.format(resp.status_code))
|
||||
else:
|
||||
response = resp.json()
|
||||
return [response['address']['country_code'], response['address']['city']]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
xmltodict~=0.12.0
|
||||
numpy~=1.18.5
|
||||
numpy~=1.19.0
|
||||
open3d~=0.10.0.0
|
||||
trimesh~=3.7.0
|
||||
pyproj~=2.6.1.post1
|
||||
|
@ -15,7 +15,7 @@ parso~=0.7.0
|
|||
jedi~=0.17.0
|
||||
pytz~=2020.1
|
||||
setuptools~=47.3.0
|
||||
scipy~=1.4.1
|
||||
scipy~=1.5.0
|
||||
six~=1.15.0
|
||||
webencodings~=0.5.1
|
||||
packaging~=20.4
|
||||
|
|
Loading…
Reference in New Issue
Block a user