qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.51k stars 2.99k forks source link

Fastest path result wrong depending on project CRS #42762

Open kgjenkins opened 3 years ago

kgjenkins commented 3 years ago

Describe the bug

When using the "Shortest path (point to point)" to calculate the "fastest" path, the result "cost" is in hours, but this value is incorrect if the project CRS is not in meters.

Calculating the fastest path with the exact same inputs, with the only difference being the project CRS, gives the following results:

CRS CRS units cost (hours)
WGS 84 / UTM Zone 12N (EPSG 32612) meters 0.5 (correct)
WGS 84 (EPSG:4326) degrees 4.4918e-06
NAD83 / Utah Central (ftUS) (EPSG:3566) feet 1.64

Apparently, the number of hours is being multiplied by the ratio of project CRS units to meters.

How to Reproduce

  1. Download and extract the test data test_fastest_path.zip, which includes a single 40-mile road, with max speed 80mph (speed_kmph = 128.747)
  2. Load "road" layer into QGIS
  3. Set the project CRS to EPSG:4326 or EPSG:3566
  4. Run "Shortest Path (point to point)"
    • "Path type to calculate" = Fastest
    • set "Start point" and "End point" to the opposite ends of the road
    • set "Speed field" to "speed_kmph"
  5. Run

The correct cost value should be 0.5

fastest-path-error

QGIS and OS versions

QGIS version 3.18.1-Zürich QGIS code revision 202f1bf7e5 Compiled against Qt 5.11.2 Running against Qt 5.11.2 Compiled against GDAL/OGR 3.1.4 Running against GDAL/OGR 3.1.4 Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3 Compiled against SQLite 3.29.0 Running against SQLite 3.29.0 PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0 QWT Version 6.1.3 QScintilla2 Version 2.10.8 Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020 OS Version Windows 10 (10.0) Active python plugins DissolveWithStats; mmqgis; OSMDownloader; plugin_reloader; processing_saga_nextgen; processing_wbt; Qgis2threejs; qgis2web; QuickOSM; quick_map_services; SRTM-Downloader; valuetool; visualist; db_manager; processing

Pedro-Murteira commented 2 years ago

This issue is still valid on QGIS 3.22.3.

kgjenkins commented 2 years ago

I don't fully understand C++, but I wonder if the problem is that the multiplier is getting applied twice, in lines 110 and 118 of qgsalgorithmshortestpathpointtopoint.cpp

albertojose commented 8 months ago

Still encountering this issue in QGIS 3.34.3.