(→Calculate driving distance and store result into rows with callback action) |
(→Calculate driving distance and store result into rows with callback action) |
||
Line 140: | Line 140: | ||
===Calculate driving distance and store result into [[Datatypes#rows|rows]] with callback action=== | ===Calculate driving distance and store result into [[Datatypes#rows|rows]] with callback action=== | ||
− | :;<code>[gn:act_calculateDrivingDistance]|[rowsTarget,sourceColumnName, | + | :;<code>[gn:act_calculateDrivingDistance]|[rowsTarget,sourceColumnName,source,searchColumnName,searchColumnValueId;numericTargetColumnName,stringTargetColumnName,stringSuffix;eventWidgetId,event]</code> |
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | :{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | ||
Line 157: | Line 157: | ||
:*<code>[[Datatypes#gps|gps]]</code> | :*<code>[[Datatypes#gps|gps]]</code> | ||
|- | |- | ||
− | | <code>[[source| | + | | <code>[[source|source]]</code> |
| [[source]] from where [[Datatypes#gps|gps]] coordinate will be used for calculation | | [[source]] from where [[Datatypes#gps|gps]] coordinate will be used for calculation | ||
* Valid [[source|sources]]: | * Valid [[source|sources]]: |
Revision as of 17:14, 8 August 2019
Contents
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 - Valid targets:
source1
source from where gps coordinate will be used for calculation - Valid sources:
source2
source from where gps coordinate will be used for calculation - Valid sources:
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 - Valid targets:
source1
source from where gps coordinate will be used for calculation - Valid sources:
source2
source from where gps coordinate will be used for calculation - Valid sources:
eventWidgetId
target on which defined event
will be executed- Valid sources:
event
event which will be fired after action is executed - Valid sources:
hardcoded
Example
@+id/deviceKm
- target@+id/gpsInput
- source1@+id/deviceGps
- source2@+id/onDistanceReceive
- callback widgetgn: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 - Valid targets:
source1
source from where gps coordinate will be used for calculation - Valid sources:
source2
source from where gps coordinate will be used for calculation - Valid sources:
searchColumnName
rows column name which will be searched for specific searchColumnValue - Valid sources:
hardcoded
searchColumnValueId
source from which the value will be used for matching correct row by checking searchColumnName
column- Valid sources:
any source
targetColumnName
rows column name where the calculated driving distance will be stored - Valid sources:
hardcoded
Example
@variable/finalDeviceList
- target@+id/gpsInput
- source1@+id/deviceGps
- source2devices_inventoryNumber
- searchColumnName@variable/deviceNumber
- searchColumnValueIddevice_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 - Valid targets:
sourceColumnName
column from where gps coordinate will be used for calculation - Valid sources:
source
source from where gps coordinate will be used for calculation - Valid sources:
searchColumnName
rows column name which will be searched for specific searchColumnValue - Valid sources:
hardcoded
searchColumnValueId
source from which the value will be used for matching correct row by checking searchColumnName
column- Valid sources:
any source
numericTargetColumnName
rows column name where the calculated driving distance will be stored as number - Valid sources:
hardcoded
stringTargetColumnName
rows column name where the calculated driving distance will be stored as text - Valid sources:
hardcoded
stringSuffix
suffix value displayed in stringTargetColumnName - Valid sources:
eventWidgetId
target on which defined event
will be executed- Valid sources:
event
event which will be fired after action is executed - Valid sources:
hardcoded
Example
@variable/finalDeviceList
- rows with devicesdevices_gps
- column in finalDeviceList variable, with GPS@+id/gpsInput
- widget with GPS positiondevices_km
- target column, which will store result in meters, like 1200devices_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 widgetgn: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 "devicesFullInfo_gps". - asynchronously connect to our osrm server and send startPoint GPS "@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointOne" and endPoint GPS value of column "devicesFullInfo_gps" and get the distance and store it into number datatype and then into row as column "devices_km" and store same result distance into text datatype, add suffix "@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult_km" and store it into "devices_kmText" column into row. - execute callback on widget "@+id/myCallbackBlock" for action "gn:act_set"