Skip to content

Commit

Permalink
Route Details + configurability enabled + tsDoc comments + Unit Tests…
Browse files Browse the repository at this point in the history
… + types update + README work in progress
  • Loading branch information
datKaMa committed Feb 3, 2025
1 parent 0a23b0c commit 4052ef7
Show file tree
Hide file tree
Showing 10 changed files with 1,248 additions and 243 deletions.
15 changes: 3 additions & 12 deletions packages/clients/snowbox/src/mapConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,19 +265,14 @@ export const mapConfiguration = {
routing: {
serviceUrl: 'https://geodienste.hamburg.de/web_ors//v2/directions/',
format: 'geojson',
selectableTravelModes: [
'driving-car',
'driving-hgv',
'foot-walking',
'cycling-regular',
],
selectablePreferences: ['recommended', 'fastest', 'shortest'],
selectableTravelModes: [],
selectablePreferences: [],
displayPreferences: true,
displayRouteTypesToAvoid: true,
style: {
stroke: {
color: '#e51313',
width: 2,
width: 6,
},
},
addressSearch: {
Expand All @@ -296,10 +291,6 @@ export const mapConfiguration = {
],
minLength: 3,
waitMs: 300,
loadingIndicator: {
loaderStyle: 'SpinnerLoader',
displayComponent: true,
},
},
},
}
77 changes: 75 additions & 2 deletions packages/plugins/Routing/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,82 @@
# Routing

The Routing plugin...
The Routing Plugin offers a routing functionality to the user.

## Scope
The user can choose the start and endpoint of the route either with a click on the map, by entering coordinates or by entering an address. The User has to choose a travel mode and a preferred route before the request can be processed. The user can optionally choose a route type to avoid. The requested route is drawn on the map. The user can reset the form and clear the map at the same time. Once a route is requested by the user, a detailed listing of every route segment is available including instructions, distance and duration.

This module has been written for the "BKG-Routing-Service" and uses the "Adressservice Hamburg" for the address search. The return format is custom and no other Services are currently supported. Please mind this when trying to use this plugin with any other routing or address search services. For usage with other services, those must either fit the current ones, or a generalization of this plugin is required.

## Configuration

## Store
| fieldName | type | description |
| - | - | - |
|serviceUrl|string|The url of the routing service to be used.|
|format|string|The format in which the answer of the routing service is expected in.|
|selectableTravelModes|string[]|Specifies which selection of transportation modes (e.g. driving-car, driving-hgv, foot-walking, cycling-regular, wheelchair) is available to the user. In the default setting, all modes are offered.|
|selectable Preferences|string[]|Specifies which preferences for the route are offered to the user.|
|displayPreferences|bolean|Defines wether the preferences for the route are offered to the user for selection.|
|displayRouteTypesToAvoid|boolean|Defines wether route types to avoid are offered to the user for selection.|
|style|||
|style.stroke|||
|style.color|||
|style.width|||
|addressSearch|||
|addressSearch.addLoading|||
|addressSearch.removeLoading|||
|addressSearch.searchMethods|||
|addressSearch.searchMethods.queryParameters|||
|addressSearch.searchMethods.queryParameters.searchAddress|boolean||
|addressSearch.searchMethods.queryParameters.searchStreets|boolean||
|addressSearch.searchMethods.queryParameters.searchHouseNumbers|boolean||
|addressSearch.searchMethods.type|string||
|addressSearch.searchMethods.url|string|The url of the service to be used for the address search.|
|addressSearch.minLength|number||
|addressSearch.waitMs|number||

## Store // TODO: Ans Routing-Plugin anpassen

### Mutations

#### setSelectedGroupName

This can be used to change the selected search group by name.

```js
map.$store.commit(
'plugin/addressSearch/setSelectedGroupName',
'Parcel search'
)
```

Please mind that programmatically changing the search group will _not_ trigger a search, unlike a search group change by the user. If you need a search after change, consider the `search` action.

### Actions

#### search

This is a purely programmatical search method. It is not used by user input.

```js
map.$store.dispatch('plugin/addressSearch/search', {
input: 'Station Road 12',
autoselect: 'first',
})
```

The payload object supports the following fields:

| fieldName | type | description |
| - | - | - |
| input | string | Search string to be used. |
| autoselect | enum['first', 'only', 'never'] | By default, 'never' is selected, and results will be presented as if the user searched for them. Setting 'only' will autoselect if a single result was returned; setting 'first' will autoselect the first of an arbitrary amount of results >=1. |

### State

```js
map.subscribe('plugin/addressSearch/chosenAddress', (chosenAddress) => {
/* Your code. */
})
```

Address object _as returned by search service_. The result and its fields differ depending on the used backend. The callback is used whenever the user clicks on a search result or started a one-result search, which results in an auto-select of the singular result.
Loading

0 comments on commit 4052ef7

Please sign in to comment.