{{indexmenu_n>1}} ===== GPS Coordinates Capture ===== \\ **We only need to follow the steps 1 and 2, except in Pocket PC, that we need besides the step 3.** \\ \\ For adding GPS support to any application, we advise **COPY AND PASTE** the next code, with the DB structure that we have already working in other projects and that can be seen in the definition of the following collections: \\ \\ **iOS EXCLUSIVE NODES **\\ \\ By default, iOS uses its own Apple location services, if we want to use those ones from Google, we must specify the two attributes described bellow. **THEY ARE APP NODE ATTRIBUTES**. ^ATTRIBUTE^DESCRIPTION^ |**google-api-enable**|true or false. By default, iOS uses the Apple services to locate the coordinates we are going to display in a contents of the MapView type. If we want touse the Google API for a better location and that the location be exactly the same than in Android, we must put this attribute to true.| |**google-api-key**|Here, we will put the API key value that Google provides us to be able to use its services, if the previous attribute is to true, here we must specify a value.| \\ ===== Step 1. Definition of the Collections ===== \\ Definition of the Collections.\\ \\ Dirección: Descripción: DIAS \\ * The ConectarGPS collection is a **special**collection that gets the data from the internal GPS of the device and shows them in the form of the collection, so that we can call it any time. \\ * The second collection CoordenadasGPS, is a collection that we use in some projects to save the position data, as we will see at the step 2, we use the maintenance node to save the GPS position data each minute in this collection, although as we said before, we can call the ConectarGPS collection at any time and take its values when and how we want to, there is no reason to use this second collection or the maintenance node. \\ ===== Step 2. Data Collection ===== \\ Before the data collection, we must start the device GPS, for this, **we are going to use the onlogon and onlogoff nodes of the Companies collection**, so that the GPS starts when entering the application and stops when we leave it. \\ \\ \\ Next, we are going to take the GPS data reading, for this, we are going to use the **maintenance** node, that will be inside the **Companies Collection**.\\ \\ This is an action to make the GPS reading that the PDA has, which coordinates will be saved in database.\\ This script is associated to the two collections described at the step 1.\\ **Setting the values of the period and frequency to the desired values**. \\ \\ === EXAMPLE WITH JAVASCRIPT === \\ \\ ===== STEP 3 (Windows Mobile only) ===== \\ ==== GPS capture Program ==== \\ The GPS module will be a process, XOneGPS.exe. For booting when starting the device, or it is saved at the //Start Up// folder from Windows, or a direct access is created to that executable.\\ \\ ==== Data in the record ==== \\ No key is necessary in the record for its configuration. Anyways, in order the application can be connected to the GPS module, it is done through the ports by default which are the **4242** for reading, and the **4244** for stopping.\\ \\ These ones can be modified from the record, but it is not necessary to modify them:\\ \\ "HKLM","SOFTWARE\CGSoft\GPS","Port","0x00000000","4242" "HKLM","SOFTWARE\CGSoft\GPS","PortStop","0x00000000","4244" \\ ==== Data reading ==== \\ It would be a coll with the node, in which the **connstring** attribute is specified the port for reading ( 4242 ) and the //data source//. \\ \\ Code from Script for data capturing:\\ \\ Set collGPS=appdata.GetCollection("ConectarGPS") Set x=collGPS("LONGITUD") . . . \\ ==== Stopping Data reading ==== \\ In this case, another coll is defined, where the stopping port is specified, the 4244.\\ \\ \\ Script code.\\ \\ Set collGPS=appdata.GetCollection("stopGPS") Set x=collGPS("STATUS") collGPS.clear collGPS = nothing . . . \\ ====== Function to check the GPS status ====== \\ result = ui.CheckGPSStatus if result = 0 then ui.MsgBox "El dispositivo no tiene hardware de localización", "Error", 0 end if if result = 1 then ui.MsgBox "La localización precisa mediante GPS está habilitado", "Mensaje", 0 end if if result = 2 then ui.MsgBox "La localización imprecisa mediante redes WiFi está habilitada", "Mensaje", 0 end if if result = 3 then ui.MsgBox "No hay habilitado ningún método de localización", "Mensaje", 0 end if if result = -1 then ui.MsgBox "Error inesperado al comprobar características de localización", "Mensaje", 0 end if \\ ====== Functions of Position cache (Android only) ====== \\ Dim a a = ui.GetLastKnownLocation \\ If the GPS is active, it returns a string with the last known position, has been captured by the framework or by any other program.\\ \\ Dim a a = ui.GetLastKnownLocationLatitude a = ui.GetLastKnownLocationLongitude a = ui.GetLastKnownLocationAltitude a = ui.GetLastKnownLocationAccuracy \\ The same than the previous one, but they return only the latitude, longitude, altitude and the accuracy of each one of these methods.\\ \\