mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-05 07:02:51 +02:00
Compare commits
27 Commits
Author | SHA1 | Date | |
---|---|---|---|
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.7.{build}
|
||||
configuration: Release
|
||||
platform: Any CPU
|
||||
environment:
|
||||
|
@ -4,7 +4,7 @@ GPXSee is a Qt-based GPS log file viewer and analyzer that supports all common G
|
||||
## Features
|
||||
* 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).
|
||||
* 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.
|
||||
* Support for DEM files (SRTM HGT).
|
||||
* Support for multiple tracks in one view.
|
||||
|
@ -3,7 +3,7 @@ unix:!macx {
|
||||
} else {
|
||||
TARGET = GPXSee
|
||||
}
|
||||
VERSION = 7.6
|
||||
VERSION = 7.7
|
||||
|
||||
QT += core \
|
||||
gui \
|
||||
@ -177,7 +177,8 @@ HEADERS += src/common/config.h \
|
||||
src/map/IMG/subdiv.h \
|
||||
src/map/IMG/units.h \
|
||||
src/map/IMG/style.h \
|
||||
src/map/IMG/netfile.h
|
||||
src/map/IMG/netfile.h \
|
||||
src/GUI/limitedcombobox.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/common/coordinates.cpp \
|
||||
src/common/rectc.cpp \
|
||||
@ -388,7 +389,7 @@ win32 {
|
||||
|
||||
unix:!macx {
|
||||
isEmpty(PREFIX):PREFIX = /usr/local
|
||||
lessThan(QT_MAJOR_VERSION, 5) {DEFINES += PREFIX=\\\"$$PREFIX\\\"}
|
||||
DEFINES += PREFIX=\\\"$$PREFIX\\\"
|
||||
|
||||
maps.files = pkg/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>
|
||||
<summary>GPS log file viewer and analyzer</summary>
|
||||
<description>
|
||||
<p>GPXSee is a GPS log file viewer and analyzer that supports GPX, TCX,
|
||||
KML, FIT, IGC, NMEA, SLF, LOC, GeoJSON and OziExplorer files.</p>
|
||||
<p>GPXSee is a GPS log file viewer and analyzer that supports all common
|
||||
GPS log file formats.</p>
|
||||
|
||||
<p>Features:</p>
|
||||
<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,
|
||||
WMS, TMS).</li>
|
||||
<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
|
||||
graphs.</li>
|
||||
<li>Support for multiple tracks in one view.</li>
|
||||
@ -23,8 +25,6 @@
|
||||
<li>Print/export to PDF.</li>
|
||||
<li>Full-screen mode.</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>
|
||||
</description>
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "7.6"
|
||||
!define VERSION "7.7"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
|
@ -7,7 +7,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "7.6"
|
||||
!define VERSION "7.7"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
|
@ -103,7 +103,6 @@ GUI::GUI()
|
||||
readSettings();
|
||||
|
||||
updateGraphTabs();
|
||||
updateMapView();
|
||||
updateStatusBarInfo();
|
||||
}
|
||||
|
||||
@ -725,6 +724,8 @@ void GUI::paths()
|
||||
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
||||
+ tr("DEM directory:") + "</td><td><code>"
|
||||
+ 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>"
|
||||
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
||||
);
|
||||
@ -805,7 +806,7 @@ bool GUI::loadFile(const QString &fileName)
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++)
|
||||
graphs.append(_tabs.at(i)->loadData(data));
|
||||
if (updateGraphTabs() | updateMapView())
|
||||
if (updateGraphTabs())
|
||||
_splitter->refresh();
|
||||
paths = _mapView->loadData(data);
|
||||
|
||||
@ -828,7 +829,6 @@ bool GUI::loadFile(const QString &fileName)
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateMapView();
|
||||
|
||||
QString error = tr("Error loading data file:") + "\n\n"
|
||||
+ fileName + "\n\n" + data.errorString();
|
||||
@ -930,6 +930,7 @@ void GUI::openOptions()
|
||||
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
||||
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
||||
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
||||
SET_VIEW_OPTION(projection, setProjection);
|
||||
|
||||
SET_TAB_OPTION(palette, setPalette);
|
||||
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
||||
@ -974,8 +975,6 @@ void GUI::openOptions()
|
||||
reloadFile();
|
||||
|
||||
_options = options;
|
||||
|
||||
updateMapView();
|
||||
}
|
||||
|
||||
void GUI::printFile()
|
||||
@ -1230,7 +1229,6 @@ void GUI::closeAll()
|
||||
updateStatusBarInfo();
|
||||
updateWindowTitle();
|
||||
updateGraphTabs();
|
||||
updateMapView();
|
||||
}
|
||||
|
||||
void GUI::showGraphs(bool show)
|
||||
@ -1473,19 +1471,6 @@ bool GUI::updateGraphTabs()
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i <_tabs.count(); i++)
|
||||
@ -1847,8 +1832,8 @@ void GUI::writeSettings()
|
||||
_options.separateGraphPage);
|
||||
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
||||
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
||||
if (_options.alwaysShowMap != ALWAYS_SHOW_MAP_DEFAULT)
|
||||
settings.setValue(ALWAYS_SHOW_MAP_SETTING, _options.alwaysShowMap);
|
||||
if (_options.projection != PROJECTION_DEFAULT)
|
||||
settings.setValue(PROJECTION_SETTING, _options.projection);
|
||||
#ifdef ENABLE_HIDPI
|
||||
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
||||
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
||||
@ -2110,8 +2095,8 @@ void GUI::readSettings()
|
||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
||||
SLIDER_COLOR_DEFAULT).value<QColor>();
|
||||
_options.alwaysShowMap = settings.value(ALWAYS_SHOW_MAP_SETTING,
|
||||
ALWAYS_SHOW_MAP_DEFAULT).toBool();
|
||||
_options.projection = settings.value(PROJECTION_SETTING, PROJECTION_DEFAULT)
|
||||
.toInt();
|
||||
#ifdef ENABLE_HIDPI
|
||||
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
||||
.toBool();
|
||||
@ -2139,6 +2124,7 @@ void GUI::readSettings()
|
||||
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||
#endif // ENABLE_HIDPI
|
||||
_mapView->setProjection(_options.projection);
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++) {
|
||||
_tabs.at(i)->setPalette(_options.palette);
|
||||
|
@ -116,7 +116,6 @@ private:
|
||||
void updateWindowTitle();
|
||||
void updateNavigationActions();
|
||||
bool updateGraphTabs();
|
||||
bool updateMapView();
|
||||
|
||||
TimeType timeType() const;
|
||||
Units units() const;
|
||||
|
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/data.h"
|
||||
#include "map/map.h"
|
||||
#include "map/pcs.h"
|
||||
#include "opengl.h"
|
||||
#include "trackitem.h"
|
||||
#include "routeitem.h"
|
||||
@ -48,8 +49,10 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
_coordinates->setVisible(false);
|
||||
_scene->addItem(_coordinates);
|
||||
|
||||
_projection = PCS::pcs(3857);
|
||||
_map = map;
|
||||
_map->load();
|
||||
_map->setProjection(_projection);
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||
|
||||
_poi = poi;
|
||||
@ -312,6 +315,7 @@ void MapView::setMap(Map *map)
|
||||
|
||||
_map = map;
|
||||
_map->load();
|
||||
_map->setProjection(_projection);
|
||||
#ifdef ENABLE_HIDPI
|
||||
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||
#endif // ENABLE_HIDPI
|
||||
@ -1012,3 +1016,17 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||
Q_UNUSED(mapRatio);
|
||||
#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/config.h"
|
||||
#include "data/waypoint.h"
|
||||
#include "data/polygon.h"
|
||||
#include "map/projection.h"
|
||||
#include "searchpointer.h"
|
||||
#include "units.h"
|
||||
#include "format.h"
|
||||
#include "palette.h"
|
||||
#include "data/polygon.h"
|
||||
|
||||
|
||||
class Data;
|
||||
class POI;
|
||||
@ -80,6 +82,7 @@ public slots:
|
||||
void clearMapCache();
|
||||
void setCoordinatesFormat(CoordinatesFormat format);
|
||||
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||
void setProjection(int id);
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
@ -132,6 +135,7 @@ private:
|
||||
Units _units;
|
||||
CoordinatesFormat _coordinatesFormat;
|
||||
qreal _mapOpacity;
|
||||
Projection _projection;
|
||||
|
||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||
|
@ -12,11 +12,14 @@
|
||||
#include <QRadioButton>
|
||||
#include <QLabel>
|
||||
#include <QSysInfo>
|
||||
#include <QInputDialog>
|
||||
#include "map/pcs.h"
|
||||
#include "icons.h"
|
||||
#include "colorbox.h"
|
||||
#include "stylecombobox.h"
|
||||
#include "oddspinbox.h"
|
||||
#include "percentslider.h"
|
||||
#include "limitedcombobox.h"
|
||||
#include "optionsdialog.h"
|
||||
|
||||
|
||||
@ -36,10 +39,15 @@ static QFrame *line()
|
||||
|
||||
QWidget *OptionsDialog::createMapPage()
|
||||
{
|
||||
_alwaysShowMap = new QCheckBox(tr("Always show the map"));
|
||||
_alwaysShowMap->setChecked(_options->alwaysShowMap);
|
||||
_alwaysShowMap->setToolTip("<p>" +
|
||||
tr("Show the map even when no files are loaded.") + "</p>");
|
||||
_projection = new LimitedComboBox(200);
|
||||
QList<PCS::Info> projections(PCS::pcsList());
|
||||
qSort(projections);
|
||||
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
|
||||
_hidpi = new QRadioButton(tr("High-resolution"));
|
||||
@ -60,14 +68,14 @@ QWidget *OptionsDialog::createMapPage()
|
||||
llo->setFont(f);
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
QFormLayout *showMapLayout = new QFormLayout();
|
||||
showMapLayout->addWidget(_alwaysShowMap);
|
||||
QFormLayout *vectorLayout = new QFormLayout();
|
||||
vectorLayout->addRow(tr("Projection:"), _projection);
|
||||
|
||||
QWidget *mapTab = new QWidget();
|
||||
QVBoxLayout *mapTabLayout = new QVBoxLayout();
|
||||
mapTabLayout->addLayout(showMapLayout);
|
||||
mapTabLayout->addStretch();
|
||||
mapTab->setLayout(mapTabLayout);
|
||||
QWidget *vectorMapsTab = new QWidget();
|
||||
QVBoxLayout *vectorMapsTabLayout = new QVBoxLayout();
|
||||
vectorMapsTabLayout->addLayout(vectorLayout);
|
||||
vectorMapsTabLayout->addStretch();
|
||||
vectorMapsTab->setLayout(vectorMapsTabLayout);
|
||||
|
||||
#ifdef ENABLE_HIDPI
|
||||
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
||||
@ -83,7 +91,7 @@ QWidget *OptionsDialog::createMapPage()
|
||||
#endif // ENABLE_HIDPI
|
||||
|
||||
QTabWidget *mapPage = new QTabWidget();
|
||||
mapPage->addTab(mapTab, tr("General"));
|
||||
mapPage->addTab(vectorMapsTab, tr("Vector maps"));
|
||||
#ifdef ENABLE_HIDPI
|
||||
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
||||
#endif // ENABLE_HIDPI
|
||||
@ -261,6 +269,7 @@ QWidget *OptionsDialog::createAppearancePage()
|
||||
_backgroundColor = new ColorBox();
|
||||
_backgroundColor->setColor(_options->backgroundColor);
|
||||
_backgroundColor->enableAlphaChannel(false);
|
||||
|
||||
QFormLayout *mapLayout = new QFormLayout();
|
||||
mapLayout->addRow(tr("Background color:"), _backgroundColor);
|
||||
mapLayout->addRow(tr("Map opacity:"), _mapOpacity);
|
||||
@ -656,7 +665,8 @@ void OptionsDialog::accept()
|
||||
_options->sliderColor = _sliderColor->color();
|
||||
_options->graphAntiAliasing = _graphAA->isChecked();
|
||||
|
||||
_options->alwaysShowMap = _alwaysShowMap->isChecked();
|
||||
_options->projection = _projection->itemData(_projection->currentIndex())
|
||||
.toInt();
|
||||
#ifdef ENABLE_HIDPI
|
||||
_options->hidpiMap = _hidpi->isChecked();
|
||||
#endif // ENABLE_HIDPI
|
||||
|
@ -15,6 +15,7 @@ class QComboBox;
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
class PercentSlider;
|
||||
class LimitedComboBox;
|
||||
|
||||
struct Options {
|
||||
// Appearance
|
||||
@ -37,7 +38,7 @@ struct Options {
|
||||
int mapOpacity;
|
||||
QColor backgroundColor;
|
||||
// Map
|
||||
bool alwaysShowMap;
|
||||
int projection;
|
||||
#ifdef ENABLE_HIDPI
|
||||
bool hidpiMap;
|
||||
#endif // ENABLE_HIDPI
|
||||
@ -79,11 +80,14 @@ class OptionsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
|
||||
public:
|
||||
OptionsDialog(Options *options, QWidget *parent = 0);
|
||||
|
||||
public slots:
|
||||
void accept();
|
||||
//private slots:
|
||||
// void projectionChanged(int index);
|
||||
|
||||
private:
|
||||
QWidget *createMapPage();
|
||||
@ -116,7 +120,7 @@ private:
|
||||
ColorBox *_sliderColor;
|
||||
QCheckBox *_graphAA;
|
||||
// Map
|
||||
QCheckBox *_alwaysShowMap;
|
||||
LimitedComboBox *_projection;
|
||||
#ifdef ENABLE_HIDPI
|
||||
QRadioButton *_hidpi;
|
||||
QRadioButton *_lodpi;
|
||||
|
@ -171,8 +171,8 @@
|
||||
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
||||
#define SLIDER_COLOR_SETTING "sliderColor"
|
||||
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
||||
#define ALWAYS_SHOW_MAP_SETTING "alwaysShowMap"
|
||||
#define ALWAYS_SHOW_MAP_DEFAULT true
|
||||
#define PROJECTION_SETTING "projection"
|
||||
#define PROJECTION_DEFAULT 3857
|
||||
#define HIDPI_MAP_SETTING "HiDPIMap"
|
||||
#define HIDPI_MAP_DEFAULT true
|
||||
|
||||
|
@ -9,9 +9,11 @@
|
||||
#define DEM_DIR "DEM"
|
||||
#define TILES_DIR "tiles"
|
||||
#define TRANSLATIONS_DIR "translations"
|
||||
#define STYLE_DIR "style"
|
||||
#define ELLIPSOID_FILE "ellipsoids.csv"
|
||||
#define GCS_FILE "gcs.csv"
|
||||
#define PCS_FILE "pcs.csv"
|
||||
#define TYP_FILE "style.typ"
|
||||
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0)
|
||||
@ -79,6 +81,11 @@ QString ProgramPaths::demDir(bool writable)
|
||||
return dir(DEM_DIR, writable);
|
||||
}
|
||||
|
||||
QString ProgramPaths::styleDir(bool writable)
|
||||
{
|
||||
return dir(STYLE_DIR, writable);
|
||||
}
|
||||
|
||||
QString ProgramPaths::tilesDir()
|
||||
{
|
||||
#if defined(Q_OS_WIN32)
|
||||
@ -113,6 +120,11 @@ QString ProgramPaths::pcsFile()
|
||||
return file(dir(CSV_DIR), PCS_FILE);
|
||||
}
|
||||
|
||||
QString ProgramPaths::typFile()
|
||||
{
|
||||
return file(dir(STYLE_DIR), TYP_FILE);
|
||||
}
|
||||
|
||||
#else // QT_VERSION < 5
|
||||
|
||||
#include <QStandardPaths>
|
||||
@ -157,6 +169,16 @@ QString ProgramPaths::demDir(bool writable)
|
||||
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()
|
||||
{
|
||||
return QDir(QStandardPaths::writableLocation(
|
||||
@ -187,4 +209,10 @@ QString ProgramPaths::pcsFile()
|
||||
CSV_DIR "/" PCS_FILE, QStandardPaths::LocateFile);
|
||||
}
|
||||
|
||||
QString ProgramPaths::typFile()
|
||||
{
|
||||
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||
STYLE_DIR "/" TYP_FILE, QStandardPaths::LocateFile);
|
||||
}
|
||||
|
||||
#endif // QT_VERSION < 5
|
||||
|
@ -9,11 +9,13 @@ namespace ProgramPaths
|
||||
QString poiDir(bool writable = false);
|
||||
QString csvDir(bool writable = false);
|
||||
QString demDir(bool writable = false);
|
||||
QString styleDir(bool writable = false);
|
||||
QString tilesDir();
|
||||
QString translationsDir();
|
||||
QString ellipsoidsFile();
|
||||
QString gcsFile();
|
||||
QString pcsFile();
|
||||
QString typFile();
|
||||
}
|
||||
|
||||
#endif // PROGRAMPATHS_H
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <QSet>
|
||||
#include <QtEndian>
|
||||
#include "common/programpaths.h"
|
||||
#include "vectortile.h"
|
||||
#include "img.h"
|
||||
|
||||
@ -162,9 +163,18 @@ IMG::IMG(const QString &fileName) : _file(fileName), _valid(false)
|
||||
|
||||
// Read TYP file if any
|
||||
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();
|
||||
_style = Style(typ);
|
||||
qDeleteAll(TYPMap);
|
||||
} else {
|
||||
QFile typFile(ProgramPaths::typFile());
|
||||
if (typFile.exists()) {
|
||||
SubFile typ(&typFile);
|
||||
_style = Style(&typ);
|
||||
}
|
||||
}
|
||||
|
||||
_valid = true;
|
||||
|
@ -50,20 +50,19 @@ public:
|
||||
const QString &name() const {return _name;}
|
||||
const RectC &bounds() const {return _bounds;}
|
||||
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;}
|
||||
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:
|
||||
friend class SubFile;
|
||||
|
||||
typedef RTree<VectorTile*, double, 2> TileTree;
|
||||
|
||||
QString fileName() const {return _file.fileName();}
|
||||
int blockSize() const {return _blockSize;}
|
||||
bool readBlock(int blockNum, QByteArray &data);
|
||||
qint64 read(char *data, qint64 maxSize);
|
||||
|
@ -779,7 +779,7 @@ bool Style::parseTYPFile(SubFile *file)
|
||||
&& parsePolygons(file, hdl, polygons)
|
||||
&& parseDrawOrder(file, hdl, order))) {
|
||||
qWarning("%s: Invalid TYP file, using default style",
|
||||
qPrintable(file->imgName()));
|
||||
qPrintable(file->fileName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -791,7 +791,7 @@ Style::Style(SubFile *typ)
|
||||
defaultLineStyle();
|
||||
defaultPolygonStyle();
|
||||
|
||||
if (typ)
|
||||
if (typ && typ->isValid())
|
||||
parseTYPFile(typ);
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include <QFile>
|
||||
#include "img.h"
|
||||
#include "subfile.h"
|
||||
|
||||
@ -19,42 +20,68 @@ SubFile::Type SubFile::type(const char str[3])
|
||||
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
|
||||
{
|
||||
return ((quint32)_img->blockSize() * (quint32)_blocks.size() - _size
|
||||
< (quint32)_img->blockSize());
|
||||
return _file
|
||||
? _file->isOpen()
|
||||
: ((quint32)_img->blockSize() * (quint32)_blocks.size() - _size
|
||||
< (quint32)_img->blockSize());
|
||||
}
|
||||
|
||||
bool SubFile::seek(Handle &handle, quint32 pos) const
|
||||
{
|
||||
quint32 blockSize = _img->blockSize();
|
||||
int blockNum = pos / blockSize;
|
||||
Q_ASSERT(_img || _file);
|
||||
|
||||
if (handle.blockNum != blockNum) {
|
||||
if (blockNum >= _blocks.size())
|
||||
return false;
|
||||
if (!_img->readBlock(_blocks.at(blockNum), handle.data))
|
||||
return false;
|
||||
handle.blockNum = blockNum;
|
||||
if (_file)
|
||||
return _file->seek(pos);
|
||||
else {
|
||||
quint32 blockSize = _img->blockSize();
|
||||
int blockNum = pos / blockSize;
|
||||
|
||||
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
|
||||
{
|
||||
val = handle.data.at(handle.blockPos++);
|
||||
handle.pos++;
|
||||
return (handle.blockPos >= _img->blockSize())
|
||||
? seek(handle, handle.pos) : true;
|
||||
Q_ASSERT(_img || _file);
|
||||
|
||||
if (_file)
|
||||
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
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
class IMG;
|
||||
class QFile;
|
||||
|
||||
class SubFile
|
||||
{
|
||||
@ -21,12 +22,13 @@ public:
|
||||
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);}
|
||||
bool isValid() const;
|
||||
|
||||
quint32 size() const {return _size;}
|
||||
quint32 size() const;
|
||||
bool seek(Handle &handle, quint32 pos) const;
|
||||
bool readByte(Handle &handle, quint8 &val) const;
|
||||
|
||||
@ -79,7 +81,7 @@ public:
|
||||
}
|
||||
|
||||
quint16 offset() const {return _blocks.first();}
|
||||
const QString &imgName() const;
|
||||
QString fileName() const;
|
||||
|
||||
static Type type(const char str[3]);
|
||||
|
||||
@ -87,6 +89,7 @@ public:
|
||||
|
||||
private:
|
||||
IMG *_img;
|
||||
QFile *_file;
|
||||
quint32 _size;
|
||||
QVector<quint16> _blocks;
|
||||
};
|
||||
|
@ -66,8 +66,14 @@ void TextPointItem::paint(QPainter *painter) const
|
||||
painter->setPen(*_color);
|
||||
painter->drawText(_textRect, FLAGS, *_text);
|
||||
} else {
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||
img.invertPixels();
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,3 +369,10 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
painter->drawPixmap(mt.xy(), pm);
|
||||
}
|
||||
}
|
||||
|
||||
void IMGMap::setProjection(const Projection &projection)
|
||||
{
|
||||
_projection = projection;
|
||||
updateTransform();
|
||||
QPixmapCache::clear();
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
|
||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||
|
||||
void setProjection(const Projection &projection);
|
||||
|
||||
bool isValid() const {return _valid;}
|
||||
QString errorString() const {return _errorString;}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <QLineF>
|
||||
#include "map.h"
|
||||
#include "pcs.h"
|
||||
|
||||
qreal Map::resolution(const QRectF &rect)
|
||||
{
|
||||
|
@ -7,8 +7,10 @@
|
||||
#include <QFlags>
|
||||
#include "common/coordinates.h"
|
||||
|
||||
|
||||
class QPainter;
|
||||
class RectC;
|
||||
class Projection;
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
@ -45,6 +47,7 @@ public:
|
||||
virtual void load() {}
|
||||
virtual void unload() {}
|
||||
virtual void setDevicePixelRatio(qreal, qreal) {}
|
||||
virtual void setProjection(const Projection &) {}
|
||||
|
||||
virtual bool isValid() const {return true;}
|
||||
virtual QString errorString() const {return QString();}
|
||||
|
@ -5,13 +5,16 @@
|
||||
|
||||
class PCS::Entry {
|
||||
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 proj() const {return _proj;}
|
||||
const PCS &pcs() const {return _pcs;}
|
||||
|
||||
private:
|
||||
QString _name;
|
||||
int _id, _proj;
|
||||
PCS _pcs;
|
||||
};
|
||||
@ -21,8 +24,9 @@ QList<PCS::Entry> PCS::_pcss = defaults();
|
||||
QList<PCS::Entry> PCS::defaults()
|
||||
{
|
||||
QList<PCS::Entry> list;
|
||||
list.append(PCS::Entry(3857, 3856, PCS(&GCS::WGS84(), 1024,
|
||||
Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN), 9001, 4499)));
|
||||
list.append(PCS::Entry("WGS 84 / Pseudo-Mercator", 3857, 3856,
|
||||
PCS(&GCS::WGS84(), 1024, Projection::Setup(0, 0, NAN, 0, 0, NAN, NAN),
|
||||
9001, 4499)));
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -154,27 +158,28 @@ void PCS::loadList(const QString &path)
|
||||
continue;
|
||||
}
|
||||
|
||||
int id = list[1].trimmed().toInt(&res);
|
||||
QString name(list.at(0).trimmed());
|
||||
int id = list.at(1).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid PCS code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int gcsid = list[2].trimmed().toInt(&res);
|
||||
int gcsid = list.at(2).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid GCS code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int proj = list[3].trimmed().toInt(&res);
|
||||
int proj = list.at(3).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid projection code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int units = list[4].trimmed().toInt(&res);
|
||||
int units = list.at(4).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid linear units code", qPrintable(path), ln);
|
||||
continue;
|
||||
}
|
||||
int transform = list[5].trimmed().toInt(&res);
|
||||
int transform = list.at(5).trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid coordinate transformation code",
|
||||
qPrintable(path), ln);
|
||||
@ -214,10 +219,20 @@ void PCS::loadList(const QString &path)
|
||||
}
|
||||
|
||||
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
|
||||
QDebug operator<<(QDebug dbg, const PCS &pcs)
|
||||
{
|
||||
|
@ -11,6 +11,20 @@
|
||||
class PCS
|
||||
{
|
||||
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(const GCS *gcs, const Projection::Method &method,
|
||||
const Projection::Setup &setup, const LinearUnits &units,
|
||||
@ -34,11 +48,12 @@ public:
|
||||
static void loadList(const QString &path);
|
||||
static const PCS *pcs(int id);
|
||||
static const PCS *pcs(const GCS *gcs, int proj);
|
||||
static QList<Info> pcsList();
|
||||
|
||||
private:
|
||||
class Entry;
|
||||
|
||||
static QList<PCS::Entry> defaults();
|
||||
static QList<Entry> defaults();
|
||||
|
||||
const GCS *_gcs;
|
||||
Projection::Method _method;
|
||||
|
Reference in New Issue
Block a user