Board index FlightGear Development Scenery

ogr-decode swapping lon/lat

Questions and discussion about enhancing and populating the FlightGear world.

ogr-decode swapping lon/lat

Postby barta » Sun May 31, 2020 5:12 am

Hi,

I'm building a scenery based on Openstreetmap landuse, basically transofrming .osm files, into shapefiles. Then run ogr-decode and the rest of the toolchain as in any normal terragear construct.

The process runs fine in my computer, generating precise and complete scenery. So I decided to use a cheap vps to run the scenery generation there and spare my laptop from the hassle.

I've installed all the tools and libraries required, compiled OpenSceneGraph, Simgear, FlightGear and Terragear. All fine.
But at the first test run, discovered that ogr-decode writes the result on a folder with lon and lat swapped!

I've downloaded the osm data for a bounding box like this: east: -60, north:-32, south:-33, west: -61, which corresponds to the bucket w061s33, but ogr-decode saves the files in
Code: Select all
work/<landuse type>/w040s70/w034s61


The command used to generate the files:
Code: Select all
ogr-decode  --max-segment 500 --area-type Industrial work/industrial data/industrial/industrial.dbf



The .osm file downloaded has the correct data, like:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API 0.7.56.3 eb200aeb">
<note>The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.</note>
<meta osm_base="2020-05-30T23:30:02Z"/>

  <bounds minlat="-33.0000000" minlon="-61.0000000" maxlat="-32.0000000" maxlon="-60.0000000"/>

  <node id="54361867" lat="-32.9982467" lon="-60.6935950" version="5" timestamp="2017-05-23T00:37:58Z" changeset="48901842" uid="1311281" user="mweper"/>
  <node id="54361868" lat="-32.9957112" lon="-60.6973594" version="3" timestamp="2012-11-30T17:16:17Z" changeset="14101141" uid="560942" user="otho261"/>
  <node id="54361870" lat="-32.9945448" lon="-60.6988502" version="11" timestamp="2018-09-06T00:03:20Z" changeset="62326902" uid="1311281" user="mweper">
    <tag k="direction" v="forward"/>
    <tag k="exit_to" v="Avenida Uriburu;Rosario (Centro)"/>
    <tag k="highway" v="motorway_junction"/>
    <tag k="side" v="right"/>
    <tag k="traffic_sign" v="ES:s26a"/>
  </node>
....


The .dbf and .shp generated by ogr2ogr are fine. I've opened them with QGis and shows the right locations.

The vps has Centos 8, 2 cores and 2 GB ram.
Versions installed:
OpenSceneGraph: master
SimGear: release/2020.1
FlightGear: release/2020.1
Terragear: ws_20

Any help will be appreciated
Thanks!
"When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return."
- Leonardo da Vinci
barta
 
Posts: 36
Joined: Thu Mar 05, 2009 12:24 am
Location: On the air, preferrably

Re: ogr-decode swapping lon/lat

Postby barta » Sun May 31, 2020 4:19 pm

Well, I can confirm 100% that the osm files are NOT the problem.
Running ogr-decode with a well-known v0_grasscover dataset pulled from map-server (circa 2013) does the same (writes the directories with lon/lat swapped)
The dataset contains shapes from w65 s40 to w70 s20, and ogr-decode generates a directory structure like this:
Code: Select all
w020s60/
    w018s60/
        2656128/
        2656129/
        2656136/
        2656137/
        2656144/
        2656152/
        2656160/
        2656168/
    w019s58/
    w019s59/
etc.


From the ogr-decode output, one can clearly see that is swapping lat/lon :
Code: Select all
$ ogr-decode  --max-segment 500 --area-type GrassCover work/prueba2 ../data/shapefiles/v0_grasscover2.dbf
ogr-decode version 2.1.0
Processing datasource ../data/shapefiles/v0_grasscover2.dbf
   CLIPPED row 0 of 2 - center lat is -56.9375   <== THIS SHOULD BE THE CENTER LONGITUDE
   CLIPPED row 1 of 2 - center lat is -56.8125
   CLIPPED row 2 of 2 - center lat is -56.6875


I'm guessing that at some point a version of SimGear or something like that, switched lon/lats in some constructor.

Maybe I should ask in the development forum....
"When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return."
- Leonardo da Vinci
barta
 
Posts: 36
Joined: Thu Mar 05, 2009 12:24 am
Location: On the air, preferrably

Re: ogr-decode swapping lon/lat

Postby wlbragg » Sun May 31, 2020 7:09 pm

Maybe I should ask in the development forum....

Yes, please do. Hopefully someone will recognize this an be able to point to the regression.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5673
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: ogr-decode swapping lon/lat

Postby barta » Tue Jun 02, 2020 2:38 pm

It was GDAL's fault.
Starting at v2.5 the axis ordering scheme is changed. Centos 8 ships with GDAL 3.0.
Downloaded and compiled GDAL 2.4 and everything runs fine now.
"When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return."
- Leonardo da Vinci
barta
 
Posts: 36
Joined: Thu Mar 05, 2009 12:24 am
Location: On the air, preferrably

Re: ogr-decode swapping lon/lat

Postby wlbragg » Tue Jun 02, 2020 3:11 pm

Now that's irritating. That type of change in a dependency is really annoying.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
Intel i5 3570K AMDRX480
User avatar
wlbragg
 
Posts: 5673
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/AMDRX480

Re: ogr-decode swapping lon/lat

Postby montagdude » Wed Jun 03, 2020 5:38 pm

Hm, I wonder if that has anything to do with the problems I've had with ogr-decode on Linux. I have GDAL 3.0.4, and ogr-decode never would write output files for me. I ended up using the TerraGear docker image instead.

Edit: checking back through my old posts, I was having that problem but didn't notice it. Will have to check if I get output with an older gdal version. Thanks for tracking this down.
montagdude
 
Posts: 225
Joined: Tue Dec 31, 2019 6:04 am

Re: ogr-decode swapping lon/lat

Postby D-ECHO » Thu Jul 23, 2020 11:16 am

Is it possible to amend ogr-decode in a way that makes it detect a newer version of GDAL and adapt?
User avatar
D-ECHO
 
Posts: 2111
Joined: Sat May 09, 2015 12:31 pm

Re: ogr-decode swapping lon/lat

Postby wkitty42 » Thu Jul 23, 2020 11:27 am

it is possible but...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 6551
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: ogr-decode swapping lon/lat

Postby F-TLS13 » Mon Jul 27, 2020 7:32 pm

Many thanks for finding the answer!
I really didn't understand why my newly generated tile was empty apart from the airport...

I opened the following ticket https://sourceforge.net/p/flightgear/codetickets/2318/ and submitted a merge request to fix the problem.
For those interested to keep GDAL 3, the patch is as simple as https://sourceforge.net/u/tlesne/flight ... 07bdb450b/

Thomas

Edit: changed the commit ref, it seems both source and target SpatialReference need to be patched.
Last edited by F-TLS13 on Tue Jul 28, 2020 9:43 am, edited 1 time in total.
F-TLS13
 
Posts: 11
Joined: Thu Jul 25, 2019 4:18 pm
Location: France
Callsign: F-TLS13
Version: 2020.3
OS: Fedora 32

Re: ogr-decode swapping lon/lat

Postby D-ECHO » Tue Jul 28, 2020 6:19 am

Thank you so much!
User avatar
D-ECHO
 
Posts: 2111
Joined: Sat May 09, 2015 12:31 pm

Re: ogr-decode swapping lon/lat

Postby F-TLS13 » Tue Jul 28, 2020 9:47 am

I edited my previous message since I changed the commit.

Can someone try to rebuild ogr-decode with the patch with GDAL 3 and comment in the sourceforge ticket?
F-TLS13
 
Posts: 11
Joined: Thu Jul 25, 2019 4:18 pm
Location: France
Callsign: F-TLS13
Version: 2020.3
OS: Fedora 32

Re: ogr-decode swapping lon/lat

Postby montagdude » Tue Aug 25, 2020 4:01 am

F-TLS13 wrote in Tue Jul 28, 2020 9:47 am:I edited my previous message since I changed the commit.

Can someone try to rebuild ogr-decode with the patch with GDAL 3 and comment in the sourceforge ticket?
I tried your change against the scenery/ws2.0 branch, and it seems to work! Thanks, now I don't need to run docker for TerraGear. I couldn't use the patch exactly as given, because I am building against commit da1ade82c. Here is what the patch looks like:

Code: Select all
--- src/Prep/OGRDecode/ogr-decode.cxx   2018-06-24 10:59:27.000000000 -0400
+++ src/Prep/OGRDecode/ogr-decode.cxx.new   2020-08-24 23:19:30.472365862 -0400
@@ -409,6 +409,11 @@
 
     oTargetSRS.SetWellKnownGeogCS( "WGS84" );
 
+#if GDAL_VERSION_MAJOR >= 3
+    oSourceSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
+    oTargetSRS.SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER);
+#endif
+
     OGRCoordinateTransformation *poCT = OGRCreateCoordinateTransformation(oSourceSRS, &oTargetSRS);
 
     /* setup attribute and spatial queries */
montagdude
 
Posts: 225
Joined: Tue Dec 31, 2019 6:04 am


Return to Scenery

Who is online

Users browsing this forum: ludomotico, V12 and 4 guests