Skip to content

@turf/shortest-path produces inconsistent results for the same resolution in different units #2943

Description

@ziegler-daniel

Summary

The shortestPath function returns different results depending on the unit used to specify the resolution. For example, {resolution: 0.0001, units: 'kilometers'} leads to a different result than {resolution: 10, units: 'centimeters'}. The reason for this is the created point grid for the A* algorithm. In addition, the spacing between the points in the grid differs from the specified resolution.

Example

Example 1:

  • For {resolution: 0.0001, units: 'kilometers'}
Image

GeoJSON file: grid_10cm_in_km.json

Example 2:

  • For {resolution: 10, units: 'centimeters'}
Image

GeoJSON file: grid_10cm_in_cm.json

Version

I tested this with @turf/shortest-path version 7.2.0

Note

I’d be happy to provide a pull request for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions