From 6362e4c764e43e313723073605fd1ea1aa4c5181 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 8 Apr 2015 09:26:01 -0700 Subject: [PATCH 1/3] Restructure location plugin build Restructured to better fit existing build structure --- QGCApplication.pro | 689 +++++++++++++++++ QGCCommon.pri | 184 +++++ QGCLocationPlugin.pro | 33 + libs/QtLocationQGC/.qmake.conf | 3 - libs/QtLocationQGC/QtLocationQGC.pro | 32 - libs/QtLocationQGC/qgc_maps_plugin.json | 11 - libs/QtLocationQGC/src/OpenPilotMaps.cc | 490 ------------ libs/QtLocationQGC/src/OpenPilotMaps.h | 157 ---- libs/QtLocationQGC/src/qgeocodereplyqgc.cpp | 301 -------- libs/QtLocationQGC/src/qgeocodereplyqgc.h | 75 -- .../src/qgeocodingmanagerengineqgc.cpp | 181 ----- .../QtLocationQGC/src/qgeocodingmanagerengineqgc.h | 81 -- libs/QtLocationQGC/src/qgeomapreplyqgc.cpp | 142 ---- libs/QtLocationQGC/src/qgeomapreplyqgc.h | 78 -- .../src/qgeoserviceproviderpluginqgc.cpp | 82 --- .../src/qgeoserviceproviderpluginqgc.h | 70 -- .../src/qgeotiledmappingmanagerengineqgc.cpp | 166 ----- .../src/qgeotiledmappingmanagerengineqgc.h | 66 -- libs/QtLocationQGC/src/qgeotilefetcherqgc.cpp | 150 ---- libs/QtLocationQGC/src/qgeotilefetcherqgc.h | 78 -- qgcsystem.pro | 819 --------------------- qgroundcontrol.pro | 12 +- src/QtLocationPlugin/OpenPilotMaps.cc | 490 ++++++++++++ src/QtLocationPlugin/OpenPilotMaps.h | 157 ++++ src/QtLocationPlugin/qgc_maps_plugin.json | 11 + src/QtLocationPlugin/qgeocodereplyqgc.cpp | 296 ++++++++ src/QtLocationPlugin/qgeocodereplyqgc.h | 71 ++ .../qgeocodingmanagerengineqgc.cpp | 177 +++++ src/QtLocationPlugin/qgeocodingmanagerengineqgc.h | 81 ++ src/QtLocationPlugin/qgeomapreplyqgc.cpp | 142 ++++ src/QtLocationPlugin/qgeomapreplyqgc.h | 74 ++ .../qgeoserviceproviderpluginqgc.cpp | 78 ++ .../qgeoserviceproviderpluginqgc.h | 67 ++ .../qgeotiledmappingmanagerengineqgc.cpp | 162 ++++ .../qgeotiledmappingmanagerengineqgc.h | 62 ++ src/QtLocationPlugin/qgeotilefetcherqgc.cpp | 146 ++++ src/QtLocationPlugin/qgeotilefetcherqgc.h | 74 ++ 37 files changed, 3003 insertions(+), 2985 deletions(-) create mode 100644 QGCApplication.pro create mode 100644 QGCCommon.pri create mode 100644 QGCLocationPlugin.pro delete mode 100644 libs/QtLocationQGC/.qmake.conf delete mode 100644 libs/QtLocationQGC/QtLocationQGC.pro delete mode 100644 libs/QtLocationQGC/qgc_maps_plugin.json delete mode 100644 libs/QtLocationQGC/src/OpenPilotMaps.cc delete mode 100644 libs/QtLocationQGC/src/OpenPilotMaps.h delete mode 100644 libs/QtLocationQGC/src/qgeocodereplyqgc.cpp delete mode 100644 libs/QtLocationQGC/src/qgeocodereplyqgc.h delete mode 100644 libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.cpp delete mode 100644 libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.h delete mode 100644 libs/QtLocationQGC/src/qgeomapreplyqgc.cpp delete mode 100644 libs/QtLocationQGC/src/qgeomapreplyqgc.h delete mode 100644 libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.cpp delete mode 100644 libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.h delete mode 100644 libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.cpp delete mode 100644 libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.h delete mode 100644 libs/QtLocationQGC/src/qgeotilefetcherqgc.cpp delete mode 100644 libs/QtLocationQGC/src/qgeotilefetcherqgc.h delete mode 100644 qgcsystem.pro create mode 100644 src/QtLocationPlugin/OpenPilotMaps.cc create mode 100644 src/QtLocationPlugin/OpenPilotMaps.h create mode 100644 src/QtLocationPlugin/qgc_maps_plugin.json create mode 100644 src/QtLocationPlugin/qgeocodereplyqgc.cpp create mode 100644 src/QtLocationPlugin/qgeocodereplyqgc.h create mode 100644 src/QtLocationPlugin/qgeocodingmanagerengineqgc.cpp create mode 100644 src/QtLocationPlugin/qgeocodingmanagerengineqgc.h create mode 100644 src/QtLocationPlugin/qgeomapreplyqgc.cpp create mode 100644 src/QtLocationPlugin/qgeomapreplyqgc.h create mode 100644 src/QtLocationPlugin/qgeoserviceproviderpluginqgc.cpp create mode 100644 src/QtLocationPlugin/qgeoserviceproviderpluginqgc.h create mode 100644 src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp create mode 100644 src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.h create mode 100644 src/QtLocationPlugin/qgeotilefetcherqgc.cpp create mode 100644 src/QtLocationPlugin/qgeotilefetcherqgc.h diff --git a/QGCApplication.pro b/QGCApplication.pro new file mode 100644 index 0000000..134c24f --- /dev/null +++ b/QGCApplication.pro @@ -0,0 +1,689 @@ +# ------------------------------------------------- +# QGroundControl - Micro Air Vehicle Groundstation +# Please see our website at +# Maintainer: +# Lorenz Meier +# (c) 2009-2014 QGroundControl Developers +# This file is part of the open groundstation project +# QGroundControl is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# QGroundControl is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with QGroundControl. If not, see . +# ------------------------------------------------- + +include(QGCCommon.pri) + +TARGET = qgroundcontrol + +# Load additional config flags from user_config.pri +exists(user_config.pri):infile(user_config.pri, CONFIG) { + CONFIG += $$fromfile(user_config.pri, CONFIG) + message($$sprintf("Using user-supplied additional config: '%1' specified in user_config.pri", $$fromfile(user_config.pri, CONFIG))) +} + +LinuxBuild { + CONFIG += link_pkgconfig +} + +message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET) + +# QGC QtLocation plugin + +LIBS += -L$${LOCATION_PLUGIN_DESTDIR} + +LinuxBuild { + LIBS += -l$${LOCATION_PLUGIN_NAME} + PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/lib$${LOCATION_PLUGIN_NAME}.a +} + +WindowsBuild { + DebugBuild { + LIBS += -l$${LOCATION_PLUGIN_NAME}d + PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/$${LOCATION_PLUGIN_NAME}d.lib + } + ReleaseBuild { + LIBS += -l$${LOCATION_PLUGIN_NAME} + PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/$${LOCATION_PLUGIN_NAME}.lib + } +} + +MacBuild { + DebugBuild { + LIBS += -l$${LOCATION_PLUGIN_NAME}_debug + PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/lib$${LOCATION_PLUGIN_NAME}_debug.a + } + ReleaseBuild { + LIBS += -l$${LOCATION_PLUGIN_NAME} + PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/lib$${LOCATION_PLUGIN_NAME}.a + } +} + +# Qt configuration + +CONFIG += qt \ + thread + +QT += network \ + opengl \ + svg \ + xml \ + concurrent \ + widgets \ + gui \ + serialport \ + sql \ + printsupport \ + qml \ + quick \ + quickwidgets \ + location \ + positioning + +contains(DEFINES, QGC_NOTIFY_TUNES_ENABLED) { + QT += multimedia +} + +# testlib is needed even in release flavor for QSignalSpy support +QT += testlib + +# +# OS Specific settings +# + +MacBuild { + QMAKE_INFO_PLIST = Custom-Info.plist + ICON = $$BASEDIR/resources/icons/macx.icns + QT += quickwidgets +} + +LinuxBuild { + CONFIG += qesp_linux_udev +} + +WindowsBuild { + RC_FILE = $$BASEDIR/qgroundcontrol.rc +} + +# +# Build-specific settings +# + +DebugBuild { + CONFIG += console +} + +# qextserialport should not be used by general QGroundControl code. Use QSerialPort instead. This is only +# here to support special case Firmware Upgrade code. +include(libs/qextserialport/src/qextserialport.pri) + +# +# External library configuration +# + +include(QGCExternalLibs.pri) + +# +# Post link configuration +# + +include(QGCSetup.pri) + +# +# Installer targets +# + +include(QGCInstaller.pri) + +# +# Main QGroundControl portion of project file +# + +RESOURCES += qgroundcontrol.qrc + +DEPENDPATH += \ + . \ + plugins + +INCLUDEPATH += . + +INCLUDEPATH += \ + src \ + src/ui \ + src/ui/linechart \ + src/ui/uas \ + src/ui/map \ + src/uas \ + src/comm \ + src/audio \ + include/ui \ + src/input \ + src/lib/qmapcontrol \ + src/ui/mavlink \ + src/ui/param \ + src/ui/map3D \ + src/ui/mission \ + src/ui/designer \ + src/ui/configuration \ + src/ui/px4_configuration \ + src/ui/main \ + src/ui/toolbar \ + src/ui/flightdisplay \ + src/VehicleSetup \ + src/AutoPilotPlugins \ + src/QmlControls + +FORMS += \ + src/ui/MainWindow.ui \ + src/ui/SerialSettings.ui \ + src/ui/UASControl.ui \ + src/ui/UASList.ui \ + src/ui/UASInfo.ui \ + src/ui/Linechart.ui \ + src/ui/UASView.ui \ + src/ui/ParameterInterface.ui \ + src/ui/WaypointList.ui \ + src/ui/JoystickWidget.ui \ + src/ui/DebugConsole.ui \ + src/ui/HDDisplay.ui \ + src/ui/MAVLinkSettingsWidget.ui \ + src/ui/QGCSensorSettingsWidget.ui \ + src/ui/QGCDataPlot2D.ui \ + src/ui/QMap3D.ui \ + src/ui/uas/QGCUnconnectedInfoWidget.ui \ + src/ui/designer/QGCToolWidget.ui \ + src/ui/designer/QGCParamSlider.ui \ + src/ui/designer/QGCActionButton.ui \ + src/ui/designer/QGCCommandButton.ui \ + src/ui/designer/QGCToolWidgetComboBox.ui \ + src/ui/designer/QGCTextLabel.ui \ + src/ui/designer/QGCXYPlot.ui \ + src/ui/QGCMAVLinkLogPlayer.ui \ + src/ui/QGCWaypointListMulti.ui \ + src/ui/QGCUASFileViewMulti.ui \ + src/ui/QGCTCPLinkConfiguration.ui \ + src/ui/SettingsDialog.ui \ + src/ui/map/QGCMapTool.ui \ + src/ui/map/QGCMapToolBar.ui \ + src/ui/QGCMAVLinkInspector.ui \ + src/ui/WaypointViewOnlyView.ui \ + src/ui/WaypointEditableView.ui \ + src/ui/mavlink/QGCMAVLinkMessageSender.ui \ + src/ui/QGCPluginHost.ui \ + src/ui/mission/QGCMissionOther.ui \ + src/ui/mission/QGCMissionNavWaypoint.ui \ + src/ui/mission/QGCMissionDoJump.ui \ + src/ui/mission/QGCMissionConditionDelay.ui \ + src/ui/mission/QGCMissionNavLoiterUnlim.ui \ + src/ui/mission/QGCMissionNavLoiterTurns.ui \ + src/ui/mission/QGCMissionNavLoiterTime.ui \ + src/ui/mission/QGCMissionNavReturnToLaunch.ui \ + src/ui/mission/QGCMissionNavLand.ui \ + src/ui/mission/QGCMissionNavTakeoff.ui \ + src/ui/mission/QGCMissionNavSweep.ui \ + src/ui/mission/QGCMissionDoStartSearch.ui \ + src/ui/mission/QGCMissionDoFinishSearch.ui \ + src/ui/QGCHilConfiguration.ui \ + src/ui/QGCHilFlightGearConfiguration.ui \ + src/ui/QGCHilJSBSimConfiguration.ui \ + src/ui/QGCHilXPlaneConfiguration.ui \ + src/ui/uas/UASQuickView.ui \ + src/ui/uas/UASQuickViewItemSelect.ui \ + src/ui/QGCTabbedInfoView.ui \ + src/ui/UASRawStatusView.ui \ + src/ui/uas/UASMessageView.ui \ + src/ui/JoystickButton.ui \ + src/ui/JoystickAxis.ui \ + src/ui/configuration/terminalconsole.ui \ + src/ui/configuration/SerialSettingsDialog.ui \ + src/ui/px4_configuration/PX4RCCalibration.ui \ + src/ui/QGCUASFileView.ui \ + src/QGCQmlWidgetHolder.ui \ + src/ui/QGCMapRCToParamDialog.ui \ + src/ui/QGCLinkConfiguration.ui \ + src/ui/QGCCommConfiguration.ui \ + src/ui/QGCUDPLinkConfiguration.ui + +HEADERS += \ + src/MG.h \ + src/QGCApplication.h \ + src/QGCSingleton.h \ + src/uas/UASInterface.h \ + src/uas/UAS.h \ + src/uas/UASManager.h \ + src/comm/LinkManager.h \ + src/comm/LinkInterface.h \ + src/comm/SerialLink.h \ + src/comm/ProtocolInterface.h \ + src/comm/MAVLinkProtocol.h \ + src/comm/QGCFlightGearLink.h \ + src/comm/QGCJSBSimLink.h \ + src/comm/QGCXPlaneLink.h \ + src/ui/SerialConfigurationWindow.h \ + src/ui/MainWindow.h \ + src/ui/uas/UASControlWidget.h \ + src/ui/uas/UASListWidget.h \ + src/ui/uas/UASInfoWidget.h \ + src/ui/HUD.h \ + src/ui/linechart/LinechartWidget.h \ + src/ui/linechart/LinechartPlot.h \ + src/ui/linechart/Scrollbar.h \ + src/ui/linechart/ScrollZoomer.h \ + src/QGCConfig.h \ + src/ui/uas/UASView.h \ + src/ui/CameraView.h \ + src/comm/MAVLinkSimulationLink.h \ + src/comm/UDPLink.h \ + src/comm/TCPLink.h \ + src/ui/ParameterInterface.h \ + src/ui/WaypointList.h \ + src/Waypoint.h \ + src/input/JoystickInput.h \ + src/ui/JoystickWidget.h \ + src/ui/DebugConsole.h \ + src/ui/HDDisplay.h \ + src/ui/MAVLinkSettingsWidget.h \ + src/GAudioOutput.h \ + src/LogCompressor.h \ + src/ui/QGCParamWidget.h \ + src/ui/QGCSensorSettingsWidget.h \ + src/ui/linechart/Linecharts.h \ + src/uas/UASWaypointManager.h \ + src/ui/HSIDisplay.h \ + src/QGC.h \ + src/ui/QGCDataPlot2D.h \ + src/ui/linechart/IncrementalPlot.h \ + src/comm/QGCMAVLink.h \ + src/ui/QGCMainWindowAPConfigurator.h \ + src/comm/MAVLinkSwarmSimulationLink.h \ + src/ui/uas/QGCUnconnectedInfoWidget.h \ + src/ui/designer/QGCToolWidget.h \ + src/ui/designer/QGCParamSlider.h \ + src/ui/designer/QGCCommandButton.h \ + src/ui/designer/QGCToolWidgetItem.h \ + src/ui/designer/QGCToolWidgetComboBox.h \ + src/ui/designer/QGCTextLabel.h \ + src/ui/designer/QGCRadioChannelDisplay.h \ + src/ui/designer/QGCXYPlot.h \ + src/ui/designer/RCChannelWidget.h \ + src/ui/QGCMAVLinkLogPlayer.h \ + src/comm/MAVLinkSimulationWaypointPlanner.h \ + src/comm/MAVLinkSimulationMAV.h \ + src/uas/QGCMAVLinkUASFactory.h \ + src/ui/QGCWaypointListMulti.h \ + src/ui/QGCUASFileViewMulti.h \ + src/ui/QGCTCPLinkConfiguration.h \ + src/ui/SettingsDialog.h \ + src/uas/QGCUASParamManager.h \ + src/ui/map/QGCMapWidget.h \ + src/ui/map/MAV2DIcon.h \ + src/ui/map/Waypoint2DIcon.h \ + src/ui/map/QGCMapTool.h \ + src/ui/map/QGCMapToolBar.h \ + src/QGCGeo.h \ + src/ui/QGCMAVLinkInspector.h \ + src/ui/MAVLinkDecoder.h \ + src/ui/WaypointViewOnlyView.h \ + src/ui/WaypointEditableView.h \ + src/ui/QGCRGBDView.h \ + src/ui/mavlink/QGCMAVLinkMessageSender.h \ + src/ui/QGCPluginHost.h \ + src/ui/mission/QGCMissionOther.h \ + src/ui/mission/QGCMissionNavWaypoint.h \ + src/ui/mission/QGCMissionDoJump.h \ + src/ui/mission/QGCMissionConditionDelay.h \ + src/ui/mission/QGCMissionNavLoiterUnlim.h \ + src/ui/mission/QGCMissionNavLoiterTurns.h \ + src/ui/mission/QGCMissionNavLoiterTime.h \ + src/ui/mission/QGCMissionNavReturnToLaunch.h \ + src/ui/mission/QGCMissionNavLand.h \ + src/ui/mission/QGCMissionNavTakeoff.h \ + src/ui/mission/QGCMissionNavSweep.h \ + src/ui/mission/QGCMissionDoStartSearch.h \ + src/ui/mission/QGCMissionDoFinishSearch.h \ + src/comm/QGCHilLink.h \ + src/ui/QGCHilConfiguration.h \ + src/ui/QGCHilFlightGearConfiguration.h \ + src/ui/QGCHilJSBSimConfiguration.h \ + src/ui/QGCHilXPlaneConfiguration.h \ + src/ui/uas/UASQuickView.h \ + src/ui/uas/UASQuickViewItem.h \ + src/ui/linechart/ChartPlot.h \ + src/ui/uas/UASQuickViewItemSelect.h \ + src/ui/uas/UASQuickViewTextItem.h \ + src/ui/uas/UASQuickViewGaugeItem.h \ + src/ui/QGCTabbedInfoView.h \ + src/ui/UASRawStatusView.h \ + src/ui/PrimaryFlightDisplay.h \ + src/ui/uas/UASMessageView.h \ + src/ui/JoystickButton.h \ + src/ui/JoystickAxis.h \ + src/ui/configuration/console.h \ + src/ui/configuration/SerialSettingsDialog.h \ + src/ui/configuration/terminalconsole.h \ + src/ui/configuration/ApmHighlighter.h \ + src/uas/UASParameterDataModel.h \ + src/uas/UASParameterCommsMgr.h \ + src/ui/QGCPendingParamWidget.h \ + src/ui/QGCBaseParamWidget.h \ + src/ui/px4_configuration/PX4RCCalibration.h \ + src/ui/px4_configuration/RCValueWidget.h \ + src/uas/UASManagerInterface.h \ + src/uas/QGCUASParamManagerInterface.h \ + src/uas/QGCUASFileManager.h \ + src/ui/QGCUASFileView.h \ + src/CmdLineOptParser.h \ + src/QGCFileDialog.h \ + src/QGCMessageBox.h \ + src/QGCComboBox.h \ + src/QGCTemporaryFile.h \ + src/audio/QGCAudioWorker.h \ + src/QGCQuickWidget.h \ + src/QGCPalette.h \ + src/QGCQmlWidgetHolder.h \ + src/ui/QGCParamTreeWidget.h \ + src/ui/QGCMapRCToParamDialog.h \ + src/QGCDockWidget.h \ + src/ui/QGCLinkConfiguration.h \ + src/comm/LinkConfiguration.h \ + src/ui/QGCCommConfiguration.h \ + src/ui/QGCUDPLinkConfiguration.h \ + src/uas/UASMessageHandler.h \ + src/ui/toolbar/MainToolBar.h \ + src/QmlControls/ScreenTools.h \ + src/QGCLoggingCategory.h \ + src/ui/flightdisplay/QGCFlightDisplay.h + +SOURCES += \ + src/main.cc \ + src/QGCApplication.cc \ + src/QGCSingleton.cc \ + src/uas/UASManager.cc \ + src/uas/UAS.cc \ + src/comm/LinkManager.cc \ + src/comm/SerialLink.cc \ + src/comm/MAVLinkProtocol.cc \ + src/comm/QGCFlightGearLink.cc \ + src/comm/QGCJSBSimLink.cc \ + src/comm/QGCXPlaneLink.cc \ + src/ui/SerialConfigurationWindow.cc \ + src/ui/MainWindow.cc \ + src/ui/uas/UASControlWidget.cc \ + src/ui/uas/UASListWidget.cc \ + src/ui/uas/UASInfoWidget.cc \ + src/ui/HUD.cc \ + src/ui/linechart/LinechartWidget.cc \ + src/ui/linechart/LinechartPlot.cc \ + src/ui/linechart/Scrollbar.cc \ + src/ui/linechart/ScrollZoomer.cc \ + src/ui/uas/UASView.cc \ + src/ui/CameraView.cc \ + src/comm/MAVLinkSimulationLink.cc \ + src/comm/UDPLink.cc \ + src/comm/TCPLink.cc \ + src/ui/ParameterInterface.cc \ + src/ui/WaypointList.cc \ + src/Waypoint.cc \ + src/input/JoystickInput.cc \ + src/ui/JoystickWidget.cc \ + src/ui/DebugConsole.cc \ + src/ui/HDDisplay.cc \ + src/ui/MAVLinkSettingsWidget.cc \ + src/GAudioOutput.cc \ + src/LogCompressor.cc \ + src/ui/QGCParamWidget.cc \ + src/ui/QGCSensorSettingsWidget.cc \ + src/ui/linechart/Linecharts.cc \ + src/uas/UASWaypointManager.cc \ + src/ui/HSIDisplay.cc \ + src/QGC.cc \ + src/ui/QGCDataPlot2D.cc \ + src/ui/linechart/IncrementalPlot.cc \ + src/ui/QGCMainWindowAPConfigurator.cc \ + src/comm/MAVLinkSwarmSimulationLink.cc \ + src/ui/uas/QGCUnconnectedInfoWidget.cc \ + src/ui/designer/QGCToolWidget.cc \ + src/ui/designer/QGCParamSlider.cc \ + src/ui/designer/QGCCommandButton.cc \ + src/ui/designer/QGCToolWidgetItem.cc \ + src/ui/designer/QGCToolWidgetComboBox.cc \ + src/ui/designer/QGCTextLabel.cc \ + src/ui/designer/QGCRadioChannelDisplay.cpp \ + src/ui/designer/QGCXYPlot.cc \ + src/ui/designer/RCChannelWidget.cc \ + src/ui/QGCMAVLinkLogPlayer.cc \ + src/comm/MAVLinkSimulationWaypointPlanner.cc \ + src/comm/MAVLinkSimulationMAV.cc \ + src/uas/QGCMAVLinkUASFactory.cc \ + src/ui/QGCWaypointListMulti.cc \ + src/ui/QGCUASFileViewMulti.cc \ + src/ui/QGCTCPLinkConfiguration.cc \ + src/ui/SettingsDialog.cc \ + src/uas/QGCUASParamManager.cc \ + src/ui/map/QGCMapWidget.cc \ + src/ui/map/MAV2DIcon.cc \ + src/ui/map/Waypoint2DIcon.cc \ + src/ui/map/QGCMapTool.cc \ + src/ui/map/QGCMapToolBar.cc \ + src/ui/QGCMAVLinkInspector.cc \ + src/ui/MAVLinkDecoder.cc \ + src/ui/WaypointViewOnlyView.cc \ + src/ui/WaypointEditableView.cc \ + src/ui/QGCRGBDView.cc \ + src/ui/mavlink/QGCMAVLinkMessageSender.cc \ + src/ui/QGCPluginHost.cc \ + src/ui/mission/QGCMissionOther.cc \ + src/ui/mission/QGCMissionNavWaypoint.cc \ + src/ui/mission/QGCMissionDoJump.cc \ + src/ui/mission/QGCMissionConditionDelay.cc \ + src/ui/mission/QGCMissionNavLoiterUnlim.cc \ + src/ui/mission/QGCMissionNavLoiterTurns.cc \ + src/ui/mission/QGCMissionNavLoiterTime.cc \ + src/ui/mission/QGCMissionNavReturnToLaunch.cc \ + src/ui/mission/QGCMissionNavLand.cc \ + src/ui/mission/QGCMissionNavTakeoff.cc \ + src/ui/mission/QGCMissionNavSweep.cc \ + src/ui/mission/QGCMissionDoStartSearch.cc \ + src/ui/mission/QGCMissionDoFinishSearch.cc \ + src/ui/QGCHilConfiguration.cc \ + src/ui/QGCHilFlightGearConfiguration.cc \ + src/ui/QGCHilJSBSimConfiguration.cc \ + src/ui/QGCHilXPlaneConfiguration.cc \ + src/ui/uas/UASQuickViewItem.cc \ + src/ui/uas/UASQuickView.cc \ + src/ui/linechart/ChartPlot.cc \ + src/ui/uas/UASQuickViewTextItem.cc \ + src/ui/uas/UASQuickViewGaugeItem.cc \ + src/ui/uas/UASQuickViewItemSelect.cc \ + src/ui/QGCTabbedInfoView.cpp \ + src/ui/UASRawStatusView.cpp \ + src/ui/PrimaryFlightDisplay.cc \ + src/ui/JoystickButton.cc \ + src/ui/JoystickAxis.cc \ + src/ui/uas/UASMessageView.cc \ + src/ui/configuration/terminalconsole.cpp \ + src/ui/configuration/console.cpp \ + src/ui/configuration/SerialSettingsDialog.cc \ + src/ui/configuration/ApmHighlighter.cc \ + src/uas/UASParameterDataModel.cc \ + src/uas/UASParameterCommsMgr.cc \ + src/ui/QGCPendingParamWidget.cc \ + src/ui/QGCBaseParamWidget.cc \ + src/ui/px4_configuration/PX4RCCalibration.cc \ + src/ui/px4_configuration/RCValueWidget.cc \ + src/uas/QGCUASFileManager.cc \ + src/ui/QGCUASFileView.cc \ + src/CmdLineOptParser.cc \ + src/QGCFileDialog.cc \ + src/QGCComboBox.cc \ + src/QGCTemporaryFile.cc \ + src/audio/QGCAudioWorker.cpp \ + src/QGCQuickWidget.cc \ + src/QGCPalette.cc \ + src/QGCQmlWidgetHolder.cpp \ + src/ui/QGCParamTreeWidget.cpp \ + src/ui/QGCMapRCToParamDialog.cpp \ + src/QGCDockWidget.cc \ + src/ui/QGCLinkConfiguration.cc \ + src/comm/LinkConfiguration.cc \ + src/ui/QGCCommConfiguration.cc \ + src/ui/QGCUDPLinkConfiguration.cc \ + src/uas/UASMessageHandler.cc \ + src/ui/toolbar/MainToolBar.cc \ + src/QmlControls/ScreenTools.cc \ + src/QGCLoggingCategory.cc \ + src/ui/flightdisplay/QGCFlightDisplay.cc + +# +# Unit Test specific configuration goes here +# +# We have to special case Windows debug_and_release builds because you can't have files +# which are only in the debug variant [QTBUG-40351]. So in this case we include unit tests +# even in the release variant. If you want a Windows release build with no unit tests run +# qmake with CONFIG-=debug_and_release CONFIG+=release. +# + +DebugBuild|WindowsDebugAndRelease { + +INCLUDEPATH += \ + src/qgcunittest + +HEADERS += \ + src/qgcunittest/UnitTest.h \ + src/qgcunittest/MessageBoxTest.h \ + src/qgcunittest/FileDialogTest.h \ + src/qgcunittest/MockLink.h \ + src/qgcunittest/MockLinkMissionItemHandler.h \ + src/qgcunittest/MockUASManager.h \ + src/qgcunittest/MockUAS.h \ + src/qgcunittest/MockQGCUASParamManager.h \ + src/qgcunittest/MockMavlinkInterface.h \ + src/qgcunittest/MockMavlinkFileServer.h \ + src/qgcunittest/MultiSignalSpy.h \ + src/qgcunittest/FlightGearTest.h \ + src/qgcunittest/TCPLinkTest.h \ + src/qgcunittest/TCPLoopBackServer.h \ + src/qgcunittest/QGCUASFileManagerTest.h \ + src/qgcunittest/PX4RCCalibrationTest.h \ + src/qgcunittest/LinkManagerTest.h \ + src/qgcunittest/MainWindowTest.h \ + src/qgcunittest/MavlinkLogTest.h \ + src/FactSystem/FactSystemTestBase.h \ + src/FactSystem/FactSystemTestPX4.h \ + src/FactSystem/FactSystemTestGeneric.h \ + src/QmlControls/QmlTestWidget.h \ + src/VehicleSetup/SetupViewTest.h \ + +SOURCES += \ + src/qgcunittest/UnitTest.cc \ + src/qgcunittest/MessageBoxTest.cc \ + src/qgcunittest/FileDialogTest.cc \ + src/qgcunittest/MockLink.cc \ + src/qgcunittest/MockLinkMissionItemHandler.cc \ + src/qgcunittest/MockUASManager.cc \ + src/qgcunittest/MockUAS.cc \ + src/qgcunittest/MockQGCUASParamManager.cc \ + src/qgcunittest/MockMavlinkFileServer.cc \ + src/qgcunittest/MultiSignalSpy.cc \ + src/qgcunittest/FlightGearTest.cc \ + src/qgcunittest/TCPLinkTest.cc \ + src/qgcunittest/TCPLoopBackServer.cc \ + src/qgcunittest/QGCUASFileManagerTest.cc \ + src/qgcunittest/PX4RCCalibrationTest.cc \ + src/qgcunittest/LinkManagerTest.cc \ + src/qgcunittest/MainWindowTest.cc \ + src/qgcunittest/MavlinkLogTest.cc \ + src/FactSystem/FactSystemTestBase.cc \ + src/FactSystem/FactSystemTestPX4.cc \ + src/FactSystem/FactSystemTestGeneric.cc \ + src/QmlControls/QmlTestWidget.cc \ + src/VehicleSetup/SetupViewTest.cc \ + +} + +# +# AutoPilot Plugin Support +# + +INCLUDEPATH += \ + src/VehicleSetup + +FORMS += \ + src/VehicleSetup/ParameterEditor.ui \ + src/VehicleSetup/SetupView.ui \ + +HEADERS+= \ + src/VehicleSetup/SetupView.h \ + src/VehicleSetup/ParameterEditor.h \ + src/VehicleSetup/VehicleComponent.h \ + src/VehicleSetup/FirmwareUpgradeController.h \ + src/VehicleSetup/PX4Bootloader.h \ + src/VehicleSetup/PX4FirmwareUpgradeThread.h \ + src/AutoPilotPlugins/AutoPilotPluginManager.h \ + src/AutoPilotPlugins/AutoPilotPlugin.h \ + src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \ + src/AutoPilotPlugins/Generic/GenericParameterFacts.h \ + src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \ + src/AutoPilotPlugins/PX4/PX4Component.h \ + src/AutoPilotPlugins/PX4/RadioComponent.h \ + src/AutoPilotPlugins/PX4/FlightModesComponent.h \ + src/AutoPilotPlugins/PX4/FlightModesComponentController.h \ + src/AutoPilotPlugins/PX4/AirframeComponent.h \ + src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \ + src/AutoPilotPlugins/PX4/AirframeComponentController.h \ + src/AutoPilotPlugins/PX4/SensorsComponent.h \ + src/AutoPilotPlugins/PX4/SensorsComponentController.h \ + src/AutoPilotPlugins/PX4/SafetyComponent.h \ + src/AutoPilotPlugins/PX4/PowerComponent.h \ + src/AutoPilotPlugins/PX4/PX4ParameterFacts.h \ + +SOURCES += \ + src/VehicleSetup/SetupView.cc \ + src/VehicleSetup/ParameterEditor.cc \ + src/VehicleSetup/VehicleComponent.cc \ + src/VehicleSetup/FirmwareUpgradeController.cc \ + src/VehicleSetup/PX4Bootloader.cc \ + src/VehicleSetup/PX4FirmwareUpgradeThread.cc \ + src/AutoPilotPlugins/AutoPilotPluginManager.cc \ + src/AutoPilotPlugins/AutoPilotPlugin.cc \ + src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \ + src/AutoPilotPlugins/Generic/GenericParameterFacts.cc \ + src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \ + src/AutoPilotPlugins/PX4/PX4Component.cc \ + src/AutoPilotPlugins/PX4/RadioComponent.cc \ + src/AutoPilotPlugins/PX4/FlightModesComponent.cc \ + src/AutoPilotPlugins/PX4/FlightModesComponentController.cc \ + src/AutoPilotPlugins/PX4/AirframeComponent.cc \ + src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc \ + src/AutoPilotPlugins/PX4/AirframeComponentController.cc \ + src/AutoPilotPlugins/PX4/SensorsComponent.cc \ + src/AutoPilotPlugins/PX4/SensorsComponentController.cc \ + src/AutoPilotPlugins/PX4/SafetyComponent.cc \ + src/AutoPilotPlugins/PX4/PowerComponent.cc \ + src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc \ + +# Fact System code + +INCLUDEPATH += \ + src/FactSystem + +HEADERS += \ + src/FactSystem/FactSystem.h \ + src/FactSystem/Fact.h \ + src/FactSystem/FactBinder.h \ + src/FactSystem/FactMetaData.h \ + src/FactSystem/FactValidator.h \ + src/FactSystem/ParameterLoader.h \ + +SOURCES += \ + src/FactSystem/FactSystem.cc \ + src/FactSystem/Fact.cc \ + src/FactSystem/FactBinder.cc \ + src/FactSystem/FactMetaData.cc \ + src/FactSystem/FactValidator.cc \ + src/FactSystem/ParameterLoader.cc \ diff --git a/QGCCommon.pri b/QGCCommon.pri new file mode 100644 index 0000000..1251903 --- /dev/null +++ b/QGCCommon.pri @@ -0,0 +1,184 @@ +# ------------------------------------------------- +# QGroundControl - Micro Air Vehicle Groundstation +# Please see our website at +# Maintainer: +# Lorenz Meier +# (c) 2009-2014 QGroundControl Developers +# This file is part of the open groundstation project +# QGroundControl is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# QGroundControl is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with QGroundControl. If not, see . +# ------------------------------------------------- + +# +# This file contains configuration settings which are common to both the QGC Application and +# the Location Plugin. It should mainly contains intial CONFIG tag setup and compiler settings. +# + +# Setup our supported build types. We do this once here and then use the defined config scopes +# to allow us to easily modify suported build types in one place instead of duplicated throughout +# the project file. + +linux { + linux-g++ | linux-g++-64 { + message("Linux build") + CONFIG += LinuxBuild + } else { + error("Unsuported Linux toolchain, only GCC 32- or 64-bit is supported") + } +} else : win32 { + win32-msvc2010 | win32-msvc2012 | win32-msvc2013 { + message("Windows build") + CONFIG += WindowsBuild + } else { + error("Unsupported Windows toolchain, only Visual Studio 2010, 2012, and 2013 are supported") + } +} else : macx { + macx-clang | macx-llvm { + message("Mac build") + CONFIG += MacBuild + QMAKE_CXXFLAGS += -fvisibility=hidden + } else { + error("Unsupported Mac toolchain, only 64-bit LLVM+clang is supported") + } +} else { + error("Unsupported build platform, only Linux, Windows, and Mac are supported") +} + +# Installer configuration + +installer { + CONFIG -= debug + CONFIG -= debug_and_release + CONFIG += release + message(Build Installer) +} + +# Setup our supported build flavors + +CONFIG(debug, debug|release) { + message(Debug flavor) + CONFIG += DebugBuild +} else:CONFIG(release, debug|release) { + message(Release flavor) + CONFIG += ReleaseBuild +} else { + error(Unsupported build flavor) +} + +# Need to special case Windows debug_and_release since VS Project creation in this case does strange things [QTBUG-40351] +win32:debug_and_release { + CONFIG += WindowsDebugAndRelease +} + +# Setup our build directories + +BASEDIR = $${IN_PWD} + +DebugBuild { + DESTDIR = $${OUT_PWD}/debug + BUILDDIR = $${OUT_PWD}/build-debug +} + +ReleaseBuild { + DESTDIR = $${OUT_PWD}/release + BUILDDIR = $${OUT_PWD}/build-release +} + +LOCATION_PLUGIN_DESTDIR = $${BUILDDIR}/QGCLocationPlugin +LOCATION_PLUGIN_NAME = QGeoServiceProviderFactoryQGC + +OBJECTS_DIR = $${BUILDDIR}/obj +MOC_DIR = $${BUILDDIR}/moc +UI_DIR = $${BUILDDIR}/ui +RCC_DIR = $${BUILDDIR}/rcc +LANGUAGE = C++ + +message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET) + +# Turn off serial port warnings +DEFINES += _TTY_NOWARN_ + +# +# OS Specific settings +# + +MacBuild { + CONFIG += x86_64 + CONFIG -= x86 + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 + QMAKE_MAC_SDK = macosx10.9 +} + +LinuxBuild { + DEFINES += __STDC_LIMIT_MACROS +} + +WindowsBuild { + DEFINES += __STDC_LIMIT_MACROS + + # Specify multi-process compilation within Visual Studio. + # (drastically improves compilation times for multi-core computers) + QMAKE_CXXFLAGS_DEBUG += -MP + QMAKE_CXXFLAGS_RELEASE += -MP +} + +# +# By default warnings as errors are turned off. Even so, in order for a pull request +# to be accepted you must compile cleanly with warnings as errors turned on the default +# set of OS builds. See http://www.qgroundcontrol.org/dev/contribute for more details. +# You can use the WarningsAsErrorsOn CONFIG switch to turn warnings as errors on for your +# own builds. +# + +MacBuild | LinuxBuild { + QMAKE_CXXFLAGS_WARN_ON += -Wall + WarningsAsErrorsOn { + QMAKE_CXXFLAGS_WARN_ON += -Werror + } +} + +WindowsBuild { + QMAKE_CXXFLAGS_WARN_ON += /W3 \ + /wd4996 \ # silence warnings about deprecated strcpy and whatnot + /wd4005 \ # silence warnings about macro redefinition + /wd4290 \ # ignore exception specifications + /Zc:strictStrings- # work around win 8.1 sdk sapi.h problem + WarningsAsErrorsOn { + QMAKE_CXXFLAGS_WARN_ON += /WX + } +} + +# +# Build-specific settings +# + +ReleaseBuild { + DEFINES += QT_NO_DEBUG + + WindowsBuild { + # Use link time code generation for better optimization (I believe this is supported in MSVC Express, but not 100% sure) + QMAKE_LFLAGS_LTCG = /LTCG + QMAKE_CFLAGS_LTCG = -GL + } +} + +# +# Unit Test specific configuration goes here +# +# We have to special case Windows debug_and_release builds because you can't have files +# which are only in the debug variant [QTBUG-40351]. So in this case we include unit tests +# even in the release variant. If you want a Windows release build with no unit tests run +# qmake with CONFIG-=debug_and_release CONFIG+=release. +# + +DebugBuild|WindowsDebugAndRelease { + DEFINES += UNITTEST_BUILD +} diff --git a/QGCLocationPlugin.pro b/QGCLocationPlugin.pro new file mode 100644 index 0000000..fb2f761 --- /dev/null +++ b/QGCLocationPlugin.pro @@ -0,0 +1,33 @@ +include(QGCCommon.pri) + +TEMPLATE = lib +TARGET = $$qtLibraryTarget(QGeoServiceProviderFactoryQGC) +CONFIG += plugin static +QT += location-private positioning-private network +PLUGIN_TYPE = geoservices + +DESTDIR = $${LOCATION_PLUGIN_DESTDIR} + +INCLUDEPATH += $$QT.location.includes + +HEADERS += \ + src/QtLocationPlugin/qgeoserviceproviderpluginqgc.h \ + src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.h \ + src/QtLocationPlugin/qgeotilefetcherqgc.h \ + src/QtLocationPlugin/qgeomapreplyqgc.h \ + src/QtLocationPlugin/qgeocodingmanagerengineqgc.h \ + src/QtLocationPlugin/qgeocodereplyqgc.h \ + src/QtLocationPlugin/OpenPilotMaps.h + +SOURCES += \ + src/QtLocationPlugin/qgeoserviceproviderpluginqgc.cpp \ + src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp \ + src/QtLocationPlugin/qgeotilefetcherqgc.cpp \ + src/QtLocationPlugin/qgeomapreplyqgc.cpp \ + src/QtLocationPlugin/qgeocodingmanagerengineqgc.cpp \ + src/QtLocationPlugin/qgeocodereplyqgc.cpp \ + src/QtLocationPlugin/OpenPilotMaps.cc + +OTHER_FILES += \ + src/QtLocationPlugin/qgc_maps_plugin.json + diff --git a/libs/QtLocationQGC/.qmake.conf b/libs/QtLocationQGC/.qmake.conf deleted file mode 100644 index 42a8dd9..0000000 --- a/libs/QtLocationQGC/.qmake.conf +++ /dev/null @@ -1,3 +0,0 @@ -load(qt_build_config) - -MODULE_VERSION = 5.4.1 diff --git a/libs/QtLocationQGC/QtLocationQGC.pro b/libs/QtLocationQGC/QtLocationQGC.pro deleted file mode 100644 index 7704868..0000000 --- a/libs/QtLocationQGC/QtLocationQGC.pro +++ /dev/null @@ -1,32 +0,0 @@ -TARGET = qtgeoservices_qgc -CONFIG += static -QT += location-private positioning-private network -PLUGIN_TYPE = geoservices - -PLUGIN_CLASS_NAME = QGeoServiceProviderFactoryQGC - -load(qt_plugin) - -INCLUDEPATH += $$QT.location.includes - -HEADERS += \ - $$PWD/src/qgeoserviceproviderpluginqgc.h \ - $$PWD/src/qgeotiledmappingmanagerengineqgc.h \ - $$PWD/src/qgeotilefetcherqgc.h \ - $$PWD/src/qgeomapreplyqgc.h \ - $$PWD/src/qgeocodingmanagerengineqgc.h \ - $$PWD/src/qgeocodereplyqgc.h \ - $$PWD/src/OpenPilotMaps.h - -SOURCES += \ - $$PWD/src/qgeoserviceproviderpluginqgc.cpp \ - $$PWD/src/qgeotiledmappingmanagerengineqgc.cpp \ - $$PWD/src/qgeotilefetcherqgc.cpp \ - $$PWD/src/qgeomapreplyqgc.cpp \ - $$PWD/src/qgeocodingmanagerengineqgc.cpp \ - $$PWD/src/qgeocodereplyqgc.cpp \ - $$PWD/src/OpenPilotMaps.cc - -OTHER_FILES += \ - $$PWD/qgc_maps_plugin.json - diff --git a/libs/QtLocationQGC/qgc_maps_plugin.json b/libs/QtLocationQGC/qgc_maps_plugin.json deleted file mode 100644 index dd52d9f..0000000 --- a/libs/QtLocationQGC/qgc_maps_plugin.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Keys": ["qgc-maps"], - "Provider": "QGroundControl", - "Version": 101, - "Experimental": false, - "Features": [ - "OnlineMappingFeature", - "OnlineGeocodingFeature", - "ReverseGeocodingFeature" - ] -} diff --git a/libs/QtLocationQGC/src/OpenPilotMaps.cc b/libs/QtLocationQGC/src/OpenPilotMaps.cc deleted file mode 100644 index e38d564..0000000 --- a/libs/QtLocationQGC/src/OpenPilotMaps.cc +++ /dev/null @@ -1,490 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief QGC Open Pilot Mapping Tools - * @author Gus Grubba - * Original work: The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - */ - -#include -#include -#include -#include - -#include "OpenPilotMaps.h" - -namespace OpenPilot { - -const QString ProviderStrings::levelsForSigPacSpainMap[] = - { "0", "1", "2", "3", "4", - "MTNSIGPAC", - "MTN2000", "MTN2000", "MTN2000", "MTN2000", "MTN2000", - "MTN200", "MTN200", "MTN200", - "MTN25", "MTN25", - "ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS" }; - -const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84 - -ProviderStrings::ProviderStrings() -{ - // Google version strings - VersionGoogleMap = "m@113"; - VersionGoogleSatellite = "s"; - VersionGoogleLabels = "h@221000000"; - VersionGoogleTerrain = "t@132,r@249000000"; - SecGoogleWord = "Galileo"; - - // Google (China) version strings - VersionGoogleMapChina = "m@132"; - VersionGoogleSatelliteChina = "s@71"; - VersionGoogleLabelsChina = "h@132"; - VersionGoogleTerrainChina = "t@125,r@132"; - - // Google (Korea) version strings - VersionGoogleMapKorea = "kr1.12"; - VersionGoogleSatelliteKorea = "66"; - VersionGoogleLabelsKorea = "kr1t.12"; - - /// - /// Google Maps API generated using http://greatmaps.codeplex.com/ - /// from http://code.google.com/intl/en-us/apis/maps/signup.html - /// - GoogleMapsAPIKey = "ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA"; - - // Yahoo version strings - VersionYahooMap = "4.3"; - VersionYahooSatellite = "1.9"; - VersionYahooLabels = "4.3"; - - // BingMaps - VersionBingMaps = "563"; - - // YandexMap - VersionYandexMap = "2.16.0"; - - /// - /// Bing Maps Customer Identification, more info here - /// http://msdn.microsoft.com/en-us/library/bb924353.aspx - /// - BingMapsClientToken = ""; -} - -UrlFactory::UrlFactory() - : _isCorrectedGoogleVersions(false) - , _correctGoogleVersions(true) - , _timeout(5 * 1000) -{ - Proxy.setType(QNetworkProxy::NoProxy); - UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"; -} - -UrlFactory::~UrlFactory() -{ - -} - -QString UrlFactory::_tileXYToQuadKey(const int& tileX, const int& tileY, const int& levelOfDetail) const -{ - QString quadKey; - for (int i = levelOfDetail; i > 0; i--) { - char digit = '0'; - int mask = 1 << (i - 1); - if ((tileX & mask) != 0) { - digit++; - } - if ((tileY & mask) != 0) { - digit++; - digit++; - } - quadKey.append(digit); - } - return quadKey; -} - -int UrlFactory::_getServerNum(const QPoint &pos, const int &max) const -{ - return (pos.x() + 2 * pos.y()) % max; -} - -void UrlFactory::_tryCorrectGoogleVersions() -{ - static bool _kVersionRetrieved = false; - if (_kVersionRetrieved) { - return; - } - QMutexLocker locker(&mutex); - if (_correctGoogleVersions && !_isCorrectedGoogleVersions) { - QNetworkReply* reply; - QNetworkRequest qheader; - QNetworkAccessManager network; - QEventLoop q; - QTimer tT; - tT.setSingleShot(true); - connect(&network, SIGNAL(finished(QNetworkReply *)), &q, SLOT(quit())); - connect(&tT, SIGNAL(timeout()), &q, SLOT(quit())); - network.setProxy(Proxy); - _isCorrectedGoogleVersions = true; - QString url = "https://maps.google.com/maps?output=classic"; - qheader.setUrl(QUrl(url)); - qheader.setRawHeader("User-Agent", UserAgent); - reply = network.get(qheader); - tT.start(_timeout); - q.exec(); - if (!tT.isActive()) { - return; - } - tT.stop(); - if ((reply->error() != QNetworkReply::NoError)) { - return; - } - QString html = QString(reply->readAll()); - QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive); - if (reg.indexIn(html) != -1) { - QStringList gc = reg.capturedTexts(); - VersionGoogleMap = QString("m@%1").arg(gc[1]); - VersionGoogleMapChina = VersionGoogleMap; - VersionGoogleMapKorea = VersionGoogleMap; - } - reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=h@(\\d*)", Qt::CaseInsensitive); - if (reg.indexIn(html) != -1) { - QStringList gc = reg.capturedTexts(); - VersionGoogleLabels = QString("h@%1").arg(gc[1]); - VersionGoogleLabelsChina = VersionGoogleLabels; - VersionGoogleLabelsKorea = VersionGoogleLabels; - } - reg = QRegExp("\"*https://khms0.google.com/kh/v=(\\d*)", Qt::CaseInsensitive); - if (reg.indexIn(html) != -1) { - QStringList gc = reg.capturedTexts(); - VersionGoogleSatellite = "s@" + gc[1]; - VersionGoogleSatelliteKorea = VersionGoogleSatellite; - VersionGoogleSatelliteChina = VersionGoogleSatellite; - } - reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive); - if (reg.indexIn(html) != -1) { - QStringList gc = reg.capturedTexts(); - VersionGoogleTerrain = QString("t@%1,r@%2").arg(gc[1]).arg(gc[2]); - VersionGoogleTerrainChina = VersionGoogleTerrain; - VersionGoogleTerrainChina = VersionGoogleTerrain; - } - reply->deleteLater(); - _kVersionRetrieved = true; - } -} - -QString UrlFactory::makeImageUrl(const MapType &type, const QPoint& pos, const int &zoom, const QString &language) -{ - switch (type) { - case GoogleMap: - { - // http://mt1.google.com/vt/lyrs=m - QString server = "mt"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10&scale=2").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleMap).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleSatellite: - { - // http://mt1.google.com/vt/lyrs=s - QString server = "mt"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10&scale=2").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleLabels: - { - QString server = "mts"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleTerrain: - { - QString server = "mts"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10&scale=2").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrain).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleMapChina: - { - QString server = "mt"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // http://mt0.google.cn/vt/v=w2.101&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga - return QString("http://%1%2.google.cn/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleMapChina).arg("zh-CN").arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleSatelliteChina: - { - QString server = "mt"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // http://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga - return QString("http://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteChina).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleLabelsChina: - { - QString server = "mt"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga - return QString("http://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsChina).arg("zh-CN").arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleTerrainChina: - { - QString server = "mt"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga - return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrainChina).arg("zh-CN").arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleMapKorea: - { - QString server = "mts"; - QString request = "vt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // https://mts0.google.com/vt/lyrs=m@224000000&hl=ko&gl=KR&src=app&x=107&y=50&z=7&s=Gal - // https://mts0.google.com/mt/v=kr1.11&hl=ko&x=109&y=49&z=7&s= - QString ret = QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - return ret; - } - break; - case GoogleSatelliteKorea: - { - QString server = "khms"; - QString request = "kh"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s= - return QString("https://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case GoogleLabelsKorea: - { - QString server = "mts"; - QString request = "mt"; - QString sec1 = ""; // after &x=... - QString sec2 = ""; // after &zoom=... - _getSecGoogleWords(pos, sec1, sec2); - _tryCorrectGoogleVersions(); - // https://mts1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G - return QString("https://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); - } - break; - case YahooMap: - { - return QString("http://maps%1.yimg.com/hx/tl?v=%2&.intl=%3&x=%4&y=%5&z=%6&r=1").arg(((_getServerNum(pos, 2)) + 1)).arg(VersionYahooMap).arg(language).arg(pos.x()).arg((((1 << zoom) >> 1) - 1 - pos.y())).arg((zoom + 1)); - } - case YahooSatellite: - { - return QString("http://maps%1.yimg.com/ae/ximg?v=%2&t=a&s=256&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("3").arg(VersionYahooSatellite).arg(language).arg(pos.x()).arg(((1 << zoom) >> 1) - 1 - pos.y()).arg(zoom + 1); - } - break; - case YahooLabels: - { - return QString("http://maps%1.yimg.com/hx/tl?v=%2&t=h&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("1").arg(VersionYahooLabels).arg(language).arg(pos.x()).arg(((1 << zoom) >> 1) - 1 - pos.y()).arg(zoom + 1); - } - break; - case OpenStreetMap: - { - char letter = "abc"[_getServerNum(pos, 3)]; - return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.x()).arg(pos.y()); - } - break; - case OpenStreetOsm: - { - char letter = "abc"[_getServerNum(pos, 3)]; - return QString("http://%1.tah.openstreetmap.org/Tiles/tile/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.x()).arg(pos.y()); - } - break; - case OpenStreetMapSurfer: - { - // http://tiles1.mapsurfer.net/tms_r.ashx?x=37378&y=20826&z=16 - return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.x()).arg(pos.y()).arg(zoom); - } - break; - case OpenStreetMapSurferTerrain: - { - // http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14 - return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.x()).arg(pos.y()).arg(zoom); - } - break; - case BingMap: - { - QString key = _tileXYToQuadKey(pos.x(), pos.y(), zoom); - return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4%5").arg(_getServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull() | BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString("")); - } - break; - case BingSatellite: - { - QString key = _tileXYToQuadKey(pos.x(), pos.y(), zoom); - return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4%5").arg(_getServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull() | BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString("")); - } - break; - case BingHybrid: - { - QString key = _tileXYToQuadKey(pos.x(), pos.y(), zoom); - return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4%5").arg(_getServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull() | BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString("")); - } - case ArcGIS_Map: - { - // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/0/0/0.jpg - return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); - } - break; - case ArcGIS_Satellite: - { - // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/1/0/1.jpg - return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); - } - break; - case ArcGIS_ShadedRelief: - { - // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/1/0/1.jpg - return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); - } - break; - case ArcGIS_Terrain: - { - // http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/4/3/15 - return QString("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); - } - break; - case ArcGIS_MapsLT_OrtoFoto: - { - // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg - // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13 - // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.y(), pos.x()); - // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg - // return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.y(), pos.x()); - // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg - // TODO verificar - return QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom, 2, 10, (QChar)'0').arg(pos.y(), 8, 16, (QChar)'0').arg(pos.x(), 8, 16, (QChar)'0'); - } - break; - case ArcGIS_MapsLT_Map: - { - // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg - // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13 - // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.y(), pos.x()); - // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt/MapServer/tile/7/1162/1684.png - // http://dc1.maps.lt/cache/mapslt_512/map/_alllayers/L03/R0000001b/C00000029.png - // TODO verificar - // http://dc1.maps.lt/cache/mapslt/map/_alllayers/L02/R0000001c/C00000029.png - return QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.y(), 8, 16, (QChar)'0').arg(pos.x(), 8, 16, (QChar)'0'); - } - break; - case ArcGIS_MapsLT_Map_Labels: - { - // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13 - // return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.y(), pos.x()); - // http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png - // TODO verificar - return QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.y(), 8, 16, (QChar)'0').arg(pos.x(), 8, 16, (QChar)'0'); - } - break; - case PergoTurkeyMap: - { - // http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png - // http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png - // That means: Zoom Level: 0 TileX: 1 TileY: 0 - // http://domain/tile/14/000/019/371/000/011/825.png - // That means: Zoom Level: 14 TileX: 19371 TileY:11825 - // string x = pos.x().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001 - // string y = pos.y().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000 - QString x = QString("%1").arg(QString::number(pos.x()), 9, (QChar)'0'); - x.insert(3, "/").insert(7, "/"); - QString y = QString("%1").arg(QString::number(pos.y()), 9, (QChar)'0'); - y.insert(3, "/").insert(7, "/"); - // "http://map03.pergo.com.tr/tile/2/000/000/003/000/000/002.png" - return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(_getServerNum(pos, 4)).arg(zoom, 2, 10, (QChar)'0').arg(x).arg(y); - } - break; - case SigPacSpainMap: - { - return QString("http://sigpac.mapa.es/kmlserver/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.x()).arg((2 << (zoom - 1)) - pos.y() - 1); - } - break; - case YandexMapRu: - { - QString server = "vec"; - // http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11 - return QString("http://%1").arg(server) + QString("0%2.maps.yandex.ru/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(_getServerNum(pos, 4) + 1).arg(VersionYandexMap).arg(pos.x()).arg(pos.y()).arg(zoom); - } - break; - default: - qWarning("Unknown map id %d\n", type); - break; - } - return QString::null; -} - -void UrlFactory::_getSecGoogleWords(const QPoint &pos, QString &sec1, QString &sec2) -{ - sec1 = ""; // after &x=... - sec2 = ""; // after &zoom=... - int seclen = ((pos.x() * 3) + pos.y()) % 8; - sec2 = SecGoogleWord.left(seclen); - if (pos.y() >= 10000 && pos.y() < 100000) { - sec1 = "&s="; - } -} - -} diff --git a/libs/QtLocationQGC/src/OpenPilotMaps.h b/libs/QtLocationQGC/src/OpenPilotMaps.h deleted file mode 100644 index 5d88d6a..0000000 --- a/libs/QtLocationQGC/src/OpenPilotMaps.h +++ /dev/null @@ -1,157 +0,0 @@ -/*===================================================================== - -QGroundControl Open Source Ground Control Station - -(c) 2009, 2015 QGROUNDCONTROL PROJECT - -This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - QGROUNDCONTROL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with QGROUNDCONTROL. If not, see . - -======================================================================*/ - -/** - * @file - * @brief QGC Open Pilot Mapping Tools - * @author Gus Grubba - * Original work: The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - */ - -#ifndef OPENPILOTTOOLS_H -#define OPENPILOTTOOLS_H - -#include -#include -#include -#include -#include - -namespace OpenPilot { - -enum MapType -{ - GoogleMap = 1, - GoogleSatellite = 4, - GoogleLabels = 8, - GoogleTerrain = 16, - GoogleHybrid = 20, - - GoogleMapChina = 22, - GoogleSatelliteChina = 24, - GoogleLabelsChina = 26, - GoogleTerrainChina = 28, - GoogleHybridChina = 29, - - OpenStreetMap = 32, - OpenStreetOsm = 33, - OpenStreetMapSurfer = 34, - OpenStreetMapSurferTerrain=35, - - YahooMap = 64, - YahooSatellite = 128, - YahooLabels = 256, - YahooHybrid = 333, - - BingMap = 444, - BingSatellite = 555, - BingHybrid = 666, - - ArcGIS_Map = 777, - ArcGIS_Satellite = 788, - ArcGIS_ShadedRelief = 799, - ArcGIS_Terrain = 811, - - ArcGIS_MapsLT_Map = 1000, - ArcGIS_MapsLT_OrtoFoto = 1001, - ArcGIS_MapsLT_Map_Labels= 1002, - ArcGIS_MapsLT_Map_Hybrid= 1003, - - PergoTurkeyMap = 2001, - SigPacSpainMap = 3001, - - GoogleMapKorea = 4001, - GoogleSatelliteKorea = 4002, - GoogleLabelsKorea = 4003, - GoogleHybridKorea = 4005, - - YandexMapRu = 5000 -}; - -class ProviderStrings { -public: - ProviderStrings(); - static const QString levelsForSigPacSpainMap[]; - QString GoogleMapsAPIKey; - // Google version strings - QString VersionGoogleMap; - QString VersionGoogleSatellite; - QString VersionGoogleLabels; - QString VersionGoogleTerrain; - QString SecGoogleWord; - // Google (China) version strings - QString VersionGoogleMapChina; - QString VersionGoogleSatelliteChina; - QString VersionGoogleLabelsChina; - QString VersionGoogleTerrainChina; - // Google (Korea) version strings - QString VersionGoogleMapKorea; - QString VersionGoogleSatelliteKorea; - QString VersionGoogleLabelsKorea; - /// - /// Google Maps API generated using http://greatmaps.codeplex.com/ - /// from http://code.google.com/intl/en-us/apis/maps/signup.html - /// - // Yahoo version strings - QString VersionYahooMap; - QString VersionYahooSatellite; - QString VersionYahooLabels; - // BingMaps - QString VersionBingMaps; - // YandexMap - QString VersionYandexMap; - /// - /// Bing Maps Customer Identification, more info here - /// http://msdn.microsoft.com/en-us/library/bb924353.aspx - /// - QString BingMapsClientToken; -}; - -class UrlFactory : public QObject, public ProviderStrings { - Q_OBJECT -public: - QByteArray UserAgent; - QNetworkProxy Proxy; - - UrlFactory(); - ~UrlFactory(); - - QString makeImageUrl (const MapType &type, const QPoint &pos, const int &zoom, const QString &language); - -private: - void _getSecGoogleWords (const QPoint &pos, QString &sec1, QString &sec2); - int _getServerNum (const QPoint& pos, const int &max) const; - void _tryCorrectGoogleVersions (); - QString _tileXYToQuadKey (const int &tileX, const int &tileY, const int &levelOfDetail) const; - - bool _isCorrectedGoogleVersions; - bool _correctGoogleVersions; - int _timeout; - - QMutex mutex; - static const double EarthRadiusKm; -}; - -} - -#endif // FOO_H diff --git a/libs/QtLocationQGC/src/qgeocodereplyqgc.cpp b/libs/QtLocationQGC/src/qgeocodereplyqgc.cpp deleted file mode 100644 index de948ee..0000000 --- a/libs/QtLocationQGC/src/qgeocodereplyqgc.cpp +++ /dev/null @@ -1,301 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qgeocodereplyqgc.h" - -QT_BEGIN_NAMESPACE - -enum QGeoCodeTypeGoogle { - GeoCodeTypeUnknown, - StreetAddress, // indicates a precise street address. - Route, // indicates a named route (such as "US 101"). - Intersection, // indicates a major intersection, usually of two major roads. - Political, // indicates a political entity. Usually, this type indicates a polygon of some civil administration. - Country, // indicates the national political entity, and is typically the highest order type returned by the Geocoder. - AdministrativeAreaLevel1, // indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states. - AdministrativeAreaLevel2, // indicates a second-order civil entity below the country level. Within the United States, these administrative levels are counties. - AdministrativeAreaLevel3, // indicates a third-order civil entity below the country level. This type indicates a minor civil division. - ColloquialArea, // indicates a commonly-used alternative name for the entity. - Locality, // indicates an incorporated city or town political entity. - Sublocality, // indicates a first-order civil entity below a locality. For some locations may receive one of the additional types: sublocality_level_1 through to sublocality_level_5. Each sublocality level is a civil entity. Larger numbers indicate a smaller geographic area. - SublocalityLevel1, - SublocalityLevel2, - SublocalityLevel3, - SublocalityLevel4, - SublocalityLevel5, - Neighborhood, // indicates a named neighborhood - Premise, // indicates a named location, usually a building or collection of buildings with a common name - Subpremise, // indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a common name - PostalCode, // indicates a postal code as used to address postal mail within the country. - NaturalFeature, // indicates a prominent natural feature. - Airport, // indicates an airport. - Park, // indicates a named park. - PointOfInterest, // indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in another category such as "Empire State Building" or "Statue of Liberty." - Floor, // indicates the floor of a building address. - Establishment, // typically indicates a place that has not yet been categorized. - Parking, // indicates a parking lot or parking structure. - PostBox, // indicates a specific postal box. - PostalTown, // indicates a grouping of geographic areas, such as locality and sublocality, used for mailing addresses in some countries. - RoomIndicates, // the room of a building address. - StreetNumber, // indicates the precise street number. - BusStation, // indicate the location of a bus stop. - TrainStation, // indicate the location of a train stop. - TransitStation, // indicate the location of a public transit stop. -}; - -class JasonMonger { -public: - JasonMonger(); - QSet json2QGeoCodeTypeGoogle(const QJsonArray &types); -private: - int _getCode(const QString &key); - QMap _m; -}; - -JasonMonger::JasonMonger() -{ - _m[QStringLiteral("street_address")] = StreetAddress; - _m[QStringLiteral("route")] = Route; - _m[QStringLiteral("intersection")] = Intersection; - _m[QStringLiteral("political")] = Political; - _m[QStringLiteral("country")] = Country; - _m[QStringLiteral("administrative_area_level_1")] = AdministrativeAreaLevel1; - _m[QStringLiteral("administrative_area_level_2")] = AdministrativeAreaLevel2; - _m[QStringLiteral("administrative_area_level_3")] = AdministrativeAreaLevel3; - _m[QStringLiteral("colloquial_area")] = ColloquialArea; - _m[QStringLiteral("locality")] = Locality; - _m[QStringLiteral("sublocality")] = Sublocality; - _m[QStringLiteral("sublocality_level_1")] = SublocalityLevel1; - _m[QStringLiteral("sublocality_level_2")] = SublocalityLevel2; - _m[QStringLiteral("sublocality_level_3")] = SublocalityLevel3; - _m[QStringLiteral("sublocality_level_4")] = SublocalityLevel4; - _m[QStringLiteral("sublocality_level_5")] = SublocalityLevel5; - _m[QStringLiteral("neighborhood")] = Neighborhood; - _m[QStringLiteral("premise")] = Premise; - _m[QStringLiteral("subpremise")] = Subpremise; - _m[QStringLiteral("postal_code")] = PostalCode; - _m[QStringLiteral("natural_feature")] = NaturalFeature; - _m[QStringLiteral("airport")] = Airport; - _m[QStringLiteral("park")] = Park; - _m[QStringLiteral("point_of_interest")] = PointOfInterest; - _m[QStringLiteral("floor")] = Floor; - _m[QStringLiteral("establishment")] = Establishment; - _m[QStringLiteral("parking")] = Parking; - _m[QStringLiteral("post_box")] = PostBox; - _m[QStringLiteral("postal_town")] = PostalTown; - _m[QStringLiteral("room indicates")] = RoomIndicates; - _m[QStringLiteral("street_number")] = StreetNumber; - _m[QStringLiteral("bus_station")] = BusStation; - _m[QStringLiteral("train_station")] = TrainStation; - _m[QStringLiteral("transit_station")] = TransitStation; -} - -int JasonMonger::_getCode(const QString &key) { - return _m.value(key, GeoCodeTypeUnknown); -} - -QSet JasonMonger::json2QGeoCodeTypeGoogle(const QJsonArray &types) { - QSet result; - for (int i=0; ideleteLater(); -} - -void QGeoCodeReplyQGC::abort() -{ - if (!m_reply) - return; - - m_reply->abort(); - - m_reply->deleteLater(); - m_reply = 0; -} - -void QGeoCodeReplyQGC::networkReplyFinished() -{ - if (!m_reply) - return; - - if (m_reply->error() != QNetworkReply::NoError) - return; - - QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); - QJsonObject object = document.object(); - - if (object.value(QStringLiteral("status")) != QStringLiteral("OK")) { - QString error = object.value(QStringLiteral("status")).toString(); - qWarning() << m_reply->url() << "returned" << error; - setError(QGeoCodeReply::CommunicationError, error); - m_reply->deleteLater(); - m_reply = 0; - return; - } - - QList locations; - QJsonArray results = object.value(QStringLiteral("results")).toArray(); - for (int i=0; i types = kMonger.json2QGeoCodeTypeGoogle(c[QStringLiteral("types")].toArray()); - QString long_name = c[QStringLiteral("long_name")].toString(); - QString short_name = c[QStringLiteral("short_name")].toString(); - if (types.contains(Country)) { - address.setCountry(long_name); - address.setCountryCode(short_name); - } else if (types.contains(AdministrativeAreaLevel1)) { - address.setState(long_name); - } else if (types.contains(AdministrativeAreaLevel2)) { - address.setCounty(long_name); - } else if (types.contains(Locality)) { - address.setCity(long_name); - } else if (types.contains(Sublocality)) { - address.setDistrict(long_name); - } else if (types.contains(PostalCode)) { - address.setPostalCode(long_name); - } else if (types.contains(StreetAddress) || types.contains(Route) || types.contains(Intersection)) { - address.setStreet(long_name); - } - } - } - - QGeoCoordinate coordinate; - QGeoRectangle boundingBox; - if (geocode.contains(QStringLiteral("geometry"))) { - QJsonObject geom = geocode.value(QStringLiteral("geometry")).toObject(); - if (geom.contains(QStringLiteral("location"))) { - QJsonObject location = geom.value(QStringLiteral("location")).toObject(); - coordinate.setLatitude(location.value(QStringLiteral("lat")).toDouble()); - coordinate.setLongitude(location.value(QStringLiteral("lng")).toDouble()); - } - if (geom.contains(QStringLiteral("bounds"))) { - QJsonObject bounds = geom.value(QStringLiteral("bounds")).toObject(); - QJsonObject northeast = bounds.value(QStringLiteral("northeast")).toObject(); - QJsonObject southwest = bounds.value(QStringLiteral("southwest")).toObject(); - QGeoCoordinate topRight(northeast.value(QStringLiteral("lat")).toDouble(), - northeast.value(QStringLiteral("lng")).toDouble()); - QGeoCoordinate bottomLeft(southwest.value(QStringLiteral("lat")).toDouble(), - southwest.value(QStringLiteral("lng")).toDouble()); - boundingBox.setTopRight(topRight); - boundingBox.setBottomLeft(bottomLeft); - } - } - - QGeoLocation location; - location.setAddress(address); - location.setCoordinate(coordinate); - location.setBoundingBox(boundingBox); - - locations << location; - } - - setLocations(locations); - setFinished(true); - - m_reply->deleteLater(); - m_reply = 0; -} - -void QGeoCodeReplyQGC::networkReplyError(QNetworkReply::NetworkError error) -{ - Q_UNUSED(error) - if (!m_reply) - return; - setError(QGeoCodeReply::CommunicationError, m_reply->errorString()); - m_reply->deleteLater(); - m_reply = 0; -} - -QT_END_NAMESPACE diff --git a/libs/QtLocationQGC/src/qgeocodereplyqgc.h b/libs/QtLocationQGC/src/qgeocodereplyqgc.h deleted file mode 100644 index 1c4d483..0000000 --- a/libs/QtLocationQGC/src/qgeocodereplyqgc.h +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#ifndef QGEOCODEREPLYGOOGLE_H -#define QGEOCODEREPLYGOOGLE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QGeoCodeReplyQGC : public QGeoCodeReply -{ - Q_OBJECT - -public: - explicit QGeoCodeReplyQGC(QNetworkReply *reply, QObject *parent = 0); - ~QGeoCodeReplyQGC(); - - void abort(); - -private Q_SLOTS: - void networkReplyFinished(); - void networkReplyError(QNetworkReply::NetworkError error); - -private: - QNetworkReply *m_reply; -}; - -QT_END_NAMESPACE - -#endif // QGEOCODEREPLYGOOGLE_H diff --git a/libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.cpp b/libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.cpp deleted file mode 100644 index 5688043..0000000 --- a/libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qgeocodingmanagerengineqgc.h" -#include "qgeocodereplyqgc.h" - -QT_BEGIN_NAMESPACE - -static QString addressToQuery(const QGeoAddress &address) -{ - return address.street() + QStringLiteral(", ") + - address.district() + QStringLiteral(", ") + - address.city() + QStringLiteral(", ") + - address.state() + QStringLiteral(", ") + - address.country(); -} - -static QString boundingBoxToLtrb(const QGeoRectangle &rect) -{ - return QString::number(rect.topLeft().longitude()) + QLatin1Char(',') + - QString::number(rect.topLeft().latitude()) + QLatin1Char(',') + - QString::number(rect.bottomRight().longitude()) + QLatin1Char(',') + - QString::number(rect.bottomRight().latitude()); -} - -QGeoCodingManagerEngineQGC::QGeoCodingManagerEngineQGC( - const QVariantMap ¶meters, - QGeoServiceProvider::Error *error, - QString *errorString) - : QGeoCodingManagerEngine(parameters), m_networkManager(new QNetworkAccessManager(this)) -{ - if (parameters.contains(QStringLiteral("useragent"))) - m_userAgent = parameters.value(QStringLiteral("useragent")).toString().toLatin1(); - else - m_userAgent = "Qt Location based application"; - *error = QGeoServiceProvider::NoError; - errorString->clear(); -} - -QGeoCodingManagerEngineQGC::~QGeoCodingManagerEngineQGC() -{ -} - -QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QGeoAddress &address, const QGeoShape &bounds) -{ - return geocode(addressToQuery(address), -1, -1, bounds); -} - -QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds) -{ - Q_UNUSED(limit); - Q_UNUSED(offset); - - QNetworkRequest request; - request.setRawHeader("User-Agent", m_userAgent); - - QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json")); - QUrlQuery query; - query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false")); - query.addQueryItem(QStringLiteral("language"), locale().name().left(2)); - query.addQueryItem(QStringLiteral("address"), address); - if (bounds.type() == QGeoShape::RectangleType) { - query.addQueryItem(QStringLiteral("bounds"), boundingBoxToLtrb(bounds)); - } - - url.setQuery(query); - request.setUrl(url); - qDebug() << url; - - QNetworkReply *reply = m_networkManager->get(request); - reply->setParent(0); - - QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply); - - connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished())); - connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)), - this, SLOT(replyError(QGeoCodeReply::Error,QString))); - - return geocodeReply; -} - -QGeoCodeReply *QGeoCodingManagerEngineQGC::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds) -{ - Q_UNUSED(bounds) - - QNetworkRequest request; - request.setRawHeader("User-Agent", m_userAgent); - - QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json")); - QUrlQuery query; - query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false")); - query.addQueryItem(QStringLiteral("language"), locale().name().left(2)); - query.addQueryItem(QStringLiteral("latlng"), QStringLiteral("%1,%2") - .arg(coordinate.latitude()) - .arg(coordinate.longitude())); - - url.setQuery(query); - request.setUrl(url); - qDebug() << url; - - QNetworkReply *reply = m_networkManager->get(request); - reply->setParent(0); - - QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply); - - connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished())); - connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)), - this, SLOT(replyError(QGeoCodeReply::Error,QString))); - - return geocodeReply; -} - -void QGeoCodingManagerEngineQGC::replyFinished() -{ - QGeoCodeReply *reply = qobject_cast(sender()); - if (reply) - emit finished(reply); -} - -void QGeoCodingManagerEngineQGC::replyError(QGeoCodeReply::Error errorCode, const QString &errorString) -{ - QGeoCodeReply *reply = qobject_cast(sender()); - if (reply) - emit error(reply, errorCode, errorString); -} - -QT_END_NAMESPACE diff --git a/libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.h b/libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.h deleted file mode 100644 index 56040f4..0000000 --- a/libs/QtLocationQGC/src/qgeocodingmanagerengineqgc.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#ifndef QGEOCODINGMANAGERENGINEGOOGLE_H -#define QGEOCODINGMANAGERENGINEGOOGLE_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QNetworkAccessManager; - -class QGeoCodingManagerEngineQGC : public QGeoCodingManagerEngine -{ - Q_OBJECT - -public: - QGeoCodingManagerEngineQGC(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString); - ~QGeoCodingManagerEngineQGC(); - - QGeoCodeReply* geocode (const QGeoAddress &address, const QGeoShape &bounds) Q_DECL_OVERRIDE; - QGeoCodeReply* geocode (const QString &address, int limit, int offset, const QGeoShape &bounds) Q_DECL_OVERRIDE; - QGeoCodeReply* reverseGeocode (const QGeoCoordinate &coordinate, const QGeoShape &bounds) Q_DECL_OVERRIDE; - -private Q_SLOTS: - void replyFinished (); - void replyError (QGeoCodeReply::Error errorCode, const QString &errorString); - -private: - QNetworkAccessManager *m_networkManager; - QByteArray m_userAgent; -}; - -QT_END_NAMESPACE - -#endif // QGEOCODINGMANAGERENGINEGOOGLE_H diff --git a/libs/QtLocationQGC/src/qgeomapreplyqgc.cpp b/libs/QtLocationQGC/src/qgeomapreplyqgc.cpp deleted file mode 100644 index 7fad5e7..0000000 --- a/libs/QtLocationQGC/src/qgeomapreplyqgc.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#include - -#include "qgeomapreplyqgc.h" -#include "OpenPilotMaps.h" - -QGeoMapReplyQGC::QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent) - : QGeoTiledMapReply(spec, parent) - , m_reply(reply) -{ - connect(m_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished())); - connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError))); - connect(m_reply, SIGNAL(destroyed()), this, SLOT(replyDestroyed())); -} - -QGeoMapReplyQGC::~QGeoMapReplyQGC() -{ - if (m_reply) { - m_reply->deleteLater(); - m_reply = 0; - } -} - -void QGeoMapReplyQGC::abort() -{ - if (!m_reply) - return; - m_reply->abort(); -} - -QNetworkReply *QGeoMapReplyQGC::networkReply() const -{ - return m_reply; -} - -void QGeoMapReplyQGC::replyDestroyed() -{ - m_reply = 0; -} - -void QGeoMapReplyQGC::networkReplyFinished() -{ - if (!m_reply) - return; - - if (m_reply->error() != QNetworkReply::NoError) - return; - - QByteArray a = m_reply->readAll(); - setMapImageData(a); - - if(a.size() > 2) - { - if((char)a[0] == (char)0xff && (char)a[1] == (char)0xd8) - setMapImageFormat("jpg"); - else if((char)a[0] == (char)0x89 && (char)a[1] == (char)0x50) - setMapImageFormat("png"); - else - { - switch ((OpenPilot::MapType)tileSpec().mapId()) { - case OpenPilot::GoogleMap: - case OpenPilot::GoogleLabels: - case OpenPilot::GoogleTerrain: - case OpenPilot::GoogleHybrid: - case OpenPilot::BingMap: - case OpenPilot::OpenStreetMap: - setMapImageFormat("png"); - break; - case OpenPilot::GoogleSatellite: - case OpenPilot::BingSatellite: - case OpenPilot::BingHybrid: - setMapImageFormat("jpg"); - break; - default: - qWarning("Unknown map id %d", tileSpec().mapId()); - break; - } - } - } - - setFinished(true); - m_reply->deleteLater(); - m_reply = 0; -} - -void QGeoMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error) -{ - if (!m_reply) - return; - - if (error != QNetworkReply::OperationCanceledError) - setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString()); - - setFinished(true); - m_reply->deleteLater(); - m_reply = 0; -} diff --git a/libs/QtLocationQGC/src/qgeomapreplyqgc.h b/libs/QtLocationQGC/src/qgeomapreplyqgc.h deleted file mode 100644 index 33364ee..0000000 --- a/libs/QtLocationQGC/src/qgeomapreplyqgc.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#ifndef QGEOMAPREPLYGOOGLE_H -#define QGEOMAPREPLYGOOGLE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QGeoMapReplyQGC : public QGeoTiledMapReply -{ - Q_OBJECT - -public: - explicit QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent = 0); - ~QGeoMapReplyQGC(); - - void abort(); - - QNetworkReply *networkReply() const; - -private Q_SLOTS: - void replyDestroyed (); - void networkReplyFinished (); - void networkReplyError (QNetworkReply::NetworkError error); - -private: - QNetworkReply* m_reply; -}; - -QT_END_NAMESPACE - -#endif // QGEOMAPREPLYGOOGLE_H diff --git a/libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.cpp b/libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.cpp deleted file mode 100644 index 19aacae..0000000 --- a/libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#include - -#include "qdebug.h" -#include "qgeoserviceproviderpluginqgc.h" -#include "qgeotiledmappingmanagerengineqgc.h" -#include "qgeocodingmanagerengineqgc.h" - -QT_BEGIN_NAMESPACE - -QGeoCodingManagerEngine *QGeoServiceProviderFactoryQGC::createGeocodingManagerEngine( - const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const -{ - return new QGeoCodingManagerEngineQGC(parameters, error, errorString); -} - -QGeoMappingManagerEngine *QGeoServiceProviderFactoryQGC::createMappingManagerEngine( - const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const -{ - return new QGeoTiledMappingManagerEngineQGC(parameters, error, errorString); -} - -QGeoRoutingManagerEngine *QGeoServiceProviderFactoryQGC::createRoutingManagerEngine( - const QVariantMap &, QGeoServiceProvider::Error *, QString *) const -{ - // Not implemented for QGC - return NULL; -} - -QPlaceManagerEngine *QGeoServiceProviderFactoryQGC::createPlaceManagerEngine( - const QVariantMap &, QGeoServiceProvider::Error *, QString *) const -{ - // Not implemented for QGC - return NULL; -} - -QT_END_NAMESPACE diff --git a/libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.h b/libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.h deleted file mode 100644 index b4548dc..0000000 --- a/libs/QtLocationQGC/src/qgeoserviceproviderpluginqgc.h +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#ifndef QGEOSERVICEPROVIDER_GOOGLE_H -#define QGEOSERVICEPROVIDER_GOOGLE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QGeoServiceProviderFactoryQGC: public QObject, public QGeoServiceProviderFactory -{ - Q_OBJECT - Q_INTERFACES(QGeoServiceProviderFactory) - Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" FILE "qgc_maps_plugin.json") - -public: - QGeoCodingManagerEngine* createGeocodingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; - QGeoMappingManagerEngine* createMappingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; - QGeoRoutingManagerEngine* createRoutingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; - QPlaceManagerEngine* createPlaceManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; -}; - -QT_END_NAMESPACE - -#endif // QGEOSERVICEPROVIDER_GOOGLE_H diff --git a/libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.cpp b/libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.cpp deleted file mode 100644 index b46e9ea..0000000 --- a/libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include "qgeotiledmappingmanagerengineqgc.h" -#include "qgeotilefetcherqgc.h" -#include "OpenPilotMaps.h" - -QT_BEGIN_NAMESPACE - -QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) -: QGeoTiledMappingManagerEngine() -{ - QGeoCameraCapabilities cameraCaps; - cameraCaps.setMinimumZoomLevel(0.0); - cameraCaps.setMaximumZoomLevel(22.0); - setCameraCapabilities(cameraCaps); - - setTileSize(QSize(256, 256)); - - QList mapTypes; - mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Google Street Map"), tr("Google street map"), false, false, OpenPilot::GoogleMap); - mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Google Satellite Map"),tr("Google satellite map"), false, false, OpenPilot::GoogleSatellite); - mapTypes << QGeoMapType(QGeoMapType::TerrainMap, tr("Google Terrain Map"), tr("Google terrain map"), false, false, OpenPilot::GoogleTerrain); - // TODO: - // Proper hybrid maps requires collecting two separate bimaps and overlaying them. - //mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Google Hybrid Map"), tr("Google hybrid map"), false, false, OpenPilot::GoogleHybrid); - // Bing - mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Bing Street Map"), tr("Bing street map"), false, false, OpenPilot::BingMap); - mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Bing Satellite Map"), tr("Bing satellite map"), false, false, OpenPilot::BingSatellite); - mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Bing Hybrid Map"), tr("Bing hybrid map"), false, false, OpenPilot::BingHybrid); - mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Open Street Map"), tr("Open Street map"), false, false, OpenPilot::OpenStreetMap); - setSupportedMapTypes(mapTypes); - - QGeoTileFetcherQGC *tileFetcher = new QGeoTileFetcherQGC(this); - if (parameters.contains(QStringLiteral("useragent"))) { - const QByteArray ua = parameters.value(QStringLiteral("useragent")).toString().toLatin1(); - tileFetcher->setUserAgent(ua); - } else - // QGC Default - tileFetcher->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"); - - setTileFetcher(tileFetcher); - - QString cacheDir; - if (parameters.contains(QStringLiteral("mapping.cache.directory"))) - cacheDir = parameters.value(QStringLiteral("mapping.cache.directory")).toString(); - else { - cacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache"); - if(!QDir::root().mkpath(cacheDir)) { - qWarning() << "Could not create mapping disk cache directory: " << cacheDir; - cacheDir = QDir::homePath() + QLatin1String("/.qgcmapscache/"); - } - } - - if(!QDir::root().mkpath(cacheDir)) - { - qWarning() << "Could not create mapping disk cache directory: " << cacheDir; - cacheDir.clear(); - } - //else { - // qDebug() << "Mapping cache directory:" << cacheDir; - //} - - QGeoTileCache *tileCache = createTileCacheWithDir(cacheDir); - - int cacheLimit = 0; - if (parameters.contains(QStringLiteral("mapping.cache.disk.size"))) { - bool ok = false; - cacheLimit = parameters.value(QStringLiteral("mapping.cache.disk.size")).toString().toInt(&ok); - if (!ok) - cacheLimit = 0; - } - if(!cacheLimit) - // QGC Default - cacheLimit = 1024 * 1024 * 1024; - tileCache->setMaxDiskUsage(cacheLimit); - //qDebug() << "Disk caching limit:" << cacheLimit; - - cacheLimit = 0; - if (parameters.contains(QStringLiteral("mapping.cache.memory.size"))) { - bool ok = false; - cacheLimit = parameters.value(QStringLiteral("mapping.cache.memory.size")).toString().toInt(&ok); - if (!ok) - cacheLimit = 0; - } - if(!cacheLimit) - // QGC Default - cacheLimit = 10 * 1024 * 1024; - tileCache->setMaxMemoryUsage(cacheLimit); - //qDebug() << "Memory caching limit:" << cacheLimit; - - cacheLimit = 0; - if (parameters.contains(QStringLiteral("mapping.cache.texture.size"))) { - bool ok = false; - cacheLimit = parameters.value(QStringLiteral("mapping.cache.texture.size")).toString().toInt(&ok); - if (!ok) - cacheLimit = 0; - } - if(!cacheLimit) - // QGC Default - cacheLimit = 10 * 1024 * 1024; - tileCache->setExtraTextureUsage(cacheLimit); - - *error = QGeoServiceProvider::NoError; - errorString->clear(); -} - -QGeoTiledMappingManagerEngineQGC::~QGeoTiledMappingManagerEngineQGC() -{ -} - -QGeoMapData *QGeoTiledMappingManagerEngineQGC::createMapData() -{ - return new QGeoTiledMapData(this, 0); -} - -QT_END_NAMESPACE diff --git a/libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.h b/libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.h deleted file mode 100644 index 7e07bd9..0000000 --- a/libs/QtLocationQGC/src/qgeotiledmappingmanagerengineqgc.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#ifndef QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H -#define QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QGeoTiledMappingManagerEngineQGC : public QGeoTiledMappingManagerEngine -{ - Q_OBJECT -public: - QGeoTiledMappingManagerEngineQGC(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString); - ~QGeoTiledMappingManagerEngineQGC(); - QGeoMapData *createMapData(); -}; - -QT_END_NAMESPACE - -#endif // QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H diff --git a/libs/QtLocationQGC/src/qgeotilefetcherqgc.cpp b/libs/QtLocationQGC/src/qgeotilefetcherqgc.cpp deleted file mode 100644 index 7dbf880..0000000 --- a/libs/QtLocationQGC/src/qgeotilefetcherqgc.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#include -#include -#include -#include - -#include "qgeotilefetcherqgc.h" -#include "qgeomapreplyqgc.h" - -QT_BEGIN_NAMESPACE - -QGeoTileFetcherQGC::QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent) - : QGeoTileFetcher(parent) - , m_networkManager(new QNetworkAccessManager(this)) - , m_userAgent("Qt Application") -{ - QStringList langs = QLocale::system().uiLanguages(); - if (langs.length() > 0) { - m_Language = langs[0]; - } -} - -void QGeoTileFetcherQGC::setUserAgent(const QByteArray &userAgent) -{ - m_userAgent = userAgent; -} - -QGeoTiledMapReply *QGeoTileFetcherQGC::getTileImage(const QGeoTileSpec &spec) -{ - QNetworkRequest request; - QString url = m_UrlFactory.makeImageUrl((OpenPilot::MapType)spec.mapId(), QPoint(spec.x(), spec.y()), spec.zoom(), m_Language); - - request.setUrl(QUrl(url)); - request.setRawHeader("User-Agent", m_userAgent); - request.setRawHeader("Accept", "*/*"); - switch ((OpenPilot::MapType)spec.mapId()) { - case OpenPilot::GoogleMap: - case OpenPilot::GoogleSatellite: - case OpenPilot::GoogleLabels: - case OpenPilot::GoogleTerrain: - case OpenPilot::GoogleHybrid: - { - request.setRawHeader("Referrer", "http://maps.google.com/"); - } - break; - case OpenPilot::GoogleMapChina: - case OpenPilot::GoogleSatelliteChina: - case OpenPilot::GoogleLabelsChina: - case OpenPilot::GoogleTerrainChina: - case OpenPilot::GoogleHybridChina: - { - request.setRawHeader("Referrer", "http://ditu.google.cn/"); - } - break; - case OpenPilot::BingHybrid: - case OpenPilot::BingMap: - case OpenPilot::BingSatellite: - { - request.setRawHeader("Referrer", "http://www.bing.com/maps/"); - } - break; - case OpenPilot::YahooHybrid: - case OpenPilot::YahooLabels: - case OpenPilot::YahooMap: - case OpenPilot::YahooSatellite: - { - request.setRawHeader("Referrer", "http://maps.yahoo.com/"); - } - break; - case OpenPilot::ArcGIS_MapsLT_Map_Labels: - case OpenPilot::ArcGIS_MapsLT_Map: - case OpenPilot::ArcGIS_MapsLT_OrtoFoto: - case OpenPilot::ArcGIS_MapsLT_Map_Hybrid: - { - request.setRawHeader("Referrer", "http://www.maps.lt/map_beta/"); - } - break; - case OpenPilot::OpenStreetMapSurfer: - case OpenPilot::OpenStreetMapSurferTerrain: - { - request.setRawHeader("Referrer", "http://www.mapsurfer.net/"); - } - break; - case OpenPilot::OpenStreetMap: - case OpenPilot::OpenStreetOsm: - { - request.setRawHeader("Referrer", "http://www.openstreetmap.org/"); - } - break; - case OpenPilot::YandexMapRu: - { - request.setRawHeader("Referrer", "http://maps.yandex.ru/"); - } - break; - default: - break; - } - - QNetworkReply *reply = m_networkManager->get(request); - reply->setParent(0); - return new QGeoMapReplyQGC(reply, spec); - -} - -QT_END_NAMESPACE diff --git a/libs/QtLocationQGC/src/qgeotilefetcherqgc.h b/libs/QtLocationQGC/src/qgeotilefetcherqgc.h deleted file mode 100644 index 98094b9..0000000 --- a/libs/QtLocationQGC/src/qgeotilefetcherqgc.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Aaron McCarthy -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtLocation module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -** 2015.4.4 -** Adapted for use with QGroundControl -** -** Gus Grubba -** -****************************************************************************/ - -#ifndef QGEOTILEFETCHERGOOGLE_H -#define QGEOTILEFETCHERGOOGLE_H - -#include -#include -#include "OpenPilotMaps.h" - -QT_BEGIN_NAMESPACE - -class QGeoTiledMappingManagerEngine; -class QNetworkAccessManager; - -class QGeoTileFetcherQGC : public QGeoTileFetcher -{ - Q_OBJECT - -public: - explicit QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent = 0); - - void setUserAgent(const QByteArray &userAgent); - -private: - QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec); - QNetworkAccessManager* m_networkManager; - QByteArray m_userAgent; - OpenPilot::UrlFactory m_UrlFactory; - QString m_Language; -}; - -QT_END_NAMESPACE - -#endif // QGEOTILEFETCHERGOOGLE_H diff --git a/qgcsystem.pro b/qgcsystem.pro deleted file mode 100644 index e144e77..0000000 --- a/qgcsystem.pro +++ /dev/null @@ -1,819 +0,0 @@ -# ------------------------------------------------- -# QGroundControl - Micro Air Vehicle Groundstation -# Please see our website at -# Maintainer: -# Lorenz Meier -# (c) 2009-2014 QGroundControl Developers -# This file is part of the open groundstation project -# QGroundControl is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# QGroundControl is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# You should have received a copy of the GNU General Public License -# along with QGroundControl. If not, see . -# ------------------------------------------------- - -message(Qt version $$[QT_VERSION]) - -TARGET = qgroundcontrol - -# Load additional config flags from user_config.pri -exists(user_config.pri):infile(user_config.pri, CONFIG) { - CONFIG += $$fromfile(user_config.pri, CONFIG) - message($$sprintf("Using user-supplied additional config: '%1' specified in user_config.pri", $$fromfile(user_config.pri, CONFIG))) -} - -# Setup our supported build types. We do this once here and then use the defined config scopes -# to allow us to easily modify suported build types in one place instead of duplicated throughout -# the project file. - -!equals(QT_MAJOR_VERSION, 5) | !greaterThan(QT_MINOR_VERSION, 3) { - error("Unsupported Qt version, 5.4+ is required") -} - -linux { - linux-g++ | linux-g++-64 { - message("Linux build") - CONFIG += LinuxBuild link_pkgconfig - } else { - error("Unsuported Linux toolchain, only GCC 32- or 64-bit is supported") - } -} else : win32 { - win32-msvc2010 | win32-msvc2012 | win32-msvc2013 { - message("Windows build") - CONFIG += WindowsBuild - } else { - error("Unsupported Windows toolchain, only Visual Studio 2010, 2012, and 2013 are supported") - } -} else : macx { - macx-clang | macx-llvm { - message("Mac build") - CONFIG += MacBuild - QMAKE_CXXFLAGS += -fvisibility=hidden - } else { - error("Unsupported Mac toolchain, only 64-bit LLVM+clang is supported") - } -} else { - error("Unsupported build platform, only Linux, Windows, and Mac are supported") -} - -# Installer configuration - -installer { - CONFIG -= debug - CONFIG -= debug_and_release - CONFIG += release - message(Build Installer) -} - -# Setup our supported build flavors - -CONFIG(debug, debug|release) { - message(Debug flavor) - CONFIG += DebugBuild -} else:CONFIG(release, debug|release) { - message(Release flavor) - CONFIG += ReleaseBuild -} else { - error(Unsupported build flavor) -} - -# Need to special case Windows debug_and_release since VS Project creation in this case does strange things [QTBUG-40351] -win32:debug_and_release { - CONFIG += WindowsDebugAndRelease -} - -# Setup our build directories - -BASEDIR = $${IN_PWD} - -DebugBuild { - DESTDIR = $${OUT_PWD}/debug - BUILDDIR = $${OUT_PWD}/build-debug -} - -ReleaseBuild { - DESTDIR = $${OUT_PWD}/release - BUILDDIR = $${OUT_PWD}/build-release -} - -OBJECTS_DIR = $${BUILDDIR}/obj -MOC_DIR = $${BUILDDIR}/moc -UI_DIR = $${BUILDDIR}/ui -RCC_DIR = $${BUILDDIR}/rcc -LANGUAGE = C++ - -message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET) - -# QGC QtLocation - -QGCMAPDIR = $${OUT_PWD}/libs/QtLocationQGC/plugins/geoservices - -LinuxBuild { - LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc - PRE_TARGETDEPS += $$QGCMAPDIR/libqtgeoservices_qgc.a -} - -WindowsBuild { - DebugBuild { - LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgcd - PRE_TARGETDEPS += $$QGCMAPDIR/qtgeoservices_qgcd.lib - } - ReleaseBuild { - LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc - PRE_TARGETDEPS += $$QGCMAPDIR/qtgeoservices_qgc.lib - } -} - -MacBuild { - DebugBuild { - LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc_debug - PRE_TARGETDEPS += $$QGCMAPDIR/libqtgeoservices_qgc_debug.a - } - ReleaseBuild { - LIBS += -L$$QGCMAPDIR -lqtgeoservices_qgc - PRE_TARGETDEPS += $$QGCMAPDIR/libqtgeoservices_qgc.a - } -} - -# Qt configuration -CONFIG += qt \ - thread - -QT += network \ - opengl \ - svg \ - xml \ - concurrent \ - widgets \ - gui \ - serialport \ - sql \ - printsupport \ - qml \ - quick \ - quickwidgets - -contains(DEFINES, QGC_NOTIFY_TUNES_ENABLED) { - QT += multimedia -} - -# testlib is needed even in release flavor for QSignalSpy support -QT += testlib - -# Turn off serial port warnings -DEFINES += _TTY_NOWARN_ - -# -# OS Specific settings -# - -MacBuild { - QMAKE_INFO_PLIST = Custom-Info.plist - CONFIG += x86_64 - CONFIG -= x86 - QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 - QMAKE_MAC_SDK = macosx10.9 - ICON = $$BASEDIR/resources/icons/macx.icns - QT += quickwidgets -} - -LinuxBuild { - DEFINES += __STDC_LIMIT_MACROS - CONFIG += qesp_linux_udev -} - -WindowsBuild { - DEFINES += __STDC_LIMIT_MACROS - - # Specify multi-process compilation within Visual Studio. - # (drastically improves compilation times for multi-core computers) - QMAKE_CXXFLAGS_DEBUG += -MP - QMAKE_CXXFLAGS_RELEASE += -MP - - RC_FILE = $$BASEDIR/qgroundcontrol.rc -} - -# -# By default warnings as errors are turned off. Even so, in order for a pull request -# to be accepted you must compile cleanly with warnings as errors turned on the default -# set of OS builds. See http://www.qgroundcontrol.org/dev/contribute for more details. -# You can use the WarningsAsErrorsOn CONFIG switch to turn warnings as errors on for your -# own builds. -# - -MacBuild | LinuxBuild { - QMAKE_CXXFLAGS_WARN_ON += -Wall - WarningsAsErrorsOn { - QMAKE_CXXFLAGS_WARN_ON += -Werror - } -} - -WindowsBuild { - QMAKE_CXXFLAGS_WARN_ON += /W3 \ - /wd4996 \ # silence warnings about deprecated strcpy and whatnot - /wd4005 \ # silence warnings about macro redefinition - /wd4290 \ # ignore exception specifications - /Zc:strictStrings- # work around win 8.1 sdk sapi.h problem - WarningsAsErrorsOn { - QMAKE_CXXFLAGS_WARN_ON += /WX - } -} - -# -# Build-specific settings -# - -DebugBuild { - CONFIG += console -} - -ReleaseBuild { - DEFINES += QT_NO_DEBUG - - WindowsBuild { - # Use link time code generation for better optimization (I believe this is supported in MSVC Express, but not 100% sure) - QMAKE_LFLAGS_LTCG = /LTCG - QMAKE_CFLAGS_LTCG = -GL - } -} - -# qextserialport should not be used by general QGroundControl code. Use QSerialPort instead. This is only -# here to support special case Firmware Upgrade code. -include(libs/qextserialport/src/qextserialport.pri) - -# -# External library configuration -# - -include(QGCExternalLibs.pri) - -# -# Post link configuration -# - -include(QGCSetup.pri) - -# -# Installer targets -# - -include(QGCInstaller.pri) - -# -# Main QGroundControl portion of project file -# - -RESOURCES += qgroundcontrol.qrc - -TRANSLATIONS += \ - es-MX.ts \ - en-US.ts - -DEPENDPATH += \ - . \ - plugins - -INCLUDEPATH += . - -INCLUDEPATH += \ - src \ - src/ui \ - src/ui/linechart \ - src/ui/uas \ - src/ui/map \ - src/uas \ - src/comm \ - src/audio \ - include/ui \ - src/input \ - src/lib/qmapcontrol \ - src/ui/mavlink \ - src/ui/param \ - src/ui/map3D \ - src/ui/mission \ - src/ui/designer \ - src/ui/configuration \ - src/ui/px4_configuration \ - src/ui/main \ - src/ui/toolbar \ - src/ui/flightdisplay \ - src/VehicleSetup \ - src/AutoPilotPlugins \ - src/QmlControls - -FORMS += \ - src/ui/MainWindow.ui \ - src/ui/SerialSettings.ui \ - src/ui/UASControl.ui \ - src/ui/UASList.ui \ - src/ui/UASInfo.ui \ - src/ui/Linechart.ui \ - src/ui/UASView.ui \ - src/ui/ParameterInterface.ui \ - src/ui/WaypointList.ui \ - src/ui/JoystickWidget.ui \ - src/ui/DebugConsole.ui \ - src/ui/HDDisplay.ui \ - src/ui/MAVLinkSettingsWidget.ui \ - src/ui/QGCSensorSettingsWidget.ui \ - src/ui/QGCDataPlot2D.ui \ - src/ui/QMap3D.ui \ - src/ui/uas/QGCUnconnectedInfoWidget.ui \ - src/ui/designer/QGCToolWidget.ui \ - src/ui/designer/QGCParamSlider.ui \ - src/ui/designer/QGCActionButton.ui \ - src/ui/designer/QGCCommandButton.ui \ - src/ui/designer/QGCToolWidgetComboBox.ui \ - src/ui/designer/QGCTextLabel.ui \ - src/ui/designer/QGCXYPlot.ui \ - src/ui/QGCMAVLinkLogPlayer.ui \ - src/ui/QGCWaypointListMulti.ui \ - src/ui/QGCUASFileViewMulti.ui \ - src/ui/QGCTCPLinkConfiguration.ui \ - src/ui/SettingsDialog.ui \ - src/ui/map/QGCMapTool.ui \ - src/ui/map/QGCMapToolBar.ui \ - src/ui/QGCMAVLinkInspector.ui \ - src/ui/WaypointViewOnlyView.ui \ - src/ui/WaypointEditableView.ui \ - src/ui/mavlink/QGCMAVLinkMessageSender.ui \ - src/ui/QGCPluginHost.ui \ - src/ui/mission/QGCMissionOther.ui \ - src/ui/mission/QGCMissionNavWaypoint.ui \ - src/ui/mission/QGCMissionDoJump.ui \ - src/ui/mission/QGCMissionConditionDelay.ui \ - src/ui/mission/QGCMissionNavLoiterUnlim.ui \ - src/ui/mission/QGCMissionNavLoiterTurns.ui \ - src/ui/mission/QGCMissionNavLoiterTime.ui \ - src/ui/mission/QGCMissionNavReturnToLaunch.ui \ - src/ui/mission/QGCMissionNavLand.ui \ - src/ui/mission/QGCMissionNavTakeoff.ui \ - src/ui/mission/QGCMissionNavSweep.ui \ - src/ui/mission/QGCMissionDoStartSearch.ui \ - src/ui/mission/QGCMissionDoFinishSearch.ui \ - src/ui/QGCHilConfiguration.ui \ - src/ui/QGCHilFlightGearConfiguration.ui \ - src/ui/QGCHilJSBSimConfiguration.ui \ - src/ui/QGCHilXPlaneConfiguration.ui \ - src/ui/uas/UASQuickView.ui \ - src/ui/uas/UASQuickViewItemSelect.ui \ - src/ui/QGCTabbedInfoView.ui \ - src/ui/UASRawStatusView.ui \ - src/ui/uas/UASMessageView.ui \ - src/ui/JoystickButton.ui \ - src/ui/JoystickAxis.ui \ - src/ui/configuration/terminalconsole.ui \ - src/ui/configuration/SerialSettingsDialog.ui \ - src/ui/px4_configuration/PX4RCCalibration.ui \ - src/ui/QGCUASFileView.ui \ - src/QGCQmlWidgetHolder.ui \ - src/ui/QGCMapRCToParamDialog.ui \ - src/ui/QGCLinkConfiguration.ui \ - src/ui/QGCCommConfiguration.ui \ - src/ui/QGCUDPLinkConfiguration.ui - -HEADERS += \ - src/MG.h \ - src/QGCApplication.h \ - src/QGCSingleton.h \ - src/uas/UASInterface.h \ - src/uas/UAS.h \ - src/uas/UASManager.h \ - src/comm/LinkManager.h \ - src/comm/LinkInterface.h \ - src/comm/SerialLink.h \ - src/comm/ProtocolInterface.h \ - src/comm/MAVLinkProtocol.h \ - src/comm/QGCFlightGearLink.h \ - src/comm/QGCJSBSimLink.h \ - src/comm/QGCXPlaneLink.h \ - src/ui/SerialConfigurationWindow.h \ - src/ui/MainWindow.h \ - src/ui/uas/UASControlWidget.h \ - src/ui/uas/UASListWidget.h \ - src/ui/uas/UASInfoWidget.h \ - src/ui/HUD.h \ - src/ui/linechart/LinechartWidget.h \ - src/ui/linechart/LinechartPlot.h \ - src/ui/linechart/Scrollbar.h \ - src/ui/linechart/ScrollZoomer.h \ - src/QGCConfig.h \ - src/ui/uas/UASView.h \ - src/ui/CameraView.h \ - src/comm/MAVLinkSimulationLink.h \ - src/comm/UDPLink.h \ - src/comm/TCPLink.h \ - src/ui/ParameterInterface.h \ - src/ui/WaypointList.h \ - src/Waypoint.h \ - src/input/JoystickInput.h \ - src/ui/JoystickWidget.h \ - src/ui/DebugConsole.h \ - src/ui/HDDisplay.h \ - src/ui/MAVLinkSettingsWidget.h \ - src/GAudioOutput.h \ - src/LogCompressor.h \ - src/ui/QGCParamWidget.h \ - src/ui/QGCSensorSettingsWidget.h \ - src/ui/linechart/Linecharts.h \ - src/uas/UASWaypointManager.h \ - src/ui/HSIDisplay.h \ - src/QGC.h \ - src/ui/QGCDataPlot2D.h \ - src/ui/linechart/IncrementalPlot.h \ - src/comm/QGCMAVLink.h \ - src/ui/QGCMainWindowAPConfigurator.h \ - src/comm/MAVLinkSwarmSimulationLink.h \ - src/ui/uas/QGCUnconnectedInfoWidget.h \ - src/ui/designer/QGCToolWidget.h \ - src/ui/designer/QGCParamSlider.h \ - src/ui/designer/QGCCommandButton.h \ - src/ui/designer/QGCToolWidgetItem.h \ - src/ui/designer/QGCToolWidgetComboBox.h \ - src/ui/designer/QGCTextLabel.h \ - src/ui/designer/QGCRadioChannelDisplay.h \ - src/ui/designer/QGCXYPlot.h \ - src/ui/designer/RCChannelWidget.h \ - src/ui/QGCMAVLinkLogPlayer.h \ - src/comm/MAVLinkSimulationWaypointPlanner.h \ - src/comm/MAVLinkSimulationMAV.h \ - src/uas/QGCMAVLinkUASFactory.h \ - src/ui/QGCWaypointListMulti.h \ - src/ui/QGCUASFileViewMulti.h \ - src/ui/QGCTCPLinkConfiguration.h \ - src/ui/SettingsDialog.h \ - src/uas/QGCUASParamManager.h \ - src/ui/map/QGCMapWidget.h \ - src/ui/map/MAV2DIcon.h \ - src/ui/map/Waypoint2DIcon.h \ - src/ui/map/QGCMapTool.h \ - src/ui/map/QGCMapToolBar.h \ - src/QGCGeo.h \ - src/ui/QGCMAVLinkInspector.h \ - src/ui/MAVLinkDecoder.h \ - src/ui/WaypointViewOnlyView.h \ - src/ui/WaypointEditableView.h \ - src/ui/QGCRGBDView.h \ - src/ui/mavlink/QGCMAVLinkMessageSender.h \ - src/ui/QGCPluginHost.h \ - src/ui/mission/QGCMissionOther.h \ - src/ui/mission/QGCMissionNavWaypoint.h \ - src/ui/mission/QGCMissionDoJump.h \ - src/ui/mission/QGCMissionConditionDelay.h \ - src/ui/mission/QGCMissionNavLoiterUnlim.h \ - src/ui/mission/QGCMissionNavLoiterTurns.h \ - src/ui/mission/QGCMissionNavLoiterTime.h \ - src/ui/mission/QGCMissionNavReturnToLaunch.h \ - src/ui/mission/QGCMissionNavLand.h \ - src/ui/mission/QGCMissionNavTakeoff.h \ - src/ui/mission/QGCMissionNavSweep.h \ - src/ui/mission/QGCMissionDoStartSearch.h \ - src/ui/mission/QGCMissionDoFinishSearch.h \ - src/comm/QGCHilLink.h \ - src/ui/QGCHilConfiguration.h \ - src/ui/QGCHilFlightGearConfiguration.h \ - src/ui/QGCHilJSBSimConfiguration.h \ - src/ui/QGCHilXPlaneConfiguration.h \ - src/ui/uas/UASQuickView.h \ - src/ui/uas/UASQuickViewItem.h \ - src/ui/linechart/ChartPlot.h \ - src/ui/uas/UASQuickViewItemSelect.h \ - src/ui/uas/UASQuickViewTextItem.h \ - src/ui/uas/UASQuickViewGaugeItem.h \ - src/ui/QGCTabbedInfoView.h \ - src/ui/UASRawStatusView.h \ - src/ui/PrimaryFlightDisplay.h \ - src/ui/uas/UASMessageView.h \ - src/ui/JoystickButton.h \ - src/ui/JoystickAxis.h \ - src/ui/configuration/console.h \ - src/ui/configuration/SerialSettingsDialog.h \ - src/ui/configuration/terminalconsole.h \ - src/ui/configuration/ApmHighlighter.h \ - src/uas/UASParameterDataModel.h \ - src/uas/UASParameterCommsMgr.h \ - src/ui/QGCPendingParamWidget.h \ - src/ui/QGCBaseParamWidget.h \ - src/ui/px4_configuration/PX4RCCalibration.h \ - src/ui/px4_configuration/RCValueWidget.h \ - src/uas/UASManagerInterface.h \ - src/uas/QGCUASParamManagerInterface.h \ - src/uas/QGCUASFileManager.h \ - src/ui/QGCUASFileView.h \ - src/CmdLineOptParser.h \ - src/QGCFileDialog.h \ - src/QGCMessageBox.h \ - src/QGCComboBox.h \ - src/QGCTemporaryFile.h \ - src/audio/QGCAudioWorker.h \ - src/QGCQuickWidget.h \ - src/QGCPalette.h \ - src/QGCQmlWidgetHolder.h \ - src/ui/QGCParamTreeWidget.h \ - src/ui/QGCMapRCToParamDialog.h \ - src/QGCDockWidget.h \ - src/ui/QGCLinkConfiguration.h \ - src/comm/LinkConfiguration.h \ - src/ui/QGCCommConfiguration.h \ - src/ui/QGCUDPLinkConfiguration.h \ - src/uas/UASMessageHandler.h \ - src/ui/toolbar/MainToolBar.h \ - src/QmlControls/ScreenTools.h \ - src/QGCLoggingCategory.h \ - src/ui/flightdisplay/QGCFlightDisplay.h - -SOURCES += \ - src/main.cc \ - src/QGCApplication.cc \ - src/QGCSingleton.cc \ - src/uas/UASManager.cc \ - src/uas/UAS.cc \ - src/comm/LinkManager.cc \ - src/comm/SerialLink.cc \ - src/comm/MAVLinkProtocol.cc \ - src/comm/QGCFlightGearLink.cc \ - src/comm/QGCJSBSimLink.cc \ - src/comm/QGCXPlaneLink.cc \ - src/ui/SerialConfigurationWindow.cc \ - src/ui/MainWindow.cc \ - src/ui/uas/UASControlWidget.cc \ - src/ui/uas/UASListWidget.cc \ - src/ui/uas/UASInfoWidget.cc \ - src/ui/HUD.cc \ - src/ui/linechart/LinechartWidget.cc \ - src/ui/linechart/LinechartPlot.cc \ - src/ui/linechart/Scrollbar.cc \ - src/ui/linechart/ScrollZoomer.cc \ - src/ui/uas/UASView.cc \ - src/ui/CameraView.cc \ - src/comm/MAVLinkSimulationLink.cc \ - src/comm/UDPLink.cc \ - src/comm/TCPLink.cc \ - src/ui/ParameterInterface.cc \ - src/ui/WaypointList.cc \ - src/Waypoint.cc \ - src/input/JoystickInput.cc \ - src/ui/JoystickWidget.cc \ - src/ui/DebugConsole.cc \ - src/ui/HDDisplay.cc \ - src/ui/MAVLinkSettingsWidget.cc \ - src/GAudioOutput.cc \ - src/LogCompressor.cc \ - src/ui/QGCParamWidget.cc \ - src/ui/QGCSensorSettingsWidget.cc \ - src/ui/linechart/Linecharts.cc \ - src/uas/UASWaypointManager.cc \ - src/ui/HSIDisplay.cc \ - src/QGC.cc \ - src/ui/QGCDataPlot2D.cc \ - src/ui/linechart/IncrementalPlot.cc \ - src/ui/QGCMainWindowAPConfigurator.cc \ - src/comm/MAVLinkSwarmSimulationLink.cc \ - src/ui/uas/QGCUnconnectedInfoWidget.cc \ - src/ui/designer/QGCToolWidget.cc \ - src/ui/designer/QGCParamSlider.cc \ - src/ui/designer/QGCCommandButton.cc \ - src/ui/designer/QGCToolWidgetItem.cc \ - src/ui/designer/QGCToolWidgetComboBox.cc \ - src/ui/designer/QGCTextLabel.cc \ - src/ui/designer/QGCRadioChannelDisplay.cpp \ - src/ui/designer/QGCXYPlot.cc \ - src/ui/designer/RCChannelWidget.cc \ - src/ui/QGCMAVLinkLogPlayer.cc \ - src/comm/MAVLinkSimulationWaypointPlanner.cc \ - src/comm/MAVLinkSimulationMAV.cc \ - src/uas/QGCMAVLinkUASFactory.cc \ - src/ui/QGCWaypointListMulti.cc \ - src/ui/QGCUASFileViewMulti.cc \ - src/ui/QGCTCPLinkConfiguration.cc \ - src/ui/SettingsDialog.cc \ - src/uas/QGCUASParamManager.cc \ - src/ui/map/QGCMapWidget.cc \ - src/ui/map/MAV2DIcon.cc \ - src/ui/map/Waypoint2DIcon.cc \ - src/ui/map/QGCMapTool.cc \ - src/ui/map/QGCMapToolBar.cc \ - src/ui/QGCMAVLinkInspector.cc \ - src/ui/MAVLinkDecoder.cc \ - src/ui/WaypointViewOnlyView.cc \ - src/ui/WaypointEditableView.cc \ - src/ui/QGCRGBDView.cc \ - src/ui/mavlink/QGCMAVLinkMessageSender.cc \ - src/ui/QGCPluginHost.cc \ - src/ui/mission/QGCMissionOther.cc \ - src/ui/mission/QGCMissionNavWaypoint.cc \ - src/ui/mission/QGCMissionDoJump.cc \ - src/ui/mission/QGCMissionConditionDelay.cc \ - src/ui/mission/QGCMissionNavLoiterUnlim.cc \ - src/ui/mission/QGCMissionNavLoiterTurns.cc \ - src/ui/mission/QGCMissionNavLoiterTime.cc \ - src/ui/mission/QGCMissionNavReturnToLaunch.cc \ - src/ui/mission/QGCMissionNavLand.cc \ - src/ui/mission/QGCMissionNavTakeoff.cc \ - src/ui/mission/QGCMissionNavSweep.cc \ - src/ui/mission/QGCMissionDoStartSearch.cc \ - src/ui/mission/QGCMissionDoFinishSearch.cc \ - src/ui/QGCHilConfiguration.cc \ - src/ui/QGCHilFlightGearConfiguration.cc \ - src/ui/QGCHilJSBSimConfiguration.cc \ - src/ui/QGCHilXPlaneConfiguration.cc \ - src/ui/uas/UASQuickViewItem.cc \ - src/ui/uas/UASQuickView.cc \ - src/ui/linechart/ChartPlot.cc \ - src/ui/uas/UASQuickViewTextItem.cc \ - src/ui/uas/UASQuickViewGaugeItem.cc \ - src/ui/uas/UASQuickViewItemSelect.cc \ - src/ui/QGCTabbedInfoView.cpp \ - src/ui/UASRawStatusView.cpp \ - src/ui/PrimaryFlightDisplay.cc \ - src/ui/JoystickButton.cc \ - src/ui/JoystickAxis.cc \ - src/ui/uas/UASMessageView.cc \ - src/ui/configuration/terminalconsole.cpp \ - src/ui/configuration/console.cpp \ - src/ui/configuration/SerialSettingsDialog.cc \ - src/ui/configuration/ApmHighlighter.cc \ - src/uas/UASParameterDataModel.cc \ - src/uas/UASParameterCommsMgr.cc \ - src/ui/QGCPendingParamWidget.cc \ - src/ui/QGCBaseParamWidget.cc \ - src/ui/px4_configuration/PX4RCCalibration.cc \ - src/ui/px4_configuration/RCValueWidget.cc \ - src/uas/QGCUASFileManager.cc \ - src/ui/QGCUASFileView.cc \ - src/CmdLineOptParser.cc \ - src/QGCFileDialog.cc \ - src/QGCComboBox.cc \ - src/QGCTemporaryFile.cc \ - src/audio/QGCAudioWorker.cpp \ - src/QGCQuickWidget.cc \ - src/QGCPalette.cc \ - src/QGCQmlWidgetHolder.cpp \ - src/ui/QGCParamTreeWidget.cpp \ - src/ui/QGCMapRCToParamDialog.cpp \ - src/QGCDockWidget.cc \ - src/ui/QGCLinkConfiguration.cc \ - src/comm/LinkConfiguration.cc \ - src/ui/QGCCommConfiguration.cc \ - src/ui/QGCUDPLinkConfiguration.cc \ - src/uas/UASMessageHandler.cc \ - src/ui/toolbar/MainToolBar.cc \ - src/QmlControls/ScreenTools.cc \ - src/QGCLoggingCategory.cc \ - src/ui/flightdisplay/QGCFlightDisplay.cc - -# -# Unit Test specific configuration goes here -# -# We have to special case Windows debug_and_release builds because you can't have files -# which are only in the debug variant [QTBUG-40351]. So in this case we include unit tests -# even in the release variant. If you want a Windows release build with no unit tests run -# qmake with CONFIG-=debug_and_release CONFIG+=release. -# - -DebugBuild|WindowsDebugAndRelease { - -DEFINES += UNITTEST_BUILD - -INCLUDEPATH += \ - src/qgcunittest - -HEADERS += \ - src/qgcunittest/UnitTest.h \ - src/qgcunittest/MessageBoxTest.h \ - src/qgcunittest/FileDialogTest.h \ - src/qgcunittest/MockLink.h \ - src/qgcunittest/MockLinkMissionItemHandler.h \ - src/qgcunittest/MockUASManager.h \ - src/qgcunittest/MockUAS.h \ - src/qgcunittest/MockQGCUASParamManager.h \ - src/qgcunittest/MockMavlinkInterface.h \ - src/qgcunittest/MockMavlinkFileServer.h \ - src/qgcunittest/MultiSignalSpy.h \ - src/qgcunittest/FlightGearTest.h \ - src/qgcunittest/TCPLinkTest.h \ - src/qgcunittest/TCPLoopBackServer.h \ - src/qgcunittest/QGCUASFileManagerTest.h \ - src/qgcunittest/PX4RCCalibrationTest.h \ - src/qgcunittest/LinkManagerTest.h \ - src/qgcunittest/MainWindowTest.h \ - src/qgcunittest/MavlinkLogTest.h \ - src/FactSystem/FactSystemTestBase.h \ - src/FactSystem/FactSystemTestPX4.h \ - src/FactSystem/FactSystemTestGeneric.h \ - src/QmlControls/QmlTestWidget.h \ - src/VehicleSetup/SetupViewTest.h \ - -SOURCES += \ - src/qgcunittest/UnitTest.cc \ - src/qgcunittest/MessageBoxTest.cc \ - src/qgcunittest/FileDialogTest.cc \ - src/qgcunittest/MockLink.cc \ - src/qgcunittest/MockLinkMissionItemHandler.cc \ - src/qgcunittest/MockUASManager.cc \ - src/qgcunittest/MockUAS.cc \ - src/qgcunittest/MockQGCUASParamManager.cc \ - src/qgcunittest/MockMavlinkFileServer.cc \ - src/qgcunittest/MultiSignalSpy.cc \ - src/qgcunittest/FlightGearTest.cc \ - src/qgcunittest/TCPLinkTest.cc \ - src/qgcunittest/TCPLoopBackServer.cc \ - src/qgcunittest/QGCUASFileManagerTest.cc \ - src/qgcunittest/PX4RCCalibrationTest.cc \ - src/qgcunittest/LinkManagerTest.cc \ - src/qgcunittest/MainWindowTest.cc \ - src/qgcunittest/MavlinkLogTest.cc \ - src/FactSystem/FactSystemTestBase.cc \ - src/FactSystem/FactSystemTestPX4.cc \ - src/FactSystem/FactSystemTestGeneric.cc \ - src/QmlControls/QmlTestWidget.cc \ - src/VehicleSetup/SetupViewTest.cc \ - -} - -# -# AutoPilot Plugin Support -# - -INCLUDEPATH += \ - src/VehicleSetup - -FORMS += \ - src/VehicleSetup/ParameterEditor.ui \ - src/VehicleSetup/SetupView.ui \ - -HEADERS+= \ - src/VehicleSetup/SetupView.h \ - src/VehicleSetup/ParameterEditor.h \ - src/VehicleSetup/VehicleComponent.h \ - src/VehicleSetup/FirmwareUpgradeController.h \ - src/VehicleSetup/PX4Bootloader.h \ - src/VehicleSetup/PX4FirmwareUpgradeThread.h \ - src/AutoPilotPlugins/AutoPilotPluginManager.h \ - src/AutoPilotPlugins/AutoPilotPlugin.h \ - src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \ - src/AutoPilotPlugins/Generic/GenericParameterFacts.h \ - src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \ - src/AutoPilotPlugins/PX4/PX4Component.h \ - src/AutoPilotPlugins/PX4/RadioComponent.h \ - src/AutoPilotPlugins/PX4/FlightModesComponent.h \ - src/AutoPilotPlugins/PX4/FlightModesComponentController.h \ - src/AutoPilotPlugins/PX4/AirframeComponent.h \ - src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \ - src/AutoPilotPlugins/PX4/AirframeComponentController.h \ - src/AutoPilotPlugins/PX4/SensorsComponent.h \ - src/AutoPilotPlugins/PX4/SensorsComponentController.h \ - src/AutoPilotPlugins/PX4/SafetyComponent.h \ - src/AutoPilotPlugins/PX4/PowerComponent.h \ - src/AutoPilotPlugins/PX4/PX4ParameterFacts.h \ - -SOURCES += \ - src/VehicleSetup/SetupView.cc \ - src/VehicleSetup/ParameterEditor.cc \ - src/VehicleSetup/VehicleComponent.cc \ - src/VehicleSetup/FirmwareUpgradeController.cc \ - src/VehicleSetup/PX4Bootloader.cc \ - src/VehicleSetup/PX4FirmwareUpgradeThread.cc \ - src/AutoPilotPlugins/AutoPilotPluginManager.cc \ - src/AutoPilotPlugins/AutoPilotPlugin.cc \ - src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \ - src/AutoPilotPlugins/Generic/GenericParameterFacts.cc \ - src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \ - src/AutoPilotPlugins/PX4/PX4Component.cc \ - src/AutoPilotPlugins/PX4/RadioComponent.cc \ - src/AutoPilotPlugins/PX4/FlightModesComponent.cc \ - src/AutoPilotPlugins/PX4/FlightModesComponentController.cc \ - src/AutoPilotPlugins/PX4/AirframeComponent.cc \ - src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc \ - src/AutoPilotPlugins/PX4/AirframeComponentController.cc \ - src/AutoPilotPlugins/PX4/SensorsComponent.cc \ - src/AutoPilotPlugins/PX4/SensorsComponentController.cc \ - src/AutoPilotPlugins/PX4/SafetyComponent.cc \ - src/AutoPilotPlugins/PX4/PowerComponent.cc \ - src/AutoPilotPlugins/PX4/PX4ParameterFacts.cc \ - -# Fact System code - -INCLUDEPATH += \ - src/FactSystem - -HEADERS += \ - src/FactSystem/FactSystem.h \ - src/FactSystem/Fact.h \ - src/FactSystem/FactBinder.h \ - src/FactSystem/FactMetaData.h \ - src/FactSystem/FactValidator.h \ - src/FactSystem/ParameterLoader.h \ - -SOURCES += \ - src/FactSystem/FactSystem.cc \ - src/FactSystem/Fact.cc \ - src/FactSystem/FactBinder.cc \ - src/FactSystem/FactMetaData.cc \ - src/FactSystem/FactValidator.cc \ - src/FactSystem/ParameterLoader.cc \ diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index aad0996..6928aad 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -19,8 +19,14 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = libs/QtLocationQGC -SUBDIRS += ./qgcsystem.pro +SUBDIRS = ./QGCLocationPlugin.pro +SUBDIRS += ./QGCApplication.pro -qgcsystem.depends = QtLocationQGC +QGCApplication.depends = QGCLocationPlugin + +message(Qt version $$[QT_VERSION]) + +!equals(QT_MAJOR_VERSION, 5) | !greaterThan(QT_MINOR_VERSION, 3) { + error("Unsupported Qt version, 5.4+ is required") +} diff --git a/src/QtLocationPlugin/OpenPilotMaps.cc b/src/QtLocationPlugin/OpenPilotMaps.cc new file mode 100644 index 0000000..e38d564 --- /dev/null +++ b/src/QtLocationPlugin/OpenPilotMaps.cc @@ -0,0 +1,490 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief QGC Open Pilot Mapping Tools + * @author Gus Grubba + * Original work: The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + */ + +#include +#include +#include +#include + +#include "OpenPilotMaps.h" + +namespace OpenPilot { + +const QString ProviderStrings::levelsForSigPacSpainMap[] = + { "0", "1", "2", "3", "4", + "MTNSIGPAC", + "MTN2000", "MTN2000", "MTN2000", "MTN2000", "MTN2000", + "MTN200", "MTN200", "MTN200", + "MTN25", "MTN25", + "ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS", "ORTOFOTOS" }; + +const double UrlFactory::EarthRadiusKm = 6378.137; // WGS-84 + +ProviderStrings::ProviderStrings() +{ + // Google version strings + VersionGoogleMap = "m@113"; + VersionGoogleSatellite = "s"; + VersionGoogleLabels = "h@221000000"; + VersionGoogleTerrain = "t@132,r@249000000"; + SecGoogleWord = "Galileo"; + + // Google (China) version strings + VersionGoogleMapChina = "m@132"; + VersionGoogleSatelliteChina = "s@71"; + VersionGoogleLabelsChina = "h@132"; + VersionGoogleTerrainChina = "t@125,r@132"; + + // Google (Korea) version strings + VersionGoogleMapKorea = "kr1.12"; + VersionGoogleSatelliteKorea = "66"; + VersionGoogleLabelsKorea = "kr1t.12"; + + /// + /// Google Maps API generated using http://greatmaps.codeplex.com/ + /// from http://code.google.com/intl/en-us/apis/maps/signup.html + /// + GoogleMapsAPIKey = "ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA"; + + // Yahoo version strings + VersionYahooMap = "4.3"; + VersionYahooSatellite = "1.9"; + VersionYahooLabels = "4.3"; + + // BingMaps + VersionBingMaps = "563"; + + // YandexMap + VersionYandexMap = "2.16.0"; + + /// + /// Bing Maps Customer Identification, more info here + /// http://msdn.microsoft.com/en-us/library/bb924353.aspx + /// + BingMapsClientToken = ""; +} + +UrlFactory::UrlFactory() + : _isCorrectedGoogleVersions(false) + , _correctGoogleVersions(true) + , _timeout(5 * 1000) +{ + Proxy.setType(QNetworkProxy::NoProxy); + UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"; +} + +UrlFactory::~UrlFactory() +{ + +} + +QString UrlFactory::_tileXYToQuadKey(const int& tileX, const int& tileY, const int& levelOfDetail) const +{ + QString quadKey; + for (int i = levelOfDetail; i > 0; i--) { + char digit = '0'; + int mask = 1 << (i - 1); + if ((tileX & mask) != 0) { + digit++; + } + if ((tileY & mask) != 0) { + digit++; + digit++; + } + quadKey.append(digit); + } + return quadKey; +} + +int UrlFactory::_getServerNum(const QPoint &pos, const int &max) const +{ + return (pos.x() + 2 * pos.y()) % max; +} + +void UrlFactory::_tryCorrectGoogleVersions() +{ + static bool _kVersionRetrieved = false; + if (_kVersionRetrieved) { + return; + } + QMutexLocker locker(&mutex); + if (_correctGoogleVersions && !_isCorrectedGoogleVersions) { + QNetworkReply* reply; + QNetworkRequest qheader; + QNetworkAccessManager network; + QEventLoop q; + QTimer tT; + tT.setSingleShot(true); + connect(&network, SIGNAL(finished(QNetworkReply *)), &q, SLOT(quit())); + connect(&tT, SIGNAL(timeout()), &q, SLOT(quit())); + network.setProxy(Proxy); + _isCorrectedGoogleVersions = true; + QString url = "https://maps.google.com/maps?output=classic"; + qheader.setUrl(QUrl(url)); + qheader.setRawHeader("User-Agent", UserAgent); + reply = network.get(qheader); + tT.start(_timeout); + q.exec(); + if (!tT.isActive()) { + return; + } + tT.stop(); + if ((reply->error() != QNetworkReply::NoError)) { + return; + } + QString html = QString(reply->readAll()); + QRegExp reg("\"*https://mts0.google.com/vt/lyrs=m@(\\d*)", Qt::CaseInsensitive); + if (reg.indexIn(html) != -1) { + QStringList gc = reg.capturedTexts(); + VersionGoogleMap = QString("m@%1").arg(gc[1]); + VersionGoogleMapChina = VersionGoogleMap; + VersionGoogleMapKorea = VersionGoogleMap; + } + reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=h@(\\d*)", Qt::CaseInsensitive); + if (reg.indexIn(html) != -1) { + QStringList gc = reg.capturedTexts(); + VersionGoogleLabels = QString("h@%1").arg(gc[1]); + VersionGoogleLabelsChina = VersionGoogleLabels; + VersionGoogleLabelsKorea = VersionGoogleLabels; + } + reg = QRegExp("\"*https://khms0.google.com/kh/v=(\\d*)", Qt::CaseInsensitive); + if (reg.indexIn(html) != -1) { + QStringList gc = reg.capturedTexts(); + VersionGoogleSatellite = "s@" + gc[1]; + VersionGoogleSatelliteKorea = VersionGoogleSatellite; + VersionGoogleSatelliteChina = VersionGoogleSatellite; + } + reg = QRegExp("\"*https://mts0.google.com/vt/lyrs=t@(\\d*),r@(\\d*)", Qt::CaseInsensitive); + if (reg.indexIn(html) != -1) { + QStringList gc = reg.capturedTexts(); + VersionGoogleTerrain = QString("t@%1,r@%2").arg(gc[1]).arg(gc[2]); + VersionGoogleTerrainChina = VersionGoogleTerrain; + VersionGoogleTerrainChina = VersionGoogleTerrain; + } + reply->deleteLater(); + _kVersionRetrieved = true; + } +} + +QString UrlFactory::makeImageUrl(const MapType &type, const QPoint& pos, const int &zoom, const QString &language) +{ + switch (type) { + case GoogleMap: + { + // http://mt1.google.com/vt/lyrs=m + QString server = "mt"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10&scale=2").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleMap).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleSatellite: + { + // http://mt1.google.com/vt/lyrs=s + QString server = "mt"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10&scale=2").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleLabels: + { + QString server = "mts"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleTerrain: + { + QString server = "mts"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10&scale=2").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrain).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleMapChina: + { + QString server = "mt"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // http://mt0.google.cn/vt/v=w2.101&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga + return QString("http://%1%2.google.cn/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleMapChina).arg("zh-CN").arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleSatelliteChina: + { + QString server = "mt"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // http://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga + return QString("http://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteChina).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleLabelsChina: + { + QString server = "mt"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga + return QString("http://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsChina).arg("zh-CN").arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleTerrainChina: + { + QString server = "mt"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga + return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrainChina).arg("zh-CN").arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleMapKorea: + { + QString server = "mts"; + QString request = "vt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // https://mts0.google.com/vt/lyrs=m@224000000&hl=ko&gl=KR&src=app&x=107&y=50&z=7&s=Gal + // https://mts0.google.com/mt/v=kr1.11&hl=ko&x=109&y=49&z=7&s= + QString ret = QString("https://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + return ret; + } + break; + case GoogleSatelliteKorea: + { + QString server = "khms"; + QString request = "kh"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s= + return QString("https://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case GoogleLabelsKorea: + { + QString server = "mts"; + QString request = "mt"; + QString sec1 = ""; // after &x=... + QString sec2 = ""; // after &zoom=... + _getSecGoogleWords(pos, sec1, sec2); + _tryCorrectGoogleVersions(); + // https://mts1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G + return QString("https://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(_getServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(language).arg(pos.x()).arg(sec1).arg(pos.y()).arg(zoom).arg(sec2); + } + break; + case YahooMap: + { + return QString("http://maps%1.yimg.com/hx/tl?v=%2&.intl=%3&x=%4&y=%5&z=%6&r=1").arg(((_getServerNum(pos, 2)) + 1)).arg(VersionYahooMap).arg(language).arg(pos.x()).arg((((1 << zoom) >> 1) - 1 - pos.y())).arg((zoom + 1)); + } + case YahooSatellite: + { + return QString("http://maps%1.yimg.com/ae/ximg?v=%2&t=a&s=256&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("3").arg(VersionYahooSatellite).arg(language).arg(pos.x()).arg(((1 << zoom) >> 1) - 1 - pos.y()).arg(zoom + 1); + } + break; + case YahooLabels: + { + return QString("http://maps%1.yimg.com/hx/tl?v=%2&t=h&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("1").arg(VersionYahooLabels).arg(language).arg(pos.x()).arg(((1 << zoom) >> 1) - 1 - pos.y()).arg(zoom + 1); + } + break; + case OpenStreetMap: + { + char letter = "abc"[_getServerNum(pos, 3)]; + return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.x()).arg(pos.y()); + } + break; + case OpenStreetOsm: + { + char letter = "abc"[_getServerNum(pos, 3)]; + return QString("http://%1.tah.openstreetmap.org/Tiles/tile/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.x()).arg(pos.y()); + } + break; + case OpenStreetMapSurfer: + { + // http://tiles1.mapsurfer.net/tms_r.ashx?x=37378&y=20826&z=16 + return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.x()).arg(pos.y()).arg(zoom); + } + break; + case OpenStreetMapSurferTerrain: + { + // http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14 + return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.x()).arg(pos.y()).arg(zoom); + } + break; + case BingMap: + { + QString key = _tileXYToQuadKey(pos.x(), pos.y(), zoom); + return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4%5").arg(_getServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull() | BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString("")); + } + break; + case BingSatellite: + { + QString key = _tileXYToQuadKey(pos.x(), pos.y(), zoom); + return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4%5").arg(_getServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull() | BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString("")); + } + break; + case BingHybrid: + { + QString key = _tileXYToQuadKey(pos.x(), pos.y(), zoom); + return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4%5").arg(_getServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull() | BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString("")); + } + case ArcGIS_Map: + { + // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/0/0/0.jpg + return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); + } + break; + case ArcGIS_Satellite: + { + // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/1/0/1.jpg + return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); + } + break; + case ArcGIS_ShadedRelief: + { + // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/1/0/1.jpg + return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); + } + break; + case ArcGIS_Terrain: + { + // http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/4/3/15 + return QString("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.y()).arg(pos.x()); + } + break; + case ArcGIS_MapsLT_OrtoFoto: + { + // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg + // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13 + // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.y(), pos.x()); + // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg + // return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.y(), pos.x()); + // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg + // TODO verificar + return QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom, 2, 10, (QChar)'0').arg(pos.y(), 8, 16, (QChar)'0').arg(pos.x(), 8, 16, (QChar)'0'); + } + break; + case ArcGIS_MapsLT_Map: + { + // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg + // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13 + // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.y(), pos.x()); + // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt/MapServer/tile/7/1162/1684.png + // http://dc1.maps.lt/cache/mapslt_512/map/_alllayers/L03/R0000001b/C00000029.png + // TODO verificar + // http://dc1.maps.lt/cache/mapslt/map/_alllayers/L02/R0000001c/C00000029.png + return QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.y(), 8, 16, (QChar)'0').arg(pos.x(), 8, 16, (QChar)'0'); + } + break; + case ArcGIS_MapsLT_Map_Labels: + { + // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13 + // return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.y(), pos.x()); + // http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png + // TODO verificar + return QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom, 2, 10, (QChar)'0').arg(pos.y(), 8, 16, (QChar)'0').arg(pos.x(), 8, 16, (QChar)'0'); + } + break; + case PergoTurkeyMap: + { + // http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png + // http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png + // That means: Zoom Level: 0 TileX: 1 TileY: 0 + // http://domain/tile/14/000/019/371/000/011/825.png + // That means: Zoom Level: 14 TileX: 19371 TileY:11825 + // string x = pos.x().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001 + // string y = pos.y().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000 + QString x = QString("%1").arg(QString::number(pos.x()), 9, (QChar)'0'); + x.insert(3, "/").insert(7, "/"); + QString y = QString("%1").arg(QString::number(pos.y()), 9, (QChar)'0'); + y.insert(3, "/").insert(7, "/"); + // "http://map03.pergo.com.tr/tile/2/000/000/003/000/000/002.png" + return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(_getServerNum(pos, 4)).arg(zoom, 2, 10, (QChar)'0').arg(x).arg(y); + } + break; + case SigPacSpainMap: + { + return QString("http://sigpac.mapa.es/kmlserver/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.x()).arg((2 << (zoom - 1)) - pos.y() - 1); + } + break; + case YandexMapRu: + { + QString server = "vec"; + // http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11 + return QString("http://%1").arg(server) + QString("0%2.maps.yandex.ru/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(_getServerNum(pos, 4) + 1).arg(VersionYandexMap).arg(pos.x()).arg(pos.y()).arg(zoom); + } + break; + default: + qWarning("Unknown map id %d\n", type); + break; + } + return QString::null; +} + +void UrlFactory::_getSecGoogleWords(const QPoint &pos, QString &sec1, QString &sec2) +{ + sec1 = ""; // after &x=... + sec2 = ""; // after &zoom=... + int seclen = ((pos.x() * 3) + pos.y()) % 8; + sec2 = SecGoogleWord.left(seclen); + if (pos.y() >= 10000 && pos.y() < 100000) { + sec1 = "&s="; + } +} + +} diff --git a/src/QtLocationPlugin/OpenPilotMaps.h b/src/QtLocationPlugin/OpenPilotMaps.h new file mode 100644 index 0000000..5d88d6a --- /dev/null +++ b/src/QtLocationPlugin/OpenPilotMaps.h @@ -0,0 +1,157 @@ +/*===================================================================== + +QGroundControl Open Source Ground Control Station + +(c) 2009, 2015 QGROUNDCONTROL PROJECT + +This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + QGROUNDCONTROL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with QGROUNDCONTROL. If not, see . + +======================================================================*/ + +/** + * @file + * @brief QGC Open Pilot Mapping Tools + * @author Gus Grubba + * Original work: The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + */ + +#ifndef OPENPILOTTOOLS_H +#define OPENPILOTTOOLS_H + +#include +#include +#include +#include +#include + +namespace OpenPilot { + +enum MapType +{ + GoogleMap = 1, + GoogleSatellite = 4, + GoogleLabels = 8, + GoogleTerrain = 16, + GoogleHybrid = 20, + + GoogleMapChina = 22, + GoogleSatelliteChina = 24, + GoogleLabelsChina = 26, + GoogleTerrainChina = 28, + GoogleHybridChina = 29, + + OpenStreetMap = 32, + OpenStreetOsm = 33, + OpenStreetMapSurfer = 34, + OpenStreetMapSurferTerrain=35, + + YahooMap = 64, + YahooSatellite = 128, + YahooLabels = 256, + YahooHybrid = 333, + + BingMap = 444, + BingSatellite = 555, + BingHybrid = 666, + + ArcGIS_Map = 777, + ArcGIS_Satellite = 788, + ArcGIS_ShadedRelief = 799, + ArcGIS_Terrain = 811, + + ArcGIS_MapsLT_Map = 1000, + ArcGIS_MapsLT_OrtoFoto = 1001, + ArcGIS_MapsLT_Map_Labels= 1002, + ArcGIS_MapsLT_Map_Hybrid= 1003, + + PergoTurkeyMap = 2001, + SigPacSpainMap = 3001, + + GoogleMapKorea = 4001, + GoogleSatelliteKorea = 4002, + GoogleLabelsKorea = 4003, + GoogleHybridKorea = 4005, + + YandexMapRu = 5000 +}; + +class ProviderStrings { +public: + ProviderStrings(); + static const QString levelsForSigPacSpainMap[]; + QString GoogleMapsAPIKey; + // Google version strings + QString VersionGoogleMap; + QString VersionGoogleSatellite; + QString VersionGoogleLabels; + QString VersionGoogleTerrain; + QString SecGoogleWord; + // Google (China) version strings + QString VersionGoogleMapChina; + QString VersionGoogleSatelliteChina; + QString VersionGoogleLabelsChina; + QString VersionGoogleTerrainChina; + // Google (Korea) version strings + QString VersionGoogleMapKorea; + QString VersionGoogleSatelliteKorea; + QString VersionGoogleLabelsKorea; + /// + /// Google Maps API generated using http://greatmaps.codeplex.com/ + /// from http://code.google.com/intl/en-us/apis/maps/signup.html + /// + // Yahoo version strings + QString VersionYahooMap; + QString VersionYahooSatellite; + QString VersionYahooLabels; + // BingMaps + QString VersionBingMaps; + // YandexMap + QString VersionYandexMap; + /// + /// Bing Maps Customer Identification, more info here + /// http://msdn.microsoft.com/en-us/library/bb924353.aspx + /// + QString BingMapsClientToken; +}; + +class UrlFactory : public QObject, public ProviderStrings { + Q_OBJECT +public: + QByteArray UserAgent; + QNetworkProxy Proxy; + + UrlFactory(); + ~UrlFactory(); + + QString makeImageUrl (const MapType &type, const QPoint &pos, const int &zoom, const QString &language); + +private: + void _getSecGoogleWords (const QPoint &pos, QString &sec1, QString &sec2); + int _getServerNum (const QPoint& pos, const int &max) const; + void _tryCorrectGoogleVersions (); + QString _tileXYToQuadKey (const int &tileX, const int &tileY, const int &levelOfDetail) const; + + bool _isCorrectedGoogleVersions; + bool _correctGoogleVersions; + int _timeout; + + QMutex mutex; + static const double EarthRadiusKm; +}; + +} + +#endif // FOO_H diff --git a/src/QtLocationPlugin/qgc_maps_plugin.json b/src/QtLocationPlugin/qgc_maps_plugin.json new file mode 100644 index 0000000..dd52d9f --- /dev/null +++ b/src/QtLocationPlugin/qgc_maps_plugin.json @@ -0,0 +1,11 @@ +{ + "Keys": ["qgc-maps"], + "Provider": "QGroundControl", + "Version": 101, + "Experimental": false, + "Features": [ + "OnlineMappingFeature", + "OnlineGeocodingFeature", + "ReverseGeocodingFeature" + ] +} diff --git a/src/QtLocationPlugin/qgeocodereplyqgc.cpp b/src/QtLocationPlugin/qgeocodereplyqgc.cpp new file mode 100644 index 0000000..3c0348f --- /dev/null +++ b/src/QtLocationPlugin/qgeocodereplyqgc.cpp @@ -0,0 +1,296 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include "qgeocodereplyqgc.h" + +enum QGeoCodeTypeGoogle { + GeoCodeTypeUnknown, + StreetAddress, // indicates a precise street address. + Route, // indicates a named route (such as "US 101"). + Intersection, // indicates a major intersection, usually of two major roads. + Political, // indicates a political entity. Usually, this type indicates a polygon of some civil administration. + Country, // indicates the national political entity, and is typically the highest order type returned by the Geocoder. + AdministrativeAreaLevel1, // indicates a first-order civil entity below the country level. Within the United States, these administrative levels are states. + AdministrativeAreaLevel2, // indicates a second-order civil entity below the country level. Within the United States, these administrative levels are counties. + AdministrativeAreaLevel3, // indicates a third-order civil entity below the country level. This type indicates a minor civil division. + ColloquialArea, // indicates a commonly-used alternative name for the entity. + Locality, // indicates an incorporated city or town political entity. + Sublocality, // indicates a first-order civil entity below a locality. For some locations may receive one of the additional types: sublocality_level_1 through to sublocality_level_5. Each sublocality level is a civil entity. Larger numbers indicate a smaller geographic area. + SublocalityLevel1, + SublocalityLevel2, + SublocalityLevel3, + SublocalityLevel4, + SublocalityLevel5, + Neighborhood, // indicates a named neighborhood + Premise, // indicates a named location, usually a building or collection of buildings with a common name + Subpremise, // indicates a first-order entity below a named location, usually a singular building within a collection of buildings with a common name + PostalCode, // indicates a postal code as used to address postal mail within the country. + NaturalFeature, // indicates a prominent natural feature. + Airport, // indicates an airport. + Park, // indicates a named park. + PointOfInterest, // indicates a named point of interest. Typically, these "POI"s are prominent local entities that don't easily fit in another category such as "Empire State Building" or "Statue of Liberty." + Floor, // indicates the floor of a building address. + Establishment, // typically indicates a place that has not yet been categorized. + Parking, // indicates a parking lot or parking structure. + PostBox, // indicates a specific postal box. + PostalTown, // indicates a grouping of geographic areas, such as locality and sublocality, used for mailing addresses in some countries. + RoomIndicates, // the room of a building address. + StreetNumber, // indicates the precise street number. + BusStation, // indicate the location of a bus stop. + TrainStation, // indicate the location of a train stop. + TransitStation, // indicate the location of a public transit stop. +}; + +class JasonMonger { +public: + JasonMonger(); + QSet json2QGeoCodeTypeGoogle(const QJsonArray &types); +private: + int _getCode(const QString &key); + QMap _m; +}; + +JasonMonger::JasonMonger() +{ + _m[QStringLiteral("street_address")] = StreetAddress; + _m[QStringLiteral("route")] = Route; + _m[QStringLiteral("intersection")] = Intersection; + _m[QStringLiteral("political")] = Political; + _m[QStringLiteral("country")] = Country; + _m[QStringLiteral("administrative_area_level_1")] = AdministrativeAreaLevel1; + _m[QStringLiteral("administrative_area_level_2")] = AdministrativeAreaLevel2; + _m[QStringLiteral("administrative_area_level_3")] = AdministrativeAreaLevel3; + _m[QStringLiteral("colloquial_area")] = ColloquialArea; + _m[QStringLiteral("locality")] = Locality; + _m[QStringLiteral("sublocality")] = Sublocality; + _m[QStringLiteral("sublocality_level_1")] = SublocalityLevel1; + _m[QStringLiteral("sublocality_level_2")] = SublocalityLevel2; + _m[QStringLiteral("sublocality_level_3")] = SublocalityLevel3; + _m[QStringLiteral("sublocality_level_4")] = SublocalityLevel4; + _m[QStringLiteral("sublocality_level_5")] = SublocalityLevel5; + _m[QStringLiteral("neighborhood")] = Neighborhood; + _m[QStringLiteral("premise")] = Premise; + _m[QStringLiteral("subpremise")] = Subpremise; + _m[QStringLiteral("postal_code")] = PostalCode; + _m[QStringLiteral("natural_feature")] = NaturalFeature; + _m[QStringLiteral("airport")] = Airport; + _m[QStringLiteral("park")] = Park; + _m[QStringLiteral("point_of_interest")] = PointOfInterest; + _m[QStringLiteral("floor")] = Floor; + _m[QStringLiteral("establishment")] = Establishment; + _m[QStringLiteral("parking")] = Parking; + _m[QStringLiteral("post_box")] = PostBox; + _m[QStringLiteral("postal_town")] = PostalTown; + _m[QStringLiteral("room indicates")] = RoomIndicates; + _m[QStringLiteral("street_number")] = StreetNumber; + _m[QStringLiteral("bus_station")] = BusStation; + _m[QStringLiteral("train_station")] = TrainStation; + _m[QStringLiteral("transit_station")] = TransitStation; +} + +int JasonMonger::_getCode(const QString &key) { + return _m.value(key, GeoCodeTypeUnknown); +} + +QSet JasonMonger::json2QGeoCodeTypeGoogle(const QJsonArray &types) { + QSet result; + for (int i=0; ideleteLater(); +} + +void QGeoCodeReplyQGC::abort() +{ + if (!m_reply) + return; + + m_reply->abort(); + + m_reply->deleteLater(); + m_reply = 0; +} + +void QGeoCodeReplyQGC::networkReplyFinished() +{ + if (!m_reply) + return; + + if (m_reply->error() != QNetworkReply::NoError) + return; + + QJsonDocument document = QJsonDocument::fromJson(m_reply->readAll()); + QJsonObject object = document.object(); + + if (object.value(QStringLiteral("status")) != QStringLiteral("OK")) { + QString error = object.value(QStringLiteral("status")).toString(); + qWarning() << m_reply->url() << "returned" << error; + setError(QGeoCodeReply::CommunicationError, error); + m_reply->deleteLater(); + m_reply = 0; + return; + } + + QList locations; + QJsonArray results = object.value(QStringLiteral("results")).toArray(); + for (int i=0; i types = kMonger.json2QGeoCodeTypeGoogle(c[QStringLiteral("types")].toArray()); + QString long_name = c[QStringLiteral("long_name")].toString(); + QString short_name = c[QStringLiteral("short_name")].toString(); + if (types.contains(Country)) { + address.setCountry(long_name); + address.setCountryCode(short_name); + } else if (types.contains(AdministrativeAreaLevel1)) { + address.setState(long_name); + } else if (types.contains(AdministrativeAreaLevel2)) { + address.setCounty(long_name); + } else if (types.contains(Locality)) { + address.setCity(long_name); + } else if (types.contains(Sublocality)) { + address.setDistrict(long_name); + } else if (types.contains(PostalCode)) { + address.setPostalCode(long_name); + } else if (types.contains(StreetAddress) || types.contains(Route) || types.contains(Intersection)) { + address.setStreet(long_name); + } + } + } + + QGeoCoordinate coordinate; + QGeoRectangle boundingBox; + if (geocode.contains(QStringLiteral("geometry"))) { + QJsonObject geom = geocode.value(QStringLiteral("geometry")).toObject(); + if (geom.contains(QStringLiteral("location"))) { + QJsonObject location = geom.value(QStringLiteral("location")).toObject(); + coordinate.setLatitude(location.value(QStringLiteral("lat")).toDouble()); + coordinate.setLongitude(location.value(QStringLiteral("lng")).toDouble()); + } + if (geom.contains(QStringLiteral("bounds"))) { + QJsonObject bounds = geom.value(QStringLiteral("bounds")).toObject(); + QJsonObject northeast = bounds.value(QStringLiteral("northeast")).toObject(); + QJsonObject southwest = bounds.value(QStringLiteral("southwest")).toObject(); + QGeoCoordinate topRight(northeast.value(QStringLiteral("lat")).toDouble(), + northeast.value(QStringLiteral("lng")).toDouble()); + QGeoCoordinate bottomLeft(southwest.value(QStringLiteral("lat")).toDouble(), + southwest.value(QStringLiteral("lng")).toDouble()); + boundingBox.setTopRight(topRight); + boundingBox.setBottomLeft(bottomLeft); + } + } + + QGeoLocation location; + location.setAddress(address); + location.setCoordinate(coordinate); + location.setBoundingBox(boundingBox); + + locations << location; + } + + setLocations(locations); + setFinished(true); + + m_reply->deleteLater(); + m_reply = 0; +} + +void QGeoCodeReplyQGC::networkReplyError(QNetworkReply::NetworkError error) +{ + Q_UNUSED(error) + if (!m_reply) + return; + setError(QGeoCodeReply::CommunicationError, m_reply->errorString()); + m_reply->deleteLater(); + m_reply = 0; +} diff --git a/src/QtLocationPlugin/qgeocodereplyqgc.h b/src/QtLocationPlugin/qgeocodereplyqgc.h new file mode 100644 index 0000000..b53b172 --- /dev/null +++ b/src/QtLocationPlugin/qgeocodereplyqgc.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#ifndef QGEOCODEREPLYGOOGLE_H +#define QGEOCODEREPLYGOOGLE_H + +#include +#include + +class QGeoCodeReplyQGC : public QGeoCodeReply +{ + Q_OBJECT + +public: + explicit QGeoCodeReplyQGC(QNetworkReply *reply, QObject *parent = 0); + ~QGeoCodeReplyQGC(); + + void abort(); + +private Q_SLOTS: + void networkReplyFinished(); + void networkReplyError(QNetworkReply::NetworkError error); + +private: + QNetworkReply *m_reply; +}; + +#endif // QGEOCODEREPLYGOOGLE_H diff --git a/src/QtLocationPlugin/qgeocodingmanagerengineqgc.cpp b/src/QtLocationPlugin/qgeocodingmanagerengineqgc.cpp new file mode 100644 index 0000000..59f7fdd --- /dev/null +++ b/src/QtLocationPlugin/qgeocodingmanagerengineqgc.cpp @@ -0,0 +1,177 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qgeocodingmanagerengineqgc.h" +#include "qgeocodereplyqgc.h" + +static QString addressToQuery(const QGeoAddress &address) +{ + return address.street() + QStringLiteral(", ") + + address.district() + QStringLiteral(", ") + + address.city() + QStringLiteral(", ") + + address.state() + QStringLiteral(", ") + + address.country(); +} + +static QString boundingBoxToLtrb(const QGeoRectangle &rect) +{ + return QString::number(rect.topLeft().longitude()) + QLatin1Char(',') + + QString::number(rect.topLeft().latitude()) + QLatin1Char(',') + + QString::number(rect.bottomRight().longitude()) + QLatin1Char(',') + + QString::number(rect.bottomRight().latitude()); +} + +QGeoCodingManagerEngineQGC::QGeoCodingManagerEngineQGC( + const QVariantMap ¶meters, + QGeoServiceProvider::Error *error, + QString *errorString) + : QGeoCodingManagerEngine(parameters), m_networkManager(new QNetworkAccessManager(this)) +{ + if (parameters.contains(QStringLiteral("useragent"))) + m_userAgent = parameters.value(QStringLiteral("useragent")).toString().toLatin1(); + else + m_userAgent = "Qt Location based application"; + *error = QGeoServiceProvider::NoError; + errorString->clear(); +} + +QGeoCodingManagerEngineQGC::~QGeoCodingManagerEngineQGC() +{ +} + +QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QGeoAddress &address, const QGeoShape &bounds) +{ + return geocode(addressToQuery(address), -1, -1, bounds); +} + +QGeoCodeReply *QGeoCodingManagerEngineQGC::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds) +{ + Q_UNUSED(limit); + Q_UNUSED(offset); + + QNetworkRequest request; + request.setRawHeader("User-Agent", m_userAgent); + + QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json")); + QUrlQuery query; + query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false")); + query.addQueryItem(QStringLiteral("language"), locale().name().left(2)); + query.addQueryItem(QStringLiteral("address"), address); + if (bounds.type() == QGeoShape::RectangleType) { + query.addQueryItem(QStringLiteral("bounds"), boundingBoxToLtrb(bounds)); + } + + url.setQuery(query); + request.setUrl(url); + qDebug() << url; + + QNetworkReply *reply = m_networkManager->get(request); + reply->setParent(0); + + QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply); + + connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished())); + connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)), + this, SLOT(replyError(QGeoCodeReply::Error,QString))); + + return geocodeReply; +} + +QGeoCodeReply *QGeoCodingManagerEngineQGC::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds) +{ + Q_UNUSED(bounds) + + QNetworkRequest request; + request.setRawHeader("User-Agent", m_userAgent); + + QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json")); + QUrlQuery query; + query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false")); + query.addQueryItem(QStringLiteral("language"), locale().name().left(2)); + query.addQueryItem(QStringLiteral("latlng"), QStringLiteral("%1,%2") + .arg(coordinate.latitude()) + .arg(coordinate.longitude())); + + url.setQuery(query); + request.setUrl(url); + qDebug() << url; + + QNetworkReply *reply = m_networkManager->get(request); + reply->setParent(0); + + QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply); + + connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished())); + connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)), + this, SLOT(replyError(QGeoCodeReply::Error,QString))); + + return geocodeReply; +} + +void QGeoCodingManagerEngineQGC::replyFinished() +{ + QGeoCodeReply *reply = qobject_cast(sender()); + if (reply) + emit finished(reply); +} + +void QGeoCodingManagerEngineQGC::replyError(QGeoCodeReply::Error errorCode, const QString &errorString) +{ + QGeoCodeReply *reply = qobject_cast(sender()); + if (reply) + emit error(reply, errorCode, errorString); +} diff --git a/src/QtLocationPlugin/qgeocodingmanagerengineqgc.h b/src/QtLocationPlugin/qgeocodingmanagerengineqgc.h new file mode 100644 index 0000000..56040f4 --- /dev/null +++ b/src/QtLocationPlugin/qgeocodingmanagerengineqgc.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#ifndef QGEOCODINGMANAGERENGINEGOOGLE_H +#define QGEOCODINGMANAGERENGINEGOOGLE_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QNetworkAccessManager; + +class QGeoCodingManagerEngineQGC : public QGeoCodingManagerEngine +{ + Q_OBJECT + +public: + QGeoCodingManagerEngineQGC(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString); + ~QGeoCodingManagerEngineQGC(); + + QGeoCodeReply* geocode (const QGeoAddress &address, const QGeoShape &bounds) Q_DECL_OVERRIDE; + QGeoCodeReply* geocode (const QString &address, int limit, int offset, const QGeoShape &bounds) Q_DECL_OVERRIDE; + QGeoCodeReply* reverseGeocode (const QGeoCoordinate &coordinate, const QGeoShape &bounds) Q_DECL_OVERRIDE; + +private Q_SLOTS: + void replyFinished (); + void replyError (QGeoCodeReply::Error errorCode, const QString &errorString); + +private: + QNetworkAccessManager *m_networkManager; + QByteArray m_userAgent; +}; + +QT_END_NAMESPACE + +#endif // QGEOCODINGMANAGERENGINEGOOGLE_H diff --git a/src/QtLocationPlugin/qgeomapreplyqgc.cpp b/src/QtLocationPlugin/qgeomapreplyqgc.cpp new file mode 100644 index 0000000..7fad5e7 --- /dev/null +++ b/src/QtLocationPlugin/qgeomapreplyqgc.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#include + +#include "qgeomapreplyqgc.h" +#include "OpenPilotMaps.h" + +QGeoMapReplyQGC::QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent) + : QGeoTiledMapReply(spec, parent) + , m_reply(reply) +{ + connect(m_reply, SIGNAL(finished()), this, SLOT(networkReplyFinished())); + connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError))); + connect(m_reply, SIGNAL(destroyed()), this, SLOT(replyDestroyed())); +} + +QGeoMapReplyQGC::~QGeoMapReplyQGC() +{ + if (m_reply) { + m_reply->deleteLater(); + m_reply = 0; + } +} + +void QGeoMapReplyQGC::abort() +{ + if (!m_reply) + return; + m_reply->abort(); +} + +QNetworkReply *QGeoMapReplyQGC::networkReply() const +{ + return m_reply; +} + +void QGeoMapReplyQGC::replyDestroyed() +{ + m_reply = 0; +} + +void QGeoMapReplyQGC::networkReplyFinished() +{ + if (!m_reply) + return; + + if (m_reply->error() != QNetworkReply::NoError) + return; + + QByteArray a = m_reply->readAll(); + setMapImageData(a); + + if(a.size() > 2) + { + if((char)a[0] == (char)0xff && (char)a[1] == (char)0xd8) + setMapImageFormat("jpg"); + else if((char)a[0] == (char)0x89 && (char)a[1] == (char)0x50) + setMapImageFormat("png"); + else + { + switch ((OpenPilot::MapType)tileSpec().mapId()) { + case OpenPilot::GoogleMap: + case OpenPilot::GoogleLabels: + case OpenPilot::GoogleTerrain: + case OpenPilot::GoogleHybrid: + case OpenPilot::BingMap: + case OpenPilot::OpenStreetMap: + setMapImageFormat("png"); + break; + case OpenPilot::GoogleSatellite: + case OpenPilot::BingSatellite: + case OpenPilot::BingHybrid: + setMapImageFormat("jpg"); + break; + default: + qWarning("Unknown map id %d", tileSpec().mapId()); + break; + } + } + } + + setFinished(true); + m_reply->deleteLater(); + m_reply = 0; +} + +void QGeoMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error) +{ + if (!m_reply) + return; + + if (error != QNetworkReply::OperationCanceledError) + setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString()); + + setFinished(true); + m_reply->deleteLater(); + m_reply = 0; +} diff --git a/src/QtLocationPlugin/qgeomapreplyqgc.h b/src/QtLocationPlugin/qgeomapreplyqgc.h new file mode 100644 index 0000000..90d8558 --- /dev/null +++ b/src/QtLocationPlugin/qgeomapreplyqgc.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#ifndef QGEOMAPREPLYGOOGLE_H +#define QGEOMAPREPLYGOOGLE_H + +#include +#include + +class QGeoMapReplyQGC : public QGeoTiledMapReply +{ + Q_OBJECT + +public: + explicit QGeoMapReplyQGC(QNetworkReply *reply, const QGeoTileSpec &spec, QObject *parent = 0); + ~QGeoMapReplyQGC(); + + void abort(); + + QNetworkReply *networkReply() const; + +private Q_SLOTS: + void replyDestroyed (); + void networkReplyFinished (); + void networkReplyError (QNetworkReply::NetworkError error); + +private: + QNetworkReply* m_reply; +}; + +#endif // QGEOMAPREPLYGOOGLE_H diff --git a/src/QtLocationPlugin/qgeoserviceproviderpluginqgc.cpp b/src/QtLocationPlugin/qgeoserviceproviderpluginqgc.cpp new file mode 100644 index 0000000..446ea2f --- /dev/null +++ b/src/QtLocationPlugin/qgeoserviceproviderpluginqgc.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#include + +#include "qdebug.h" +#include "qgeoserviceproviderpluginqgc.h" +#include "qgeotiledmappingmanagerengineqgc.h" +#include "qgeocodingmanagerengineqgc.h" + +QGeoCodingManagerEngine *QGeoServiceProviderFactoryQGC::createGeocodingManagerEngine( + const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const +{ + return new QGeoCodingManagerEngineQGC(parameters, error, errorString); +} + +QGeoMappingManagerEngine *QGeoServiceProviderFactoryQGC::createMappingManagerEngine( + const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const +{ + return new QGeoTiledMappingManagerEngineQGC(parameters, error, errorString); +} + +QGeoRoutingManagerEngine *QGeoServiceProviderFactoryQGC::createRoutingManagerEngine( + const QVariantMap &, QGeoServiceProvider::Error *, QString *) const +{ + // Not implemented for QGC + return NULL; +} + +QPlaceManagerEngine *QGeoServiceProviderFactoryQGC::createPlaceManagerEngine( + const QVariantMap &, QGeoServiceProvider::Error *, QString *) const +{ + // Not implemented for QGC + return NULL; +} diff --git a/src/QtLocationPlugin/qgeoserviceproviderpluginqgc.h b/src/QtLocationPlugin/qgeoserviceproviderpluginqgc.h new file mode 100644 index 0000000..a4d86e8 --- /dev/null +++ b/src/QtLocationPlugin/qgeoserviceproviderpluginqgc.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#ifndef QGEOSERVICEPROVIDER_GOOGLE_H +#define QGEOSERVICEPROVIDER_GOOGLE_H + +#include +#include +#include + +class QGeoServiceProviderFactoryQGC: public QObject, public QGeoServiceProviderFactory +{ + Q_OBJECT + Q_INTERFACES(QGeoServiceProviderFactory) + Q_PLUGIN_METADATA(IID "org.qt-project.qt.geoservice.serviceproviderfactory/5.0" FILE "qgc_maps_plugin.json") + +public: + QGeoCodingManagerEngine* createGeocodingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; + QGeoMappingManagerEngine* createMappingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; + QGeoRoutingManagerEngine* createRoutingManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; + QPlaceManagerEngine* createPlaceManagerEngine(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const; +}; + +#endif // QGEOSERVICEPROVIDER_GOOGLE_H diff --git a/src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp b/src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp new file mode 100644 index 0000000..ae5cd85 --- /dev/null +++ b/src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "qgeotiledmappingmanagerengineqgc.h" +#include "qgeotilefetcherqgc.h" +#include "OpenPilotMaps.h" + +QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) +: QGeoTiledMappingManagerEngine() +{ + QGeoCameraCapabilities cameraCaps; + cameraCaps.setMinimumZoomLevel(0.0); + cameraCaps.setMaximumZoomLevel(22.0); + setCameraCapabilities(cameraCaps); + + setTileSize(QSize(256, 256)); + + QList mapTypes; + mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Google Street Map"), tr("Google street map"), false, false, OpenPilot::GoogleMap); + mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Google Satellite Map"),tr("Google satellite map"), false, false, OpenPilot::GoogleSatellite); + mapTypes << QGeoMapType(QGeoMapType::TerrainMap, tr("Google Terrain Map"), tr("Google terrain map"), false, false, OpenPilot::GoogleTerrain); + // TODO: + // Proper hybrid maps requires collecting two separate bimaps and overlaying them. + //mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Google Hybrid Map"), tr("Google hybrid map"), false, false, OpenPilot::GoogleHybrid); + // Bing + mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Bing Street Map"), tr("Bing street map"), false, false, OpenPilot::BingMap); + mapTypes << QGeoMapType(QGeoMapType::SatelliteMapDay, tr("Bing Satellite Map"), tr("Bing satellite map"), false, false, OpenPilot::BingSatellite); + mapTypes << QGeoMapType(QGeoMapType::HybridMap, tr("Bing Hybrid Map"), tr("Bing hybrid map"), false, false, OpenPilot::BingHybrid); + mapTypes << QGeoMapType(QGeoMapType::StreetMap, tr("Open Street Map"), tr("Open Street map"), false, false, OpenPilot::OpenStreetMap); + setSupportedMapTypes(mapTypes); + + QGeoTileFetcherQGC *tileFetcher = new QGeoTileFetcherQGC(this); + if (parameters.contains(QStringLiteral("useragent"))) { + const QByteArray ua = parameters.value(QStringLiteral("useragent")).toString().toLatin1(); + tileFetcher->setUserAgent(ua); + } else + // QGC Default + tileFetcher->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"); + + setTileFetcher(tileFetcher); + + QString cacheDir; + if (parameters.contains(QStringLiteral("mapping.cache.directory"))) + cacheDir = parameters.value(QStringLiteral("mapping.cache.directory")).toString(); + else { + cacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache"); + if(!QDir::root().mkpath(cacheDir)) { + qWarning() << "Could not create mapping disk cache directory: " << cacheDir; + cacheDir = QDir::homePath() + QLatin1String("/.qgcmapscache/"); + } + } + + if(!QDir::root().mkpath(cacheDir)) + { + qWarning() << "Could not create mapping disk cache directory: " << cacheDir; + cacheDir.clear(); + } + //else { + // qDebug() << "Mapping cache directory:" << cacheDir; + //} + + QGeoTileCache *tileCache = createTileCacheWithDir(cacheDir); + + int cacheLimit = 0; + if (parameters.contains(QStringLiteral("mapping.cache.disk.size"))) { + bool ok = false; + cacheLimit = parameters.value(QStringLiteral("mapping.cache.disk.size")).toString().toInt(&ok); + if (!ok) + cacheLimit = 0; + } + if(!cacheLimit) + // QGC Default + cacheLimit = 1024 * 1024 * 1024; + tileCache->setMaxDiskUsage(cacheLimit); + //qDebug() << "Disk caching limit:" << cacheLimit; + + cacheLimit = 0; + if (parameters.contains(QStringLiteral("mapping.cache.memory.size"))) { + bool ok = false; + cacheLimit = parameters.value(QStringLiteral("mapping.cache.memory.size")).toString().toInt(&ok); + if (!ok) + cacheLimit = 0; + } + if(!cacheLimit) + // QGC Default + cacheLimit = 10 * 1024 * 1024; + tileCache->setMaxMemoryUsage(cacheLimit); + //qDebug() << "Memory caching limit:" << cacheLimit; + + cacheLimit = 0; + if (parameters.contains(QStringLiteral("mapping.cache.texture.size"))) { + bool ok = false; + cacheLimit = parameters.value(QStringLiteral("mapping.cache.texture.size")).toString().toInt(&ok); + if (!ok) + cacheLimit = 0; + } + if(!cacheLimit) + // QGC Default + cacheLimit = 10 * 1024 * 1024; + tileCache->setExtraTextureUsage(cacheLimit); + + *error = QGeoServiceProvider::NoError; + errorString->clear(); +} + +QGeoTiledMappingManagerEngineQGC::~QGeoTiledMappingManagerEngineQGC() +{ +} + +QGeoMapData *QGeoTiledMappingManagerEngineQGC::createMapData() +{ + return new QGeoTiledMapData(this, 0); +} diff --git a/src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.h b/src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.h new file mode 100644 index 0000000..0bee02c --- /dev/null +++ b/src/QtLocationPlugin/qgeotiledmappingmanagerengineqgc.h @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#ifndef QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H +#define QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H + +#include +#include + +class QGeoTiledMappingManagerEngineQGC : public QGeoTiledMappingManagerEngine +{ + Q_OBJECT +public: + QGeoTiledMappingManagerEngineQGC(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString); + ~QGeoTiledMappingManagerEngineQGC(); + QGeoMapData *createMapData(); +}; + +#endif // QGEOTILEDMAPPINGMANAGERENGINEGOOGLE_H diff --git a/src/QtLocationPlugin/qgeotilefetcherqgc.cpp b/src/QtLocationPlugin/qgeotilefetcherqgc.cpp new file mode 100644 index 0000000..2aaa3a1 --- /dev/null +++ b/src/QtLocationPlugin/qgeotilefetcherqgc.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "qgeotilefetcherqgc.h" +#include "qgeomapreplyqgc.h" + +QGeoTileFetcherQGC::QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent) + : QGeoTileFetcher(parent) + , m_networkManager(new QNetworkAccessManager(this)) + , m_userAgent("Qt Application") +{ + QStringList langs = QLocale::system().uiLanguages(); + if (langs.length() > 0) { + m_Language = langs[0]; + } +} + +void QGeoTileFetcherQGC::setUserAgent(const QByteArray &userAgent) +{ + m_userAgent = userAgent; +} + +QGeoTiledMapReply *QGeoTileFetcherQGC::getTileImage(const QGeoTileSpec &spec) +{ + QNetworkRequest request; + QString url = m_UrlFactory.makeImageUrl((OpenPilot::MapType)spec.mapId(), QPoint(spec.x(), spec.y()), spec.zoom(), m_Language); + + request.setUrl(QUrl(url)); + request.setRawHeader("User-Agent", m_userAgent); + request.setRawHeader("Accept", "*/*"); + switch ((OpenPilot::MapType)spec.mapId()) { + case OpenPilot::GoogleMap: + case OpenPilot::GoogleSatellite: + case OpenPilot::GoogleLabels: + case OpenPilot::GoogleTerrain: + case OpenPilot::GoogleHybrid: + { + request.setRawHeader("Referrer", "http://maps.google.com/"); + } + break; + case OpenPilot::GoogleMapChina: + case OpenPilot::GoogleSatelliteChina: + case OpenPilot::GoogleLabelsChina: + case OpenPilot::GoogleTerrainChina: + case OpenPilot::GoogleHybridChina: + { + request.setRawHeader("Referrer", "http://ditu.google.cn/"); + } + break; + case OpenPilot::BingHybrid: + case OpenPilot::BingMap: + case OpenPilot::BingSatellite: + { + request.setRawHeader("Referrer", "http://www.bing.com/maps/"); + } + break; + case OpenPilot::YahooHybrid: + case OpenPilot::YahooLabels: + case OpenPilot::YahooMap: + case OpenPilot::YahooSatellite: + { + request.setRawHeader("Referrer", "http://maps.yahoo.com/"); + } + break; + case OpenPilot::ArcGIS_MapsLT_Map_Labels: + case OpenPilot::ArcGIS_MapsLT_Map: + case OpenPilot::ArcGIS_MapsLT_OrtoFoto: + case OpenPilot::ArcGIS_MapsLT_Map_Hybrid: + { + request.setRawHeader("Referrer", "http://www.maps.lt/map_beta/"); + } + break; + case OpenPilot::OpenStreetMapSurfer: + case OpenPilot::OpenStreetMapSurferTerrain: + { + request.setRawHeader("Referrer", "http://www.mapsurfer.net/"); + } + break; + case OpenPilot::OpenStreetMap: + case OpenPilot::OpenStreetOsm: + { + request.setRawHeader("Referrer", "http://www.openstreetmap.org/"); + } + break; + case OpenPilot::YandexMapRu: + { + request.setRawHeader("Referrer", "http://maps.yandex.ru/"); + } + break; + default: + break; + } + + QNetworkReply *reply = m_networkManager->get(request); + reply->setParent(0); + return new QGeoMapReplyQGC(reply, spec); + +} diff --git a/src/QtLocationPlugin/qgeotilefetcherqgc.h b/src/QtLocationPlugin/qgeotilefetcherqgc.h new file mode 100644 index 0000000..be6d682 --- /dev/null +++ b/src/QtLocationPlugin/qgeotilefetcherqgc.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Aaron McCarthy +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +** 2015.4.4 +** Adapted for use with QGroundControl +** +** Gus Grubba +** +****************************************************************************/ + +#ifndef QGEOTILEFETCHERGOOGLE_H +#define QGEOTILEFETCHERGOOGLE_H + +#include +#include +#include "OpenPilotMaps.h" + +class QGeoTiledMappingManagerEngine; +class QNetworkAccessManager; + +class QGeoTileFetcherQGC : public QGeoTileFetcher +{ + Q_OBJECT + +public: + explicit QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent = 0); + + void setUserAgent(const QByteArray &userAgent); + +private: + QGeoTiledMapReply* getTileImage(const QGeoTileSpec &spec); + QNetworkAccessManager* m_networkManager; + QByteArray m_userAgent; + OpenPilot::UrlFactory m_UrlFactory; + QString m_Language; +}; + +#endif // QGEOTILEFETCHERGOOGLE_H From e485eb052dc75bc9e541a259a2a1d08219aeb795 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 8 Apr 2015 10:13:07 -0700 Subject: [PATCH 2/3] Relocate plugin lib to make clean work --- QGCCommon.pri | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/QGCCommon.pri b/QGCCommon.pri index 1251903..b1e891a 100644 --- a/QGCCommon.pri +++ b/QGCCommon.pri @@ -92,15 +92,16 @@ ReleaseBuild { BUILDDIR = $${OUT_PWD}/build-release } -LOCATION_PLUGIN_DESTDIR = $${BUILDDIR}/QGCLocationPlugin -LOCATION_PLUGIN_NAME = QGeoServiceProviderFactoryQGC - OBJECTS_DIR = $${BUILDDIR}/obj MOC_DIR = $${BUILDDIR}/moc UI_DIR = $${BUILDDIR}/ui RCC_DIR = $${BUILDDIR}/rcc LANGUAGE = C++ +# We place the created plugin lib into the objects dir so that make clean will clean it as well +LOCATION_PLUGIN_DESTDIR = $${OBJECTS_DIR} +LOCATION_PLUGIN_NAME = QGeoServiceProviderFactoryQGC + message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET) # Turn off serial port warnings From 3a793264f53aa0889b2be2a883f00af32ddacbc4 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Wed, 8 Apr 2015 10:25:12 -0700 Subject: [PATCH 3/3] Get rid of $$qtlibrarytarget This just mangles the library names for no good reason. --- QGCApplication.pro | 24 +++--------------------- QGCLocationPlugin.pro | 2 +- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/QGCApplication.pro b/QGCApplication.pro index 134c24f..0732ea7 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -36,32 +36,14 @@ message(BASEDIR $$BASEDIR DESTDIR $$DESTDIR TARGET $$TARGET) # QGC QtLocation plugin LIBS += -L$${LOCATION_PLUGIN_DESTDIR} +LIBS += -l$${LOCATION_PLUGIN_NAME} -LinuxBuild { - LIBS += -l$${LOCATION_PLUGIN_NAME} +LinuxBuild|MacBuild { PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/lib$${LOCATION_PLUGIN_NAME}.a } WindowsBuild { - DebugBuild { - LIBS += -l$${LOCATION_PLUGIN_NAME}d - PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/$${LOCATION_PLUGIN_NAME}d.lib - } - ReleaseBuild { - LIBS += -l$${LOCATION_PLUGIN_NAME} - PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/$${LOCATION_PLUGIN_NAME}.lib - } -} - -MacBuild { - DebugBuild { - LIBS += -l$${LOCATION_PLUGIN_NAME}_debug - PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/lib$${LOCATION_PLUGIN_NAME}_debug.a - } - ReleaseBuild { - LIBS += -l$${LOCATION_PLUGIN_NAME} - PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/lib$${LOCATION_PLUGIN_NAME}.a - } + PRE_TARGETDEPS += $${LOCATION_PLUGIN_DESTDIR}/$${LOCATION_PLUGIN_NAME}.lib } # Qt configuration diff --git a/QGCLocationPlugin.pro b/QGCLocationPlugin.pro index fb2f761..e2da91a 100644 --- a/QGCLocationPlugin.pro +++ b/QGCLocationPlugin.pro @@ -1,7 +1,7 @@ include(QGCCommon.pri) TEMPLATE = lib -TARGET = $$qtLibraryTarget(QGeoServiceProviderFactoryQGC) +TARGET = QGeoServiceProviderFactoryQGC CONFIG += plugin static QT += location-private positioning-private network PLUGIN_TYPE = geoservices