finding the top 5 geographical locations in a database - geolocation

I am trying to write a program that has the ability to search through an sqlite database of different sites that have their geographical coordinates and i need to be able to return the closes five coordinates to the users current position, I already have used reverse-geocoding to find my current position and the distance from the sites, however I have not been able to display the closest five. Any help would be much appreciated, Thank you!

Related

How to get near by places in radius of 2 kilometer from current location without using Google API in iOS Objective C

I am developing a Map based iOS app in Objective C. Basically what I need to achieve is to get the details data of suggested location that is within 5 kilo meter to the current user location without using Google API. I have searched a lot but could not find any answer to my question.
I tried below links related to my problem but could not get satisfactory solution :
how to find nearest latitude and longitude form current place?
get nearest locations from my current location
http://api.geonames.org/findNearbyPlaceNameJSON?lat=12.9972&lng=77.6143&radius=5&username=demo
How to get the nearest area from a list of locations?
I want to know if there is some other good and efficient approach (free).
Thank You !
If you have the coordinates of all the places you want to search from in database, then you can implement Haversine formula in sql query and this will return results within the specified distance as in your case 2km.Refer to this link for detailed information.

Swift: Maps: How to tell next intersecting street on my route

I am writing an iOS app in swift. I need to be able to tell at any given point in time what street will be intersecting next on my user's route who is driving/walking.
I am able to find the street name user is currently on, the direction user is moving in and also the current coordinates but the last step stumps me: which street will intersect next?
I am open to using Apple Maps, Google Maps, OSM etc as long as it if free.
Your best bet is to use https://developers.google.com/maps/documentation/directions/
The idea is to get the legs of the directions and then determine in which leg you are currently in which you can do since you know the current street name you are in and then find the info about the next leg. It may not always be accurate but its the easiest way that you can find which street will intersect.
You can either use the Driving or Waypoints api.
Hope this helps.

Best solution for iOS Mapping multiple latitude and longitude points

What would be my best option if i want to map multiple lat, longs onto a map within an iOS App?
I have hundreds of points captured from a GPS receiver over an hours walk. Does anyone have any thoughts on how to best ingest all these points and spit out a map with the exact route followed??
Any help with this would be great. Is there anyway i can provide all the data points to the Google Maps API and they return a map plus meta data for things like total distance?
What have you tried so far? What part are you unsure about? How do you want to display the route and when?
As far as I understand, you are saving coordinates to a database at a defined interval. We don't know at what frequency. You will be able to display each point on a map, and eventually link them alltogether with a polyline. But that won't follow roads. For this you would need to use the Directions service. But this service has limitations:
You cannot assume that giving the service your start and end coordinates it would calculate the same route that you followed.
You can give the service a few waypoints but you are limited to 8 waypoints per request (with the free API).
The free API allows for 2500 requests per day / 10 per second.
Let me know if there is anything else I can help you with.

Adding topography to an Open Street Map based application

I have an application that successfully uses a pre loaded tile cache of Open Street Map .png files for a small city area about 20km x20km to support the presentation of tourist information on the web, iPad and iPhone. It is written in HTML5 and uses MoSync to create the wrapper to deliver it on the mobile devices.
This approach works well for cities but I would like to extend the app to work in countryside areas (in the UK initially) where if I could access it, Ordnance Survey mapping 25000,50000 and 250000 would deliver a much better user experience.
My specific questions are:
How do I get hold of topographic tiles?
Can I get tiles that have the same slippy map structure as OSM.
Can I use Ordnance Survey as a source for the UK and if so is it a one off license fee?
What zoom levels are available? I expect 25000, 50000 and 250000. Is 100000 available?
What formula do I use to identify the specific tile from a lat and long pair?
Will all the tiles at a specified zoom level be the same delta lat and delta long? If not how do I tile them?
Answering a few of your questions:
There are several OSM based maps with topographic elements. Take a look at the list of tile servers and the list of OSM based services. Remember to check each usage policy first before using them in your application.
For determining the filenames of the slippy map for a given latitude, longitude and zoom level, read the slippy map tilenames page in the OSM wiki.

Scalable solution for geocoding on iOS

I'm working on an iOS app that pulls events from Google Calendar and subsequently generates pins on a map for each event (based on what the event creator fills in for "Location"). The user can select a date range (today, this week, this month, etc.) and see all the events taking place near them over that period.
Problem 1: The app is for my local university, so a majority of the locations will be buildings on campus. These buildings have inconsistent addresses that are often difficult to find, so it would be good if the location "Foo Hall" would result in a pin on that building. Google Maps is capable of doing this, however Apple Maps has no knowledge of the buildings on my school campus.
Problem 2: In an ideal situation, thousands of students would be using this app. Each time they open the app, they could be viewing dozens of pins. Therefore, I'm worried that I may be pushing the limits imposed by Google's geocoding API (definitely the 2500 request limit, and maybe even the 100,000 request limit for the Business API).
So my question is... what would be the best solution for these two problems? Should I create a local database for building names and map them to coordinates? Or is there a way I can overcome the limitations of Google's Geocoding API? Is there a better solution I'm not thinking of?
Thanks for any help!
I would use latitude and longitude coordinates for the buildings and allow for people to add locations to the database if they are meeting somewhere that you have not added already. This way, the pins will drop in the center of the building if you want them to, because you are not relying on an address or on looking up a building name. You simply know that "Foo Hall" is at X latt. and Y long. And if someone selects "Foo Hall" or sees an event at "Foo Hall" there is a perfectly placed pin right in the middle of it on the map. I don't think you need to worry as much about the geocoding API if you are using hardcoded locations for the buildings either, because you won't have to be polling Google to get the building locations.
I would also use some sort of server to store the building locations so they can be updated or added to, either by you or by the users.
That's how I would handle it, good luck!

Resources