API for nearby search #ios

Hi everyone, I’d like to retrieve the nearby MRT, bus stops, schools or supermarkets near user location. Like the way sg one map use on their website.
Which API could I use ?

If i supposed to use retrieving theme, I’d tried it (https://docs.onemap.sg/#retrieve-theme), but I couldn’t find any explanation about user location format “extents=1.291789,%20103.7796402,1.3290461,%20103.8726032”. What are they? Anybody help me out here?

Hi emerald,

I have forwarded an email to the relevant product managers on their decision to release the data.

For the extents (“extents=1.291789,103.7796402,1.3290461,103.8726032”), it acts as a bounding box(Square based on two pairs of lat-lng) on our thematic data. This isn’t a circle(buffer) but you should be able to get nearby amenities.

Alternatively, you could use Turf library to perform geo-processing on our Point of Interests.

You can find Turf @ https://github.com/Turfjs/turf

Regards,
Kai

Hi Kai,

Thanks. I’ll read through Turf.
Aside from Turf, according to your explanation, I need to work on these bounding box calculation algorithm - eg: Adding/ Reducing 500 meters from user location in following format.
“extents =1.291789(latitude) + “%20” + 103.7796402 (longitude)”.

And is there any meaning of adding “%20” for nearby search ?

Thanks,
Emerald

Hi emerald,

Actually, you don’t have to work on this calculation. There is a swift version of Turf library underway.

Turf-Switch : https://github.com/mapbox/turf-swift/

For vertical distance from a Latlng, you can use the “turf-distance” function.

And “%20” is a url-encoding for space(" "), you can do without it. We will trim your spaces at our backend.

Hope these explanations help in your development.

Regards,
Kai

Cool! In this time between, I produced algorithm. :smile: Will give a try turf. Thank you.

1 Like

Hi Emerald,

I am facing this issues too, Can you share me how you can solve it?

Hi,

You can simply write an algorithm to calculate the straight line distance of a particular location to the point-of-interest using Core Location’s CLLocation

double distance = [poiLocation distanceFromLocation:busStopLocation];

From there, determine if this particular location should be shown on map based on the desired nearby distance

Best Regards,
Alan

Hi kaicong,

I have a similar use case where I am trying to retrieve POIs (mrt, school, hospital, mall etc) from One Map. To that end, I would like to know if the below API found on onemap.sg is available for use by the public

developers.onemap.sg/publicapi/schooldataAPI/querySchools

developers.onemap.sg/publicapi/schooldataAPI/retrieveAllSchools

developers.onemap.sg/publicapi/psvcs/getNearbyOCBCAtm

developers.onemap.sg/publicapi/cp/getNearbyCarparks

developers.onemap.sg/publicapi/themesvc/retrieveNearbyTheme

onemap.sg/nearby-api/getNearestBusStops

onemap.sg/nearby-api/getNearestMrtStops

I’ve tried using the search API (to retrieve POIs) with limited success in the absence of a category column. For example,

developers.onemap.sg/commonapi/search?searchVal=university&returnGeom=Y&getAddrDetails=Y&pageNum=1

would yield the following which is not a university.

{"SEARCHVAL":"UNIVERSITY PARK","BLK_NO":"46","ROAD_NAME":"UNIVERSITY WALK","BUILDING":"UNIVERSITY PARK","ADDRESS":"46 UNIVERSITY WALK UNIVERSITY PARK SINGAPORE 297759","POSTAL":"297759","X":"26278.1388283903","Y":"34133.0788691584","LATITUDE":"1.32496191267704","LONGITUDE":"103.817846728169","LONGTITUDE":"103.817846728169"}

Any advice on alternative ways of using the search api to retrieve POIs (MRT, school, malls, hospital) would be appreciated as well.

Regards,
John

Hi john,

Currently, these API services are routed for internal use. However, you could put in a request to onemap@sla.gov.sg with your use-cases. With more information, we could open a discussion on how we could work together. :smiley:

Regards,
Kai

1 Like

Hi Kaicong,

  Thank you for the reply. Will do in due time.

Regards,
John

1 Like

Any updates in releasing the theme data on bus stops? Thanks.

Any likewise library for Android?

Hi goondu,

you can look into https://github.com/Turfjs/turf

There are android, IOS and Web example.

Thanks.

Hi goondu,

For the theme data on bus stops, won’t be so fast.

For a mean while, you can look through https://docs.onemap.sg/#themes

you can get the theme data from there.

Thanks.

Thanks. I shall take a look at it.

Hi Jinhong,

Appreciate if you can clarify the following for me:

I’m trying to use the retrieve theme api:
/privateapi/themesvc/retrieveTheme?queryName={Query Name}&token={token}&extents={Set Location}

May I know these 2 things,

  1. how is the parameter “extents” set. Particularly, in the demo, it’s uses 2 sets of Lon-lat which, I am unclear how the 2 lon-Lat helps in retrieving the theme.
  2. how should I set my extent so that I can retrieve themes say, around 1km from my point of interests?

Thanks. Appreciate if anyone can help me to. I need the data for a school project.

Hi Khayweee,

extents={Set Loctation} is based on 4326(WGS84)

Example:
1.291789, 103.7796402,1.3290461, 103.8726032
*This Parameters is optional
*The 2 lon-lat is getting the boundaries only.

If you want to get 1km from the current location,
u need to set the calculate the distance from your Location and the themes lat lon.

Thanks.