mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-08 16:24:28 +02:00
Compare commits
62 Commits
Author | SHA1 | Date | |
---|---|---|---|
494a8a6da1 | |||
47206316b7 | |||
fe69280cc5 | |||
ff3c0aafa1 | |||
2fb2beecda | |||
432ca35df9 | |||
301172f5e8 | |||
20956625db | |||
273fe51dcd | |||
e4098e6dfb | |||
747acf1580 | |||
738b49668c | |||
48674bb50b | |||
6d054c76f9 | |||
40578d0dee | |||
a16354a6ba | |||
44862cebcc | |||
ef5cfde22b | |||
019bd4de10 | |||
9c6ffed35e | |||
d7a55b3f9c | |||
a9327d2cca | |||
c059cbb848 | |||
3b3559eacf | |||
f071e88bd0 | |||
8bec307e03 | |||
3204723614 | |||
c688b5fc09 | |||
94bca87982 | |||
3f97d12a76 | |||
ab7aa63a33 | |||
4de22d6679 | |||
c58a52e362 | |||
5b2af9fc9c | |||
4eb54ed8f2 | |||
681c83d017 | |||
dbd8750524 | |||
d9489935df | |||
f5d2ccfdb9 | |||
1afd59902b | |||
a253147760 | |||
667a1c350d | |||
d7a9464e37 | |||
d1be147f64 | |||
98708f11ac | |||
c5605eeab1 | |||
f29ac69594 | |||
49101cba6c | |||
c1f746b32a | |||
704be7baf9 | |||
3c6ec704ab | |||
bf6b6fb100 | |||
56a2618f29 | |||
785bf94a01 | |||
3747ae6afc | |||
1f5a051bee | |||
268c42ab03 | |||
8a8595d98e | |||
37c971a720 | |||
f0d71d667b | |||
f652457f19 | |||
1acf603076 |
@ -1,4 +1,4 @@
|
|||||||
version: 7.6.{build}
|
version: 7.8.{build}
|
||||||
configuration: Release
|
configuration: Release
|
||||||
platform: Any CPU
|
platform: Any CPU
|
||||||
environment:
|
environment:
|
||||||
|
@ -4,7 +4,7 @@ GPXSee is a Qt-based GPS log file viewer and analyzer that supports all common G
|
|||||||
## Features
|
## Features
|
||||||
* Opens GPX, TCX, FIT, KML, IGC, NMEA, SLF, LOC, GeoJSON, OziExplorer (PLT, RTE, WPT), Garmin CSV and geotagged JPEG files.
|
* Opens GPX, TCX, FIT, KML, IGC, NMEA, SLF, LOC, GeoJSON, OziExplorer (PLT, RTE, WPT), Garmin CSV and geotagged JPEG files.
|
||||||
* User-definable online maps (OpenStreetMap/Google tiles, WMTS, WMS, TMS).
|
* User-definable online maps (OpenStreetMap/Google tiles, WMTS, WMS, TMS).
|
||||||
* Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases, Garmin JNX maps, TwoNav RMaps, GeoTIFF images).
|
* Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases, Garmin IMG & JNX maps, TwoNav RMaps, GeoTIFF images).
|
||||||
* Elevation, speed, heart rate, cadence, power, temperature and gear ratio/shifts graphs.
|
* Elevation, speed, heart rate, cadence, power, temperature and gear ratio/shifts graphs.
|
||||||
* Support for DEM files (SRTM HGT).
|
* Support for DEM files (SRTM HGT).
|
||||||
* Support for multiple tracks in one view.
|
* Support for multiple tracks in one view.
|
||||||
|
11
gpxsee.pro
11
gpxsee.pro
@ -3,7 +3,7 @@ unix:!macx {
|
|||||||
} else {
|
} else {
|
||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
}
|
}
|
||||||
VERSION = 7.6
|
VERSION = 7.8
|
||||||
|
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
@ -177,7 +177,9 @@ HEADERS += src/common/config.h \
|
|||||||
src/map/IMG/subdiv.h \
|
src/map/IMG/subdiv.h \
|
||||||
src/map/IMG/units.h \
|
src/map/IMG/units.h \
|
||||||
src/map/IMG/style.h \
|
src/map/IMG/style.h \
|
||||||
src/map/IMG/netfile.h
|
src/map/IMG/netfile.h \
|
||||||
|
src/GUI/limitedcombobox.h \
|
||||||
|
src/GUI/pathtickitem.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/common/coordinates.cpp \
|
src/common/coordinates.cpp \
|
||||||
src/common/rectc.cpp \
|
src/common/rectc.cpp \
|
||||||
@ -306,7 +308,8 @@ SOURCES += src/main.cpp \
|
|||||||
src/map/IMG/lblfile.cpp \
|
src/map/IMG/lblfile.cpp \
|
||||||
src/map/IMG/vectortile.cpp \
|
src/map/IMG/vectortile.cpp \
|
||||||
src/map/IMG/style.cpp \
|
src/map/IMG/style.cpp \
|
||||||
src/map/IMG/netfile.cpp
|
src/map/IMG/netfile.cpp \
|
||||||
|
src/GUI/pathtickitem.cpp
|
||||||
|
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||||
HEADERS += src/data/geojsonparser.h
|
HEADERS += src/data/geojsonparser.h
|
||||||
@ -388,7 +391,7 @@ win32 {
|
|||||||
|
|
||||||
unix:!macx {
|
unix:!macx {
|
||||||
isEmpty(PREFIX):PREFIX = /usr/local
|
isEmpty(PREFIX):PREFIX = /usr/local
|
||||||
lessThan(QT_MAJOR_VERSION, 5) {DEFINES += PREFIX=\\\"$$PREFIX\\\"}
|
DEFINES += PREFIX=\\\"$$PREFIX\\\"
|
||||||
|
|
||||||
maps.files = pkg/maps/*
|
maps.files = pkg/maps/*
|
||||||
maps.path = $$PREFIX/share/gpxsee/maps
|
maps.path = $$PREFIX/share/gpxsee/maps
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -7,15 +7,17 @@
|
|||||||
<name>GPXSee</name>
|
<name>GPXSee</name>
|
||||||
<summary>GPS log file viewer and analyzer</summary>
|
<summary>GPS log file viewer and analyzer</summary>
|
||||||
<description>
|
<description>
|
||||||
<p>GPXSee is a GPS log file viewer and analyzer that supports GPX, TCX,
|
<p>GPXSee is a GPS log file viewer and analyzer that supports all common
|
||||||
KML, FIT, IGC, NMEA, SLF, LOC, GeoJSON and OziExplorer files.</p>
|
GPS log file formats.</p>
|
||||||
|
|
||||||
<p>Features:</p>
|
<p>Features:</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Opens GPX, TCX, FIT, KML, IGC, NMEA, SLF, LOC, OziExplorer (PLT,
|
||||||
|
WPT, RTE), GeoJSON, Garmin CSV and geotagged JPEG files.</li>
|
||||||
<li>User-definable online maps (OpenStreetMap/Google tiles, WMTS,
|
<li>User-definable online maps (OpenStreetMap/Google tiles, WMTS,
|
||||||
WMS, TMS).</li>
|
WMS, TMS).</li>
|
||||||
<li>Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases,
|
<li>Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases,
|
||||||
GeoTIFF images).</li>
|
TwoNav RMaps, Garmin IMG & JNX, GeoTIFF images).</li>
|
||||||
<li>Elevation, speed, heart rate, cadence, power and temperature
|
<li>Elevation, speed, heart rate, cadence, power and temperature
|
||||||
graphs.</li>
|
graphs.</li>
|
||||||
<li>Support for multiple tracks in one view.</li>
|
<li>Support for multiple tracks in one view.</li>
|
||||||
@ -23,8 +25,6 @@
|
|||||||
<li>Print/export to PDF.</li>
|
<li>Print/export to PDF.</li>
|
||||||
<li>Full-screen mode.</li>
|
<li>Full-screen mode.</li>
|
||||||
<li>HiDPI/Retina displays & maps support.</li>
|
<li>HiDPI/Retina displays & maps support.</li>
|
||||||
<li>Opens GPX, TCX, FIT, KML, IGC, NMEA, SLF, LOC, OziExplorer (PLT,
|
|
||||||
WPT, RTE), GeoJSON and Garmin CSV files.</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "7.6"
|
!define VERSION "7.8"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "7.6"
|
!define VERSION "7.8"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
|
@ -29,8 +29,8 @@ private:
|
|||||||
|
|
||||||
Ticks::Ticks(double minValue, double maxValue, int maxCount)
|
Ticks::Ticks(double minValue, double maxValue, int maxCount)
|
||||||
{
|
{
|
||||||
double range = niceNum(maxValue - minValue, 0);
|
double range = niceNum(maxValue - minValue, false);
|
||||||
_d = niceNum(range / maxCount, 1);
|
_d = niceNum(range / maxCount, true);
|
||||||
_min = ceil(minValue / _d) * _d;
|
_min = ceil(minValue / _d) * _d;
|
||||||
_max = floor(maxValue / _d) * _d;
|
_max = floor(maxValue / _d) * _d;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
|
|||||||
_alpha = true;
|
_alpha = true;
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
setAttribute(Qt::WA_Hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize ColorBox::sizeHint() const
|
QSize ColorBox::sizeHint() const
|
||||||
|
@ -103,7 +103,6 @@ GUI::GUI()
|
|||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateMapView();
|
|
||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,6 +349,11 @@ void GUI::createActions()
|
|||||||
_showRouteWaypointsAction->setCheckable(true);
|
_showRouteWaypointsAction->setCheckable(true);
|
||||||
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _mapView,
|
connect(_showRouteWaypointsAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
SLOT(showRouteWaypoints(bool)));
|
SLOT(showRouteWaypoints(bool)));
|
||||||
|
_showTicksAction = new QAction(tr("km/mi markers"), this);
|
||||||
|
_showTicksAction->setMenuRole(QAction::NoRole);
|
||||||
|
_showTicksAction->setCheckable(true);
|
||||||
|
connect(_showTicksAction, SIGNAL(triggered(bool)), _mapView,
|
||||||
|
SLOT(showTicks(bool)));
|
||||||
|
|
||||||
// Graph actions
|
// Graph actions
|
||||||
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
_showGraphsAction = new QAction(QIcon(SHOW_GRAPHS_ICON), tr("Show graphs"),
|
||||||
@ -537,6 +541,7 @@ void GUI::createMenus()
|
|||||||
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
QMenu *displayMenu = dataMenu->addMenu(tr("Display"));
|
||||||
displayMenu->addAction(_showWaypointLabelsAction);
|
displayMenu->addAction(_showWaypointLabelsAction);
|
||||||
displayMenu->addAction(_showRouteWaypointsAction);
|
displayMenu->addAction(_showRouteWaypointsAction);
|
||||||
|
displayMenu->addAction(_showTicksAction);
|
||||||
dataMenu->addSeparator();
|
dataMenu->addSeparator();
|
||||||
dataMenu->addAction(_showTracksAction);
|
dataMenu->addAction(_showTracksAction);
|
||||||
dataMenu->addAction(_showRoutesAction);
|
dataMenu->addAction(_showRoutesAction);
|
||||||
@ -725,6 +730,8 @@ void GUI::paths()
|
|||||||
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ tr("DEM directory:") + "</td><td><code>"
|
+ tr("DEM directory:") + "</td><td><code>"
|
||||||
+ QDir::cleanPath(ProgramPaths::demDir(true)) + "</code></td></tr><tr><td>"
|
+ QDir::cleanPath(ProgramPaths::demDir(true)) + "</code></td></tr><tr><td>"
|
||||||
|
+ tr("Styles directory:") + "</td><td><code>"
|
||||||
|
+ QDir::cleanPath(ProgramPaths::styleDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ tr("Tile cache directory:") + "</td><td><code>"
|
+ tr("Tile cache directory:") + "</td><td><code>"
|
||||||
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
||||||
);
|
);
|
||||||
@ -805,7 +812,7 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++)
|
for (int i = 0; i < _tabs.count(); i++)
|
||||||
graphs.append(_tabs.at(i)->loadData(data));
|
graphs.append(_tabs.at(i)->loadData(data));
|
||||||
if (updateGraphTabs() | updateMapView())
|
if (updateGraphTabs())
|
||||||
_splitter->refresh();
|
_splitter->refresh();
|
||||||
paths = _mapView->loadData(data);
|
paths = _mapView->loadData(data);
|
||||||
|
|
||||||
@ -828,7 +835,6 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateMapView();
|
|
||||||
|
|
||||||
QString error = tr("Error loading data file:") + "\n\n"
|
QString error = tr("Error loading data file:") + "\n\n"
|
||||||
+ fileName + "\n\n" + data.errorString();
|
+ fileName + "\n\n" + data.errorString();
|
||||||
@ -930,6 +936,7 @@ void GUI::openOptions()
|
|||||||
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
||||||
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
||||||
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
||||||
|
SET_VIEW_OPTION(projection, setProjection);
|
||||||
|
|
||||||
SET_TAB_OPTION(palette, setPalette);
|
SET_TAB_OPTION(palette, setPalette);
|
||||||
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
||||||
@ -974,8 +981,6 @@ void GUI::openOptions()
|
|||||||
reloadFile();
|
reloadFile();
|
||||||
|
|
||||||
_options = options;
|
_options = options;
|
||||||
|
|
||||||
updateMapView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::printFile()
|
void GUI::printFile()
|
||||||
@ -1230,7 +1235,6 @@ void GUI::closeAll()
|
|||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
updateWindowTitle();
|
updateWindowTitle();
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateMapView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::showGraphs(bool show)
|
void GUI::showGraphs(bool show)
|
||||||
@ -1473,19 +1477,6 @@ bool GUI::updateGraphTabs()
|
|||||||
return (hidden != _graphTabWidget->isHidden());
|
return (hidden != _graphTabWidget->isHidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GUI::updateMapView()
|
|
||||||
{
|
|
||||||
bool hidden = _mapView->isHidden();
|
|
||||||
|
|
||||||
if (_options.alwaysShowMap)
|
|
||||||
_mapView->setHidden(false);
|
|
||||||
else
|
|
||||||
_mapView->setHidden(!(_trackCount + _routeCount + _waypointCount
|
|
||||||
+ _areaCount));
|
|
||||||
|
|
||||||
return (hidden != _mapView->isHidden());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::setTimeType(TimeType type)
|
void GUI::setTimeType(TimeType type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i <_tabs.count(); i++)
|
for (int i = 0; i <_tabs.count(); i++)
|
||||||
@ -1736,6 +1727,9 @@ void GUI::writeSettings()
|
|||||||
if (_showRouteWaypointsAction->isChecked() != SHOW_ROUTE_WAYPOINTS_DEFAULT)
|
if (_showRouteWaypointsAction->isChecked() != SHOW_ROUTE_WAYPOINTS_DEFAULT)
|
||||||
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
settings.setValue(SHOW_ROUTE_WAYPOINTS_SETTING,
|
||||||
_showRouteWaypointsAction->isChecked());
|
_showRouteWaypointsAction->isChecked());
|
||||||
|
if (_showTicksAction->isChecked() != SHOW_TICKS_DEFAULT)
|
||||||
|
settings.setValue(SHOW_TICKS_SETTING,
|
||||||
|
_showTicksAction->isChecked());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||||
@ -1847,8 +1841,8 @@ void GUI::writeSettings()
|
|||||||
_options.separateGraphPage);
|
_options.separateGraphPage);
|
||||||
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
||||||
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
||||||
if (_options.alwaysShowMap != ALWAYS_SHOW_MAP_DEFAULT)
|
if (_options.projection != PROJECTION_DEFAULT)
|
||||||
settings.setValue(ALWAYS_SHOW_MAP_SETTING, _options.alwaysShowMap);
|
settings.setValue(PROJECTION_SETTING, _options.projection);
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
||||||
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
||||||
@ -1999,6 +1993,10 @@ void GUI::readSettings()
|
|||||||
_mapView->showRouteWaypoints(false);
|
_mapView->showRouteWaypoints(false);
|
||||||
else
|
else
|
||||||
_showRouteWaypointsAction->setChecked(true);
|
_showRouteWaypointsAction->setChecked(true);
|
||||||
|
if (settings.value(SHOW_TICKS_SETTING, SHOW_TICKS_DEFAULT).toBool()) {
|
||||||
|
_mapView->showTicks(true);
|
||||||
|
_showTicksAction->setChecked(true);
|
||||||
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
settings.beginGroup(EXPORT_SETTINGS_GROUP);
|
||||||
@ -2110,8 +2108,8 @@ void GUI::readSettings()
|
|||||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||||
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
||||||
SLIDER_COLOR_DEFAULT).value<QColor>();
|
SLIDER_COLOR_DEFAULT).value<QColor>();
|
||||||
_options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING,
|
_options.projection = settings.value(PROJECTION_SETTING, PROJECTION_DEFAULT)
|
||||||
ALWAYS_SHOW_MAP_DEFAULT).toBool();
|
.toInt();
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
||||||
.toBool();
|
.toBool();
|
||||||
@ -2139,6 +2137,7 @@ void GUI::readSettings()
|
|||||||
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||||
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
_mapView->setProjection(_options.projection);
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++) {
|
for (int i = 0; i < _tabs.count(); i++) {
|
||||||
_tabs.at(i)->setPalette(_options.palette);
|
_tabs.at(i)->setPalette(_options.palette);
|
||||||
|
@ -116,7 +116,6 @@ private:
|
|||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
void updateNavigationActions();
|
void updateNavigationActions();
|
||||||
bool updateGraphTabs();
|
bool updateGraphTabs();
|
||||||
bool updateMapView();
|
|
||||||
|
|
||||||
TimeType timeType() const;
|
TimeType timeType() const;
|
||||||
Units units() const;
|
Units units() const;
|
||||||
@ -193,6 +192,7 @@ private:
|
|||||||
QAction *_showAreasAction;
|
QAction *_showAreasAction;
|
||||||
QAction *_showRouteWaypointsAction;
|
QAction *_showRouteWaypointsAction;
|
||||||
QAction *_showMarkersAction;
|
QAction *_showMarkersAction;
|
||||||
|
QAction *_showTicksAction;
|
||||||
QAction *_showCoordinatesAction;
|
QAction *_showCoordinatesAction;
|
||||||
QAction *_openOptionsAction;
|
QAction *_openOptionsAction;
|
||||||
QAction *_mapsEnd;
|
QAction *_mapsEnd;
|
||||||
|
39
src/GUI/limitedcombobox.h
Normal file
39
src/GUI/limitedcombobox.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef LIMITEDCOMBOBOX_H
|
||||||
|
#define LIMITEDCOMBOBOX_H
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
class LimitedComboBox : public QComboBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LimitedComboBox(int limit, QWidget *parent = 0)
|
||||||
|
: QComboBox(parent), _limit(limit)
|
||||||
|
{
|
||||||
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
setStyleSheet("combobox-popup: 0;");
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(qMin(_limit, QComboBox::sizeHint().width()),
|
||||||
|
QComboBox::sizeHint().height());
|
||||||
|
}
|
||||||
|
QSize minimumSizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(qMin(_limit, QComboBox::minimumSizeHint().width()),
|
||||||
|
QComboBox::minimumSizeHint().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool event(QEvent *e)
|
||||||
|
{
|
||||||
|
if (e->type() == QEvent::Polish)
|
||||||
|
view()->setMinimumWidth(QComboBox::sizeHint().width());
|
||||||
|
return QComboBox::event(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _limit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIMITEDCOMBOBOX_H
|
@ -7,6 +7,7 @@
|
|||||||
#include "data/poi.h"
|
#include "data/poi.h"
|
||||||
#include "data/data.h"
|
#include "data/data.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
|
#include "map/pcs.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
@ -48,8 +49,10 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_coordinates->setVisible(false);
|
_coordinates->setVisible(false);
|
||||||
_scene->addItem(_coordinates);
|
_scene->addItem(_coordinates);
|
||||||
|
|
||||||
|
_projection = PCS::pcs(3857);
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
|
_map->setProjection(_projection);
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
_poi = poi;
|
_poi = poi;
|
||||||
@ -72,6 +75,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_overlapPOIs = true;
|
_overlapPOIs = true;
|
||||||
_showRouteWaypoints = true;
|
_showRouteWaypoints = true;
|
||||||
_showMarkers = true;
|
_showMarkers = true;
|
||||||
|
_showPathTicks = false;
|
||||||
_trackWidth = 3;
|
_trackWidth = 3;
|
||||||
_routeWidth = 3;
|
_routeWidth = 3;
|
||||||
_trackStyle = Qt::SolidLine;
|
_trackStyle = Qt::SolidLine;
|
||||||
@ -122,6 +126,7 @@ PathItem *MapView::addTrack(const Track &track)
|
|||||||
ti->setDigitalZoom(_digitalZoom);
|
ti->setDigitalZoom(_digitalZoom);
|
||||||
ti->setMarkerColor(_markerColor);
|
ti->setMarkerColor(_markerColor);
|
||||||
ti->showMarker(_showMarkers);
|
ti->showMarker(_showMarkers);
|
||||||
|
ti->showTicks(_showPathTicks);
|
||||||
_scene->addItem(ti);
|
_scene->addItem(ti);
|
||||||
|
|
||||||
if (_showTracks)
|
if (_showTracks)
|
||||||
@ -151,6 +156,7 @@ PathItem *MapView::addRoute(const Route &route)
|
|||||||
ri->setDigitalZoom(_digitalZoom);
|
ri->setDigitalZoom(_digitalZoom);
|
||||||
ri->setMarkerColor(_markerColor);
|
ri->setMarkerColor(_markerColor);
|
||||||
ri->showMarker(_showMarkers);
|
ri->showMarker(_showMarkers);
|
||||||
|
ri->showTicks(_showPathTicks);
|
||||||
_scene->addItem(ri);
|
_scene->addItem(ri);
|
||||||
|
|
||||||
if (_showRoutes)
|
if (_showRoutes)
|
||||||
@ -312,6 +318,7 @@ void MapView::setMap(Map *map)
|
|||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
|
_map->setProjection(_projection);
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
@ -720,6 +727,15 @@ void MapView::showMarkers(bool show)
|
|||||||
_routes.at(i)->showMarker(show);
|
_routes.at(i)->showMarker(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::showTicks(bool show)
|
||||||
|
{
|
||||||
|
_showPathTicks = show;
|
||||||
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
|
_tracks.at(i)->showTicks(show);
|
||||||
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
|
_routes.at(i)->showTicks(show);
|
||||||
|
}
|
||||||
|
|
||||||
void MapView::showMap(bool show)
|
void MapView::showMap(bool show)
|
||||||
{
|
{
|
||||||
_showMap = show;
|
_showMap = show;
|
||||||
@ -1012,3 +1028,17 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
|||||||
Q_UNUSED(mapRatio);
|
Q_UNUSED(mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapView::setProjection(int id)
|
||||||
|
{
|
||||||
|
Projection projection(PCS::pcs(id));
|
||||||
|
if (!projection.isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_projection = projection;
|
||||||
|
|
||||||
|
Coordinates center = _map->xy2ll(mapToScene(viewport()->rect().center()));
|
||||||
|
_map->setProjection(_projection);
|
||||||
|
rescale();
|
||||||
|
centerOn(_map->ll2xy(center));
|
||||||
|
}
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "common/config.h"
|
#include "common/config.h"
|
||||||
#include "data/waypoint.h"
|
#include "data/waypoint.h"
|
||||||
|
#include "data/polygon.h"
|
||||||
|
#include "map/projection.h"
|
||||||
#include "searchpointer.h"
|
#include "searchpointer.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "data/polygon.h"
|
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
class POI;
|
class POI;
|
||||||
@ -77,9 +79,11 @@ public slots:
|
|||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
void showMarkers(bool show);
|
void showMarkers(bool show);
|
||||||
void showCoordinates(bool show);
|
void showCoordinates(bool show);
|
||||||
|
void showTicks(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void setCoordinatesFormat(CoordinatesFormat format);
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
|
void setProjection(int id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePOI();
|
void updatePOI();
|
||||||
@ -132,10 +136,11 @@ private:
|
|||||||
Units _units;
|
Units _units;
|
||||||
CoordinatesFormat _coordinatesFormat;
|
CoordinatesFormat _coordinatesFormat;
|
||||||
qreal _mapOpacity;
|
qreal _mapOpacity;
|
||||||
|
Projection _projection;
|
||||||
|
|
||||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||||
_showMarkers;
|
_showMarkers, _showPathTicks;
|
||||||
bool _overlapPOIs;
|
bool _overlapPOIs;
|
||||||
int _trackWidth, _routeWidth, _areaWidth;
|
int _trackWidth, _routeWidth, _areaWidth;
|
||||||
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
Qt::PenStyle _trackStyle, _routeStyle, _areaStyle;
|
||||||
|
@ -12,11 +12,14 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
|
#include <QInputDialog>
|
||||||
|
#include "map/pcs.h"
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "colorbox.h"
|
#include "colorbox.h"
|
||||||
#include "stylecombobox.h"
|
#include "stylecombobox.h"
|
||||||
#include "oddspinbox.h"
|
#include "oddspinbox.h"
|
||||||
#include "percentslider.h"
|
#include "percentslider.h"
|
||||||
|
#include "limitedcombobox.h"
|
||||||
#include "optionsdialog.h"
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
|
|
||||||
@ -36,10 +39,15 @@ static QFrame *line()
|
|||||||
|
|
||||||
QWidget *OptionsDialog::createMapPage()
|
QWidget *OptionsDialog::createMapPage()
|
||||||
{
|
{
|
||||||
_alwaysShowMap = new QCheckBox(tr("Always show the map"));
|
_projection = new LimitedComboBox(200);
|
||||||
_alwaysShowMap->setChecked(_options->alwaysShowMap);
|
QList<PCS::Info> projections(PCS::pcsList());
|
||||||
_alwaysShowMap->setToolTip("<p>" +
|
qSort(projections);
|
||||||
tr("Show the map even when no files are loaded.") + "</p>");
|
for (int i = 0; i < projections.size(); i++) {
|
||||||
|
QString text = QString::number(projections.at(i).id()) + " - "
|
||||||
|
+ projections.at(i).name();
|
||||||
|
_projection->addItem(text, QVariant(projections.at(i).id()));
|
||||||
|
}
|
||||||
|
_projection->setCurrentIndex(_projection->findData(_options->projection));
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_hidpi = new QRadioButton(tr("High-resolution"));
|
_hidpi = new QRadioButton(tr("High-resolution"));
|
||||||
@ -60,14 +68,14 @@ QWidget *OptionsDialog::createMapPage()
|
|||||||
llo->setFont(f);
|
llo->setFont(f);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
QFormLayout *showMapLayout = new QFormLayout();
|
QFormLayout *vectorLayout = new QFormLayout();
|
||||||
showMapLayout->addWidget(_alwaysShowMap);
|
vectorLayout->addRow(tr("Projection:"), _projection);
|
||||||
|
|
||||||
QWidget *mapTab = new QWidget();
|
QWidget *vectorMapsTab = new QWidget();
|
||||||
QVBoxLayout *mapTabLayout = new QVBoxLayout();
|
QVBoxLayout *vectorMapsTabLayout = new QVBoxLayout();
|
||||||
mapTabLayout->addLayout(showMapLayout);
|
vectorMapsTabLayout->addLayout(vectorLayout);
|
||||||
mapTabLayout->addStretch();
|
vectorMapsTabLayout->addStretch();
|
||||||
mapTab->setLayout(mapTabLayout);
|
vectorMapsTab->setLayout(vectorMapsTabLayout);
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
||||||
@ -83,7 +91,7 @@ QWidget *OptionsDialog::createMapPage()
|
|||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
QTabWidget *mapPage = new QTabWidget();
|
QTabWidget *mapPage = new QTabWidget();
|
||||||
mapPage->addTab(mapTab, tr("General"));
|
mapPage->addTab(vectorMapsTab, tr("Vector maps"));
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
@ -261,6 +269,7 @@ QWidget *OptionsDialog::createAppearancePage()
|
|||||||
_backgroundColor = new ColorBox();
|
_backgroundColor = new ColorBox();
|
||||||
_backgroundColor->setColor(_options->backgroundColor);
|
_backgroundColor->setColor(_options->backgroundColor);
|
||||||
_backgroundColor->enableAlphaChannel(false);
|
_backgroundColor->enableAlphaChannel(false);
|
||||||
|
|
||||||
QFormLayout *mapLayout = new QFormLayout();
|
QFormLayout *mapLayout = new QFormLayout();
|
||||||
mapLayout->addRow(tr("Background color:"), _backgroundColor);
|
mapLayout->addRow(tr("Background color:"), _backgroundColor);
|
||||||
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
|
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
|
||||||
@ -656,7 +665,8 @@ void OptionsDialog::accept()
|
|||||||
_options->sliderColor = _sliderColor->color();
|
_options->sliderColor = _sliderColor->color();
|
||||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||||
|
|
||||||
_options->alwaysShowMap = _alwaysShowMap->isChecked();
|
_options->projection = _projection->itemData(_projection->currentIndex())
|
||||||
|
.toInt();
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_options->hidpiMap = _hidpi->isChecked();
|
_options->hidpiMap = _hidpi->isChecked();
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
@ -15,6 +15,7 @@ class QComboBox;
|
|||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
class PercentSlider;
|
class PercentSlider;
|
||||||
|
class LimitedComboBox;
|
||||||
|
|
||||||
struct Options {
|
struct Options {
|
||||||
// Appearance
|
// Appearance
|
||||||
@ -37,7 +38,7 @@ struct Options {
|
|||||||
int mapOpacity;
|
int mapOpacity;
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
// Map
|
// Map
|
||||||
bool alwaysShowMap;
|
int projection;
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
bool hidpiMap;
|
bool hidpiMap;
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
@ -79,11 +80,14 @@ class OptionsDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionsDialog(Options *options, QWidget *parent = 0);
|
OptionsDialog(Options *options, QWidget *parent = 0);
|
||||||
|
|
||||||
public slots:
|
//private slots:
|
||||||
void accept();
|
// void projectionChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *createMapPage();
|
QWidget *createMapPage();
|
||||||
@ -116,7 +120,7 @@ private:
|
|||||||
ColorBox *_sliderColor;
|
ColorBox *_sliderColor;
|
||||||
QCheckBox *_graphAA;
|
QCheckBox *_graphAA;
|
||||||
// Map
|
// Map
|
||||||
QCheckBox *_alwaysShowMap;
|
LimitedComboBox *_projection;
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
QRadioButton *_hidpi;
|
QRadioButton *_hidpi;
|
||||||
QRadioButton *_lodpi;
|
QRadioButton *_lodpi;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/greatcircle.h"
|
#include "common/greatcircle.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
|
#include "pathtickitem.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
@ -23,14 +24,17 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
|||||||
{
|
{
|
||||||
Q_ASSERT(_path.isValid());
|
Q_ASSERT(_path.isValid());
|
||||||
|
|
||||||
|
_units = Metric;
|
||||||
_digitalZoom = 0;
|
_digitalZoom = 0;
|
||||||
_width = 3;
|
_width = 3;
|
||||||
QBrush brush(Qt::SolidPattern);
|
QBrush brush(Qt::SolidPattern);
|
||||||
_pen = QPen(brush, _width);
|
_pen = QPen(brush, _width);
|
||||||
_showMarker = true;
|
_showMarker = true;
|
||||||
|
_showTicks = false;
|
||||||
|
|
||||||
updatePainterPath();
|
updatePainterPath();
|
||||||
updateShape();
|
updateShape();
|
||||||
|
updateTicks();
|
||||||
|
|
||||||
_markerDistance = _path.first().first().distance();
|
_markerDistance = _path.first().first().distance();
|
||||||
_marker = new MarkerItem(this);
|
_marker = new MarkerItem(this);
|
||||||
@ -111,8 +115,7 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
painter->drawPath(_painterPath);
|
painter->drawPath(_painterPath);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QPen p = QPen(QBrush(Qt::red), 0);
|
painter->setPen(Qt::red);
|
||||||
painter->setPen(p);
|
|
||||||
painter->drawRect(boundingRect());
|
painter->drawRect(boundingRect());
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
@ -125,6 +128,7 @@ void PathItem::setMap(Map *map)
|
|||||||
|
|
||||||
updatePainterPath();
|
updatePainterPath();
|
||||||
updateShape();
|
updateShape();
|
||||||
|
updateTicks();
|
||||||
|
|
||||||
QPointF pos = position(_markerDistance);
|
QPointF pos = position(_markerDistance);
|
||||||
if (isValid(pos))
|
if (isValid(pos))
|
||||||
@ -284,6 +288,75 @@ void PathItem::showMarker(bool show)
|
|||||||
_marker->setVisible(show && isValid(position(_markerDistance)));
|
_marker->setVisible(show && isValid(position(_markerDistance)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal PathItem::xInM() const
|
||||||
|
{
|
||||||
|
return (_units == Nautical) ? NMIINM : (_units == Imperial) ? MIINM : KMINM;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned PathItem::tickSize() const
|
||||||
|
{
|
||||||
|
qreal res = _map->resolution(sceneBoundingRect());
|
||||||
|
|
||||||
|
if (res < 10)
|
||||||
|
return 1;
|
||||||
|
else if (res < 25)
|
||||||
|
return 5;
|
||||||
|
else if (res < 100)
|
||||||
|
return 10;
|
||||||
|
else if (res < 500)
|
||||||
|
return 50;
|
||||||
|
else if (res < 2000)
|
||||||
|
return 100;
|
||||||
|
else if (res < 10000)
|
||||||
|
return 500;
|
||||||
|
else if (res < 20000)
|
||||||
|
return 1000;
|
||||||
|
else
|
||||||
|
return 5000;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::updateTicks()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _ticks.size(); i++)
|
||||||
|
delete _ticks[i];
|
||||||
|
_ticks.clear();
|
||||||
|
|
||||||
|
if (!_showTicks)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int ts = tickSize();
|
||||||
|
int tc = _path.last().last().distance() / (ts * xInM());
|
||||||
|
QRect tr = PathTickItem::tickRect(ts * tc);
|
||||||
|
|
||||||
|
_ticks.resize(tc);
|
||||||
|
for (int i = 0; i < tc; i++) {
|
||||||
|
_ticks[i] = new PathTickItem(tr, (i + 1) * ts, this);
|
||||||
|
_ticks[i]->setPos(position((i + 1) * ts * xInM()));
|
||||||
|
_ticks[i]->setColor(_pen.color());
|
||||||
|
_ticks[i]->setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::showTicks(bool show)
|
||||||
|
{
|
||||||
|
if (_showTicks == show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
_showTicks = show;
|
||||||
|
updateTicks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathItem::setUnits(Units units)
|
||||||
|
{
|
||||||
|
if (_units == units)
|
||||||
|
return;
|
||||||
|
|
||||||
|
prepareGeometryChange();
|
||||||
|
_units = units;
|
||||||
|
updateTicks();
|
||||||
|
}
|
||||||
|
|
||||||
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
@ -5,8 +5,10 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include "data/path.h"
|
#include "data/path.h"
|
||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
class PathTickItem;
|
||||||
|
|
||||||
class PathItem : public QGraphicsObject
|
class PathItem : public QGraphicsObject
|
||||||
{
|
{
|
||||||
@ -24,12 +26,16 @@ public:
|
|||||||
|
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
|
|
||||||
|
void setUnits(Units units);
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
void setWidth(qreal width);
|
void setWidth(qreal width);
|
||||||
void setStyle(Qt::PenStyle style);
|
void setStyle(Qt::PenStyle style);
|
||||||
void setDigitalZoom(int zoom);
|
void setDigitalZoom(int zoom);
|
||||||
void setMarkerColor(const QColor &color);
|
void setMarkerColor(const QColor &color);
|
||||||
void showMarker(bool show);
|
void showMarker(bool show);
|
||||||
|
void showTicks(bool show);
|
||||||
|
|
||||||
|
Units units() const {return _units;}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void moveMarker(qreal distance);
|
void moveMarker(qreal distance);
|
||||||
@ -38,10 +44,6 @@ public slots:
|
|||||||
signals:
|
signals:
|
||||||
void selected(bool);
|
void selected(bool);
|
||||||
|
|
||||||
protected:
|
|
||||||
Path _path;
|
|
||||||
MarkerItem *_marker;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const PathSegment *segment(qreal x) const;
|
const PathSegment *segment(qreal x) const;
|
||||||
QPointF position(qreal distance) const;
|
QPointF position(qreal distance) const;
|
||||||
@ -49,19 +51,28 @@ private:
|
|||||||
void updateShape();
|
void updateShape();
|
||||||
void addSegment(const Coordinates &c1, const Coordinates &c2);
|
void addSegment(const Coordinates &c1, const Coordinates &c2);
|
||||||
|
|
||||||
|
qreal xInM() const;
|
||||||
|
unsigned tickSize() const;
|
||||||
|
void updateTicks();
|
||||||
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
|
Path _path;
|
||||||
Map *_map;
|
Map *_map;
|
||||||
qreal _markerDistance;
|
qreal _markerDistance;
|
||||||
int _digitalZoom;
|
int _digitalZoom;
|
||||||
|
|
||||||
|
Units _units;
|
||||||
qreal _width;
|
qreal _width;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
QPainterPath _painterPath;
|
QPainterPath _painterPath;
|
||||||
bool _showMarker;
|
bool _showMarker;
|
||||||
|
bool _showTicks;
|
||||||
|
|
||||||
|
MarkerItem *_marker;
|
||||||
|
QVector<PathTickItem*> _ticks;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATHITEM_H
|
#endif // PATHITEM_H
|
||||||
|
71
src/GUI/pathtickitem.cpp
Normal file
71
src/GUI/pathtickitem.cpp
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include <QPainter>
|
||||||
|
#include <QCursor>
|
||||||
|
#include "font.h"
|
||||||
|
#include "pathtickitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
static QFont defaultFont()
|
||||||
|
{
|
||||||
|
QFont font;
|
||||||
|
font.setPixelSize(10);
|
||||||
|
font.setFamily(FONT_FAMILY);
|
||||||
|
font.setBold(true);
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont PathTickItem::_font = defaultFont();
|
||||||
|
|
||||||
|
PathTickItem::PathTickItem(const QRectF &tickRect, int value,
|
||||||
|
QGraphicsItem *parent) : QGraphicsItem(parent), _tickRect(tickRect),
|
||||||
|
_text(QString::number(value))
|
||||||
|
{
|
||||||
|
_tickRect.moveCenter(QPointF(0, -_tickRect.height()/2.0 - 3));
|
||||||
|
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF PathTickItem::boundingRect() const
|
||||||
|
{
|
||||||
|
return _tickRect.adjusted(0, 0, 0, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathTickItem::paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(option);
|
||||||
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
QPointF arrow[3] = {QPointF(0, 0), QPointF(3, -3), QPointF(-3, -3)};
|
||||||
|
|
||||||
|
painter->setFont(_font);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing, false);
|
||||||
|
|
||||||
|
painter->setPen(Qt::white);
|
||||||
|
painter->setBrush(_brush);
|
||||||
|
painter->drawPolygon(arrow, 3);
|
||||||
|
painter->drawRoundedRect(_tickRect, 1.5, 1.5);
|
||||||
|
painter->drawText(_tickRect, Qt::AlignCenter, _text);
|
||||||
|
|
||||||
|
/*
|
||||||
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
painter->setPen(Qt::red);
|
||||||
|
painter->drawRect(boundingRect());
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void PathTickItem::setPos(const QPointF &pos)
|
||||||
|
{
|
||||||
|
/* For propper rounded rect rendering, the item must be positioned in the
|
||||||
|
middle of a pixel */
|
||||||
|
QPoint p(pos.toPoint());
|
||||||
|
QGraphicsItem::setPos(QPointF(p.x() - 0.5, p.y() - 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect PathTickItem::tickRect(int value)
|
||||||
|
{
|
||||||
|
QFontMetrics fm(_font);
|
||||||
|
return fm.boundingRect(QRect(), Qt::AlignCenter,
|
||||||
|
QString::number(qMax(value, 10))).adjusted(-2, 0, 2, 0);
|
||||||
|
}
|
29
src/GUI/pathtickitem.h
Normal file
29
src/GUI/pathtickitem.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef PATHTICKITEM_H
|
||||||
|
#define PATHTICKITEM_H
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
class PathTickItem : public QGraphicsItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PathTickItem(const QRectF &tickRect, int value, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget);
|
||||||
|
|
||||||
|
void setPos(const QPointF &pos);
|
||||||
|
void setColor(const QColor &color) {_brush = QBrush(color);}
|
||||||
|
|
||||||
|
static QRect tickRect(int value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QRectF _tickRect;
|
||||||
|
QString _text;
|
||||||
|
QBrush _brush;
|
||||||
|
|
||||||
|
static QFont _font;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PATHTICKITEM_H
|
@ -15,7 +15,7 @@ QString RouteItem::toolTip(Units units) const
|
|||||||
tt.insert(tr("Name"), _name);
|
tt.insert(tr("Name"), _name);
|
||||||
if (!_desc.isEmpty())
|
if (!_desc.isEmpty())
|
||||||
tt.insert(tr("Description"), _desc);
|
tt.insert(tr("Description"), _desc);
|
||||||
tt.insert(tr("Distance"), Format::distance(_path.last().last().distance(),
|
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
||||||
units));
|
units));
|
||||||
|
|
||||||
return tt.toString();
|
return tt.toString();
|
||||||
@ -26,12 +26,12 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
|||||||
{
|
{
|
||||||
const QVector<Waypoint> &waypoints = route.waypoints();
|
const QVector<Waypoint> &waypoints = route.waypoints();
|
||||||
|
|
||||||
|
_waypoints.resize(waypoints.size());
|
||||||
for (int i = 0; i < waypoints.size(); i++)
|
for (int i = 0; i < waypoints.size(); i++)
|
||||||
new WaypointItem(waypoints.at(i), map, this);
|
_waypoints[i] = new WaypointItem(waypoints.at(i), map, this);
|
||||||
|
|
||||||
_name = route.name();
|
_name = route.name();
|
||||||
_desc = route.description();
|
_desc = route.description();
|
||||||
_units = Metric;
|
|
||||||
_coordinatesFormat = DecimalDegrees;
|
_coordinatesFormat = DecimalDegrees;
|
||||||
|
|
||||||
setToolTip(toolTip(Metric));
|
setToolTip(toolTip(Metric));
|
||||||
@ -39,33 +39,23 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
|||||||
|
|
||||||
void RouteItem::setMap(Map *map)
|
void RouteItem::setMap(Map *map)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
for (int i = 0; i < childs.count(); i++) {
|
_waypoints[i]->setMap(map);
|
||||||
if (childs.at(i) != _marker) {
|
|
||||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
|
||||||
wi->setMap(map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PathItem::setMap(map);
|
PathItem::setMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setUnits(Units units)
|
void RouteItem::setUnits(Units u)
|
||||||
{
|
{
|
||||||
if (_units == units)
|
if (units() == u)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_units = units;
|
PathItem::setUnits(u);
|
||||||
|
|
||||||
setToolTip(toolTip(_units));
|
setToolTip(toolTip(units()));
|
||||||
|
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
for (int i = 0; i < childs.count(); i++) {
|
_waypoints[i]->setToolTipFormat(units(), _coordinatesFormat);
|
||||||
if (childs.at(i) != _marker) {
|
|
||||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
|
||||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
||||||
@ -75,30 +65,18 @@ void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
|
|||||||
|
|
||||||
_coordinatesFormat = format;
|
_coordinatesFormat = format;
|
||||||
|
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
for (int i = 0; i < childs.count(); i++) {
|
_waypoints[i]->setToolTipFormat(units(), _coordinatesFormat);
|
||||||
if (childs.at(i) != _marker) {
|
|
||||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
|
||||||
wi->setToolTipFormat(_units, _coordinatesFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::showWaypoints(bool show)
|
void RouteItem::showWaypoints(bool show)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
for (int i = 0; i < childs.count(); i++)
|
_waypoints[i]->setVisible(show);
|
||||||
if (childs.at(i) != _marker)
|
|
||||||
childs.at(i)->setVisible(show);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::showWaypointLabels(bool show)
|
void RouteItem::showWaypointLabels(bool show)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
for (int i = 0; i < _waypoints.count(); i++)
|
||||||
for (int i = 0; i < childs.count(); i++) {
|
_waypoints[i]->showLabel(show);
|
||||||
if (childs.at(i) != _marker) {
|
|
||||||
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
|
||||||
wi->showLabel(show);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
|
||||||
class Map;
|
class Map;
|
||||||
|
class WaypointItem;
|
||||||
|
|
||||||
class RouteItem : public PathItem
|
class RouteItem : public PathItem
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ public:
|
|||||||
|
|
||||||
void setMap(Map *map);
|
void setMap(Map *map);
|
||||||
|
|
||||||
void setUnits(Units units);
|
void setUnits(Units u);
|
||||||
void setCoordinatesFormat(CoordinatesFormat format);
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
@ -27,8 +28,9 @@ private:
|
|||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _desc;
|
QString _desc;
|
||||||
Units _units;
|
|
||||||
CoordinatesFormat _coordinatesFormat;
|
CoordinatesFormat _coordinatesFormat;
|
||||||
|
|
||||||
|
QVector<WaypointItem*> _waypoints;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ROUTEITEM_H
|
#endif // ROUTEITEM_H
|
||||||
|
@ -61,9 +61,9 @@ void ScaleItem::computeScale()
|
|||||||
qreal res = _res * pow(2, -_digitalZoom);
|
qreal res = _res * pow(2, -_digitalZoom);
|
||||||
|
|
||||||
if (_units == Imperial) {
|
if (_units == Imperial) {
|
||||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
if (_length >= MIINFT) {
|
if (_length >= MIINFT) {
|
||||||
_length = niceNum((res * M2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2MI * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
_width = (_length / (res * M2MI));
|
_width = (_length / (res * M2MI));
|
||||||
_scale = true;
|
_scale = true;
|
||||||
} else {
|
} else {
|
||||||
@ -71,9 +71,9 @@ void ScaleItem::computeScale()
|
|||||||
_scale = false;
|
_scale = false;
|
||||||
}
|
}
|
||||||
} else if (_units == Nautical) {
|
} else if (_units == Nautical) {
|
||||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
if (_length >= NMIINFT) {
|
if (_length >= NMIINFT) {
|
||||||
_length = niceNum((res * M2NMI * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * M2NMI * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
_width = (_length / (res * M2NMI));
|
_width = (_length / (res * M2NMI));
|
||||||
_scale = true;
|
_scale = true;
|
||||||
} else {
|
} else {
|
||||||
@ -81,7 +81,7 @@ void ScaleItem::computeScale()
|
|||||||
_scale = false;
|
_scale = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_length = niceNum((res * SCALE_WIDTH) / SEGMENTS, 1);
|
_length = niceNum((res * SCALE_WIDTH) / SEGMENTS, true);
|
||||||
if (_length >= KMINM) {
|
if (_length >= KMINM) {
|
||||||
_length *= M2KM;
|
_length *= M2KM;
|
||||||
_width = (_length / (res * M2KM));
|
_width = (_length / (res * M2KM));
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#define SHOW_GRAPH_SLIDER_INFO_DEFAULT true
|
#define SHOW_GRAPH_SLIDER_INFO_DEFAULT true
|
||||||
#define SHOW_MARKERS_SETTING "pathMarkers"
|
#define SHOW_MARKERS_SETTING "pathMarkers"
|
||||||
#define SHOW_MARKERS_DEFAULT true
|
#define SHOW_MARKERS_DEFAULT true
|
||||||
|
#define SHOW_TICKS_SETTING "pathTicks"
|
||||||
|
#define SHOW_TICKS_DEFAULT false
|
||||||
|
|
||||||
#define MAP_SETTINGS_GROUP "Map"
|
#define MAP_SETTINGS_GROUP "Map"
|
||||||
#define CURRENT_MAP_SETTING "map"
|
#define CURRENT_MAP_SETTING "map"
|
||||||
@ -171,8 +173,8 @@
|
|||||||
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
||||||
#define SLIDER_COLOR_SETTING "sliderColor"
|
#define SLIDER_COLOR_SETTING "sliderColor"
|
||||||
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
||||||
#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap"
|
#define PROJECTION_SETTING "projection"
|
||||||
#define ALWAYS_SHOW_MAP_DEFAULT true
|
#define PROJECTION_DEFAULT 3857
|
||||||
#define HIDPI_MAP_SETTING "HiDPIMap"
|
#define HIDPI_MAP_SETTING "HiDPIMap"
|
||||||
#define HIDPI_MAP_DEFAULT true
|
#define HIDPI_MAP_DEFAULT true
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ QString TrackItem::toolTip(Units units) const
|
|||||||
tt.insert(tr("Name"), _name);
|
tt.insert(tr("Name"), _name);
|
||||||
if (!_desc.isEmpty())
|
if (!_desc.isEmpty())
|
||||||
tt.insert(tr("Description"), _desc);
|
tt.insert(tr("Description"), _desc);
|
||||||
tt.insert(tr("Distance"), Format::distance(_path.last().last().distance(),
|
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
|
||||||
units));
|
units));
|
||||||
if (_time > 0)
|
if (_time > 0)
|
||||||
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
||||||
@ -39,5 +39,6 @@ TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
|
|||||||
|
|
||||||
void TrackItem::setUnits(Units units)
|
void TrackItem::setUnits(Units units)
|
||||||
{
|
{
|
||||||
|
PathItem::setUnits(units);
|
||||||
setToolTip(toolTip(units));
|
setToolTip(toolTip(units));
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,11 @@
|
|||||||
#define DEM_DIR "DEM"
|
#define DEM_DIR "DEM"
|
||||||
#define TILES_DIR "tiles"
|
#define TILES_DIR "tiles"
|
||||||
#define TRANSLATIONS_DIR "translations"
|
#define TRANSLATIONS_DIR "translations"
|
||||||
|
#define STYLE_DIR "style"
|
||||||
#define ELLIPSOID_FILE "ellipsoids.csv"
|
#define ELLIPSOID_FILE "ellipsoids.csv"
|
||||||
#define GCS_FILE "gcs.csv"
|
#define GCS_FILE "gcs.csv"
|
||||||
#define PCS_FILE "pcs.csv"
|
#define PCS_FILE "pcs.csv"
|
||||||
|
#define TYP_FILE "style.typ"
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||||
@ -79,6 +81,11 @@ QString ProgramPaths::demDir(bool writable)
|
|||||||
return dir(DEM_DIR, writable);
|
return dir(DEM_DIR, writable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::styleDir(bool writable)
|
||||||
|
{
|
||||||
|
return dir(STYLE_DIR, writable);
|
||||||
|
}
|
||||||
|
|
||||||
QString ProgramPaths::tilesDir()
|
QString ProgramPaths::tilesDir()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
@ -113,6 +120,11 @@ QString ProgramPaths::pcsFile()
|
|||||||
return file(dir(CSV_DIR), PCS_FILE);
|
return file(dir(CSV_DIR), PCS_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::typFile()
|
||||||
|
{
|
||||||
|
return file(dir(STYLE_DIR), TYP_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
#else // QT_VERSION < 5
|
#else // QT_VERSION < 5
|
||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@ -157,6 +169,16 @@ QString ProgramPaths::demDir(bool writable)
|
|||||||
DEM_DIR, QStandardPaths::LocateDirectory);
|
DEM_DIR, QStandardPaths::LocateDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::styleDir(bool writable)
|
||||||
|
{
|
||||||
|
if (writable)
|
||||||
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::AppDataLocation)).filePath(STYLE_DIR);
|
||||||
|
else
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
STYLE_DIR, QStandardPaths::LocateDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
QString ProgramPaths::tilesDir()
|
QString ProgramPaths::tilesDir()
|
||||||
{
|
{
|
||||||
return QDir(QStandardPaths::writableLocation(
|
return QDir(QStandardPaths::writableLocation(
|
||||||
@ -187,4 +209,10 @@ QString ProgramPaths::pcsFile()
|
|||||||
CSV_DIR "/" PCS_FILE, QStandardPaths::LocateFile);
|
CSV_DIR "/" PCS_FILE, QStandardPaths::LocateFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::typFile()
|
||||||
|
{
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
STYLE_DIR "/" TYP_FILE, QStandardPaths::LocateFile);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QT_VERSION < 5
|
#endif // QT_VERSION < 5
|
||||||
|
@ -9,11 +9,13 @@ namespace ProgramPaths
|
|||||||
QString poiDir(bool writable = false);
|
QString poiDir(bool writable = false);
|
||||||
QString csvDir(bool writable = false);
|
QString csvDir(bool writable = false);
|
||||||
QString demDir(bool writable = false);
|
QString demDir(bool writable = false);
|
||||||
|
QString styleDir(bool writable = false);
|
||||||
QString tilesDir();
|
QString tilesDir();
|
||||||
QString translationsDir();
|
QString translationsDir();
|
||||||
QString ellipsoidsFile();
|
QString ellipsoidsFile();
|
||||||
QString gcsFile();
|
QString gcsFile();
|
||||||
QString pcsFile();
|
QString pcsFile();
|
||||||
|
QString typFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // PROGRAMPATHS_H
|
#endif // PROGRAMPATHS_H
|
||||||
|
@ -17,7 +17,7 @@ int str2int(const char *str, int len)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
double niceNum(double x, int round)
|
double niceNum(double x, bool round)
|
||||||
{
|
{
|
||||||
int expv;
|
int expv;
|
||||||
double f;
|
double f;
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
#define UTIL_H
|
#define UTIL_H
|
||||||
|
|
||||||
int str2int(const char *str, int len);
|
int str2int(const char *str, int len);
|
||||||
double niceNum(double x, int round);
|
double niceNum(double x, bool round);
|
||||||
|
|
||||||
#endif // UTIL_H
|
#endif // UTIL_H
|
||||||
|
@ -118,6 +118,9 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
|
|||||||
trackpoint.setTimestamp(time());
|
trackpoint.setTimestamp(time());
|
||||||
else if (_reader.name() == QLatin1String("geoidheight"))
|
else if (_reader.name() == QLatin1String("geoidheight"))
|
||||||
gh = number();
|
gh = number();
|
||||||
|
// GPX 1.0
|
||||||
|
else if (_reader.name() == QLatin1String("speed"))
|
||||||
|
trackpoint.setSpeed(number());
|
||||||
else if (_reader.name() == QLatin1String("extensions"))
|
else if (_reader.name() == QLatin1String("extensions"))
|
||||||
trkptExtensions(trackpoint);
|
trkptExtensions(trackpoint);
|
||||||
else
|
else
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
#include "common/programpaths.h"
|
||||||
#include "vectortile.h"
|
#include "vectortile.h"
|
||||||
#include "img.h"
|
#include "img.h"
|
||||||
|
|
||||||
@ -162,9 +163,18 @@ IMG::IMG(const QString &fileName) : _file(fileName), _valid(false)
|
|||||||
|
|
||||||
// Read TYP file if any
|
// Read TYP file if any
|
||||||
if (!TYPMap.isEmpty()) {
|
if (!TYPMap.isEmpty()) {
|
||||||
|
if (TYPMap.size() > 1)
|
||||||
|
qWarning("%s: Multiple TYP files, using %s",
|
||||||
|
qPrintable(_file.fileName()), qPrintable(TYPMap.keys().first()));
|
||||||
SubFile *typ = TYPMap.values().first();
|
SubFile *typ = TYPMap.values().first();
|
||||||
_style = Style(typ);
|
_style = Style(typ);
|
||||||
qDeleteAll(TYPMap);
|
qDeleteAll(TYPMap);
|
||||||
|
} else {
|
||||||
|
QFile typFile(ProgramPaths::typFile());
|
||||||
|
if (typFile.exists()) {
|
||||||
|
SubFile typ(&typFile);
|
||||||
|
_style = Style(&typ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
|
@ -50,20 +50,19 @@ public:
|
|||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
const RectC &bounds() const {return _bounds;}
|
const RectC &bounds() const {return _bounds;}
|
||||||
Range zooms() const {return Range(_bits.first(), _bits.last());}
|
Range zooms() const {return Range(_bits.first(), _bits.last());}
|
||||||
|
void objects(const RectC &rect, int bits, QList<Poly> *polygons,
|
||||||
|
QList<Poly> *lines, QList<Point> *points) const;
|
||||||
|
const Style &style() const {return _style;}
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
void objects(const RectC &rect, int bits, QList<Poly> *polygons,
|
|
||||||
QList<Poly> *lines, QList<Point> *points) const;
|
|
||||||
|
|
||||||
const Style &style() const {return _style;}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class SubFile;
|
friend class SubFile;
|
||||||
|
|
||||||
typedef RTree<VectorTile*, double, 2> TileTree;
|
typedef RTree<VectorTile*, double, 2> TileTree;
|
||||||
|
|
||||||
|
QString fileName() const {return _file.fileName();}
|
||||||
int blockSize() const {return _blockSize;}
|
int blockSize() const {return _blockSize;}
|
||||||
bool readBlock(int blockNum, QByteArray &data);
|
bool readBlock(int blockNum, QByteArray &data);
|
||||||
qint64 read(char *data, qint64 maxSize);
|
qint64 read(char *data, qint64 maxSize);
|
||||||
|
@ -779,7 +779,7 @@ bool Style::parseTYPFile(SubFile *file)
|
|||||||
&& parsePolygons(file, hdl, polygons)
|
&& parsePolygons(file, hdl, polygons)
|
||||||
&& parseDrawOrder(file, hdl, order))) {
|
&& parseDrawOrder(file, hdl, order))) {
|
||||||
qWarning("%s: Invalid TYP file, using default style",
|
qWarning("%s: Invalid TYP file, using default style",
|
||||||
qPrintable(file->imgName()));
|
qPrintable(file->fileName()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,7 +791,7 @@ Style::Style(SubFile *typ)
|
|||||||
defaultLineStyle();
|
defaultLineStyle();
|
||||||
defaultPolygonStyle();
|
defaultPolygonStyle();
|
||||||
|
|
||||||
if (typ)
|
if (typ && typ->isValid())
|
||||||
parseTYPFile(typ);
|
parseTYPFile(typ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <QFile>
|
||||||
#include "img.h"
|
#include "img.h"
|
||||||
#include "subfile.h"
|
#include "subfile.h"
|
||||||
|
|
||||||
@ -19,42 +20,68 @@ SubFile::Type SubFile::type(const char str[3])
|
|||||||
return Unknown;
|
return Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SubFile::SubFile(QFile *file) : _img(0), _file(file), _size(0)
|
||||||
|
{
|
||||||
|
if (!_file->open(QIODevice::ReadOnly))
|
||||||
|
qWarning("Error opening %s: %s", qPrintable(_file->fileName()),
|
||||||
|
qPrintable(_file->errorString()));
|
||||||
|
}
|
||||||
|
|
||||||
bool SubFile::isValid() const
|
bool SubFile::isValid() const
|
||||||
{
|
{
|
||||||
return ((quint32)_img->blockSize() * (quint32)_blocks.size() - _size
|
return _file
|
||||||
< (quint32)_img->blockSize());
|
? _file->isOpen()
|
||||||
|
: ((quint32)_img->blockSize() * (quint32)_blocks.size() - _size
|
||||||
|
< (quint32)_img->blockSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SubFile::seek(Handle &handle, quint32 pos) const
|
bool SubFile::seek(Handle &handle, quint32 pos) const
|
||||||
{
|
{
|
||||||
quint32 blockSize = _img->blockSize();
|
Q_ASSERT(_img || _file);
|
||||||
int blockNum = pos / blockSize;
|
|
||||||
|
|
||||||
if (handle.blockNum != blockNum) {
|
if (_file)
|
||||||
if (blockNum >= _blocks.size())
|
return _file->seek(pos);
|
||||||
return false;
|
else {
|
||||||
if (!_img->readBlock(_blocks.at(blockNum), handle.data))
|
quint32 blockSize = _img->blockSize();
|
||||||
return false;
|
int blockNum = pos / blockSize;
|
||||||
handle.blockNum = blockNum;
|
|
||||||
|
if (handle.blockNum != blockNum) {
|
||||||
|
if (blockNum >= _blocks.size())
|
||||||
|
return false;
|
||||||
|
if (!_img->readBlock(_blocks.at(blockNum), handle.data))
|
||||||
|
return false;
|
||||||
|
handle.blockNum = blockNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle.blockPos = pos % blockSize;
|
||||||
|
handle.pos = pos;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.blockPos = pos % blockSize;
|
|
||||||
handle.pos = pos;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SubFile::readByte(Handle &handle, quint8 &val) const
|
bool SubFile::readByte(Handle &handle, quint8 &val) const
|
||||||
{
|
{
|
||||||
val = handle.data.at(handle.blockPos++);
|
Q_ASSERT(_img || _file);
|
||||||
handle.pos++;
|
|
||||||
return (handle.blockPos >= _img->blockSize())
|
if (_file)
|
||||||
? seek(handle, handle.pos) : true;
|
return _file->getChar((char*)&val);
|
||||||
|
else {
|
||||||
|
val = handle.data.at(handle.blockPos++);
|
||||||
|
handle.pos++;
|
||||||
|
return (handle.blockPos >= _img->blockSize())
|
||||||
|
? seek(handle, handle.pos) : true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &SubFile::imgName() const
|
quint32 SubFile::size() const
|
||||||
{
|
{
|
||||||
return _img->name();
|
return _img ? _size : (quint32)_file->size();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SubFile::fileName() const
|
||||||
|
{
|
||||||
|
return _img ? _img->fileName() : _file->fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class IMG;
|
class IMG;
|
||||||
|
class QFile;
|
||||||
|
|
||||||
class SubFile
|
class SubFile
|
||||||
{
|
{
|
||||||
@ -21,12 +22,13 @@ public:
|
|||||||
int pos;
|
int pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
SubFile(IMG *img, quint32 size) : _img(img), _size(size) {}
|
SubFile(IMG *img, quint32 size) : _img(img), _file(0), _size(size) {}
|
||||||
|
SubFile(QFile *file);
|
||||||
|
|
||||||
void addBlock(quint16 block) {_blocks.append(block);}
|
void addBlock(quint16 block) {_blocks.append(block);}
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
quint32 size() const {return _size;}
|
quint32 size() const;
|
||||||
bool seek(Handle &handle, quint32 pos) const;
|
bool seek(Handle &handle, quint32 pos) const;
|
||||||
bool readByte(Handle &handle, quint8 &val) const;
|
bool readByte(Handle &handle, quint8 &val) const;
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
quint16 offset() const {return _blocks.first();}
|
quint16 offset() const {return _blocks.first();}
|
||||||
const QString &imgName() const;
|
QString fileName() const;
|
||||||
|
|
||||||
static Type type(const char str[3]);
|
static Type type(const char str[3]);
|
||||||
|
|
||||||
@ -87,6 +89,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
IMG *_img;
|
IMG *_img;
|
||||||
|
QFile *_file;
|
||||||
quint32 _size;
|
quint32 _size;
|
||||||
QVector<quint16> _blocks;
|
QVector<quint16> _blocks;
|
||||||
};
|
};
|
||||||
|
@ -66,8 +66,14 @@ void TextPointItem::paint(QPainter *painter) const
|
|||||||
painter->setPen(*_color);
|
painter->setPen(*_color);
|
||||||
painter->drawText(_textRect, FLAGS, *_text);
|
painter->drawText(_textRect, FLAGS, *_text);
|
||||||
} else {
|
} else {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||||
img.invertPixels();
|
img.invertPixels();
|
||||||
painter->drawImage(_textRect, img);
|
painter->drawImage(_textRect, img);
|
||||||
|
#else // QT >= 5.4
|
||||||
|
QImage iimg(img.convertToFormat(QImage::Format_ARGB32));
|
||||||
|
iimg.invertPixels();
|
||||||
|
painter->drawImage(_textRect, iimg);
|
||||||
|
#endif // QT >= 5.4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,13 +109,13 @@ QRectF IMGMap::bounds()
|
|||||||
int IMGMap::zoomFit(const QSize &size, const RectC &rect)
|
int IMGMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (rect.isValid()) {
|
if (rect.isValid()) {
|
||||||
QPointF sc((rect.right() - rect.left()) / size.width(),
|
RectD pr(rect, _projection, 10);
|
||||||
(rect.top() - rect.bottom()) / size.height());
|
|
||||||
double resolution = qMax(qAbs(sc.x()), qAbs(sc.y()));
|
|
||||||
|
|
||||||
_zoom = _zooms.min();
|
_zoom = _zooms.min();
|
||||||
for (int i = _zooms.min(); i <= _zooms.max(); i++) {
|
for (int i = _zooms.min() + 1; i <= _zooms.max(); i++) {
|
||||||
if (360.0 / (1<<i) < resolution)
|
Transform t(transform(i));
|
||||||
|
QRectF r(t.proj2img(pr.topLeft()), t.proj2img(pr.bottomRight()));
|
||||||
|
if (size.width() < r.width() || size.height() < r.height())
|
||||||
break;
|
break;
|
||||||
_zoom = i;
|
_zoom = i;
|
||||||
}
|
}
|
||||||
@ -141,12 +141,23 @@ int IMGMap::zoomOut()
|
|||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMGMap::setZoom(int zoom)
|
||||||
|
{
|
||||||
|
_zoom = zoom;
|
||||||
|
updateTransform();
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform IMGMap::transform(int zoom) const
|
||||||
|
{
|
||||||
|
double scale = (2.0 * M_PI * WGS84_RADIUS) / (1<<zoom);
|
||||||
|
PointD topLeft(_projection.ll2xy(_img.bounds().topLeft()));
|
||||||
|
return Transform(ReferencePoint(PointD(0, 0), topLeft),
|
||||||
|
PointD(scale, scale));
|
||||||
|
}
|
||||||
|
|
||||||
void IMGMap::updateTransform()
|
void IMGMap::updateTransform()
|
||||||
{
|
{
|
||||||
double scale = (2.0 * M_PI * WGS84_RADIUS) / (1<<_zoom);;
|
_transform = transform(_zoom);
|
||||||
PointD topLeft(_projection.ll2xy(_img.bounds().topLeft()));
|
|
||||||
_transform = Transform(ReferencePoint(PointD(0, 0), topLeft),
|
|
||||||
PointD(scale, scale));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF IMGMap::ll2xy(const Coordinates &c)
|
QPointF IMGMap::ll2xy(const Coordinates &c)
|
||||||
@ -369,3 +380,10 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
painter->drawPixmap(mt.xy(), pm);
|
painter->drawPixmap(mt.xy(), pm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IMGMap::setProjection(const Projection &projection)
|
||||||
|
{
|
||||||
|
_projection = projection;
|
||||||
|
updateTransform();
|
||||||
|
QPixmapCache::clear();
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
QRectF bounds();
|
QRectF bounds();
|
||||||
|
|
||||||
virtual int zoom() const {return _zoom;}
|
virtual int zoom() const {return _zoom;}
|
||||||
virtual void setZoom(int zoom) {_zoom = zoom;}
|
virtual void setZoom(int zoom);
|
||||||
virtual int zoomFit(const QSize &, const RectC &);
|
virtual int zoomFit(const QSize &, const RectC &);
|
||||||
virtual int zoomIn();
|
virtual int zoomIn();
|
||||||
virtual int zoomOut();
|
virtual int zoomOut();
|
||||||
@ -31,12 +31,15 @@ public:
|
|||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
|
void setProjection(const Projection &projection);
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class RasterTile;
|
friend class RasterTile;
|
||||||
|
|
||||||
|
Transform transform(int zoom) const;
|
||||||
void updateTransform();
|
void updateTransform();
|
||||||
void drawPolygons(QPainter *painter, QList<IMG::Poly> &polygons);
|
void drawPolygons(QPainter *painter, QList<IMG::Poly> &polygons);
|
||||||
void drawLines(QPainter *painter, QList<IMG::Poly> &lines,
|
void drawLines(QPainter *painter, QList<IMG::Poly> &lines,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <QLineF>
|
#include <QLineF>
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "pcs.h"
|
||||||
|
|
||||||
qreal Map::resolution(const QRectF &rect)
|
qreal Map::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
|
@ -7,8 +7,10 @@
|
|||||||
#include <QFlags>
|
#include <QFlags>
|
||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
|
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class RectC;
|
class RectC;
|
||||||
|
class Projection;
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
{
|
{
|
||||||
@ -45,6 +47,7 @@ public:
|
|||||||
virtual void load() {}
|
virtual void load() {}
|
||||||
virtual void unload() {}
|
virtual void unload() {}
|
||||||
virtual void setDevicePixelRatio(qreal, qreal) {}
|
virtual void setDevicePixelRatio(qreal, qreal) {}
|
||||||
|
virtual void setProjection(const Projection &) {}
|
||||||
|
|
||||||
virtual bool isValid() const {return true;}
|
virtual bool isValid() const {return true;}
|
||||||
virtual QString errorString() const {return QString();}
|
virtual QString errorString() const {return QString();}
|
||||||
|
@ -160,6 +160,8 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
|||||||
config.type = WMS;
|
config.type = WMS;
|
||||||
else if (type == "TMS")
|
else if (type == "TMS")
|
||||||
config.type = TMS;
|
config.type = TMS;
|
||||||
|
else if (type == "QuadTiles")
|
||||||
|
config.type = QuadTiles;
|
||||||
else if (type == "OSM" || type.isEmpty())
|
else if (type == "OSM" || type.isEmpty())
|
||||||
config.type = OSM;
|
config.type = OSM;
|
||||||
else {
|
else {
|
||||||
@ -293,11 +295,15 @@ Map *MapSource::loadMap(const QString &path, QString &errorString)
|
|||||||
case TMS:
|
case TMS:
|
||||||
return new OnlineMap(config.name, config.url, config.zooms,
|
return new OnlineMap(config.name, config.url, config.zooms,
|
||||||
config.bounds, config.tileRatio, config.authorization,
|
config.bounds, config.tileRatio, config.authorization,
|
||||||
config.tileSize, config.scalable, true);
|
config.tileSize, config.scalable, true, false);
|
||||||
case OSM:
|
case OSM:
|
||||||
return new OnlineMap(config.name, config.url, config.zooms,
|
return new OnlineMap(config.name, config.url, config.zooms,
|
||||||
config.bounds, config.tileRatio, config.authorization,
|
config.bounds, config.tileRatio, config.authorization,
|
||||||
config.tileSize, config.scalable, false);
|
config.tileSize, config.scalable, false, false);
|
||||||
|
case QuadTiles:
|
||||||
|
return new OnlineMap(config.name, config.url, config.zooms,
|
||||||
|
config.bounds, config.tileRatio, config.authorization,
|
||||||
|
config.tileSize, config.scalable, false, true);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,8 @@ private:
|
|||||||
OSM,
|
OSM,
|
||||||
WMTS,
|
WMTS,
|
||||||
WMS,
|
WMS,
|
||||||
TMS
|
TMS,
|
||||||
|
QuadTiles
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
|
@ -11,15 +11,16 @@
|
|||||||
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
||||||
const Range &zooms, const RectC &bounds, qreal tileRatio,
|
const Range &zooms, const RectC &bounds, qreal tileRatio,
|
||||||
const Authorization &authorization, int tileSize, bool scalable, bool invertY,
|
const Authorization &authorization, int tileSize, bool scalable, bool invertY,
|
||||||
QObject *parent)
|
bool quadTiles, QObject *parent)
|
||||||
: Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
: Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
||||||
_zoom(_zooms.max()), _mapRatio(1.0), _tileRatio(tileRatio),
|
_zoom(_zooms.max()), _mapRatio(1.0), _tileRatio(tileRatio),
|
||||||
_tileSize(tileSize), _scalable(scalable), _invertY(invertY), _scaledSize(0)
|
_tileSize(tileSize), _scalable(scalable), _invertY(invertY)
|
||||||
{
|
{
|
||||||
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
|
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
|
||||||
this);
|
this);
|
||||||
_tileLoader->setUrl(url);
|
_tileLoader->setUrl(url);
|
||||||
_tileLoader->setAuthorization(authorization);
|
_tileLoader->setAuthorization(authorization);
|
||||||
|
_tileLoader->setQuadTiles(quadTiles);
|
||||||
connect(_tileLoader, SIGNAL(finished()), this, SIGNAL(loaded()));
|
connect(_tileLoader, SIGNAL(finished()), this, SIGNAL(loaded()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ void OnlineMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
|||||||
_mapRatio = mapRatio;
|
_mapRatio = mapRatio;
|
||||||
|
|
||||||
if (_scalable) {
|
if (_scalable) {
|
||||||
_scaledSize = _tileSize * deviceRatio;
|
_tileLoader->setScaledSize(_tileSize * deviceRatio);
|
||||||
_tileRatio = deviceRatio;
|
_tileRatio = deviceRatio;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +113,7 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
for (int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
for (int j = 0; j < height; j++)
|
for (int j = 0; j < height; j++)
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, _invertY ? (1<<_zoom)
|
tiles.append(Tile(QPoint(tile.x() + i, _invertY ? (1<<_zoom)
|
||||||
- (tile.y() + j) - 1 : tile.y() + j), _zoom, _scaledSize));
|
- (tile.y() + j) - 1 : tile.y() + j), _zoom));
|
||||||
|
|
||||||
if (flags & Map::Block)
|
if (flags & Map::Block)
|
||||||
_tileLoader->loadTilesSync(tiles);
|
_tileLoader->loadTilesSync(tiles);
|
||||||
|
@ -13,7 +13,8 @@ class OnlineMap : public Map
|
|||||||
public:
|
public:
|
||||||
OnlineMap(const QString &name, const QString &url, const Range &zooms,
|
OnlineMap(const QString &name, const QString &url, const Range &zooms,
|
||||||
const RectC &bounds, qreal tileRatio, const Authorization &authorization,
|
const RectC &bounds, qreal tileRatio, const Authorization &authorization,
|
||||||
int tileSize, bool scalable, bool invertY, QObject *parent = 0);
|
int tileSize, bool scalable, bool invertY, bool quadTiles,
|
||||||
|
QObject *parent = 0);
|
||||||
|
|
||||||
QString name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
@ -49,7 +50,6 @@ private:
|
|||||||
int _tileSize;
|
int _tileSize;
|
||||||
bool _scalable;
|
bool _scalable;
|
||||||
bool _invertY;
|
bool _invertY;
|
||||||
int _scaledSize;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ONLINEMAP_H
|
#endif // ONLINEMAP_H
|
||||||
|
@ -5,13 +5,16 @@
|
|||||||
|
|
||||||
class PCS::Entry {
|
class PCS::Entry {
|
||||||
public:
|
public:
|
||||||
Entry(int id, int proj, const PCS &pcs) : _id(id), _proj(proj), _pcs(pcs) {}
|
Entry(const QString &name, int id, int proj, const PCS &pcs)
|
||||||
|
: _name(name), _id(id), _proj(proj), _pcs(pcs) {}
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
int id() const {return _id;}
|
int id() const {return _id;}
|
||||||
int proj() const {return _proj;}
|
int proj() const {return _proj;}
|
||||||
const PCS &pcs() const {return _pcs;}
|
const PCS &pcs() const {return _pcs;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString _name;
|
||||||
int _id, _proj;
|
int _id, _proj;
|
||||||
PCS _pcs;
|
PCS _pcs;
|
||||||
};
|
};
|
||||||
@ -21,8 +24,9 @@ QList<PCS::Entry> PCS::_pcss = defaults();
|
|||||||
QList<PCS::Entry> PCS::defaults()
|
QList<PCS::Entry> PCS::defaults()
|
||||||
{
|
{
|
||||||
QList<PCS::Entry> list;
|
QList<PCS::Entry> list;
|
||||||
list.append(PCS::Entry(3857, 3856, PCS(&GCS::WGS84(), 1024,
|
list.append(PCS::Entry("WGS 84 / Pseudo-Mercator", 3857, 3856,
|
||||||
Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN), 9001, 4499)));
|
PCS(&GCS::WGS84(), 1024, Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN),
|
||||||
|
9001, 4499)));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,27 +158,28 @@ void PCS::loadList(const QString &path)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = list[1].trimmed().toInt(&res);
|
QString name(list.at(0).trimmed());
|
||||||
|
int id = list.at(1).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid PCS code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid PCS code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int gcsid = list[2].trimmed().toInt(&res);
|
int gcsid = list.at(2).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid GCS code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid GCS code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int proj = list[3].trimmed().toInt(&res);
|
int proj = list.at(3).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid projection code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid projection code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int units = list[4].trimmed().toInt(&res);
|
int units = list.at(4).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid linear units code", qPrintable(path), ln);
|
qWarning("%s:%d: Invalid linear units code", qPrintable(path), ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int transform = list[5].trimmed().toInt(&res);
|
int transform = list.at(5).trimmed().toInt(&res);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
qWarning("%s:%d: Invalid coordinate transformation code",
|
qWarning("%s:%d: Invalid coordinate transformation code",
|
||||||
qPrintable(path), ln);
|
qPrintable(path), ln);
|
||||||
@ -214,10 +219,20 @@ void PCS::loadList(const QString &path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PCS pcs(gcs, transform, setup, units, cs);
|
PCS pcs(gcs, transform, setup, units, cs);
|
||||||
_pcss.append(Entry(id, proj, pcs));
|
_pcss.append(Entry(name, id, proj, pcs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<PCS::Info> PCS::pcsList()
|
||||||
|
{
|
||||||
|
QList<Info> list;
|
||||||
|
|
||||||
|
for (int i = 0; i < _pcss.size(); i++)
|
||||||
|
list.append(Info(_pcss.at(i).id(), _pcss.at(i).name()));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_DEBUG
|
#ifndef QT_NO_DEBUG
|
||||||
QDebug operator<<(QDebug dbg, const PCS &pcs)
|
QDebug operator<<(QDebug dbg, const PCS &pcs)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,20 @@
|
|||||||
class PCS
|
class PCS
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
class Info {
|
||||||
|
public:
|
||||||
|
Info(int id, const QString &name) : _id(id), _name(name) {}
|
||||||
|
|
||||||
|
int id() const {return _id;}
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
bool operator<(const Info &other) const {return _id < other._id;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _id;
|
||||||
|
QString _name;
|
||||||
|
};
|
||||||
|
|
||||||
PCS() : _gcs(0) {}
|
PCS() : _gcs(0) {}
|
||||||
PCS(const GCS *gcs, const Projection::Method &method,
|
PCS(const GCS *gcs, const Projection::Method &method,
|
||||||
const Projection::Setup &setup, const LinearUnits &units,
|
const Projection::Setup &setup, const LinearUnits &units,
|
||||||
@ -34,11 +48,12 @@ public:
|
|||||||
static void loadList(const QString &path);
|
static void loadList(const QString &path);
|
||||||
static const PCS *pcs(int id);
|
static const PCS *pcs(int id);
|
||||||
static const PCS *pcs(const GCS *gcs, int proj);
|
static const PCS *pcs(const GCS *gcs, int proj);
|
||||||
|
static QList<Info> pcsList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Entry;
|
class Entry;
|
||||||
|
|
||||||
static QList<PCS::Entry> defaults();
|
static QList<Entry> defaults();
|
||||||
|
|
||||||
const GCS *_gcs;
|
const GCS *_gcs;
|
||||||
Projection::Method _method;
|
Projection::Method _method;
|
||||||
|
@ -128,6 +128,8 @@ Projection::~Projection()
|
|||||||
|
|
||||||
Projection &Projection::operator=(const Projection &p)
|
Projection &Projection::operator=(const Projection &p)
|
||||||
{
|
{
|
||||||
|
delete _ct;
|
||||||
|
|
||||||
_gcs = p._gcs;
|
_gcs = p._gcs;
|
||||||
_units = p._units;
|
_units = p._units;
|
||||||
_ct = p._ct ? p._ct->clone() : 0;
|
_ct = p._ct ? p._ct->clone() : 0;
|
||||||
|
@ -10,21 +10,18 @@
|
|||||||
class Tile
|
class Tile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Tile() : _scaledSize(0) {}
|
Tile() {}
|
||||||
Tile(const QPoint &xy, const QVariant &zoom, int scaledSize = 0,
|
Tile(const QPoint &xy, const QVariant &zoom, const RectD &bbox = RectD())
|
||||||
const RectD &bbox = RectD()) : _xy(xy), _zoom(zoom),
|
: _xy(xy), _zoom(zoom), _bbox(bbox) {}
|
||||||
_scaledSize(scaledSize), _bbox(bbox) {}
|
|
||||||
|
|
||||||
const QVariant &zoom() const {return _zoom;}
|
const QVariant &zoom() const {return _zoom;}
|
||||||
const QPoint &xy() const {return _xy;}
|
const QPoint &xy() const {return _xy;}
|
||||||
const RectD &bbox() const {return _bbox;}
|
const RectD &bbox() const {return _bbox;}
|
||||||
int scaledSize() const {return _scaledSize;}
|
|
||||||
QPixmap& pixmap() {return _pixmap;}
|
QPixmap& pixmap() {return _pixmap;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPoint _xy;
|
QPoint _xy;
|
||||||
QVariant _zoom;
|
QVariant _zoom;
|
||||||
int _scaledSize;
|
|
||||||
RectD _bbox;
|
RectD _bbox;
|
||||||
QPixmap _pixmap;
|
QPixmap _pixmap;
|
||||||
};
|
};
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
class TileImage
|
class TileImage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TileImage() : _tile(0) {}
|
TileImage() : _tile(0), _scaledSize(0) {}
|
||||||
TileImage(const QString &file, Tile *tile)
|
TileImage(const QString &file, Tile *tile, int scaledSize)
|
||||||
: _file(file), _tile(tile) {}
|
: _file(file), _tile(tile), _scaledSize(scaledSize) {}
|
||||||
|
|
||||||
void createPixmap()
|
void createPixmap()
|
||||||
{
|
{
|
||||||
@ -26,8 +26,8 @@ public:
|
|||||||
{
|
{
|
||||||
QByteArray z(_tile->zoom().toString().toLatin1());
|
QByteArray z(_tile->zoom().toString().toLatin1());
|
||||||
QImageReader reader(_file, z);
|
QImageReader reader(_file, z);
|
||||||
if (_tile->scaledSize())
|
if (_scaledSize)
|
||||||
reader.setScaledSize(QSize(_tile->scaledSize(), _tile->scaledSize()));
|
reader.setScaledSize(QSize(_scaledSize, _scaledSize));
|
||||||
reader.read(&_image);
|
reader.read(&_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString _file;
|
QString _file;
|
||||||
Tile *_tile;
|
Tile *_tile;
|
||||||
|
int _scaledSize;
|
||||||
QImage _image;
|
QImage _image;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -45,8 +46,25 @@ static void render(TileImage &ti)
|
|||||||
ti.load();
|
ti.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString quadKey(const QPoint &xy, int zoom)
|
||||||
|
{
|
||||||
|
QString qk;
|
||||||
|
|
||||||
|
for (int i = zoom; i > 0; i--) {
|
||||||
|
char digit = '0';
|
||||||
|
unsigned mask = 1 << (i - 1);
|
||||||
|
if (xy.x() & mask)
|
||||||
|
digit++;
|
||||||
|
if (xy.y() & mask)
|
||||||
|
digit += 2;
|
||||||
|
qk.append(digit);
|
||||||
|
}
|
||||||
|
|
||||||
|
return qk;
|
||||||
|
}
|
||||||
|
|
||||||
TileLoader::TileLoader(const QString &dir, QObject *parent)
|
TileLoader::TileLoader(const QString &dir, QObject *parent)
|
||||||
: QObject(parent), _dir(dir)
|
: QObject(parent), _dir(dir), _scaledSize(0), _quadTiles(false)
|
||||||
{
|
{
|
||||||
if (!QDir().mkpath(_dir))
|
if (!QDir().mkpath(_dir))
|
||||||
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
|
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
|
||||||
@ -70,11 +88,11 @@ void TileLoader::loadTilesAsync(QVector<Tile> &list)
|
|||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
|
||||||
if (fi.exists())
|
if (fi.exists())
|
||||||
imgs.append(TileImage(file, &t));
|
imgs.append(TileImage(file, &t, _scaledSize));
|
||||||
else {
|
else {
|
||||||
QUrl url(tileUrl(t));
|
QUrl url(tileUrl(t));
|
||||||
if (url.isLocalFile())
|
if (url.isLocalFile())
|
||||||
imgs.append(TileImage(url.toLocalFile(), &t));
|
imgs.append(TileImage(url.toLocalFile(), &t, _scaledSize));
|
||||||
else
|
else
|
||||||
dl.append(Download(url, file));
|
dl.append(Download(url, file));
|
||||||
}
|
}
|
||||||
@ -109,11 +127,11 @@ void TileLoader::loadTilesSync(QVector<Tile> &list)
|
|||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
|
||||||
if (fi.exists())
|
if (fi.exists())
|
||||||
imgs.append(TileImage(file, &t));
|
imgs.append(TileImage(file, &t, _scaledSize));
|
||||||
else {
|
else {
|
||||||
QUrl url(tileUrl(t));
|
QUrl url(tileUrl(t));
|
||||||
if (url.isLocalFile())
|
if (url.isLocalFile())
|
||||||
imgs.append(TileImage(url.toLocalFile(), &t));
|
imgs.append(TileImage(url.toLocalFile(), &t, _scaledSize));
|
||||||
else {
|
else {
|
||||||
dl.append(Download(url, file));
|
dl.append(Download(url, file));
|
||||||
tl.append(&t);
|
tl.append(&t);
|
||||||
@ -131,7 +149,7 @@ void TileLoader::loadTilesSync(QVector<Tile> &list)
|
|||||||
Tile *t = tl[i];
|
Tile *t = tl[i];
|
||||||
QString file = tileFile(*t);
|
QString file = tileFile(*t);
|
||||||
if (QFileInfo(file).exists())
|
if (QFileInfo(file).exists())
|
||||||
imgs.append(TileImage(file, t));
|
imgs.append(TileImage(file, t, _scaledSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +182,8 @@ QUrl TileLoader::tileUrl(const Tile &tile) const
|
|||||||
QString::number(tile.bbox().right(), 'f', 6),
|
QString::number(tile.bbox().right(), 'f', 6),
|
||||||
QString::number(tile.bbox().top(), 'f', 6));
|
QString::number(tile.bbox().top(), 'f', 6));
|
||||||
url.replace("$bbox", bbox);
|
url.replace("$bbox", bbox);
|
||||||
|
} else if (_quadTiles) {
|
||||||
|
url.replace("$quadkey", quadKey(tile.xy(), tile.zoom().toInt()));
|
||||||
} else {
|
} else {
|
||||||
url.replace("$z", tile.zoom().toString());
|
url.replace("$z", tile.zoom().toString());
|
||||||
url.replace("$x", QString::number(tile.xy().x()));
|
url.replace("$x", QString::number(tile.xy().x()));
|
||||||
|
@ -16,6 +16,8 @@ public:
|
|||||||
void setUrl(const QString &url) {_url = url;}
|
void setUrl(const QString &url) {_url = url;}
|
||||||
void setAuthorization(const Authorization &authorization)
|
void setAuthorization(const Authorization &authorization)
|
||||||
{_authorization = authorization;}
|
{_authorization = authorization;}
|
||||||
|
void setScaledSize(int size) {_scaledSize = size;}
|
||||||
|
void setQuadTiles(bool quadTiles) {_quadTiles = quadTiles;}
|
||||||
|
|
||||||
void loadTilesAsync(QVector<Tile> &list);
|
void loadTilesAsync(QVector<Tile> &list);
|
||||||
void loadTilesSync(QVector<Tile> &list);
|
void loadTilesSync(QVector<Tile> &list);
|
||||||
@ -32,6 +34,8 @@ private:
|
|||||||
QString _url;
|
QString _url;
|
||||||
QString _dir;
|
QString _dir;
|
||||||
Authorization _authorization;
|
Authorization _authorization;
|
||||||
|
int _scaledSize;
|
||||||
|
bool _quadTiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TILELOADER_Honlinemap
|
#endif // TILELOADER_Honlinemap
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#define CAPABILITIES_FILE "capabilities.xml"
|
#define CAPABILITIES_FILE "capabilities.xml"
|
||||||
#define TILE_SIZE 256
|
#define TILE_SIZE 256
|
||||||
|
#define EPSILON 1e-6
|
||||||
|
|
||||||
double WMSMap::sd2res(double scaleDenominator) const
|
double WMSMap::sd2res(double scaleDenominator) const
|
||||||
{
|
{
|
||||||
@ -50,14 +51,15 @@ void WMSMap::computeZooms(const RangeF &scaleDenominator)
|
|||||||
_zooms.clear();
|
_zooms.clear();
|
||||||
|
|
||||||
if (scaleDenominator.size() > 0) {
|
if (scaleDenominator.size() > 0) {
|
||||||
double ld = log2(scaleDenominator.max()) - log2(scaleDenominator.min());
|
double ld = log2(scaleDenominator.max() - EPSILON)
|
||||||
|
- log2(scaleDenominator.min() + EPSILON);
|
||||||
int cld = (int)ceil(ld);
|
int cld = (int)ceil(ld);
|
||||||
double step = ld / (double)cld;
|
double step = ld / (double)cld;
|
||||||
double lmax = log2(scaleDenominator.max());
|
double lmax = log2(scaleDenominator.max() - EPSILON);
|
||||||
for (int i = 0; i <= cld; i++)
|
for (int i = 0; i <= cld; i++)
|
||||||
_zooms.append(pow(2.0, lmax - i * step));
|
_zooms.append(pow(2.0, lmax - i * step));
|
||||||
} else
|
} else
|
||||||
_zooms.append(scaleDenominator.min());
|
_zooms.append(scaleDenominator.min() + EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WMSMap::updateTransform()
|
void WMSMap::updateTransform()
|
||||||
@ -194,13 +196,13 @@ void WMSMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
for (int j = tl.y(); j < br.y(); j++) {
|
for (int j = tl.y(); j < br.y(); j++) {
|
||||||
PointD ttl(_transform.img2proj(QPointF(i * TILE_SIZE,
|
PointD ttl(_transform.img2proj(QPointF(i * TILE_SIZE,
|
||||||
j * TILE_SIZE)));
|
j * TILE_SIZE)));
|
||||||
PointD tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE
|
PointD tbr(_transform.img2proj(QPointF(i * TILE_SIZE + TILE_SIZE,
|
||||||
- 1, j * TILE_SIZE + TILE_SIZE - 1)));
|
j * TILE_SIZE + TILE_SIZE)));
|
||||||
RectD bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
RectD bbox = (_cs.axisOrder() == CoordinateSystem::YX)
|
||||||
? RectD(PointD(tbr.y(), tbr.x()), PointD(ttl.y(), ttl.x()))
|
? RectD(PointD(tbr.y(), tbr.x()), PointD(ttl.y(), ttl.x()))
|
||||||
: RectD(ttl, tbr);
|
: RectD(ttl, tbr);
|
||||||
|
|
||||||
tiles.append(Tile(QPoint(i, j), _zoom, 0, bbox));
|
tiles.append(Tile(QPoint(i, j), _zoom, bbox));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user