Commit 0b0fbe87 authored by lm's avatar lm

Added opmapcontrol library in local configuration

parent 39d9a923
......@@ -31,8 +31,39 @@ include(lib/nmea/nmea.pri)
# provided by the OpenPilot team - thanks, great piece
# of open-source software!
# (We're not reusing any part of the OP GCS, just the map library)
# Try to get it from OP mainline, if this fails fall back to internal copies
exists(../openpilot/ground/openpilotgcs/src/libs) {
include(../openpilot/ground/openpilotgcs/src/libs/utils/utils_external.pri)
include(../openpilot/ground/openpilotgcs/src/libs/opmapcontrol/opmapcontrol_external.pri)
DEPENDPATH += \
../openpilot/ground/openpilotgcs/src/libs/utils \
../openpilot/ground/openpilotgcs/src/libs/utils/src \
../openpilot/ground/openpilotgcs/src/libs/opmapcontrol \
../openpilot/ground/openpilotgcs/src/libs/opmapcontrol/src
INCLUDEPATH += \
../openpilot/ground/openpilotgcs/src/libs/utils \
../openpilot/ground/openpilotgcs/src/libs \
../openpilot/ground/openpilotgcs/src/libs/opmapcontrol
message("----- USING MAINLINE OPENPILOT FROM ../openpilot -----")
message("Using OpenPilot's mapcontrol library from external folder")
message("------------------------------------------------------------------------")
} else {
include(src/libs/utils/utils_external.pri)
include(src/libs/opmapcontrol/opmapcontrol_external.pri)
DEPENDPATH += \
src/libs/utils \
src/libs/utils/src \
src/libs/opmapcontrol \
src/libs/opmapcontrol/src
INCLUDEPATH += \
src/libs/utils \
src/libs \
src/libs/opmapcontrol
}
# include(lib/opmapcontrol/opmapcontrol.pri)
# message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
......@@ -118,19 +149,12 @@ include(qgroundcontrol.pri)
# Include QWT plotting library
include(src/lib/qwt/qwt.pri)
DEPENDPATH += . \
../openpilot/ground/openpilotgcs/src/libs/utils \
../openpilot/ground/openpilotgcs/src/libs/utils/src \
../openpilot/ground/openpilotgcs/src/libs/opmapcontrol \
../openpilot/ground/openpilotgcs/src/libs/opmapcontrol/src \
plugins \
thirdParty/qserialport/include \
thirdParty/qserialport/include/QtSerialPort \
thirdParty/qserialport
INCLUDEPATH += . \
../openpilot/ground/openpilotgcs/src/libs/utils \
../openpilot/ground/openpilotgcs/src/libs \
../openpilot/ground/openpilotgcs/src/libs/opmapcontrol \
thirdParty/qserialport/include \
thirdParty/qserialport/include/QtSerialPort \
thirdParty/qserialport/src
......
#include "src/mapwidget/opmapwidget.h"
LIBS *= -l$$qtLibraryTarget(opmapwidget)
TEMPLATE = subdirs
SUBDIRS = src \
######################################################################
# Automatically generated by qmake (2.01a) Sa. Mrz 19 17:12:54 2011
######################################################################
# HACK! BIG TIME!
DEFINES += EXTERNAL_USE
DEPENDPATH += src/core src/internals src/mapwidget src/internals/projections
INCLUDEPATH += src/core src/internals src/internals/projections src/mapwidget
# Input
HEADERS += opmapcontrol.h \
src/core/accessmode.h \
src/core/alllayersoftype.h \
src/core/cache.h \
src/core/cacheitemqueue.h \
src/core/debugheader.h \
src/core/diagnostics.h \
src/core/geodecoderstatus.h \
src/core/kibertilecache.h \
src/core/languagetype.h \
src/core/maptype.h \
src/core/memorycache.h \
src/core/opmaps.h \
src/core/placemark.h \
src/core/point.h \
src/core/providerstrings.h \
src/core/pureimage.h \
src/core/pureimagecache.h \
src/core/rawtile.h \
src/core/size.h \
src/core/tilecachequeue.h \
src/core/urlfactory.h \
src/internals/copyrightstrings.h \
src/internals/core.h \
src/internals/debugheader.h \
src/internals/loadtask.h \
src/internals/mousewheelzoomtype.h \
src/internals/pointlatlng.h \
src/internals/pureprojection.h \
src/internals/rectangle.h \
src/internals/rectlatlng.h \
src/internals/sizelatlng.h \
src/internals/tile.h \
src/internals/tilematrix.h \
src/mapwidget/configuration.h \
src/mapwidget/gpsitem.h \
src/mapwidget/homeitem.h \
src/mapwidget/mapgraphicitem.h \
src/mapwidget/mapripform.h \
src/mapwidget/mapripper.h \
src/mapwidget/opmapwidget.h \
src/mapwidget/trailitem.h \
src/mapwidget/traillineitem.h \
src/mapwidget/uavitem.h \
src/mapwidget/uavmapfollowtype.h \
src/mapwidget/uavtrailtype.h \
src/mapwidget/waypointitem.h \
src/internals/projections/lks94projection.h \
src/internals/projections/mercatorprojection.h \
src/internals/projections/mercatorprojectionyandex.h \
src/internals/projections/platecarreeprojection.h \
src/internals/projections/platecarreeprojectionpergo.h
FORMS += src/mapwidget/mapripform.ui
SOURCES += src/core/alllayersoftype.cpp \
src/core/cache.cpp \
src/core/cacheitemqueue.cpp \
src/core/diagnostics.cpp \
src/core/kibertilecache.cpp \
src/core/languagetype.cpp \
src/core/memorycache.cpp \
src/core/opmaps.cpp \
src/core/placemark.cpp \
src/core/point.cpp \
src/core/providerstrings.cpp \
src/core/pureimage.cpp \
src/core/pureimagecache.cpp \
src/core/rawtile.cpp \
src/core/size.cpp \
src/core/tilecachequeue.cpp \
src/core/urlfactory.cpp \
src/internals/core.cpp \
src/internals/loadtask.cpp \
src/internals/MouseWheelZoomType.cpp \
src/internals/pointlatlng.cpp \
src/internals/pureprojection.cpp \
src/internals/rectangle.cpp \
src/internals/rectlatlng.cpp \
src/internals/sizelatlng.cpp \
src/internals/tile.cpp \
src/internals/tilematrix.cpp \
src/mapwidget/configuration.cpp \
src/mapwidget/gpsitem.cpp \
src/mapwidget/homeitem.cpp \
src/mapwidget/mapgraphicitem.cpp \
src/mapwidget/mapripform.cpp \
src/mapwidget/mapripper.cpp \
src/mapwidget/opmapwidget.cpp \
src/mapwidget/trailitem.cpp \
src/mapwidget/traillineitem.cpp \
src/mapwidget/uavitem.cpp \
src/mapwidget/waypointitem.cpp \
src/internals/projections/lks94projection.cpp \
src/internals/projections/mercatorprojection.cpp \
src/internals/projections/mercatorprojectionyandex.cpp \
src/internals/projections/platecarreeprojection.cpp \
src/internals/projections/platecarreeprojectionpergo.cpp
RESOURCES += src/mapwidget/mapresources.qrc
DESTDIR = ../build
QT += network
QT += sql
CONFIG += staticlib
TEMPLATE = lib
UI_DIR = uics
MOC_DIR = mocs
OBJECTS_DIR = objs
INCLUDEPATH +=../../../../libs/
/**
******************************************************************************
*
* @file accessmode.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ACCESSMODE_H
#define ACCESSMODE_H
#include "debugheader.h"
#include <QObject>
#include <QMetaObject>
#include <QMetaEnum>
#include <QStringList>
namespace core {
class AccessMode:public QObject
{
Q_OBJECT
Q_ENUMS(Types)
public:
enum Types
{
/// <summary>
/// access only server
/// </summary>
ServerOnly,
/// <summary>
/// access first server and caches localy
/// </summary>
ServerAndCache,
/// <summary>
/// access only cache
/// </summary>
CacheOnly
};
static QString StrByType(Types const& value)
{
QMetaObject metaObject = AccessMode().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
QString s=metaEnum.valueToKey(value);
return s;
}
static Types TypeByStr(QString const& value)
{
QMetaObject metaObject = AccessMode().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
return s;
}
static QStringList TypesList()
{
QStringList ret;
QMetaObject metaObject = AccessMode().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
for(int x=0;x<metaEnum.keyCount();++x)
{
ret.append(metaEnum.key(x));
}
return ret;
}
};
}
#endif // ACCESSMODE_H
/**
******************************************************************************
*
* @file alllayersoftype.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "alllayersoftype.h"
namespace core {
AllLayersOfType::AllLayersOfType()
{
}
QVector<MapType::Types> AllLayersOfType::GetAllLayersOfType(const MapType::Types &type)
{
QVector<MapType::Types> types;
{
switch(type)
{
case MapType::GoogleHybrid:
{
types.append(MapType::GoogleSatellite);
types.append(MapType::GoogleLabels);
}
break;
case MapType::GoogleHybridChina:
{
types.append(MapType::GoogleSatelliteChina);
types.append(MapType::GoogleLabelsChina);
}
break;
case MapType::GoogleHybridKorea:
{
types.append(MapType::GoogleSatelliteKorea);
types.append(MapType::GoogleLabelsKorea);
}
break;
case MapType::YahooHybrid:
{
types.append(MapType::YahooSatellite);
types.append(MapType::YahooLabels);
}
break;
case MapType::ArcGIS_MapsLT_Map_Hybrid:
{
types.append(MapType::ArcGIS_MapsLT_OrtoFoto);
types.append(MapType::ArcGIS_MapsLT_Map_Labels);
}
break;
default:
{
types.append(type);
}
break;
}
}
return types;
}
}
/**
******************************************************************************
*
* @file alllayersoftype.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef ALLLAYERSOFTYPE_H
#define ALLLAYERSOFTYPE_H
#include "maptype.h"
#include <QList>
#include <QVector>
namespace core {
class AllLayersOfType
{
public:
AllLayersOfType();
QVector<MapType::Types> GetAllLayersOfType(const MapType::Types &type);
};
}
#endif // ALLLAYERSOFTYPE_H
/**
******************************************************************************
*
* @file cache.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "cache.h"
#include "utils/pathutils.h"
#include <QSettings>
namespace core {
Cache* Cache::m_pInstance=0;
Cache* Cache::Instance()
{
if(!m_pInstance)
m_pInstance=new Cache;
return m_pInstance;
}
void Cache::setCacheLocation(const QString& value)
{
cache=value;
routeCache = cache + "RouteCache" + QDir::separator();
geoCache = cache + "GeocoderCache"+ QDir::separator();
placemarkCache = cache + "PlacemarkCache" + QDir::separator();
ImageCache.setGtileCache(value);
}
QString Cache::CacheLocation()
{
return cache;
}
Cache::Cache()
{
if(cache.isNull()|cache.isEmpty())
{
cache= Utils::PathUtils().GetStoragePath()+"mapscache"+QDir::separator();
setCacheLocation(cache);
}
}
QString Cache::GetGeocoderFromCache(const QString &urlEnd)
{
#ifdef DEBUG_GetGeocoderFromCache
qDebug()<<"Entered GetGeocoderFromCache";
#endif
QString ret=QString::null;
QString filename=geoCache+QString(urlEnd)+".geo";
#ifdef DEBUG_GetGeocoderFromCache
qDebug()<<"GetGeocoderFromCache: Does file exist?:"<<filename;
#endif
QFileInfo File(filename);
if (File .exists())
{
#ifdef DEBUG_GetGeocoderFromCache
qDebug()<<"GetGeocoderFromCache:File exists!!";
#endif
QFile file(filename);
if (file.open(QIODevice::ReadOnly))
{
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream>>ret;
}
}
#ifdef DEBUG_GetGeocoderFromCache
qDebug()<<"GetGeocoderFromCache:Returning:"<<ret;
#endif
return ret;
}
void Cache::CacheGeocoder(const QString &urlEnd, const QString &content)
{
QString ret=QString::null;
QString filename=geoCache+QString(urlEnd)+".geo";
#ifdef DEBUG_CACHE
qDebug()<<"CacheGeocoder: Filename:"<<filename;
#endif //DEBUG_CACHE
QFileInfo File(filename);;
QDir dir=File.absoluteDir();
QString path=dir.absolutePath();
#ifdef DEBUG_CACHE
qDebug()<<"CacheGeocoder: Path:"<<path;
#endif //DEBUG_CACHE
if(!dir.exists())
{
#ifdef DEBUG_CACHE
qDebug()<<"CacheGeocoder: Cache path doesn't exist, try to create";
#endif //DEBUG_CACHE
if(!dir.mkpath(path))
{
#ifdef DEBUG_CACHE
qDebug()<<"GetGeocoderFromCache: Could not create path";
#endif //DEBUG_CACHE
}
}
#ifdef DEBUG_CACHE
qDebug()<<"CacheGeocoder: OpenFile:"<<filename;
#endif //DEBUG_CACHE
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
{
#ifdef DEBUG_CACHE
qDebug()<<"CacheGeocoder: File Opened!!!:"<<filename;
#endif //DEBUG_CACHE
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream<<content;
}
}
QString Cache::GetPlacemarkFromCache(const QString &urlEnd)
{
#ifdef DEBUG_CACHE
qDebug()<<"Entered GetPlacemarkFromCache";
#endif //DEBUG_CACHE
QString ret=QString::null;
QString filename=placemarkCache+QString(urlEnd)+".plc";
#ifdef DEBUG_CACHE
qDebug()<<"GetPlacemarkFromCache: Does file exist?:"<<filename;
#endif //DEBUG_CACHE
QFileInfo File(filename);
if (File .exists())
{
#ifdef DEBUG_CACHE
qDebug()<<"GetPlacemarkFromCache:File exists!!";
#endif //DEBUG_CACHE
QFile file(filename);
if (file.open(QIODevice::ReadOnly))
{
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream>>ret;
}
}
#ifdef DEBUG_CACHE
qDebug()<<"GetPlacemarkFromCache:Returning:"<<ret;
#endif //DEBUG_CACHE
return ret;
}
void Cache::CachePlacemark(const QString &urlEnd, const QString &content)
{
QString ret=QString::null;
QString filename=placemarkCache+QString(urlEnd)+".plc";
#ifdef DEBUG_CACHE
qDebug()<<"CachePlacemark: Filename:"<<filename;
#endif //DEBUG_CACHE
QFileInfo File(filename);;
QDir dir=File.absoluteDir();
QString path=dir.absolutePath();
#ifdef DEBUG_CACHE
qDebug()<<"CachePlacemark: Path:"<<path;
#endif //DEBUG_CACHE
if(!dir.exists())
{
#ifdef DEBUG_CACHE
qDebug()<<"CachePlacemark: Cache path doesn't exist, try to create";
#endif //DEBUG_CACHE
if(!dir.mkpath(path))
{
#ifdef DEBUG_CACHE
qDebug()<<"CachePlacemark: Could not create path";
#endif //DEBUG_CACHE
}
}
#ifdef DEBUG_CACHE
qDebug()<<"CachePlacemark: OpenFile:"<<filename;
#endif //DEBUG_CACHE
QFile file(filename);
if (file.open(QIODevice::WriteOnly))
{
#ifdef DEBUG_CACHE
qDebug()<<"CachePlacemark: File Opened!!!:"<<filename;
#endif //DEBUG_CACHE
QTextStream stream(&file);
stream.setCodec("UTF-8");
stream<<content;
}
}
}
/**
******************************************************************************
*
* @file cache.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief
* @see The GNU Public License (GPL) Version 3
* @defgroup OPMapWidget
* @{
*
*****************************************************************************/
/*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA