Skip to content

Commit f00b55e

Browse files
authored
Merge pull request #250 from geoblocks/fix_swisstopo_first_last
fix: wrong profile first and last coord
2 parents fb869cc + a462573 commit f00b55e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/profiler/ExtractFromSegment.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ export default class ExtractFromSegment implements Profiler {
3030
.clone()
3131
.transform(this.projection, 'EPSG:4326');
3232

33-
const coordinates = geometry.getCoordinates();
3433
const coordinates_4326 = geometry_4326.getCoordinates();
3534

36-
for (let i = 0, ii = coordinates.length; i < ii; i++) {
37-
const coos = coordinates[i];
35+
for (let i = 0, ii = coordinates_4326.length; i < ii; i++) {
36+
const coos = coordinates_4326[i];
3837
const m = i === 0 ? 0 : getDistance(coordinates_4326[i - 1], coordinates_4326[i]);
3938
accDistance += m;
4039
profile.push([coos[0], coos[1], coos[2], accDistance]);

src/profiler/SwisstopoProfiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export default class SwisstopoProfiler implements Profiler {
5757
// must not be modified, the API rounds the coordinates.
5858
// Therefore, we need to update the first and last coordinates of the profile with the
5959
// original coordinates.
60-
profile.at(0).splice(0, 2, ...geometry.getCoordinateAt(0));
61-
profile.at(-1).splice(0, 2, ...geometry.getCoordinateAt(-1));
60+
profile.with(0, profile.at(0).slice(0, 2, ...geometry.getCoordinateAt(0)));
61+
profile.with(-1, profile.at(-1).slice(0, 2, ...geometry.getCoordinateAt(-1)));
6262

6363
segment.set('profile', profile);
6464
}

0 commit comments

Comments
 (0)