3liz / QuickOSM

QGIS plugin to fetch OSM data with the Overpass API
GNU General Public License v2.0
180 stars 54 forks source link

Build Raw Query Flips Extent Coordinates #455

Open ProfessorDey opened 1 year ago

ProfessorDey commented 1 year ago

What is the bug?

When using Extent coordinates in EPSG:4326, explicitly or implicitly, the processing algorithm 'Build Raw Query' flips the first and last values, causing errors as it selects the wrong regions. The original extent coordinates were obtained from the output of the GUI query builder, using the 'Generate Query' button to substitute for the {{bbox}} value.

The correctly formatted generated value was: 53.02501,-3.0147,53.07307,-2.95039 However, the query URL that's actually generated substitutes this value: -2.95039,-3.0147,53.07307,53.02501 For convenience here's a simplified version: Input: a, b, c, d Expected Output: a, b, c, d Actual Output: d, b, c, a

This naturally results in the API call messing up as it's asking for completely different coordinates than it should be. I've also confirmed that flipping the values manually flips them back to correct values that produce the expected output.

Test Query:

[out:xml] [timeout:25];
(
    way[highway=primary]( {{bbox}});
);
(._;>;);
out body;

Full Unflipped Algorithm Log:

QGIS version: 3.28.4-Firenze
QGIS code revision: fd0fb72ab3
Qt version: 5.15.3
Python version: 3.9.5
GDAL version: 3.6.2
GEOS version: 3.11.1-CAPI-1.17.1
PROJ version: Rel. 9.1.1, December 1st, 2022
PDAL version: 2.4.3 (git-version: f8d673)
Algorithm started at: 2023-03-22T12:38:16
Algorithm 'osm_query' starting…
Input parameters:
{ 'extent' : '53.02501,-3.0147,53.07307,-2.95039' }

Prepare algorithm: quickosm:buildrawquery_1
Running Build raw query [1/4]
Input Parameters:
{ AREA: '', EXTENT: '53.02501,-3.0147,53.07307,-2.95039', QUERY: '[out:xml] [timeout:25];\n(\n way[highway=primary]( {{bbox}});\n);\n(._;>;);\nout body;', SERVER: 'https://z.overpass-api.de/api/interpreter', TIMEOUT: 25 }
Prepare the url.
OK. Execution took 0.041 s (2 output(s)).
Prepare algorithm: native:filedownloader_1
Running Download file [2/4]
Input Parameters:
{ DATA: '', METHOD: 0, OUTPUT: 'C:/Users/_/AppData/Local/Temp/processing_RuZfKd/b779aa756d254b66a8206bdcd9285175/OUTPUT.file', URL: 'https://z.overpass-api.de/api/interpreter?data=[out:xml] [timeout:25];%0A(%0A way[highway%3Dprimary]( -2.95039,-3.0147,53.07307,53.02501);%0A);%0A(._;%3E;);%0Aout body;&info=QgisQuickOSMPlugin' }
Successfully downloaded https://z.overpass-api.de/api/interpreter?data=[out:xml] [timeout:25];%0A(%0A way[highway%3Dprimary]( -2.95039,-3.0147,53.07307,53.02501);%0A);%0A(._;%3E;);%0Aout body;&info=QgisQuickOSMPlugin
OK. Execution took 26.579 s (1 output(s)).
Prepare algorithm: native:loadlayer_1
Running Load layer into project [4/4]
Input Parameters:
{ INPUT: 'C:/Users/_/AppData/Local/Temp/processing_RuZfKd/b779aa756d254b66a8206bdcd9285175/OUTPUT.file|layername=lines', NAME: 'OSM Layer' }
OK. Execution took 0.013 s (1 output(s)).
Model processed OK. Executed 4 algorithm(s) total in 26.74 s.
Execution completed in 26.78 seconds
Results:
{}

Loading resulting layers
Algorithm 'osm_query' finished

Full Flipped (d, b, c, a) Log

QGIS version: 3.28.4-Firenze
QGIS code revision: fd0fb72ab3
Qt version: 5.15.3
Python version: 3.9.5
GDAL version: 3.6.2
GEOS version: 3.11.1-CAPI-1.17.1
PROJ version: Rel. 9.1.1, December 1st, 2022
PDAL version: 2.4.3 (git-version: f8d673)
Algorithm started at: 2023-03-22T12:47:09
Algorithm 'osm_query' starting…
Input parameters:
{ 'extent' : '-2.95039,-3.0147,53.07307,53.02501' }

Prepare algorithm: quickosm:buildrawquery_1
Running Build raw query [1/4]
Input Parameters:
{ AREA: '', EXTENT: '-2.95039,-3.0147,53.07307,53.02501', QUERY: '[out:xml] [timeout:25];\n(\n way[highway=primary]( {{bbox}});\n);\n(._;>;);\nout body;', SERVER: 'https://z.overpass-api.de/api/interpreter', TIMEOUT: 25 }
Prepare the url.
OK. Execution took 0.01 s (2 output(s)).
Prepare algorithm: native:filedownloader_1
Running Download file [2/4]
Input Parameters:
{ DATA: '', METHOD: 0, OUTPUT: 'C:/Users/_/AppData/Local/Temp/processing_RuZfKd/3dc1bca843e14fbba64e4d56dc2d2ffc/OUTPUT.file', URL: 'https://z.overpass-api.de/api/interpreter?data=[out:xml] [timeout:25];%0A(%0A way[highway%3Dprimary]( 53.02501,-3.0147,53.07307,-2.95039);%0A);%0A(._;%3E;);%0Aout body;&info=QgisQuickOSMPlugin' }
Successfully downloaded https://z.overpass-api.de/api/interpreter?data=[out:xml] [timeout:25];%0A(%0A way[highway%3Dprimary]( 53.02501,-3.0147,53.07307,-2.95039);%0A);%0A(._;%3E;);%0Aout body;&info=QgisQuickOSMPlugin
OK. Execution took 1.714 s (1 output(s)).
Prepare algorithm: native:loadlayer_1
Running Load layer into project [4/4]
Input Parameters:
{ INPUT: 'C:/Users/_/AppData/Local/Temp/processing_RuZfKd/3dc1bca843e14fbba64e4d56dc2d2ffc/OUTPUT.file|layername=lines', NAME: 'OSM Layer' }
OK. Execution took 0.011 s (1 output(s)).
Model processed OK. Executed 4 algorithm(s) total in 1.852 s.
Execution completed in 1.89 seconds
Results:
{}

Loading resulting layers
Algorithm 'osm_query' finished

Environment