Tracking User Location

المشرف العام

Administrator
طاقم الإدارة
I am creating an application that will track user locations and create incident tickets related to this information. Therefore I have the following setup

Basic Setup

  • iPhone App: Tracking user location (lat, long) and reverse geocode the information
  • Server: Database for saving incident tickets including the location information
I am struggling now with the “right way” to save location information for tracking users and incidents. The flow should be as follows:

Intended Approach

  • Tickets being created should be persistently saved with the information given, like lat, long, address so I see a table of incidents that happened
  • The geo information should be efficiently handled in terms of reverse geocoding, as I thought about caching the address and lat,long info, which could possibly not allowed to google TOS
Application / Server Workflow

  • Iphone App User hits a button and executes a POST request sending lat/lng to the server
  • Server system creates a ticket associated to this request and saves this ticket info in a table called incidents
The challenge I am facing now, is how to handle the management of location data correctly, like the address information. As I want to use reverse geocoding to get the street name associated with the latitude and longitude information, I could use the Reverse Geolocation service on the iPhone or GoogleMaps API. The first question I am having is:

Question 1)

Should I reverse geocode on the iPhone and send the address info via POST request to the server as well and save the info in a table?

Question 2)

Should I only sent lat/lng information and do reverse geocoding on the server before I save the data to the database

The next step I am struggling with is, how to efficiently save the data in the database, considering database normalisation.Currently whats happening on the server is:

Create incident

  • When the server receives the POST request coming from the app, an incident ticket is being created and saved to the table incidents
  • The user lat/lng posted to the server from the app will be used to attach this info to the ticket entry to be saved in the database
So the current table format is:incidents (id, incident_reference, address_id, latitude, longitude)

Now I do not know where to save the corresponding reverse geocoded information (address)

Question 3)

Should this information be saved with the ticket info itself? I see challenges there, as I would create redundant information

So the current table format would be:

incidents (id, incident_reference, latitude, longitude, street_name)

Therefore I could use the reverse geocode info I receive from the iPhone app directly to save it directly to the incidents table. But wouldn’t that be a bad practice though? I think I would create multiple times the same address information, which would not be good in terms of database normalisation? It somehow does not look like a good idea….

To find a solution, I thought about creating a separate address table with the following table setup:

incidents (id, incident_reference, address_id, latitude, longitude)addresses (address_id, latitude, longitude, street_name)

Question 4)

Using this approach I would imagine, that I could then cache the already received reversed geocode info, to save it in the database and query my table addresses next time for an existing address. The challenge i see here is, that there would be possibly never the exact same latitude/longitude so I would have duplicate address entries with different lat/lng information in the table.



أكثر...
 
أعلى