Added building_id fetcher
This commit is contained in:
parent
2c141250c9
commit
8a00fe48c5
@ -1,2 +1,3 @@
|
||||
from .rosseti import RossetiParser
|
||||
from .address import split_addresses
|
||||
from .address import split_addresses
|
||||
from .building_id import fetch_builing_ids
|
24
parser/building_id.py
Normal file
24
parser/building_id.py
Normal file
@ -0,0 +1,24 @@
|
||||
from typing import Optional, Tuple
|
||||
|
||||
import requests
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def get_building_id(row) -> Optional[Tuple[int, float, float]]:
|
||||
r = requests.get('https://geocode.gate.petersburg.ru/parse/eas', params={
|
||||
'street': row['Улица']
|
||||
})
|
||||
|
||||
res = r.json()
|
||||
|
||||
if 'error' not in res:
|
||||
return (res['Building_ID'], res['Longitude'], res['Latitude'])
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def fetch_builing_ids(df: pd.DataFrame) -> pd.DataFrame:
|
||||
df[['Building_ID', 'lng', 'lat']] = df.apply(
|
||||
get_building_id, axis=1, result_type='expand')
|
||||
|
||||
return df
|
Loading…
x
Reference in New Issue
Block a user