From wiki.ginstr.com
Revision as of 17:19, 8 August 2019 by Dinko (talk | contribs) (Workflow)
Jump to: navigation, search

gn:act_calculateDrivingDistance

Description
Action is used to calculate driving distance between two GPS coordinates and store the result into target
In order for this action to work, an internet connection must be active because the calculations are done by OSRM server.
Action returns
void

Action signatures

Calculate driving distance

[gn:act_calculateDrivingDistance]|[target,source1,source2]
Parameter Description
target target into which calculated driving distance will be stored
source1 source from where gps coordinate will be used for calculation
source2 source from where gps coordinate will be used for calculation

Example

@+id/deviceKm - target
@+id/gpsInput - source1
@+id/deviceGps - source2
[gn:act_calculateDrivingDistance]|[@+id/deviceKm,@+id/gpsInput,@+id/deviceGps]

Calculate driving distance with callback action

[gn:act_calculateDrivingDistance]|[target,source1,source2;;eventWidgetId,event]
Parameter Description
target target into which calculated driving distance will be stored
source1 source from where gps coordinate will be used for calculation
source2 source from where gps coordinate will be used for calculation
eventWidgetId target on which defined event will be executed
event event which will be fired after action is executed
  • hardcoded

Example

@+id/deviceKm - target
@+id/gpsInput - source1
@+id/deviceGps - source2
@+id/onDistanceReceive - callback widget
gn:act_set - callback action
[gn:act_calculateDrivingDistance]|[@+id/deviceKm,@+id/gpsInput,@+id/deviceGps;;@+id/onDistanceReceive,gn:act_set]

Calculate driving distance and store result into rows

[gn:act_calculateDrivingDistance]|[rowsTarget,source1,source2,searchColumnName,searchColumnValueId;targetColumnName]
Parameter Description
target target into which calculated driving distance will be stored
source1 source from where gps coordinate will be used for calculation
source2 source from where gps coordinate will be used for calculation
searchColumnName rows column name which will be searched for specific searchColumnValue
  • hardcoded
searchColumnValueId source from which the value will be used for matching correct row by checking searchColumnName column
  • any source
targetColumnName rows column name where the calculated driving distance will be stored
  • hardcoded

Example

@variable/finalDeviceList - target
@+id/gpsInput - source1
@+id/deviceGps - source2
devices_inventoryNumber - searchColumnName
@variable/deviceNumber - searchColumnValueId
device_km - targetColumnName
[gn:act_calculateDrivingDistance]|[@variable/finalDeviceList,@+id/gpsInput,@+id/deviceGps,devices_inventoryNumber;@variable/deviceNumber,device_km]

Calculate driving distance and store result into rows with callback action

[gn:act_calculateDrivingDistance]|[rowsTarget,sourceColumnName,source,searchColumnName,searchColumnValueId;numericTargetColumnName,stringTargetColumnName,stringSuffix;eventWidgetId,event]
Parameter Description
target target into which calculated driving distance will be stored
sourceColumnName column from where the end gps coordinate will be used for calculation
source source from where the start gps coordinate will be used for calculation
searchColumnName rows column name which will be searched for specific searchColumnValue
  • hardcoded
searchColumnValueId source from which the value will be used for matching correct row by checking searchColumnName column
  • any source
numericTargetColumnName rows column name where the calculated driving distance will be stored as number
  • hardcoded
stringTargetColumnName rows column name where the calculated driving distance will be stored as text
  • hardcoded
stringSuffix suffix value displayed in stringTargetColumnName
eventWidgetId target on which defined event will be executed
event event which will be fired after action is executed
  • hardcoded

Example

@variable/finalDeviceList - rows with devices
devices_gps - column in finalDeviceList variable, with GPS
@+id/gpsInput - widget with GPS position
devices_km - target column, which will store result in meters, like 1200
devices_kmText - target column, which will store result in text view, like "1,2 km"
@variable/km - text variable wich contains " km" text
@+id/onDistanceArrived - callback widget
gn:act_set - callback action
[gn:act_calculateDrivingDistance]|[@variable/finalDeviceList,devices_gps,@+id/gpsInput;devices_km,devices_kmText,@variable/km;@+id/onDistanceArrived,gn:act_set]
Workflow

For each row in "@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult" - get the datatype GPS value of the column named "devices_gps". - asynchronously connect to our osrm server and send startPoint GPS "@+id/gpsInput" and endPoint GPS value of column "devices_gps" and get the distance - store the distance into same row in column "devices_km" with number DT - store the distance (with suffix read from @variable/km) into same row in column "devices_kmText" with text DT - execute callback on widget "@+id/onDistanceArrived" for action "gn:act_set"