Skip to content

Commit

Permalink
PB-800 : move simplification tolerance into config
Browse files Browse the repository at this point in the history
so that we may use it later if needed for KML simplification too
  • Loading branch information
pakb committed Aug 5, 2024
1 parent 09bd3f8 commit 27f8854
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,14 @@ export const DEFAULT_FEATURE_COUNT_RECTANGLE_SELECTION = 50
* @type {Number}
*/
export const MAX_WIDTH_SHOW_FLOATING_TOOLTIP = 400

/**
* 12.5 meters is what was used in the old viewer, see
* https://github.com/geoadmin/mf-geoadmin3/blob/ce24a27b0ca8192a0f78f7b8cc07f4e231031304/src/components/GeomUtilsService.js#L207
*
* I tried lowering the value, but with the test GPX that were attached to the ticket PB-800 I get
* worst hiking time estimation when using something like 5m than if I use this 12.5 meters.
*
* @type {Number}
*/
export const GPX_GEOMETRY_SIMPLIFICATION_TOLERANCE = 12.5 // meters
4 changes: 2 additions & 2 deletions src/utils/gpxUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import bbox from '@turf/bbox'
import { isEmpty as isExtentEmpty } from 'ol/extent'
import GPX from 'ol/format/GPX'

import { GPX_GEOMETRY_SIMPLIFICATION_TOLERANCE } from '@/config'
import CoordinateSystem from '@/utils/coordinates/CoordinateSystem.class'
import { WGS84 } from '@/utils/coordinates/coordinateSystems'
import { gpxStyles } from '@/utils/styleUtils'
Expand Down Expand Up @@ -46,8 +47,7 @@ export function parseGpx(gpxData, projection) {
features.forEach((feature) => {
const geom = feature.getGeometry()
// PB-800 : to avoid a coastline paradox we simplify the geometry of GPXs
// 12.5 meters is what was used in the old viewer, see https://github.com/geoadmin/mf-geoadmin3/blob/ce24a27b0ca8192a0f78f7b8cc07f4e231031304/src/components/GeomUtilsService.js#L207
feature.setGeometry(geom.simplify(12.5))
feature.setGeometry(geom.simplify(GPX_GEOMETRY_SIMPLIFICATION_TOLERANCE))
feature.setStyle(gpxStyles[geom.getType()])
})
return features
Expand Down

0 comments on commit 27f8854

Please sign in to comment.