0

我正在使用 Qt 5.7 和 Marble Maps 小部件构建应用程序,我需要在应用程序中显示 FAA 剖面图(可在此处免费下载:https ://www.faa.gov/air_traffic/flight_info/aeronav/digital_products /vfr/)。这些图表采用 GEO-TIFF 格式,并且具有适当的地理参考。

在 Marble 中显示这些地图的第一步是将它们转换为图块。我正在使用 gdaltranslate 和 gdal2tiles.py 执行此操作。在蒙特利尔剖面图上运行这些实用程序后,我得到了此文件夹中显示的结果:http: //flt.l5.ca/maps/sections

转换过程似乎是成功的,因为该图表可以非常准确地覆盖在 Google 地图之上,例如: http: //flt.l5.ca/maps/sections/googlemaps.html

为了在 Marble 中显示地图,我创建了以下 DGML 文件:

<?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>

该地图确实显示在 Marble Maps 中,但在错误的半球上,即它没有显示在纬度 45N 左右的蒙特利尔顶部,而是显示在南美洲的经度相同但纬度相反 (45S) 处。

鉴于其他地图服务(如 Google 地图)将其放置在正确的位置,这怎么可能?

下面包含在 Qt 中的 MarbleWidget 中显示地图的非常简单的代码。

#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;
}
4

1 回答 1

0

找到了。gdal2tiles.py 使用的平铺文件名的命名约定基于 Google 地图使用的 XYZ 方案。Marble Maps 基于 TMS 方案,该方案使用与 XYZ 方案相反的纬度约定。对 gdal2tiles.py 源代码的修复会生成具有正确 TMS 文件名的切片并解决问题。

感谢 GitHub 上的 jeffaudi 发布他的解决方案:https ://gist.github.com/jeffaudi/9da77abf254301652baa#file-gdal2tilesg-py

于 2017-02-09T02:04:14.170 回答