Skip to content

Commit 1182b96

Browse files
authored
Merge pull request #451 from nextmv-io/nilsbeck/add-osrm-curb-approaches
nilsbeck/add-WithApproachCurb-to-TableOptions
2 parents 5fbaa79 + 59a47ed commit 1182b96

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

measure/osrm/client.go

+21-3
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,15 @@ func (c *client) tableRequests( //nolint:gocyclo
378378
path += strings.Join(annotations, ",")
379379
}
380380

381+
if config.withApproachCurb {
382+
path += "&approaches="
383+
approaches := make([]string, len(resultingChunk))
384+
for i := 0; i < len(approaches); i++ {
385+
approaches[i] = "curb"
386+
}
387+
path += strings.Join(approaches, ";")
388+
}
389+
381390
// Set scale factor. This only has an effect on durations.
382391
if c.scaleFactor != 1.0 {
383392
path += fmt.Sprintf("&scale_factor=%f", c.scaleFactor)
@@ -440,9 +449,10 @@ type TableOptions func(*tableConfig)
440449

441450
// tableConfig defines options for the table configuration.
442451
type tableConfig struct {
443-
withDistance bool
444-
withDuration bool
445-
parallelRuns int
452+
withDistance bool
453+
withDuration bool
454+
parallelRuns int
455+
withApproachCurb bool
446456
}
447457

448458
// WithDuration returns a TableOptions function for composing a tableConfig with
@@ -463,6 +473,14 @@ func WithDistance() TableOptions {
463473
}
464474
}
465475

476+
// WithApproachCurb returns a TableOptions func for a tableConfig with the
477+
// approach curb set.
478+
func WithApproachCurb() TableOptions {
479+
return func(c *tableConfig) {
480+
c.withApproachCurb = true
481+
}
482+
}
483+
466484
// ClientOption can pass options to be used with an OSRM client.
467485
type ClientOption func(*client)
468486

0 commit comments

Comments
 (0)