Search code examples
javaandroidgps

How can I incorporate a GPS into a program


Lets say I wanted to write a program that took my location and gave me a GPS of the fastest route to my kitchen or living room, how could I go about writing this? (Assume I'm writing in java or objective C)

edit: I apologize if this question is out of line with the general use of this website, I do not wish for anyone to write this code for me. Just a broad view on how to incorporate a GPS into a program is what I'm looking for.


Solution

  • First, you would need to create a variable for each location.

    Then you need to would need to determine each possible path between these object.

    Using the information about the path between objects you would need to write logic that would consider the position of the person in the home in relation to the destination variable to determine the most efficient path.

    So let's say you have Living Room, Foyer, Kitchen, Bedroom, Bathroom.

    The living room is connected to the Foyer, Bedroom, and Kitchen. The foyer connects to the Living Room and Kitchen. The Bedroom connects to the bathroom and living room.

    So let's say logically you create route #1 that goes Bedroom->Living Room->Kitchen.

    So assuming you have this information your program might say

    if(the person is in the bedroom){
      if(destination is the kitchen){
         Take route #1 
    }
    

    Of course there are more complex ways to do this but considering we are talking about a "house" with limited rooms this would be easiest. If you wanted to use an even more logical approach you would need to use a grid with each location plotted and then create logic that suggests routes depending upon the destination and persons location on the grid.