Retrieving nearby stores based on coordinates from xml file

I am creating a storage locator application. In my application, I show the nearest store to a given latitude and longitude. I get my current lan. and more.

I have an xml file on the server containing all the information about stores, latitude and longitude. I am going to connect the application to this xml file and get the nearest stores in accordance with the given coordinates. Now the problem is how can I get the nearest stores in the given coordinates.

I heard about the haversine formula, but how can I use this formula to get the nearest stores from an xml file? or if there is another way, please suggest

0
source share
2 answers

If I were you, I would analyze the whole file to get a list of stores. classified by X and then Y.

Then, to get a list of nearby stores, simply grab them from the list.

I am sure that you will not be able to get stores on the fly without parsing your file.

Another way is to send a request to the server, to which you will answer only with the nearest stores! Each task performed on a portable device, such as an iphone, requires a lot of time and battery than if it were done on a server.

+1
source

You might want to get your location, postal codes, etc. in the database. Look for it in

opengeodb

or some similar ones. You must expand your sqlite with distanceFunc because arcSin and arcCos are not part of sqlite. In your application, you then simply compare your lat stores and long to your stores. An example of math can be found here.

http://www.mamat-online.de/umkreissuche/opengeodb.php

although he is in German. You can find a good tutorial here:

http://www.thismuchiknow.co.uk/?p=71

NTN Marcus

0
source

Source: https://habr.com/ru/post/1384036/


All Articles