mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 11:39:16 +02:00
Make the source projection of JNX and KMZ maps selectable
This commit is contained in:
@ -973,7 +973,8 @@ void GUI::openOptions()
|
||||
SET_VIEW_OPTION(pathAntiAliasing, useAntiAliasing);
|
||||
SET_VIEW_OPTION(useOpenGL, useOpenGL);
|
||||
SET_VIEW_OPTION(sliderColor, setMarkerColor);
|
||||
SET_VIEW_OPTION(projection, setProjection);
|
||||
SET_VIEW_OPTION(outputProjection, setOutputProjection);
|
||||
SET_VIEW_OPTION(inputProjection, setInputProjection);
|
||||
|
||||
SET_TAB_OPTION(palette, setPalette);
|
||||
SET_TAB_OPTION(graphWidth, setGraphWidth);
|
||||
@ -2149,8 +2150,10 @@ void GUI::writeSettings()
|
||||
_options.separateGraphPage);
|
||||
if (_options.sliderColor != SLIDER_COLOR_DEFAULT)
|
||||
settings.setValue(SLIDER_COLOR_SETTING, _options.sliderColor);
|
||||
if (_options.projection != PROJECTION_DEFAULT)
|
||||
settings.setValue(PROJECTION_SETTING, _options.projection);
|
||||
if (_options.outputProjection != OUTPUT_PROJECTION_DEFAULT)
|
||||
settings.setValue(OUTPUT_PROJECTION_SETTING, _options.outputProjection);
|
||||
if (_options.inputProjection != INPUT_PROJECTION_DEFAULT)
|
||||
settings.setValue(INPUT_PROJECTION_SETTING, _options.outputProjection);
|
||||
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
||||
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
||||
settings.endGroup();
|
||||
@ -2442,8 +2445,10 @@ void GUI::readSettings()
|
||||
SEPARATE_GRAPH_PAGE_DEFAULT).toBool();
|
||||
_options.sliderColor = settings.value(SLIDER_COLOR_SETTING,
|
||||
SLIDER_COLOR_DEFAULT).value<QColor>();
|
||||
_options.projection = settings.value(PROJECTION_SETTING, PROJECTION_DEFAULT)
|
||||
.toInt();
|
||||
_options.outputProjection = settings.value(OUTPUT_PROJECTION_SETTING,
|
||||
OUTPUT_PROJECTION_DEFAULT).toInt();
|
||||
_options.inputProjection = settings.value(INPUT_PROJECTION_SETTING,
|
||||
INPUT_PROJECTION_DEFAULT).toInt();
|
||||
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
||||
.toBool();
|
||||
|
||||
@ -2467,7 +2472,8 @@ void GUI::readSettings()
|
||||
_mapView->useOpenGL(true);
|
||||
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||
_mapView->setProjection(_options.projection);
|
||||
_mapView->setOutputProjection(_options.outputProjection);
|
||||
_mapView->setInputProjection(_options.inputProjection);
|
||||
_mapView->setTimeZone(_options.timeZone.zone());
|
||||
|
||||
for (int i = 0; i < _tabs.count(); i++) {
|
||||
|
@ -67,10 +67,12 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||
_coordinates->setVisible(false);
|
||||
_scene->addItem(_coordinates);
|
||||
|
||||
_projection = PCS::pcs(3857);
|
||||
_outputProjection = PCS::pcs(3857);
|
||||
_inputProjection = GCS::gcs(4326);
|
||||
_map = map;
|
||||
_map->load();
|
||||
_map->setProjection(_projection);
|
||||
_map->setOutputProjection(_outputProjection);
|
||||
_map->setInputProjection(_inputProjection);
|
||||
connect(_map, SIGNAL(tilesLoaded()), this, SLOT(reloadMap()));
|
||||
|
||||
_poi = poi;
|
||||
@ -369,7 +371,8 @@ void MapView::setMap(Map *map)
|
||||
|
||||
_map = map;
|
||||
_map->load();
|
||||
_map->setProjection(_projection);
|
||||
_map->setOutputProjection(_outputProjection);
|
||||
_map->setInputProjection(_inputProjection);
|
||||
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||
connect(_map, SIGNAL(tilesLoaded()), this, SLOT(reloadMap()));
|
||||
|
||||
@ -1072,20 +1075,38 @@ void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||
reloadMap();
|
||||
}
|
||||
|
||||
void MapView::setProjection(int id)
|
||||
void MapView::setOutputProjection(int id)
|
||||
{
|
||||
const PCS *pcs;
|
||||
const GCS *gcs;
|
||||
Coordinates center = _map->xy2ll(mapToScene(viewport()->rect().center()));
|
||||
|
||||
if ((pcs = PCS::pcs(id)))
|
||||
_projection = Projection(pcs);
|
||||
_outputProjection = Projection(pcs);
|
||||
else if ((gcs = GCS::gcs(id)))
|
||||
_projection = Projection(gcs);
|
||||
_outputProjection = Projection(gcs);
|
||||
else
|
||||
qWarning("%d: Unknown PCS/GCS id", id);
|
||||
|
||||
_map->setProjection(_projection);
|
||||
_map->setOutputProjection(_outputProjection);
|
||||
rescale();
|
||||
centerOn(_map->ll2xy(center));
|
||||
}
|
||||
|
||||
void MapView::setInputProjection(int id)
|
||||
{
|
||||
const PCS *pcs;
|
||||
const GCS *gcs;
|
||||
Coordinates center = _map->xy2ll(mapToScene(viewport()->rect().center()));
|
||||
|
||||
if ((pcs = PCS::pcs(id)))
|
||||
_inputProjection = Projection(pcs);
|
||||
else if ((gcs = GCS::gcs(id)))
|
||||
_inputProjection = Projection(gcs);
|
||||
else
|
||||
qWarning("%d: Unknown PCS/GCS id", id);
|
||||
|
||||
_map->setInputProjection(_inputProjection);
|
||||
rescale();
|
||||
centerOn(_map->ll2xy(center));
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ public slots:
|
||||
void setCoordinatesFormat(CoordinatesFormat format);
|
||||
void setTimeZone(const QTimeZone &zone);
|
||||
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||
void setProjection(int id);
|
||||
void setOutputProjection(int id);
|
||||
void setInputProjection(int id);
|
||||
|
||||
void fitContentToSize();
|
||||
|
||||
@ -155,7 +156,7 @@ private:
|
||||
|
||||
Palette _palette;
|
||||
qreal _mapOpacity;
|
||||
Projection _projection;
|
||||
Projection _outputProjection, _inputProjection;
|
||||
|
||||
bool _showMap, _showTracks, _showRoutes, _showAreas, _showWaypoints,
|
||||
_showWaypointLabels, _showPOI, _showPOILabels, _showRouteWaypoints,
|
||||
|
@ -46,17 +46,52 @@ void OptionsDialog::automaticPauseDetectionSet(bool set)
|
||||
|
||||
QWidget *OptionsDialog::createMapPage()
|
||||
{
|
||||
_projection = new LimitedComboBox(200);
|
||||
int last = -1;
|
||||
|
||||
_outputProjection = new LimitedComboBox(200);
|
||||
QList<KV<int, QString> > projections(GCS::list() + PCS::list());
|
||||
std::sort(projections.begin(), projections.end());
|
||||
|
||||
for (int i = 0; i < projections.size(); i++) {
|
||||
QString text = QString::number(projections.at(i).key()) + " - "
|
||||
+ projections.at(i).value();
|
||||
_projection->addItem(text, QVariant(projections.at(i).key()));
|
||||
const KV<int, QString> &proj = projections.at(i);
|
||||
// There may be same EPSG codes with different names
|
||||
if (proj.key() == last)
|
||||
continue;
|
||||
else
|
||||
last = proj.key();
|
||||
QString text = QString::number(proj.key()) + " - " + proj.value();
|
||||
_outputProjection->addItem(text, QVariant(proj.key()));
|
||||
}
|
||||
_projection->setCurrentIndex(_projection->findData(_options.projection));
|
||||
_outputProjection->setCurrentIndex(_outputProjection->findData(
|
||||
_options.outputProjection));
|
||||
|
||||
_inputProjection = new LimitedComboBox(200);
|
||||
last = -1;
|
||||
for (int i = 0; i < projections.size(); i++) {
|
||||
const KV<int, QString> &proj = projections.at(i);
|
||||
// There may be same EPSG codes with different names
|
||||
if (proj.key() == last)
|
||||
continue;
|
||||
else
|
||||
last = proj.key();
|
||||
if (proj.key() == 4326 || proj.key() == 3857) {
|
||||
QString text = QString::number(proj.key()) + " - " + proj.value();
|
||||
_inputProjection->addItem(text, QVariant(proj.key()));
|
||||
}
|
||||
}
|
||||
_inputProjection->setCurrentIndex(_inputProjection->findData(
|
||||
_options.inputProjection));
|
||||
|
||||
QLabel *inInfo = new QLabel(tr("Select the propper projection of"
|
||||
" JNX and KMZ maps. Both EPSG:3857 and EPSG:4326 projected maps"
|
||||
" exist and there is no projection info in the map file."));
|
||||
QLabel *outInfo = new QLabel(tr("Select the desired projection of IMG"
|
||||
" maps. The projection must be valid for the whole map area."));
|
||||
QFont f = inInfo->font();
|
||||
f.setPointSize(f.pointSize() - 1);
|
||||
inInfo->setWordWrap(true);
|
||||
outInfo->setWordWrap(true);
|
||||
inInfo->setFont(f);
|
||||
outInfo->setFont(f);
|
||||
|
||||
_hidpi = new QRadioButton(tr("High-resolution"));
|
||||
_lodpi = new QRadioButton(tr("Standard"));
|
||||
@ -68,21 +103,24 @@ QWidget *OptionsDialog::createMapPage()
|
||||
"The map is sharp but map objects are small/hard to read."));
|
||||
QLabel *llo = new QLabel(tr("Non-HiDPI maps are loaded such as they are. "
|
||||
"Map objects have the expected size but the map is blurry."));
|
||||
QFont f = lhi->font();
|
||||
f.setPointSize(f.pointSize() - 1);
|
||||
lhi->setWordWrap(true);
|
||||
llo->setWordWrap(true);
|
||||
lhi->setFont(f);
|
||||
llo->setFont(f);
|
||||
|
||||
QFormLayout *vectorLayout = new QFormLayout();
|
||||
vectorLayout->addRow(tr("Projection:"), _projection);
|
||||
|
||||
QWidget *vectorMapsTab = new QWidget();
|
||||
QVBoxLayout *vectorMapsTabLayout = new QVBoxLayout();
|
||||
vectorMapsTabLayout->addLayout(vectorLayout);
|
||||
vectorMapsTabLayout->addStretch();
|
||||
vectorMapsTab->setLayout(vectorMapsTabLayout);
|
||||
QFormLayout *projLayout = new QFormLayout();
|
||||
projLayout->addRow(tr("Input:"), _inputProjection);
|
||||
projLayout->addWidget(inInfo);
|
||||
projLayout->addRow(tr("Output:"), _outputProjection);
|
||||
projLayout->addWidget(outInfo);
|
||||
|
||||
QWidget *projectionTab = new QWidget();
|
||||
QVBoxLayout *projectionTabLayout = new QVBoxLayout();
|
||||
projectionTabLayout->addLayout(projLayout);
|
||||
projectionTabLayout->addStretch();
|
||||
projectionTab->setLayout(projectionTabLayout);
|
||||
|
||||
QVBoxLayout *hidpiTabLayout = new QVBoxLayout();
|
||||
hidpiTabLayout->addWidget(_lodpi);
|
||||
@ -96,7 +134,7 @@ QWidget *OptionsDialog::createMapPage()
|
||||
hidpiTab->setLayout(hidpiTabLayout);
|
||||
|
||||
QTabWidget *mapPage = new QTabWidget();
|
||||
mapPage->addTab(vectorMapsTab, tr("Vector maps"));
|
||||
mapPage->addTab(projectionTab, tr("Projection"));
|
||||
mapPage->addTab(hidpiTab, tr("HiDPI display mode"));
|
||||
|
||||
return mapPage;
|
||||
@ -742,8 +780,10 @@ void OptionsDialog::accept()
|
||||
_options.sliderColor = _sliderColor->color();
|
||||
_options.graphAntiAliasing = _graphAA->isChecked();
|
||||
|
||||
_options.projection = _projection->itemData(_projection->currentIndex())
|
||||
.toInt();
|
||||
_options.outputProjection = _outputProjection->itemData(
|
||||
_outputProjection->currentIndex()).toInt();
|
||||
_options.inputProjection = _inputProjection->itemData(
|
||||
_inputProjection->currentIndex()).toInt();
|
||||
_options.hidpiMap = _hidpi->isChecked();
|
||||
|
||||
_options.elevationFilter = _elevationFilter->value();
|
||||
|
@ -39,7 +39,8 @@ struct Options {
|
||||
int mapOpacity;
|
||||
QColor backgroundColor;
|
||||
// Map
|
||||
int projection;
|
||||
int outputProjection;
|
||||
int inputProjection;
|
||||
bool hidpiMap;
|
||||
// Data
|
||||
int elevationFilter;
|
||||
@ -120,7 +121,8 @@ private:
|
||||
ColorBox *_sliderColor;
|
||||
QCheckBox *_graphAA;
|
||||
// Map
|
||||
LimitedComboBox *_projection;
|
||||
LimitedComboBox *_outputProjection;
|
||||
LimitedComboBox *_inputProjection;
|
||||
QRadioButton *_hidpi;
|
||||
QRadioButton *_lodpi;
|
||||
// Data
|
||||
|
@ -200,8 +200,10 @@
|
||||
#define SEPARATE_GRAPH_PAGE_DEFAULT false
|
||||
#define SLIDER_COLOR_SETTING "sliderColor"
|
||||
#define SLIDER_COLOR_DEFAULT QColor(Qt::red)
|
||||
#define PROJECTION_SETTING "projection"
|
||||
#define PROJECTION_DEFAULT 3857
|
||||
#define OUTPUT_PROJECTION_SETTING "outputProjection"
|
||||
#define OUTPUT_PROJECTION_DEFAULT 3857
|
||||
#define INPUT_PROJECTION_SETTING "inputProjection"
|
||||
#define INPUT_PROJECTION_DEFAULT 4326
|
||||
#define HIDPI_MAP_SETTING "HiDPIMap"
|
||||
#define HIDPI_MAP_DEFAULT true
|
||||
|
||||
|
Reference in New Issue
Block a user