0

I have a dataset of ~300 electoral districts (~10MB - 45MB depending on the file format - GML/KML/SHAPE/JSON). I'm hoping to build a mobile app (iOS/Android/Windows Phone) that will determine which electoral district a user is in based on their current lat/lon.

My original plan was to set up an Azure webservice and use SQL Server or DocumentDB's spatial functionality to provide the answer. But the electoral districts are fairly static, so if I can do this on the device it might be better.

I'm thinking I'll likely use Xamarin.Forms to build my app since the UI doesn't need to be that complex (I don't need to draw maps or electoral districts).

I see that EF6 seems to have spatial functionality that would work, but I'm finding conflicting info about whether or not that will work with Xamarin.Forms, or if the performance will be reasonable.

What's the best (fastest/simplest) library/class I can use to determine the electoral district locally in a Xamarin.Forms app?

1 Answers1

0

I wasn't able to find a library/class, but it seems like I can code a solution myself with little effort. I found this link: http://www.codeproject.com/Tips/84226/Is-a-Point-inside-a-Polygon . I didn't quite understand it the first time I looked at it, but now it makes sense.

My plan is to store my electoral district (polygons) in SQLite locally. But, I'll also include 4 columns for min/max lat/lon of each polygon. That gives me the minimum bounding rectangle for each polygon, and will serve as a primitive spatial index of sorts to quickly identify a small subset of possible electoral districts. From there I can use the algorithm found on CodeProject to confirm which electoral district is the correct one.

  • here is a question relating to adding Geo functions to SQLite - http://stackoverflow.com/questions/13326817/custom-functions-sqlite-with-mono – Jason Aug 24 '15 at 18:12