well i have a xml file that i use to store location names with their addresses and their co ordinates. i need this data to help locating tht location on map. now the xml file is huge as it contains large amount of data so i want to reduce the searching time as i want to deploy the app on the mobile platforms- android and iphone. What i exactly do is, get users current location and then parse the xml one by one, get the co ordinates , compute distance between location and user, and then if distance less than radius, print on the screen. so any sorting or search algo can i implement here that will be on the users current location co ordinates???
Share
You have a constraint on using that XML file, OK. But do you also have a constraint on not using a database at all? Against keeping XML and a database both?
If not, you can store coordinates and a key to immediately seek in the XML file into a database. This will give you fast searches, and slower (but minimal) reads from the XML file.
If you also can not use a database, you may try and store coordinates and (again) keys to the XML file in another file, which will be far smaller, and inside which maybe you can organize some sort of tree-ordering or partitioning.
Finally if you can use ONLY the one XML file, you will have to quickly parse the file and extract the relevant coordinate information. This you can probably do with a regexp, by routinely reading enough data that you always have a full record in your memory search buffer (you need an estimate of the maximum record size to do this). But it looks expensive as all hell. I’d strongly push for some other way to do this.