简体   繁体   中英

Marble Maps shows tiled FAA sectional charts (maps) on opposite latitude

I am building an app with Qt 5.7 and the Marble Maps widget and I need to display FAA sectional charts in the app (they are available for free download here: https://www.faa.gov/air_traffic/flight_info/aeronav/digital_products/vfr/ ). These charts are in GEO-TIFF format and they are properly geo-referenced.

The first step to show these maps in Marble is to convert them into tiles. I am doing this using gdaltranslate and gdal2tiles.py . After running those utilities on the Montreal sectional chart, I get the results shown in this folder: http://flt.l5.ca/maps/sectionals .

The conversion process seems to be successful because the chart can be very accurately overlayed on top of Google Maps for example: http://flt.l5.ca/maps/sectionals/googlemaps.html .

In order to show the map in Marble, I created the following DGML file:

<?xml version="1.0" encoding="UTF-8"?>
<dgml xmlns="http://edu.kde.org/marble/dgml/2.0">
  <document>
    <head>
      <license short="© FAA">© FAA</license>
      <name>FAA Sectionals</name>
      <target>earth</target>
      <theme>sectionals</theme>
      <icon pixmap="preview.png"/>
      <visible>true</visible>
      <description><![CDATA[<p>FAA Sectional Charts</p><p>FAA-provided sectional VFR charts for the USA.</p>]]></description>
      <zoom>
        <minimum>   900  </minimum>
        <maximum>  3500  </maximum>
        <discrete> true </discrete>
      </zoom>
    </head>
    <map bgcolor="#000000">
      <canvas/>
      <target/>
      <layer name="sectionals" backend="texture">
        <texture name="faa_data" expire="604800">
          <sourcedir format="PNG"> earth/sectionals </sourcedir>
          <tileSize width="256" height="256"/>
          <storageLayout levelZeroColumns="1" levelZeroRows="1" maximumTileLevel="19" mode="OpenStreetMap"/>
          <projection name="Mercator"/>
          <downloadUrl protocol="http" host="flt.l5.ca" path="/maps/sectionals"/>
        </texture>
      </layer>
    </map>
    <settings>
      <property name="coordinate-grid">
        <value>true</value>
        <available>true</available>
      </property>
      <property name="overviewmap">
        <value>true</value>
        <available>true</available>
      </property>
      <property name="compass">
        <value>true</value>
        <available>true</available>
      </property>
      <property name="scalebar">
        <value>true</value>
        <available>true</available>
      </property>
    </settings>
  </document>
</dgml>

The map does show up in Marble Maps, but on the wrong hemisphere, ie instead of being displayed on top of Montreal around 45N latitude, it shows up in South America at the same longitude but opposite latitude (45S).

How is this possible given that other mapping services like Google Maps put it in the right place?

The very simple code to display the map in the MarbleWidget in Qt is included below.

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "marble/MarbleWidget.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    Marble::MarbleWidget *mapWidget = ui->MarbleWidget;

    mapWidget->setProjection( Marble::Mercator );
    mapWidget->setMapThemeId(QStringLiteral("earth/sectionals/sectionals.dgml" ));

     mapWidget->setShowOverviewMap(false);
     mapWidget->setShowScaleBar(false);
     mapWidget->setShowCompass(false);

     mapWidget->setMapQualityForViewContext( Marble::PrintQuality, Marble::Still );
     mapWidget->setMapQualityForViewContext( Marble::LowQuality, Marble::Animation );

}

MainWindow::~MainWindow()
{
    delete ui;
}

Found it. The naming convention for the tile filenames used by gdal2tiles.py is based on the XYZ scheme which Google Maps uses. Marble Maps is based on the TMS scheme which uses the opposite latitude convention from the XYZ scheme. A fix to the source code of gdal2tiles.py produces tiles with the proper TMS filenames and resolves the problem.

Thanks to jeffaudi on GitHub for posting his solution: https://gist.github.com/jeffaudi/9da77abf254301652baa#file-gdal2tilesg-py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM