Commit 812ee272 authored by Don Gagne's avatar Don Gagne
Browse files

Cut over 100% to new Map/Mission code

- Delete all old map code
parent 782af62d
/**
******************************************************************************
*
* @file size.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 "size.h"
namespace core {
Size::Size():width(0),height(0)
{}
}
/**
******************************************************************************
*
* @file size.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 SIZE_H
#define SIZE_H
#include "point.h"
#include <QString>
#include <QHash>
namespace core {
struct Size
{
Size();
Size(Point pt){width=pt.X(); height=pt.Y();};
Size(int Width,int Height){width=Width; height=Height;};
friend uint qHash(Size const& size);
// friend bool operator==(Size const& lhs,Size const& rhs);
Size operator-(const Size &sz1){return Size(width-sz1.width,height-sz1.height);}
Size operator+(const Size &sz1){return Size(sz1.width+width,sz1.height+height);}
int GetHashCode(){return width^height;}
uint qHash(Size const& /*rect*/){return width^height;}
QString ToString(){return "With="+QString::number(width)+" ,Height="+QString::number(height);}
int Width()const {return width;}
int Height()const {return height;}
void SetWidth(int const& value){width=value;}
void SetHeight(int const& value){height=value;}
private:
int width;
int height;
};
}
#endif // SIZE_H
/**
******************************************************************************
*
* @file tilecachequeue.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 "tilecachequeue.h"
//#define DEBUG_TILECACHEQUEUE
#ifndef DEBUG_TILECACHEQUEUE
#undef qDebug
#define qDebug QT_NO_QDEBUG_MACRO
#endif
namespace core {
TileCacheQueue::TileCacheQueue()
{
}
TileCacheQueue::~TileCacheQueue()
{
quit();
_waitc.wakeAll();
wait();
this->deleteLater();
}
void TileCacheQueue::EnqueueCacheTask(CacheItemQueue *task)
{
qDebug()<<"DB Do I EnqueueCacheTask"<<task->GetPosition().X()<<","<<task->GetPosition().Y();
if(!_tileCacheQueue.contains(task)) {
qDebug()<<"EnqueueCacheTask"<<task->GetPosition().X()<<","<<task->GetPosition().Y();
_mutex.lock();
_tileCacheQueue.enqueue(task);
_mutex.unlock();
if(this->isRunning()) {
qDebug()<<"Wake Thread";
_waitc.wakeAll();
} else {
qDebug()<<"Start Thread";
this->start(QThread::NormalPriority);
}
}
}
void TileCacheQueue::run()
{
qDebug()<<"Cache Engine Start";
while(true) {
CacheItemQueue *task = NULL;
qDebug() << "Cache";
if(_tileCacheQueue.count() > 0) {
_mutex.lock();
task = _tileCacheQueue.dequeue();
_mutex.unlock();
Q_ASSERT(task);
qDebug() << "Cache engine Put:" << task->GetPosition().X() << "," << task->GetPosition().Y();
Cache* cache = Cache::Instance();
if(cache) {
cache->ImageCache.PutImageToCache(task->GetImg(), task->GetMapType(), task->GetPosition(), task->GetZoom());
}
usleep(44);
delete task;
} else {
qDebug() << "Cache engine BEGIN WAIT";
_waitmutex.lock();
_waitc.wait(&_waitmutex);
qDebug() << "Cache engine WOKE UP";
if(!this->isRunning()) {
_waitmutex.unlock();
break;
}
_waitmutex.unlock();
}
}
qDebug() << "Cache Engine Stopped";
}
}
/**
******************************************************************************
*
* @file tilecachequeue.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 TILECACHEQUEUE_H
#define TILECACHEQUEUE_H
#include <QQueue>
#include "cacheitemqueue.h"
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QObject>
#include <QMutexLocker>
#include "pureimagecache.h"
#include "cache.h"
namespace core {
class TileCacheQueue:public QThread
{
Q_OBJECT
public:
TileCacheQueue();
~TileCacheQueue();
void EnqueueCacheTask(CacheItemQueue *task);
private:
void run();
QMutex _mutex;
QMutex _waitmutex;
QWaitCondition _waitc;
QQueue<CacheItemQueue*> _tileCacheQueue;
};
}
#endif // TILECACHEQUEUE_H
This diff is collapsed.
/**
******************************************************************************
*
* @file urlfactory.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 URLFACTORY_H
#define URLFACTORY_H
#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QNetworkAccessManager>
#include <QUrl>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QTimer>
#include <QCoreApplication>
#include "providerstrings.h"
#include "pureimagecache.h"
#include "../internals/pointlatlng.h"
#include "geodecoderstatus.h"
#include <QTime>
#include "cache.h"
#include "placemark.h"
#include <QTextCodec>
#include "cmath"
namespace core {
class UrlFactory: public QObject,public ProviderStrings
{
Q_OBJECT
public:
/// <summary>
/// Gets or sets the value of the User-agent HTTP header.
/// </summary>
QByteArray UserAgent;
QNetworkProxy Proxy;
UrlFactory();
~UrlFactory();
QString MakeImageUrl(const MapType::Types &type,const core::Point &pos,const int &zoom,const QString &language);
internals::PointLatLng GetLatLngFromGeodecoder(const QString &keywords,GeoCoderStatusCode::Types &status);
Placemark GetPlacemarkFromGeocoder(internals::PointLatLng location);
int Timeout;
private:
int Random(int low, int high);
void GetSecGoogleWords(const core::Point &pos, QString &sec1, QString &sec2);
int GetServerNum(const core::Point &pos,const int &max) const;
void TryCorrectGoogleVersions();
bool isCorrectedGoogleVersions;
QString TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const;
bool CorrectGoogleVersions;
bool UseGeocoderCache; //TODO GetSet
bool UsePlacemarkCache;//TODO GetSet
static const double EarthRadiusKm;
double GetDistance(internals::PointLatLng p1,internals::PointLatLng p2);
QMutex mutex;
protected:
static short timelapse;
QString LanguageStr;
bool IsCorrectGoogleVersions();
void setIsCorrectGoogleVersions(bool value);
QString MakeGeocoderUrl(QString keywords);
QString MakeReverseGeocoderUrl(internals::PointLatLng &pt,const QString &language);
internals::PointLatLng GetLatLngFromGeocoderUrl(const QString &url,const bool &useCache, GeoCoderStatusCode::Types &status);
Placemark GetPlacemarkFromReverseGeocoderUrl(const QString &url,const bool &useCache);
};
}
#endif // URLFACTORY_H
/**
******************************************************************************
*
* @file MouseWheelZoomType.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 "mousewheelzoomtype.h"
namespace internals {
}
/**
******************************************************************************
*
* @file copyrightstrings.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 COPYRIGHTSTRINGS_H
#define COPYRIGHTSTRINGS_H
#include <QString>
#include <QDateTime>
namespace internals {
static const QString googleCopyright = QString("(c)%1 Google - Map data (c)%1 Tele Atlas, Imagery (c)%1 TerraMetrics").arg(QDate::currentDate().year());
static const QString openStreetMapCopyright = QString("(c) OpenStreetMap - Map data (c)%1 OpenStreetMap").arg(QDate::currentDate().year());
static const QString yahooMapCopyright = QString("(c) Yahoo! Inc. - Map data & Imagery (c)%1 NAVTEQ").arg(QDate::currentDate().year());
static const QString virtualEarthCopyright = QString("(c)%1 Microsoft Corporation, (c)%1 NAVTEQ, (c)%1 Image courtesy of NASA").arg(QDate::currentDate().year());
static const QString arcGisCopyright = QString("(c)%1 ESRI - Map data (c)%1 ArcGIS").arg(QDate::currentDate().year());
}
#endif // COPYRIGHTSTRINGS_H
This diff is collapsed.
/**
******************************************************************************
*
* @file core.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 CORE_H
#define CORE_H
#include "debugheader.h"
#include "../internals/pointlatlng.h"
#include "mousewheelzoomtype.h"
#include "../core/size.h"
#include "../core/point.h"
#include "../core/maptype.h"
#include "rectangle.h"
#include "QThreadPool"
#include "tilematrix.h"
#include <QQueue>
#include "loadtask.h"
#include "copyrightstrings.h"
#include "rectlatlng.h"
#include "../internals/projections/lks94projection.h"
#include "../internals/projections/mercatorprojection.h"
#include "../internals/projections/mercatorprojectionyandex.h"
#include "../internals/projections/platecarreeprojection.h"
#include "../internals/projections/platecarreeprojectionpergo.h"
#include "../core/geodecoderstatus.h"
#include "../core/opmaps.h"
#include "../core/diagnostics.h"
#include <QSemaphore>
#include <QThread>
#include <QDateTime>
#include <QObject>
namespace mapcontrol
{
class OPMapControl;
class MapGraphicItem;
}
namespace internals {
class Core:public QObject,public QRunnable
{
Q_OBJECT
friend class mapcontrol::OPMapControl;
friend class mapcontrol::MapGraphicItem;
public:
Core();
~Core();
void run();
PointLatLng CurrentPosition()const{return currentPosition;}
void SetCurrentPosition(const PointLatLng &value);
core::Point GetcurrentPositionGPixel(){return currentPositionPixel;}
void SetcurrentPositionGPixel(const core::Point &value){currentPositionPixel=value;}
core::Point GetrenderOffset(){return renderOffset;}
void SetrenderOffset(const core::Point &value){renderOffset=value;}
core::Point GetcenterTileXYLocation(){return centerTileXYLocation;}
void SetcenterTileXYLocation(const core::Point &value){centerTileXYLocation=value;}
core::Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;}
void SetcenterTileXYLocationLast(const core::Point &value){centerTileXYLocationLast=value;}
core::Point GetdragPoint(){return dragPoint;}
void SetdragPoint(const core::Point &value){dragPoint=value;}
core::Point GetmouseDown(){return mouseDown;}
void SetmouseDown(const core::Point &value){mouseDown=value;}
core::Point GetmouseCurrent(){return mouseCurrent;}
void SetmouseCurrent(const core::Point &value){mouseCurrent=value;}
core::Point GetmouseLastZoom(){return mouseLastZoom;}
void SetmouseLastZoom(const core::Point &value){mouseLastZoom=value;}
MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;}
void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;}
PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
Size GetsizeOfMapArea(){return sizeOfMapArea;}
void SetsizeOfMapArea(const Size &value){sizeOfMapArea=value;}
Size GetminOfTiles(){return minOfTiles;}
void SetminOfTiles(const Size &value){minOfTiles=value;}
Size GetmaxOfTiles(){return maxOfTiles;}
void SetmaxOfTiles(const Size &value){maxOfTiles=value;}
Rectangle GettileRect(){return tileRect;}
void SettileRect(const Rectangle &value){tileRect=value;}
core::Point GettilePoint(){return tilePoint;}
void SettilePoint(const core::Point &value){tilePoint=value;}
Rectangle GetCurrentRegion(){return CurrentRegion;}
void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
QList<core::Point> tileDrawingList;
PureProjection* Projection()
{
return projection;
}
void SetProjection(PureProjection* value)
{
if (projection) {
delete projection;
}
projection=value;
tileRect=Rectangle(core::Point(0,0),value->TileSize());
}
bool IsDragging()const{return isDragging;}
int Zoom()const{return zoom;}
void SetZoom(int const& value);
int MaxZoom()const{return maxzoom;}
void UpdateBounds();
MapType::Types GetMapType(){return mapType;}
void SetMapType(MapType::Types const& value);
void StartSystem();
void UpdateCenterTileXYLocation();
void OnMapSizeChanged(int const& width, int const& height);//TODO had as slot
void OnMapClose();//TODO had as slot
GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys);
RectLatLng CurrentViewArea();
PointLatLng FromLocalToLatLng(int const& x, int const& y);
Point FromLatLngToLocal(PointLatLng const& latlng);
int GetMaxZoomToFitRect(RectLatLng const& rect);
void BeginDrag(core::Point const& pt);
void EndDrag();
void ReloadMap();
void GoToCurrentPosition();
bool MouseWheelZooming;
void DragOffset(core::Point const& offset);
void Drag(core::Point const& pt);
void CancelAsyncTasks();
void FindTilesAround(QList<core::Point> &list);
void UpdateGroundResolution();
TileMatrix Matrix;
bool isStarted(){return started;}
diagnostics GetDiagnostics();
signals:
void OnCurrentPositionChanged(internals::PointLatLng point);
void OnTileLoadComplete();
void OnTilesStillToLoad(int number);
void OnTileLoadStart();
void OnMapDrag();
void OnMapZoomChanged();
void OnMapTypeChanged(MapType::Types type);
void OnEmptyTileError(int zoom, core::Point pos);
void OnNeedInvalidation();
private:
PointLatLng currentPosition;
core::Point currentPositionPixel;
core::Point renderOffset;
core::Point centerTileXYLocation;
core::Point centerTileXYLocationLast;
core::Point dragPoint;
Rectangle tileRect;
core::Point mouseDown;
bool CanDragMap;
core::Point mouseCurrent;
PointLatLng LastLocationInBounds;
core::Point mouseLastZoom;
MouseWheelZoomType::Types mousewheelzoomtype;
Size sizeOfMapArea;
Size minOfTiles;
Size maxOfTiles;
core::Point tilePoint;
Rectangle CurrentRegion;
QQueue<LoadTask> tileLoadQueue;
int zoom;
PureProjection* projection;
bool isDragging;
QMutex MtileLoadQueue;
QMutex Moverlays;
QMutex MtileDrawingList;
#ifdef DEBUG_CORE
QMutex Mdebug;
static qlonglong debugcounter;
#endif
Size TooltipTextPadding;
MapType::Types mapType;
QSemaphore loaderLimit;
QThreadPool ProcessLoadTaskCallback;
QMutex MtileToload;
int tilesToload;
int maxzoom;
QMutex MrunningThreads;
int runningThreads;
diagnostics diag;
protected:
bool started;
int Width;
int Height;
int pxRes100m; // 100 meters
int pxRes1000m; // 1km
int pxRes10km; // 10km
int pxRes100km; // 100km
int pxRes1000km; // 1000km
int pxRes5000km; // 5000km
void SetCurrentPositionGPixel(core::Point const& value){currentPositionPixel = value;}
void GoToCurrentPositionOnZoom();
};
}
#endif // CORE_H
#ifndef DEBUGHEADER_H
#define DEBUGHEADER_H
//#define DEBUG_CORE
//#define DEBUG_TILE
//#define DEBUG_TILEMATRIX
#endif // DEBUGHEADER_H
include (../common.pri)
HEADERS += core.h \
mousewheelzoomtype.h \
rectangle.h \
tile.h \
tilematrix.h \
loadtask.h \
copyrightstrings.h \
pureprojection.h \
pointlatlng.h \
rectlatlng.h \
sizelatlng.h \
debugheader.h
SOURCES += core.cpp \
rectangle.cpp \
tile.cpp \
tilematrix.cpp \
pureprojection.cpp \
rectlatlng.cpp \
sizelatlng.cpp \
pointlatlng.cpp \
loadtask.cpp \
mousewheelzoomtype.cpp
HEADERS += ./projections/lks94projection.h \
./projections/mercatorprojection.h \
./projections/mercatorprojectionyandex.h \
./projections/platecarreeprojection.h \
./projections/platecarreeprojectionpergo.h
SOURCES += ./projections/lks94projection.cpp \
./projections/mercatorprojection.cpp \
./projections/mercatorprojectionyandex.cpp \
./projections/platecarreeprojection.cpp \
./projections/platecarreeprojectionpergo.cpp
LIBS += -L../build \
-lcore
/**
******************************************************************************
*
* @file loadtask.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 "loadtask.h"
namespace internals {
bool operator==(LoadTask const& lhs,LoadTask const& rhs)
{
return ((lhs.Pos==rhs.Pos)&&(lhs.Zoom==rhs.Zoom));
}
}
/**
******************************************************************************
*
* @file loadtask.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 LOADTASK_H
#define LOADTASK_H
#include <QString>
#include "../core/point.h"
using namespace core;
namespace internals
{
struct LoadTask
{
friend bool operator==(LoadTask const& lhs,LoadTask const& rhs);
public:
core::Point Pos;
int Zoom;
LoadTask(Point pos, int zoom)
{
Pos = pos;
Zoom = zoom;
}
LoadTask()
{
Pos=core::Point(-1,-1);
Zoom=-1;
}
bool HasValue()
{
return !(Zoom==-1);
}
QString ToString()const
{
return QString::number(Zoom) + " - " + Pos.ToString();
}
};
}
#endif // LOADTASK_H
/**
******************************************************************************
*
* @file mousewheelzoomtype.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 MOUSEWHEELZOOMTYPE_H
#define MOUSEWHEELZOOMTYPE_H
#include <QObject>
#include <QStringList>
#include <QMetaType>
#include <QMetaObject>
#include <QMetaEnum>
namespace internals {
class MouseWheelZoomType:public QObject
{
Q_OBJECT
Q_ENUMS(Types)
public:
enum Types
{
/// <summary>
/// zooms map to current mouse position and makes it map center
/// </summary>
MousePositionAndCenter,
/// <summary>
/// zooms to current mouse position, but doesn't make it map center,
/// google/bing style ;}
/// </summary>
MousePositionWithoutCenter,
/// <summary>
/// zooms map to current view center
/// </summary>
ViewCenter
};
static QString StrByType(Types const& value)
{
QMetaObject metaObject = MouseWheelZoomType().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
QString s=metaEnum.valueToKey(value);
return s;
}
static Types TypeByStr(QString const& value)
{
QMetaObject metaObject = MouseWheelZoomType().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
Types s=(Types)metaEnum.keyToValue(value.toLatin1());
return s;
}
static QStringList TypesList()
{
QStringList ret;
QMetaObject metaObject = MouseWheelZoomType().staticMetaObject;
QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
for(int x=0;x<metaEnum.keyCount();++x)
{
ret.append(metaEnum.key(x));
}
return ret;
}
};
}
Q_DECLARE_METATYPE(internals::MouseWheelZoomType::Types)
#endif // MOUSEWHEELZOOMTYPE_H
/**
******************************************************************************
*
* @file pointlatlng.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 "pointlatlng.h"
namespace internals {
PointLatLng PointLatLng::Empty=PointLatLng();
PointLatLng::PointLatLng():lat(0),lng(0),empty(true)
{
}
bool operator==(PointLatLng const& lhs,PointLatLng const& rhs)
{
return ((lhs.Lng() == rhs.Lng()) && (lhs.Lat() == rhs.Lat()));
}
bool operator!=(PointLatLng const& left, PointLatLng const& right)
{
return !(left == right);
}
PointLatLng operator+(PointLatLng pt, SizeLatLng sz)
{
return PointLatLng::Add(pt, sz);
}
PointLatLng operator-(PointLatLng pt, SizeLatLng sz)
{
return PointLatLng::Subtract(pt, sz);
}
}
This diff is collapsed.
/**
******************************************************************************
*
* @file lks94projection.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 LKS94PROJECTION_H
#define LKS94PROJECTION_H
#include <QVector>
#include "cmath"
#include "../pureprojection.h"
namespace projections {
class LKS94Projection:public internals::PureProjection
{
public:
LKS94Projection();
double GetTileMatrixResolution(int const& zoom);
virtual QString Type(){return "LKS94Projection";}
virtual Size TileSize() const;
virtual double Axis() const;
virtual double Flattening() const;
virtual core::Point FromLatLngToPixel(double lat, double lng, int const& zoom);
virtual internals::PointLatLng FromPixelToLatLng(int const& x, int const& y, int const& zoom);
virtual double GetGroundResolution(int const& zoom, double const& latitude);
virtual Size GetTileMatrixMinXY(int const& zoom);
virtual Size GetTileMatrixMaxXY(int const& zoom);
private:
const double MinLatitude;
const double MaxLatitude;
const double MinLongitude;
const double MaxLongitude;
const double orignX;
const double orignY;
Size tileSize;
QVector <double> DTM10(const QVector <double>& lonlat);
QVector <double> MTD10(QVector <double>& pnt);
QVector <double> DTM00(QVector <double>& lonlat);
QVector <double> DTM01(QVector <double>& lonlat);
QVector <double> MTD01(QVector <double>& pnt);
QVector <double> MTD11(QVector <double>& p);
double Clip(double const& n, double const& minValue, double const& maxValue);
};
}
#endif // LKS94PROJECTION_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment