Selections and blockages
Since version 9.10 the MapTrip SDK provides the opportunity for adding blockages in a convenient way by using the Selection API.
A blockage is always a geometric object, that might be a point, polyline or polygon. Each of these blockages may have an optional start and end time.
Types of blockages
Blockages can either be temporary or persisted. You can add a blockage to one of the new provided selections of the SDK:
Temporary
Selection.getTemporaryBlockages()
The blockages of this Selection are lost after a restart of the App.
Persisted
Selection.getPersistedBlockages()
The blockages of this Selection are saved into the user data path (blockages_selection.sfs) and will again be loaded after a restart.
Common usage
If you want to add a point, polyline or polygon, you will always have to create a Polygon object with
- One point, that later is treated as a point blockage
- Several points, where the first point is not equal than the last point, that later is treated as a polyline blockage
- Several points, where the first point is equal to last point, that later is treated as a polygon blockage
If you use a polyline as a blockage, the streets are only blocked in the direction of this polyline.
When you have created a Polygon object and have set the points with Polygon.setPoints() you can optionally set a start and end time with the new functions Polygon.setStartTime() and Polygon.setEndTime().
The time has to be set as timestamp in UTC (seconds since 1970).
Additionally you can set a radius for each of these blockage objects. The radius is not only used, when you have a point blockage. The radius is also added at polylines and polygons. The following picture shows, how the radius is used:

You can set the radius with Polygon.setAttributeAsDouble("BlockageRadius", radius)
If you do not set the radius, then it will taken from the settings.ini. For each object type you can set the radius as follows:
1 2 3 4 | |
If the radius is not set in the settings.ini, 3 Meters are taken.
Once you have your new Polygon object, you can add this to the persisted or temporary Selection object. It will then be used for route calculation (offline and online!).
If you set a end time at a blockage and add this to the persisted selection, the blockage (still a Polygon object) will be deleted automatically for persistent blockages, when the time has exceeded.
Behavior
The persisted blockages are saved
- when the Application terminates correctly (uninitialize) and
- when a new route calculation is triggered (new route guidance or rerouting) and the selection was modified before.
- it is not saved after each single modification (adding or deleting a Polygon object), because this might result in some performance issues, if you do several modifications.
The blockage Selections are not automatically displayed in all of your Mapviewer. Therefore you have to call Mapviewer.showSelection(...) for the desired Mapviewer.
But if you modify a blockage Selection during a route guidance, a rerouting is automatically triggered with the next GPS update.
Example
The following example shows a Polygon blockage and the resulting route.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |

Overview new functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |