Skip to content

Commit

Permalink
avoid large gps_accuracy for larger distances
Browse files Browse the repository at this point in the history
  • Loading branch information
karussell committed Sep 20, 2023
1 parent 243c30a commit 555dc0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 12 additions & 5 deletions src/api/Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import {
import { LineString } from 'geojson'
import { getTranslation, tr } from '@/translation/Translation'
import * as config from 'config'
import { request } from 'config'
import { lessThanOrEqualTo } from 'ol/format/filter'
import { calcDist } from '@/distUtils'

interface ApiProfile {
name: string
Expand Down Expand Up @@ -119,9 +118,17 @@ export class ApiImpl implements Api {
const url = new URL(this.routingApi + 'match')
url.searchParams.append('key', this.apiKey)

// TODO NOW avoid large distances and large gps_accuracy -> measure distances?
// another problem is that response times for outdoor vehicles and larger gps_accuracy values are too slow
url.searchParams.append('gps_accuracy', ApiImpl.isMotorVehicle(args.profile) ? '160' : '50')
// avoid large distances and large gps_accuracy
let largeDistanceFactor = 1
if (args.points.length >= 2) {
const p0 = { lat: args.points[0][1], lng: args.points[0][0] }
const p1 = { lat: args.points[1][1], lng: args.points[1][0] }
if (calcDist(p0, p1) > 1_500) largeDistanceFactor = 2
}

// another problem is that response times for outdoor vehicles and larger gps_accuracy values are too slow
const gpsAccuracy = ApiImpl.isMotorVehicle(args.profile) ? 160 : 50
url.searchParams.append('gps_accuracy', '' + gpsAccuracy / largeDistanceFactor)

url.searchParams.append('profile', args.profile)
url.searchParams.append('elevation', 'true')
Expand Down
1 change: 0 additions & 1 deletion src/layers/UsePathsLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ function addHandDrawQueryPointLayer(map: Map) {
let zoom = map.getView().getZoom()
// not sure how to do this with coords.filter
for (let idx = 1; idx < coords.length; idx++) {

// TODO NOW find a better way!?
// Now skip certain locations depending on the distance (which is zoom-dependent)
if (calcDist(prevCoord, coords[idx]) > 6000 / (zoom ? zoom : 10)) {
Expand Down

0 comments on commit 555dc0d

Please sign in to comment.