From wiki.ginstr.com
Jump to: navigation, search
(Calculate driving distance and store result into rows)
(Calculate driving distance and store result into rows with callback action)
Line 97: Line 97:
 
===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]|[targetRows,targetColumnNameOrWidgetIdNumber,targetColumnNameOrWidgetIdText,targetTextSuffix,callbackWidgetWhenDistanceReceived,callbackWidgetActionSet;gpsPoint1,gpsPoint2]</code>
+
:;<code>[gn:act_calculateDrivingDistance]|[targetRows,targetColumnNameOrWidgetIdNumber,targetColumnNameOrWidgetIdText,targetTextSuffix,callbackWidgetWhenDistanceReceived,callbackWidgetActionSet;gpsPoint1,gpsPoint2]</code>(M103.8.0.5)
  
 
====Example====
 
====Example====

Revision as of 15:10, 16 September 2020

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

Full signature

[gn:act_calculateDrivingDistance]|[targetRows,targetColumnNameOrWidgetIdNumber,targetColumnNameOrWidgetIdText,targetTextSuffix,callbackWidgetWhenDistanceReceived,callbackWidgetActionSet;gpsPointsDataBlock{n}] (M103.8.0.5)
Parameter Description
targetRows target target rows which can be used as source for calculating distance and target for storing calculated distance
targetColumnNameOrWidgetIdNumber target column in row or widget into which calculated distance will be stored
  • rowColumnId id of column in case we want to store into row, column must be of type number
  • widgetId id of widget, widget must support and be of type number
targetColumnNameOrWidgetIdText target column in row or widget into which calculated distance will be stored as text. targetTextSuffix will be appended as suffix to the value
  • rowColumnId id of column in case we want to store into row, column must be of type text
  • widgetId id of widget, widget must support and be of type text
targetTextSuffix source suffix which will be added to targetColumnNameOrWidgetIdText
callbackWidgetWhenDistanceReceived target on which is defined callbackWidgetActionSet
  • widgetId
callbackWidgetActionSet event action set name which will be fired after distance is calculated and stored
  • hardcoded
gpsPointsDataBlock{n} sources which will be included into calculation
  • gps widgets and/or column id's in case targetRows is defined

Calculate driving distance

[gn:act_calculateDrivingDistance]|[,targetColumnNameOrWidgetIdNumber;gpsPoint1,gpsPoint2] (M103.8.0.5)

Example

@+id/calculateDrivingDistance_calculateDrivingDistance_result - targetColumnNameOrWidgetIdNumber
@+id/calculateDrivingDistance_calculateDrivingDistance_pointOne - gpsPoint1
@+id/calculateDrivingDistance_calculateDrivingDistance_pointTwo - gpsPoint2
@+id/calculateDrivingDistance_calculateDrivingDistance_pointThree - gpsPoint3
@+id/calculateDrivingDistance_calculateDrivingDistance_pointFour - gpsPoint4
⤷ [gn
act_calculateDrivingDistance]|[,@+id/calculateDrivingDistance_calculateDrivingDistance_result;@variable/calculateDrivingDistance_calculateDrivingDistance_pointOne,@variable/calculateDrivingDistance_calculateDrivingDistance_pointTwo,@variable/calculateDrivingDistance_calculateDrivingDistance_pointThree,@variable/calculateDrivingDistance_calculateDrivingDistance_pointFour]</code>

Calculate driving distance with callback action

[gn:act_calculateDrivingDistance]|[,targetColumnNameOrWidgetIdNumber,,,callbackWidgetWhenDistanceReceived,callbackWidgetActionSet;gpsPoint1,gpsPoint2](M103.8.0.5)

Example

@+id/calculateDrivingDistance_withCallbackAction_result - targetColumnNameOrWidgetIdNumber
@+id/calculateDrivingDistance_withCallbackAction_pointOne - gpsPoint1
@+id/calculateDrivingDistance_withCallbackAction_pointTwo - gpsPoint2
@+id/myCallbackBlock - callbackWidgetWhenDistanceReceived
gn:act_set - callbackWidgetActionSet
[gn:act_calculateDrivingDistance]|[,@+id/calculateDrivingDistance_withCallbackAction_result,,,@+id/myCallbackBlock,gn:act_set;@variable/calculateDrivingDistance_withCallbackAction_pointOne,@variable/calculateDrivingDistance_withCallbackAction_pointTwo]

Calculate driving distance and store result into rows

[gn:act_calculateDrivingDistance]|[targetRows,targetColumnNameOrWidgetIdNumber,targetColumnNameOrWidgetIdText,targetTextSuffix;gpsPoint1,gpsPoint2](M103.8.0.5)

Example

@variable/calculateDrivingDistance_storeResultIntoRows_rowsResult - targetRows
devices_km - targetColumnNameOrWidgetIdNumber
devices_kmText - targetColumnNameOrWidgetIdText
@variable/calculateDrivingDistance_storeResultIntoRows_rowsResult_km - targetTextSuffix
devicesFullInfo_gps - gpsPoint1
@variable/calculateDrivingDistance_storeResultIntoRows_pointOne - gpsPoint2
[gn:act_calculateDrivingDistance]|[@variable/calculateDrivingDistance_storeResultIntoRows_rowsResult,devices_km,devices_kmText,@variable/calculateDrivingDistance_storeResultIntoRows_rowsResult_km;devicesFullInfo_gps,@variable/calculateDrivingDistance_storeResultIntoRows_pointOne]

Calculate driving distance and store result into rows with callback action

[gn:act_calculateDrivingDistance]|[targetRows,targetColumnNameOrWidgetIdNumber,targetColumnNameOrWidgetIdText,targetTextSuffix,callbackWidgetWhenDistanceReceived,callbackWidgetActionSet;gpsPoint1,gpsPoint2](M103.8.0.5)

Example

@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult - targetRows
devices_km - targetColumnNameOrWidgetIdNumber
devices_kmText - targetColumnNameOrWidgetIdText
@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult_km - targetTextSuffix
@+id/myCallbackBlock - callbackWidgetWhenDistanceReceived
gn:act_set - callbackWidgetActionSet
devicesFullInfo_gps - gpsPoint1
@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointTwo - gpsPoint2
@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointThree - gpsPoint3
[gn:act_calculateDrivingDistance]|[@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult,devices_km,devices_kmText,@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult_km,@+id/myCallbackBlock,gn:act_set;devicesFullInfo_gps,@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointTwo,@variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointThree]
Explanation

For each row in @variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult

- get the datatype GPS value of the column named devicesFullInfo_gps, calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointTwo,calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_pointThree
- asynchronously connect to our osrm server, send gpsPoints and get the distance
- store the distance into rows calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult same row from where gpsPoints were taken in column devices_km with number DT
- store the distance (with suffix read from @variable/calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult_km) into rows calculateDrivingDistance_storeResultIntoRowsWithCallbackAction_rowsResult same row from where gpsPoints were taken in column devices_kmText with text DT
- execute callback on widget @+id/myCallbackBlock for action gn:act_set