Skip to content

Commit

Permalink
[Naver] Update point search
Browse files Browse the repository at this point in the history
  • Loading branch information
sk-zk committed Dec 17, 2024
1 parent f647918 commit 63f805f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
18 changes: 9 additions & 9 deletions streetlevel/naver/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,47 +28,47 @@ def build_depth_request_url(panoid: str) -> str:

def find_panorama(lat: float, lon: float, session: Session = None) -> dict:
return get_json(build_find_panorama_request_url(lat, lon), session=session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


async def find_panorama_async(lat: float, lon: float, session: ClientSession) -> dict:
return await get_json_async(build_find_panorama_request_url(lat, lon), session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


def find_panorama_by_id(panoid: str, language: str, session: Session = None) -> dict:
return get_json(build_find_panorama_by_id_request_url(panoid, language), session=session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


async def find_panorama_by_id_async(panoid: str, language: str, session: ClientSession) -> dict:
return await get_json_async(build_find_panorama_by_id_request_url(panoid, language), session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


def get_historical(panoid: str, session: Session = None) -> dict:
return get_json(build_timeline_request_url(panoid), session=session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


async def get_historical_async(panoid: str, session: ClientSession) -> dict:
return await get_json_async(build_timeline_request_url(panoid), session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


def get_neighbors(panoid: str, session: Session = None) -> dict:
return get_json(build_around_request_url(panoid), session=session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


async def get_neighbors_async(panoid: str, session: ClientSession) -> dict:
return await get_json_async(build_around_request_url(panoid), session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


def get_depth(panoid: str, session: Session = None) -> dict:
return get_json(build_depth_request_url(panoid), session=session,
headers={"Referer": "https://map.naver.com"})
headers=headers)


async def get_depth_async(panoid: str, session: ClientSession) -> dict:
Expand Down
3 changes: 3 additions & 0 deletions streetlevel/naver/naver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def find_panorama_by_id(panoid: str, language: str = "en",
"""
Fetches metadata of a specific panorama.
Note that ``panorama_type``, ``pitch`` and ``roll`` will be wrong if this is a 3D panorama because
Naver has yet to update this endpoint.
:param panoid: The pano ID.
:param language: *(optional)* Language of ``description`` and ``title`` fields; accepted values are
``ko`` (Korean),``en`` (English), ``ja`` (Japanese) and ``zh`` (Simplified Chinese).
Expand Down
9 changes: 5 additions & 4 deletions streetlevel/naver/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@ def parse_historical(response: dict, parent_id: str) -> List[NaverPanorama]:

def parse_nearby(response: dict) -> NaverPanorama:
feature = response["features"][0]
elevation = feature["properties"]["land_altitude"] * 0.01
heading, pitch, roll = _convert_pano_rotation(feature["properties"]["camera_angle"])
return NaverPanorama(
id=feature["properties"]["id"],
lat=feature["geometry"]["coordinates"][1],
lon=feature["geometry"]["coordinates"][0],
heading=math.radians(feature["properties"]["camera_angle"][1]),
heading=heading,
pitch=pitch,
roll=roll,
date=_parse_date(feature["properties"]["photodate"]),
description=feature["properties"]["description"],
title=feature["properties"]["title"],
altitude=elevation,
camera_height=(feature["properties"]["camera_altitude"] * 0.01) - elevation,
altitude=feature["properties"]["camera_altitude"] * 0.01,
panorama_type=PanoramaType(int(feature["properties"]["type"])),
)

Expand Down

0 comments on commit 63f805f

Please sign in to comment.