Search code examples
here-api

How to get north south east and west values from latitude and longitude using HERE API?


using this HERE API: https://geocoder.api.here.com/6.2/geocode.json?searchtext=200%20S%20Lodhi%20Colony%20CA&app_id=***&app_code=#### I am able to get all info about Lodhi Colony. Similarly I want to pass input as lat and long and want it's north south and east west values.

Example:

Input:

Lat = 41.02633002010979 Long = -111.94550019690477

Output: "mapView": { "west": 2.33073, "south": 48.86836, "east": 2.33347, "north": 48.87016 }

I tried to use info provided here(https://developer.here.com/c/geocoding) but I'm not able to use it.

**Edit : ** I want bounding box of given latitude and longitude.


Solution

  • with the help of other stack-overflow answer, I figured it out by myself without need of any API.

    import math
    latitude = 41.02633002010979
    longitude = -111.94550019690477
    offset = 1.0 / 1000.0;
    latMax = latitude + offset
    latMin = latitude - offset
    
    lngOffset = offset * math.cos(latitude * math.pi / 180.0)
    lngMax = longitude + lngOffset
    lngMin = longitude - lngOffset
    
    print("latMax = "+str(latMax), "latMin = "+str(latMin), "lngMax = "+str(lngMax), "lngMin = "+str(lngMin) )