Skip to content

Commit

Permalink
fix(pgrSource): wrong parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
azarz committed Sep 21, 2023
1 parent 567579a commit 05cbfa7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## 2.2.2
FIXED:
- Route requests not working with pgr resources

## 2.2.1

FIXED:
- Wrong geometry order on pgr results #88
- BBox check not working with negative coordinates #89
Expand Down
14 changes: 7 additions & 7 deletions src/js/sources/pgrSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ module.exports = class pgrSource extends Source {
{precision: 6}
).geometry.coordinates;
// Reverse geometry order if end point closer to start of geometry than end
if (turf.distance(legStart, turf.point(leg.geometry.coordinates[0]) > turf.distance(legStop, turf.point(leg.geometry.coordinates[0])))) {
if (turf.distance(legStart, turf.point(leg.geometry.coordinates[0])) > turf.distance(legStop, turf.point(leg.geometry.coordinates[0]))) {
leg.geometry.coordinates.reverse();
}

Expand Down Expand Up @@ -918,8 +918,8 @@ module.exports = class pgrSource extends Source {

// Reverse geometry order if end point closer to start of geometry than end
if (
turf.distance(stepStart, turf.point(currentPgrRouteStep.geometry.coordinates[0]) >
turf.distance(stepEnd, turf.point(currentPgrRouteStep.geometry.coordinates[0])))
turf.distance(stepStart, turf.point(currentPgrRouteStep.geometry.coordinates[0])) >
turf.distance(stepEnd, turf.point(currentPgrRouteStep.geometry.coordinates[0]))
) {
currentPgrRouteStep.geometry.coordinates.reverse();
}
Expand Down Expand Up @@ -947,8 +947,8 @@ module.exports = class pgrSource extends Source {
).geometry.coordinates;
// Reverse geometry order if end point closer to start of geometry than end
if (
turf.distance(stepStart, turf.point(currentPgrRouteStep.geometry.coordinates[0]) >
turf.distance(stepEnd, turf.point(currentPgrRouteStep.geometry.coordinates[0])))
turf.distance(stepStart, turf.point(currentPgrRouteStep.geometry.coordinates[0])) >
turf.distance(stepEnd, turf.point(currentPgrRouteStep.geometry.coordinates[0]))
) {
currentPgrRouteStep.geometry.coordinates.reverse();
}
Expand Down Expand Up @@ -1014,8 +1014,8 @@ module.exports = class pgrSource extends Source {
).geometry.coordinates;
// Reverse geometry order if end point closer to start of geometry than end
if (
turf.distance(common_point, turf.point(currentPgrRouteStep.geometry.coordinates[0]) >
turf.distance(stepEnd, turf.point(currentPgrRouteStep.geometry.coordinates[0])))
turf.distance(common_point, turf.point(currentPgrRouteStep.geometry.coordinates[0])) >
turf.distance(stepEnd, turf.point(currentPgrRouteStep.geometry.coordinates[0]))
) {
currentPgrRouteStep.geometry.coordinates.reverse();
}
Expand Down

0 comments on commit 05cbfa7

Please sign in to comment.