mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-25 07:54:24 +02:00
Compare commits
78 Commits
Author | SHA1 | Date | |
---|---|---|---|
9f0fcdc13e | |||
5b21d550af | |||
6f4259298b | |||
2c1a9f88c4 | |||
48438f9b4d | |||
9b7651bad4 | |||
b6ef1d36d6 | |||
d3cbdb8b92 | |||
a98e9a9784 | |||
3c6ce2dde2 | |||
4c88414677 | |||
ac5476868d | |||
bf6d7616ba | |||
9842214bb6 | |||
b6e9400392 | |||
c1a217847f | |||
409ce889cd | |||
09242841e3 | |||
a299207e5d | |||
efc773d04b | |||
16c95334a0 | |||
49ccb508a0 | |||
9c6c574443 | |||
f762013e1e | |||
f6b1344ee2 | |||
9f3129f899 | |||
f05ff372e7 | |||
c0adabe3f1 | |||
4a612f12bb | |||
8f4ce8d38c | |||
b73072795a | |||
57d3d9c965 | |||
d97a8c03a7 | |||
58b44d33a7 | |||
5c6f405795 | |||
156467a261 | |||
f4d5f8d057 | |||
b3655f6a1f | |||
f819840aff | |||
46bf281644 | |||
49470f22b2 | |||
078b272828 | |||
ed03e31949 | |||
605b09c195 | |||
ce41409713 | |||
0898953674 | |||
fd0401a4a6 | |||
869fdf5982 | |||
7fe518966c | |||
e568806366 | |||
aa32415adb | |||
c1a64d2c0b | |||
31bbdba548 | |||
0e4a5abc2b | |||
7a2f6b96a9 | |||
24c03fc15b | |||
f9af06267a | |||
2f9751672e | |||
140e975524 | |||
e6a39b5146 | |||
937251fbdc | |||
6e92557806 | |||
a3625ac89d | |||
a7e02bdc8b | |||
ed4e201b08 | |||
06901d8d7a | |||
698f14c835 | |||
f8806417d4 | |||
52e8eb1f6e | |||
0483d393ac | |||
5aa21380cb | |||
254deae04a | |||
076a091a5b | |||
bb7787b001 | |||
bc6d48d1fe | |||
9bae94f30d | |||
351fc0309a | |||
d8116c7f5d |
@ -1,4 +1,4 @@
|
|||||||
version: 6.0.{build}
|
version: 7.0.{build}
|
||||||
configuration: Release
|
configuration: Release
|
||||||
platform: Any CPU
|
platform: Any CPU
|
||||||
environment:
|
environment:
|
||||||
@ -34,6 +34,8 @@ build_script:
|
|||||||
|
|
||||||
copy pkg\%NSI% installer
|
copy pkg\%NSI% installer
|
||||||
|
|
||||||
|
copy pkg\macros.nsh installer
|
||||||
|
|
||||||
xcopy pkg\csv installer\csv /i
|
xcopy pkg\csv installer\csv /i
|
||||||
|
|
||||||
xcopy pkg\maps installer\maps /i
|
xcopy pkg\maps installer\maps /i
|
||||||
|
@ -3,8 +3,8 @@ GPXSee is a Qt-based GPS log file viewer and analyzer that supports GPX, TCX,
|
|||||||
KML, FIT, IGC, NMEA, SLF, LOC and OziExplorer files.
|
KML, FIT, IGC, NMEA, SLF, LOC and OziExplorer files.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* User-definable online maps (OSM/Google tiles, WMTS, WMS).
|
* User-definable online maps (OpenStreetMap/Google tiles, WMTS, WMS, TMS).
|
||||||
* Offline maps (OziExplorer maps, TrekBuddy maps/atlases, Garmin JNX maps, GeoTIFF images).
|
* Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases, Garmin JNX maps, 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 multiple tracks in one view.
|
* Support for multiple tracks in one view.
|
||||||
* Support for POI files.
|
* Support for POI files.
|
||||||
@ -42,4 +42,4 @@ http://www.gpxsee.org
|
|||||||
[GPXSee maps repository](https://github.com/tumic0/GPXSee-maps)
|
[GPXSee maps repository](https://github.com/tumic0/GPXSee-maps)
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
GPXSee uses [Weblate](https://hosted.weblate.org/projects/gpxsee) for translations.
|
GPXSee uses [Weblate](https://hosted.weblate.org/projects/gpxsee/translations/) for translations.
|
||||||
|
73
gpxsee.pro
73
gpxsee.pro
@ -1,10 +1,11 @@
|
|||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
VERSION = 6.0
|
VERSION = 7.0
|
||||||
|
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
network \
|
network \
|
||||||
sql
|
sql \
|
||||||
|
concurrent
|
||||||
greaterThan(QT_MAJOR_VERSION, 4) {
|
greaterThan(QT_MAJOR_VERSION, 4) {
|
||||||
QT += widgets
|
QT += widgets
|
||||||
QT += printsupport
|
QT += printsupport
|
||||||
@ -13,14 +14,17 @@ lessThan(QT_MAJOR_VERSION, 5) {QT += opengl}
|
|||||||
equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 4) {QT += opengl}
|
equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 4) {QT += opengl}
|
||||||
|
|
||||||
INCLUDEPATH += ./src
|
INCLUDEPATH += ./src
|
||||||
HEADERS += src/config.h \
|
HEADERS += src/common/config.h \
|
||||||
src/common/staticassert.h \
|
src/common/staticassert.h \
|
||||||
src/common/coordinates.h \
|
src/common/coordinates.h \
|
||||||
src/common/range.h \
|
src/common/range.h \
|
||||||
src/common/rectc.h \
|
src/common/rectc.h \
|
||||||
src/common/wgs84.h \
|
src/common/wgs84.h \
|
||||||
src/common/str2int.h \
|
src/common/util.h \
|
||||||
src/common/rtree.h \
|
src/common/rtree.h \
|
||||||
|
src/common/kv.h \
|
||||||
|
src/common/greatcircle.h \
|
||||||
|
src/common/programpaths.h \
|
||||||
src/GUI/app.h \
|
src/GUI/app.h \
|
||||||
src/GUI/icons.h \
|
src/GUI/icons.h \
|
||||||
src/GUI/gui.h \
|
src/GUI/gui.h \
|
||||||
@ -70,10 +74,10 @@ HEADERS += src/config.h \
|
|||||||
src/GUI/gearratiographitem.h \
|
src/GUI/gearratiographitem.h \
|
||||||
src/GUI/oddspinbox.h \
|
src/GUI/oddspinbox.h \
|
||||||
src/GUI/settings.h \
|
src/GUI/settings.h \
|
||||||
src/GUI/nicenum.h \
|
|
||||||
src/GUI/cpuarch.h \
|
src/GUI/cpuarch.h \
|
||||||
src/GUI/searchpointer.h \
|
src/GUI/searchpointer.h \
|
||||||
src/GUI/mapview.h \
|
src/GUI/mapview.h \
|
||||||
|
src/GUI/font.h \
|
||||||
src/map/projection.h \
|
src/map/projection.h \
|
||||||
src/map/ellipsoid.h \
|
src/map/ellipsoid.h \
|
||||||
src/map/datum.h \
|
src/map/datum.h \
|
||||||
@ -114,6 +118,15 @@ HEADERS += src/config.h \
|
|||||||
src/map/crs.h \
|
src/map/crs.h \
|
||||||
src/map/coordinatesystem.h \
|
src/map/coordinatesystem.h \
|
||||||
src/map/pointd.h \
|
src/map/pointd.h \
|
||||||
|
src/map/rectd.h \
|
||||||
|
src/map/geocentric.h \
|
||||||
|
src/map/mercator.h \
|
||||||
|
src/map/jnxmap.h \
|
||||||
|
src/map/krovak.h \
|
||||||
|
src/map/geotiffmap.h \
|
||||||
|
src/map/image.h \
|
||||||
|
src/map/mbtilesmap.h \
|
||||||
|
src/map/osm.h \
|
||||||
src/data/graph.h \
|
src/data/graph.h \
|
||||||
src/data/poi.h \
|
src/data/poi.h \
|
||||||
src/data/waypoint.h \
|
src/data/waypoint.h \
|
||||||
@ -133,24 +146,15 @@ HEADERS += src/config.h \
|
|||||||
src/data/igcparser.h \
|
src/data/igcparser.h \
|
||||||
src/data/nmeaparser.h \
|
src/data/nmeaparser.h \
|
||||||
src/data/oziparsers.h \
|
src/data/oziparsers.h \
|
||||||
src/map/rectd.h \
|
|
||||||
src/map/geocentric.h \
|
|
||||||
src/map/mercator.h \
|
|
||||||
src/map/jnxmap.h \
|
|
||||||
src/map/krovak.h \
|
|
||||||
src/GUI/kv.h \
|
|
||||||
src/data/locparser.h \
|
src/data/locparser.h \
|
||||||
src/data/slfparser.h \
|
src/data/slfparser.h
|
||||||
src/map/geotiffmap.h \
|
|
||||||
src/map/image.h \
|
|
||||||
src/common/greatcircle.h \
|
|
||||||
src/map/mbtilesmap.h \
|
|
||||||
src/map/osm.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 \
|
||||||
src/common/range.cpp \
|
src/common/range.cpp \
|
||||||
src/common/str2int.cpp \
|
src/common/util.cpp \
|
||||||
|
src/common/greatcircle.cpp \
|
||||||
|
src/common/programpaths.cpp \
|
||||||
src/GUI/app.cpp \
|
src/GUI/app.cpp \
|
||||||
src/GUI/gui.cpp \
|
src/GUI/gui.cpp \
|
||||||
src/GUI/axisitem.cpp \
|
src/GUI/axisitem.cpp \
|
||||||
@ -192,7 +196,6 @@ SOURCES += src/main.cpp \
|
|||||||
src/GUI/cadencegraphitem.cpp \
|
src/GUI/cadencegraphitem.cpp \
|
||||||
src/GUI/powergraphitem.cpp \
|
src/GUI/powergraphitem.cpp \
|
||||||
src/GUI/gearratiographitem.cpp \
|
src/GUI/gearratiographitem.cpp \
|
||||||
src/GUI/nicenum.cpp \
|
|
||||||
src/GUI/mapview.cpp \
|
src/GUI/mapview.cpp \
|
||||||
src/map/maplist.cpp \
|
src/map/maplist.cpp \
|
||||||
src/map/onlinemap.cpp \
|
src/map/onlinemap.cpp \
|
||||||
@ -229,6 +232,15 @@ SOURCES += src/main.cpp \
|
|||||||
src/map/wms.cpp \
|
src/map/wms.cpp \
|
||||||
src/map/crs.cpp \
|
src/map/crs.cpp \
|
||||||
src/map/coordinatesystem.cpp \
|
src/map/coordinatesystem.cpp \
|
||||||
|
src/map/geocentric.cpp \
|
||||||
|
src/map/mercator.cpp \
|
||||||
|
src/map/jnxmap.cpp \
|
||||||
|
src/map/krovak.cpp \
|
||||||
|
src/map/map.cpp \
|
||||||
|
src/map/geotiffmap.cpp \
|
||||||
|
src/map/image.cpp \
|
||||||
|
src/map/mbtilesmap.cpp \
|
||||||
|
src/map/osm.cpp \
|
||||||
src/data/data.cpp \
|
src/data/data.cpp \
|
||||||
src/data/poi.cpp \
|
src/data/poi.cpp \
|
||||||
src/data/track.cpp \
|
src/data/track.cpp \
|
||||||
@ -242,19 +254,8 @@ SOURCES += src/main.cpp \
|
|||||||
src/data/igcparser.cpp \
|
src/data/igcparser.cpp \
|
||||||
src/data/nmeaparser.cpp \
|
src/data/nmeaparser.cpp \
|
||||||
src/data/oziparsers.cpp \
|
src/data/oziparsers.cpp \
|
||||||
src/map/geocentric.cpp \
|
|
||||||
src/map/mercator.cpp \
|
|
||||||
src/map/jnxmap.cpp \
|
|
||||||
src/map/krovak.cpp \
|
|
||||||
src/map/map.cpp \
|
|
||||||
src/data/locparser.cpp \
|
src/data/locparser.cpp \
|
||||||
src/data/slfparser.cpp \
|
src/data/slfparser.cpp
|
||||||
src/map/geotiffmap.cpp \
|
|
||||||
src/map/image.cpp \
|
|
||||||
src/common/greatcircle.cpp \
|
|
||||||
src/map/mbtilesmap.cpp \
|
|
||||||
src/map/osm.cpp
|
|
||||||
|
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_en.ts \
|
TRANSLATIONS = lang/gpxsee_en.ts \
|
||||||
lang/gpxsee_cs.ts \
|
lang/gpxsee_cs.ts \
|
||||||
@ -263,7 +264,10 @@ TRANSLATIONS = lang/gpxsee_en.ts \
|
|||||||
lang/gpxsee_ru.ts \
|
lang/gpxsee_ru.ts \
|
||||||
lang/gpxsee_fi.ts \
|
lang/gpxsee_fi.ts \
|
||||||
lang/gpxsee_fr.ts \
|
lang/gpxsee_fr.ts \
|
||||||
lang/gpxsee_pl.ts
|
lang/gpxsee_pl.ts \
|
||||||
|
lang/gpxsee_nb.ts \
|
||||||
|
lang/gpxsee_da.ts \
|
||||||
|
lang/gpxsee_tr.ts
|
||||||
|
|
||||||
macx {
|
macx {
|
||||||
ICON = icons/gpxsee.icns
|
ICON = icons/gpxsee.icns
|
||||||
@ -276,7 +280,10 @@ macx {
|
|||||||
lang/gpxsee_fr.qm \
|
lang/gpxsee_fr.qm \
|
||||||
lang/gpxsee_ru.qm \
|
lang/gpxsee_ru.qm \
|
||||||
lang/gpxsee_sv.qm \
|
lang/gpxsee_sv.qm \
|
||||||
lang/gpxsee_pl.qm
|
lang/gpxsee_pl.qm \
|
||||||
|
lang/gpxsee_nb.qm \
|
||||||
|
lang/gpxsee_da.qm \
|
||||||
|
lang/gpxsee_tr.qm
|
||||||
CSV.path = Contents/Resources
|
CSV.path = Contents/Resources
|
||||||
CSV.files = pkg/csv
|
CSV.files = pkg/csv
|
||||||
MAPS.path = Contents/Resources
|
MAPS.path = Contents/Resources
|
||||||
|
File diff suppressed because it is too large
Load Diff
1244
lang/gpxsee_da.ts
1244
lang/gpxsee_da.ts
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS>
|
<!DOCTYPE TS>
|
||||||
<TS version="2.1" language="en_US">
|
<TS version="2.1" language="en_US">
|
||||||
<context>
|
|
||||||
<name>GUI</name>
|
|
||||||
<message numerus="yes">
|
|
||||||
<source>%n files</source>
|
|
||||||
<translation>
|
|
||||||
<numerusform>%n file</numerusform>
|
|
||||||
<numerusform>%n files</numerusform>
|
|
||||||
</translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
</TS>
|
</TS>
|
||||||
|
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
1748
lang/gpxsee_tr.ts
Normal file
1748
lang/gpxsee_tr.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,21 +8,23 @@
|
|||||||
<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 GPX, TCX,
|
||||||
KML, FIT, IGC, NMEA and OziExplorer files.</p>
|
KML, FIT, IGC, NMEA, SLF, LOC and OziExplorer files.</p>
|
||||||
|
|
||||||
<p>Features:</p>
|
<p>Features:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>User-definable online maps (OSM/Google tiles, WMTS, WMS).</li>
|
<li>User-definable online maps (OpenStreetMap/Google tiles, WMTS,
|
||||||
<li>Offline maps (OziExplorer maps, TrekBuddy maps/atlases, GeoTIFF
|
WMS, TMS).</li>
|
||||||
images).</li>
|
<li>Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases,
|
||||||
|
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>
|
||||||
<li>Support for POI files.</li>
|
<li>Support for POI files.</li>
|
||||||
<li>Print/export to PDF.</li>
|
<li>Print/export to PDF.</li>
|
||||||
<li>Full-screen mode.</li>
|
<li>Full-screen mode.</li>
|
||||||
<li>Opens GPX, TCX, FIT, KML, IGC, NMEA, OziExplorer (PLT, WPT, RTE)
|
<li>HiDPI/Retina displays & maps support.</li>
|
||||||
and Garmin CSV files.</li>
|
<li>Opens GPX, TCX, FIT, KML, IGC, NMEA, SLF, LOC, OziExplorer (PLT,
|
||||||
|
WPT, RTE) and Garmin CSV files.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
@ -38,6 +40,10 @@
|
|||||||
<categories>
|
<categories>
|
||||||
<category>Graphics</category>
|
<category>Graphics</category>
|
||||||
<category>Viewer</category>
|
<category>Viewer</category>
|
||||||
|
<category>Maps</category>
|
||||||
|
<category>Geoscience</category>
|
||||||
|
<category>Geography</category>
|
||||||
|
<category>DataVisualization</category>
|
||||||
</categories>
|
</categories>
|
||||||
|
|
||||||
<url type="homepage">http://www.gpxsee.org</url>
|
<url type="homepage">http://www.gpxsee.org</url>
|
||||||
@ -58,5 +64,7 @@
|
|||||||
<mimetype>application/vnd.oziexplorer.plt</mimetype>
|
<mimetype>application/vnd.oziexplorer.plt</mimetype>
|
||||||
<mimetype>application/vnd.oziexplorer.rte</mimetype>
|
<mimetype>application/vnd.oziexplorer.rte</mimetype>
|
||||||
<mimetype>application/vnd.oziexplorer.wpt</mimetype>
|
<mimetype>application/vnd.oziexplorer.wpt</mimetype>
|
||||||
|
<mimetype>application/loc+xml</mimetype>
|
||||||
|
<mimetype>application/slf+xml</mimetype>
|
||||||
</mimetypes>
|
</mimetypes>
|
||||||
</component>
|
</component>
|
||||||
|
@ -1,36 +1,13 @@
|
|||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "x64.nsh"
|
!include "x64.nsh"
|
||||||
!include "WinVer.nsh"
|
!include "WinVer.nsh"
|
||||||
|
!include "macros.nsh"
|
||||||
|
|
||||||
; Macros
|
|
||||||
!macro FILE_ASSOCIATION_ADD EXT DESC ICON
|
|
||||||
WriteRegStr HKCR ".${EXT}" "" "GPXSee.${EXT}"
|
|
||||||
WriteRegStr HKCR "GPXSee.${EXT}" "" "${DESC}"
|
|
||||||
WriteRegStr HKCR "GPXSee.${EXT}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,${ICON}"
|
|
||||||
WriteRegStr HKCR "GPXSee.${EXT}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
!macro FILE_ASSOCIATION_REMOVE EXT
|
|
||||||
DeleteRegKey HKCR "GPXSee.${EXT}"
|
|
||||||
DeleteRegKey HKCR ".${EXT}"
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
!macro LOCALIZATION LANG CODE
|
|
||||||
Section "${LANG}"
|
|
||||||
CreateDirectory "$INSTDIR\translations"
|
|
||||||
File /oname=translations\gpxsee_${CODE}.qm translations\gpxsee_${CODE}.qm
|
|
||||||
!if /FileExists translations\qt_${CODE}.qm
|
|
||||||
File /oname=translations\qt_${CODE}.qm translations\qt_${CODE}.qm
|
|
||||||
!endif
|
|
||||||
SectionEnd
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "6.0"
|
!define VERSION "7.0"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
@ -154,6 +131,7 @@ Section "QT framework" SEC_QT
|
|||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "Qt5Sql.dll"
|
File "Qt5Sql.dll"
|
||||||
|
File "Qt5Concurrent.dll"
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -203,12 +181,15 @@ SectionEnd
|
|||||||
|
|
||||||
SectionGroup "Localization" SEC_LOCALIZATION
|
SectionGroup "Localization" SEC_LOCALIZATION
|
||||||
!insertmacro LOCALIZATION "Czech" "cs"
|
!insertmacro LOCALIZATION "Czech" "cs"
|
||||||
|
!insertmacro LOCALIZATION "Danish" "da"
|
||||||
!insertmacro LOCALIZATION "Finnish" "fi"
|
!insertmacro LOCALIZATION "Finnish" "fi"
|
||||||
!insertmacro LOCALIZATION "French" "fr"
|
!insertmacro LOCALIZATION "French" "fr"
|
||||||
!insertmacro LOCALIZATION "German" "de"
|
!insertmacro LOCALIZATION "German" "de"
|
||||||
|
!insertmacro LOCALIZATION "Norwegian" "nb"
|
||||||
!insertmacro LOCALIZATION "Polish" "pl"
|
!insertmacro LOCALIZATION "Polish" "pl"
|
||||||
!insertmacro LOCALIZATION "Russian" "ru"
|
!insertmacro LOCALIZATION "Russian" "ru"
|
||||||
!insertmacro LOCALIZATION "Swedish" "sv"
|
!insertmacro LOCALIZATION "Swedish" "sv"
|
||||||
|
!insertmacro LOCALIZATION "Turkish" "tr"
|
||||||
SectionGroupEnd
|
SectionGroupEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
@ -1,36 +1,13 @@
|
|||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "x64.nsh"
|
!include "x64.nsh"
|
||||||
!include "WinVer.nsh"
|
!include "WinVer.nsh"
|
||||||
|
!include "macros.nsh"
|
||||||
|
|
||||||
; Macros
|
|
||||||
!macro FILE_ASSOCIATION_ADD EXT DESC ICON
|
|
||||||
WriteRegStr HKCR ".${EXT}" "" "GPXSee.${EXT}"
|
|
||||||
WriteRegStr HKCR "GPXSee.${EXT}" "" "${DESC}"
|
|
||||||
WriteRegStr HKCR "GPXSee.${EXT}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,${ICON}"
|
|
||||||
WriteRegStr HKCR "GPXSee.${EXT}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
!macro FILE_ASSOCIATION_REMOVE EXT
|
|
||||||
DeleteRegKey HKCR "GPXSee.${EXT}"
|
|
||||||
DeleteRegKey HKCR ".${EXT}"
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
!macro LOCALIZATION LANG CODE
|
|
||||||
Section "${LANG}"
|
|
||||||
CreateDirectory "$INSTDIR\translations"
|
|
||||||
File /oname=translations\gpxsee_${CODE}.qm translations\gpxsee_${CODE}.qm
|
|
||||||
!if /FileExists translations\qt_${CODE}.qm
|
|
||||||
File /oname=translations\qt_${CODE}.qm translations\qt_${CODE}.qm
|
|
||||||
!endif
|
|
||||||
SectionEnd
|
|
||||||
!macroend
|
|
||||||
|
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "6.0"
|
!define VERSION "7.0"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
@ -161,6 +138,7 @@ Section "QT framework" SEC_QT
|
|||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "Qt5Sql.dll"
|
File "Qt5Sql.dll"
|
||||||
|
File "Qt5Concurrent.dll"
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -205,12 +183,15 @@ SectionEnd
|
|||||||
|
|
||||||
SectionGroup "Localization" SEC_LOCALIZATION
|
SectionGroup "Localization" SEC_LOCALIZATION
|
||||||
!insertmacro LOCALIZATION "Czech" "cs"
|
!insertmacro LOCALIZATION "Czech" "cs"
|
||||||
|
!insertmacro LOCALIZATION "Danish" "da"
|
||||||
!insertmacro LOCALIZATION "Finnish" "fi"
|
!insertmacro LOCALIZATION "Finnish" "fi"
|
||||||
!insertmacro LOCALIZATION "French" "fr"
|
!insertmacro LOCALIZATION "French" "fr"
|
||||||
!insertmacro LOCALIZATION "German" "de"
|
!insertmacro LOCALIZATION "German" "de"
|
||||||
|
!insertmacro LOCALIZATION "Norwegian" "nb"
|
||||||
!insertmacro LOCALIZATION "Polish" "pl"
|
!insertmacro LOCALIZATION "Polish" "pl"
|
||||||
!insertmacro LOCALIZATION "Russian" "ru"
|
!insertmacro LOCALIZATION "Russian" "ru"
|
||||||
!insertmacro LOCALIZATION "Swedish" "sv"
|
!insertmacro LOCALIZATION "Swedish" "sv"
|
||||||
|
!insertmacro LOCALIZATION "Turkish" "tr"
|
||||||
SectionGroupEnd
|
SectionGroupEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
23
pkg/macros.nsh
Normal file
23
pkg/macros.nsh
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
; File association
|
||||||
|
!macro FILE_ASSOCIATION_ADD EXT DESC ICON
|
||||||
|
WriteRegStr HKCR ".${EXT}" "" "GPXSee.${EXT}"
|
||||||
|
WriteRegStr HKCR "GPXSee.${EXT}" "" "${DESC}"
|
||||||
|
WriteRegStr HKCR "GPXSee.${EXT}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,${ICON}"
|
||||||
|
WriteRegStr HKCR "GPXSee.${EXT}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!macro FILE_ASSOCIATION_REMOVE EXT
|
||||||
|
DeleteRegKey HKCR "GPXSee.${EXT}"
|
||||||
|
DeleteRegKey HKCR ".${EXT}"
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
; Translations
|
||||||
|
!macro LOCALIZATION LANG CODE
|
||||||
|
Section "${LANG}"
|
||||||
|
CreateDirectory "$INSTDIR\translations"
|
||||||
|
File /oname=translations\gpxsee_${CODE}.qm translations\gpxsee_${CODE}.qm
|
||||||
|
!if /FileExists translations\qt_${CODE}.qm
|
||||||
|
File /oname=translations\qt_${CODE}.qm translations\qt_${CODE}.qm
|
||||||
|
!endif
|
||||||
|
SectionEnd
|
||||||
|
!macroend
|
@ -5,26 +5,37 @@
|
|||||||
#include <QNetworkProxyFactory>
|
#include <QNetworkProxyFactory>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
#include <QSettings>
|
||||||
|
#include "common/programpaths.h"
|
||||||
|
#include "common/config.h"
|
||||||
#include "map/downloader.h"
|
#include "map/downloader.h"
|
||||||
#include "map/ellipsoid.h"
|
#include "map/ellipsoid.h"
|
||||||
#include "map/gcs.h"
|
#include "map/gcs.h"
|
||||||
#include "map/pcs.h"
|
#include "map/pcs.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "config.h"
|
#include "settings.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
|
||||||
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||||
_argc(argc), _argv(argv)
|
_argc(argc), _argv(argv)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
|
||||||
|
setApplicationName(APP_NAME);
|
||||||
|
#else
|
||||||
|
setApplicationName(QString(APP_NAME).toLower());
|
||||||
|
#endif
|
||||||
|
setApplicationVersion(APP_VERSION);
|
||||||
|
|
||||||
QTranslator *gpxsee = new QTranslator(this);
|
QTranslator *gpxsee = new QTranslator(this);
|
||||||
gpxsee->load(QLocale::system(), "gpxsee", "_", TRANSLATIONS_DIR);
|
gpxsee->load(QLocale::system(), "gpxsee", "_",
|
||||||
|
ProgramPaths::translationsDir());
|
||||||
installTranslator(gpxsee);
|
installTranslator(gpxsee);
|
||||||
|
|
||||||
QTranslator *qt = new QTranslator(this);
|
QTranslator *qt = new QTranslator(this);
|
||||||
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
|
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
|
||||||
qt->load(QLocale::system(), "qt", "_", TRANSLATIONS_DIR);
|
qt->load(QLocale::system(), "qt", "_", ProgramPaths::translationsDir());
|
||||||
#else // Q_OS_WIN32 || Q_OS_MAC
|
#else // Q_OS_WIN32 || Q_OS_MAC
|
||||||
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
|
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
|
||||||
QLibraryInfo::TranslationsPath));
|
QLibraryInfo::TranslationsPath));
|
||||||
@ -36,7 +47,21 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
|||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
Downloader::setNetworkAccessManager(new QNetworkAccessManager(this));
|
QSettings settings(APP_NAME, APP_NAME);
|
||||||
|
settings.beginGroup(OPTIONS_SETTINGS_GROUP);
|
||||||
|
|
||||||
|
/* The QNetworkAccessManager must be a child of QApplication, otherwise it
|
||||||
|
triggers the following warning on exit (and may probably crash):
|
||||||
|
"QThreadStorage: Thread X exited after QThreadStorage Y destroyed" */
|
||||||
|
Downloader::setNetworkManager(new QNetworkAccessManager(this));
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
Downloader::enableHTTP2(settings.value(ENABLE_HTTP2_SETTING,
|
||||||
|
ENABLE_HTTP2_DEFAULT).toBool());
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
Downloader::setTimeout(settings.value(CONNECTION_TIMEOUT_SETTING,
|
||||||
|
CONNECTION_TIMEOUT_DEFAULT).toInt());
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
OPENGL_SET_SAMPLES(4);
|
OPENGL_SET_SAMPLES(4);
|
||||||
loadDatums();
|
loadDatums();
|
||||||
loadPCSs();
|
loadPCSs();
|
||||||
@ -49,14 +74,15 @@ App::~App()
|
|||||||
delete _gui;
|
delete _gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::run()
|
int App::run()
|
||||||
{
|
{
|
||||||
_gui->show();
|
_gui->show();
|
||||||
|
|
||||||
for (int i = 1; i < _argc; i++)
|
QStringList args(arguments());
|
||||||
_gui->openFile(QString::fromLocal8Bit(_argv[i]));
|
for (int i = 1; i < args.count(); i++)
|
||||||
|
_gui->openFile(args.at(i));
|
||||||
|
|
||||||
exec();
|
return exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::event(QEvent *event)
|
bool App::event(QEvent *event)
|
||||||
@ -71,41 +97,27 @@ bool App::event(QEvent *event)
|
|||||||
|
|
||||||
void App::loadDatums()
|
void App::loadDatums()
|
||||||
{
|
{
|
||||||
QString ef, df;
|
QString ellipsoidsFile(ProgramPaths::ellipsoidsFile());
|
||||||
|
QString gcsFile(ProgramPaths::gcsFile());
|
||||||
|
|
||||||
if (QFile::exists(USER_ELLIPSOID_FILE))
|
if (ellipsoidsFile.isNull())
|
||||||
ef = USER_ELLIPSOID_FILE;
|
|
||||||
else if (QFile::exists(GLOBAL_ELLIPSOID_FILE))
|
|
||||||
ef = GLOBAL_ELLIPSOID_FILE;
|
|
||||||
else
|
|
||||||
qWarning("No ellipsoids file found.");
|
qWarning("No ellipsoids file found.");
|
||||||
|
if (gcsFile.isNull())
|
||||||
|
qWarning("No GCS file found.");
|
||||||
|
|
||||||
if (QFile::exists(USER_GCS_FILE))
|
if (!ellipsoidsFile.isNull() && !gcsFile.isNull()) {
|
||||||
df = USER_GCS_FILE;
|
Ellipsoid::loadList(ellipsoidsFile);
|
||||||
else if (QFile::exists(GLOBAL_GCS_FILE))
|
GCS::loadList(gcsFile);
|
||||||
df = GLOBAL_GCS_FILE;
|
|
||||||
else
|
|
||||||
qWarning("No datums file found.");
|
|
||||||
|
|
||||||
if (!ef.isNull() && !df.isNull()) {
|
|
||||||
Ellipsoid::loadList(ef);
|
|
||||||
GCS::loadList(df);
|
|
||||||
} else
|
} else
|
||||||
qWarning("Maps based on a datum different from WGS84 won't work.");
|
qWarning("Maps based on a datum different from WGS84 won't work.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::loadPCSs()
|
void App::loadPCSs()
|
||||||
{
|
{
|
||||||
QString file;
|
QString pcsFile(ProgramPaths::pcsFile());
|
||||||
|
|
||||||
if (QFile::exists(USER_PCS_FILE))
|
if (pcsFile.isNull())
|
||||||
file = USER_PCS_FILE;
|
|
||||||
else if (QFile::exists(GLOBAL_PCS_FILE))
|
|
||||||
file = GLOBAL_PCS_FILE;
|
|
||||||
else {
|
|
||||||
qWarning("No PCS file found.");
|
qWarning("No PCS file found.");
|
||||||
return;
|
else
|
||||||
}
|
PCS::loadList(pcsFile);
|
||||||
|
|
||||||
PCS::loadList(file);
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class App : QApplication
|
|||||||
public:
|
public:
|
||||||
App(int &argc, char **argv);
|
App(int &argc, char **argv);
|
||||||
~App();
|
~App();
|
||||||
void run();
|
int run();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "common/util.h"
|
||||||
#include "nicenum.h"
|
#include "font.h"
|
||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,9 +7,14 @@ CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
|
|||||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
_max = graph.first().y();
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++)
|
for (int i = 1; i < graph.size(); i++) {
|
||||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
qreal y = graph.at(i).y();
|
||||||
|
sum += y * (graph.at(i).s() - graph.at(i-1).s());
|
||||||
|
if (y > _max)
|
||||||
|
_max = y;
|
||||||
|
}
|
||||||
_avg = sum/graph.last().s();
|
_avg = sum/graph.last().s();
|
||||||
|
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
|
@ -11,13 +11,13 @@ public:
|
|||||||
CadenceGraphItem(const Graph &graph, GraphType type,
|
CadenceGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
qreal _avg;
|
qreal _avg, _max;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CADENCEGRAPHITEM_H
|
#endif // CADENCEGRAPHITEM_H
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include "data/data.h"
|
#include "data/data.h"
|
||||||
#include "config.h"
|
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "elevationgraphitem.h"
|
#include "elevationgraphitem.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
|
@ -7,6 +7,7 @@ ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
|||||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
_ascent = _descent = 0;
|
_ascent = _descent = 0;
|
||||||
|
_min = _max = graph.first().y();
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++) {
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
qreal cur = graph.at(j).y();
|
qreal cur = graph.at(j).y();
|
||||||
@ -16,6 +17,11 @@ ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
|||||||
_ascent += cur - prev;
|
_ascent += cur - prev;
|
||||||
if (cur < prev)
|
if (cur < prev)
|
||||||
_descent += prev - cur;
|
_descent += prev - cur;
|
||||||
|
|
||||||
|
if (cur < _min)
|
||||||
|
_min = cur;
|
||||||
|
if (cur > _max)
|
||||||
|
_max = cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
setToolTip(toolTip(Metric));
|
setToolTip(toolTip(Metric));
|
||||||
|
@ -13,15 +13,15 @@ public:
|
|||||||
|
|
||||||
qreal ascent() const {return _ascent;}
|
qreal ascent() const {return _ascent;}
|
||||||
qreal descent() const {return _descent;}
|
qreal descent() const {return _descent;}
|
||||||
qreal min() const {return -bounds().bottom();}
|
qreal min() const {return _min;}
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
|
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip(Units units) const;
|
QString toolTip(Units units) const;
|
||||||
|
|
||||||
qreal _ascent, _descent;
|
qreal _ascent, _descent, _min, _max;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ELEVATIONGRAPHITEM_H
|
#endif // ELEVATIONGRAPHITEM_H
|
||||||
|
@ -22,7 +22,8 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
|||||||
int index;
|
int index;
|
||||||
|
|
||||||
_fileSelect = new FileSelectWidget();
|
_fileSelect = new FileSelectWidget();
|
||||||
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
|
_fileSelect->setFilter(tr("PDF files") + " (*.pdf);;" + tr("All files")
|
||||||
|
+ " (*)");
|
||||||
_fileSelect->setFile(_export->fileName);
|
_fileSelect->setFile(_export->fileName);
|
||||||
|
|
||||||
_paperSize = new QComboBox();
|
_paperSize = new QComboBox();
|
||||||
|
7
src/GUI/font.h
Normal file
7
src/GUI/font.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef FONT_H
|
||||||
|
#define FONT_H
|
||||||
|
|
||||||
|
#define FONT_FAMILY "Arial"
|
||||||
|
#define FONT_SIZE 12 // px
|
||||||
|
|
||||||
|
#endif // FONT_H
|
@ -8,11 +8,18 @@ GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
|
|||||||
QGraphicsItem *parent) : GraphItem(graph, type, parent), _top(NAN)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent), _top(NAN)
|
||||||
{
|
{
|
||||||
qreal val = NAN;
|
qreal val = NAN;
|
||||||
|
_min = _max = graph.first().y();
|
||||||
|
|
||||||
|
for (int i = 1; i < graph.size(); i++) {
|
||||||
|
const GraphPoint &p = graph.at(i);
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++) {
|
|
||||||
const GraphPoint &p = graph.at(j);
|
|
||||||
qreal val = _map.value(p.y());
|
qreal val = _map.value(p.y());
|
||||||
_map.insert(p.y(), val + (p.s() - graph.at(j-1).s()));
|
_map.insert(p.y(), val + (p.s() - graph.at(i-1).s()));
|
||||||
|
|
||||||
|
if (p.y() < _min)
|
||||||
|
_min = p.y();
|
||||||
|
if (p.y() > _max)
|
||||||
|
_max = p.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (QMap<qreal, qreal>::const_iterator it = _map.constBegin();
|
for (QMap<qreal, qreal>::const_iterator it = _map.constBegin();
|
||||||
|
@ -12,8 +12,8 @@ public:
|
|||||||
GearRatioGraphItem(const Graph &graph, GraphType type,
|
GearRatioGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal min() const {return -bounds().bottom();}
|
qreal min() const {return _min;}
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
qreal top() const {return _top;}
|
qreal top() const {return _top;}
|
||||||
|
|
||||||
const QMap<qreal, qreal> &map() const {return _map;}
|
const QMap<qreal, qreal> &map() const {return _map;}
|
||||||
@ -22,7 +22,7 @@ private:
|
|||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
QMap<qreal, qreal> _map;
|
QMap<qreal, qreal> _map;
|
||||||
qreal _top;
|
qreal _top, _min, _max;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GEARRATIOGRAPHITEM_H
|
#endif // GEARRATIOGRAPHITEM_H
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include "data/graph.h"
|
#include "data/graph.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "config.h"
|
|
||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
#include "slideritem.h"
|
#include "slideritem.h"
|
||||||
#include "sliderinfoitem.h"
|
#include "sliderinfoitem.h"
|
||||||
|
141
src/GUI/gui.cpp
141
src/GUI/gui.cpp
@ -1,4 +1,4 @@
|
|||||||
#include "config.h"
|
#include "common/config.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@ -28,6 +28,7 @@
|
|||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
|
#include "common/programpaths.h"
|
||||||
#include "data/data.h"
|
#include "data/data.h"
|
||||||
#include "data/poi.h"
|
#include "data/poi.h"
|
||||||
#include "map/maplist.h"
|
#include "map/maplist.h"
|
||||||
@ -108,14 +109,9 @@ GUI::GUI()
|
|||||||
void GUI::loadMaps()
|
void GUI::loadMaps()
|
||||||
{
|
{
|
||||||
_ml = new MapList(this);
|
_ml = new MapList(this);
|
||||||
QString dir;
|
QString mapDir(ProgramPaths::mapDir());
|
||||||
|
|
||||||
if (QFile::exists(USER_MAP_DIR))
|
if (!mapDir.isNull() && !_ml->loadDir(mapDir))
|
||||||
dir = USER_MAP_DIR;
|
|
||||||
else if (QFile::exists(GLOBAL_MAP_DIR))
|
|
||||||
dir = GLOBAL_MAP_DIR;
|
|
||||||
|
|
||||||
if (!dir.isNull() && !_ml->loadDir(dir))
|
|
||||||
qWarning("%s", qPrintable(_ml->errorString()));
|
qWarning("%s", qPrintable(_ml->errorString()));
|
||||||
|
|
||||||
_map = new EmptyMap(this);
|
_map = new EmptyMap(this);
|
||||||
@ -124,14 +120,9 @@ void GUI::loadMaps()
|
|||||||
void GUI::loadPOIs()
|
void GUI::loadPOIs()
|
||||||
{
|
{
|
||||||
_poi = new POI(this);
|
_poi = new POI(this);
|
||||||
QString dir;
|
QString poiDir(ProgramPaths::poiDir());
|
||||||
|
|
||||||
if (QFile::exists(USER_POI_DIR))
|
if (!poiDir.isNull() && !_poi->loadDir(poiDir))
|
||||||
dir = USER_POI_DIR;
|
|
||||||
else if (QFile::exists(GLOBAL_POI_DIR))
|
|
||||||
dir = GLOBAL_POI_DIR;
|
|
||||||
|
|
||||||
if (!dir.isNull() && !_poi->loadDir(dir))
|
|
||||||
qWarning("%s", qPrintable(_poi->errorString()));
|
qWarning("%s", qPrintable(_poi->errorString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,44 +138,47 @@ void GUI::createMapActions()
|
|||||||
_mapsActionGroup = new QActionGroup(this);
|
_mapsActionGroup = new QActionGroup(this);
|
||||||
_mapsActionGroup->setExclusive(true);
|
_mapsActionGroup->setExclusive(true);
|
||||||
|
|
||||||
for (int i = 0; i < _ml->maps().count(); i++) {
|
for (int i = 0; i < _ml->maps().count(); i++)
|
||||||
QAction *a = new QAction(_ml->maps().at(i)->name(), this);
|
createMapAction(_ml->maps().at(i));
|
||||||
a->setMenuRole(QAction::NoRole);
|
|
||||||
a->setCheckable(true);
|
|
||||||
a->setActionGroup(_mapsActionGroup);
|
|
||||||
|
|
||||||
_mapsSignalMapper->setMapping(a, i);
|
|
||||||
connect(a, SIGNAL(triggered()), _mapsSignalMapper, SLOT(map()));
|
|
||||||
|
|
||||||
_mapActions.append(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(_mapsSignalMapper, SIGNAL(mapped(int)), this,
|
connect(_mapsSignalMapper, SIGNAL(mapped(int)), this,
|
||||||
SLOT(mapChanged(int)));
|
SLOT(mapChanged(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction *GUI::createMapAction(const Map *map)
|
||||||
|
{
|
||||||
|
QAction *a = new QAction(map->name(), this);
|
||||||
|
a->setMenuRole(QAction::NoRole);
|
||||||
|
a->setCheckable(true);
|
||||||
|
a->setActionGroup(_mapsActionGroup);
|
||||||
|
|
||||||
|
_mapActions.append(a);
|
||||||
|
_mapsSignalMapper->setMapping(a, _mapActions.size() - 1);
|
||||||
|
connect(a, SIGNAL(triggered()), _mapsSignalMapper, SLOT(map()));
|
||||||
|
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::createPOIFilesActions()
|
void GUI::createPOIFilesActions()
|
||||||
{
|
{
|
||||||
_poiFilesSignalMapper = new QSignalMapper(this);
|
_poiFilesSignalMapper = new QSignalMapper(this);
|
||||||
|
|
||||||
for (int i = 0; i < _poi->files().count(); i++)
|
for (int i = 0; i < _poi->files().count(); i++)
|
||||||
createPOIFileAction(i);
|
createPOIFileAction(_poi->files().at(i));
|
||||||
|
|
||||||
connect(_poiFilesSignalMapper, SIGNAL(mapped(int)), this,
|
connect(_poiFilesSignalMapper, SIGNAL(mapped(int)), this,
|
||||||
SLOT(poiFileChecked(int)));
|
SLOT(poiFileChecked(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction *GUI::createPOIFileAction(int index)
|
QAction *GUI::createPOIFileAction(const QString &fileName)
|
||||||
{
|
{
|
||||||
QAction *a = new QAction(QFileInfo(_poi->files().at(index)).fileName(),
|
QAction *a = new QAction(QFileInfo(fileName).fileName(), this);
|
||||||
this);
|
|
||||||
a->setMenuRole(QAction::NoRole);
|
a->setMenuRole(QAction::NoRole);
|
||||||
a->setCheckable(true);
|
a->setCheckable(true);
|
||||||
|
|
||||||
_poiFilesSignalMapper->setMapping(a, index);
|
|
||||||
connect(a, SIGNAL(triggered()), _poiFilesSignalMapper, SLOT(map()));
|
|
||||||
|
|
||||||
_poiFilesActions.append(a);
|
_poiFilesActions.append(a);
|
||||||
|
_poiFilesSignalMapper->setMapping(a, _poiFilesActions.size() - 1);
|
||||||
|
connect(a, SIGNAL(triggered()), _poiFilesSignalMapper, SLOT(map()));
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@ -641,14 +635,15 @@ void GUI::about()
|
|||||||
QUrl homepage(APP_HOMEPAGE);
|
QUrl homepage(APP_HOMEPAGE);
|
||||||
|
|
||||||
msgBox.setWindowTitle(tr("About GPXSee"));
|
msgBox.setWindowTitle(tr("About GPXSee"));
|
||||||
msgBox.setText("<h2>" + QString(APP_NAME) + "</h2><p><p>" + tr("Version ")
|
msgBox.setText("<h2>" + QString(APP_NAME) + "</h2><p><p>" + tr("Version %1")
|
||||||
+ APP_VERSION + " (" + CPU_ARCH + ", Qt " + QT_VERSION_STR + ")</p>");
|
.arg(QString(APP_VERSION) + " (" + CPU_ARCH + ", Qt " + QT_VERSION_STR
|
||||||
|
+ ")") + "</p>");
|
||||||
msgBox.setInformativeText("<table width=\"300\"><tr><td>"
|
msgBox.setInformativeText("<table width=\"300\"><tr><td>"
|
||||||
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
+ tr("GPXSee is distributed under the terms of the GNU General Public "
|
||||||
"License version 3. For more info about GPXSee visit the project "
|
"License version 3. For more info about GPXSee visit the project "
|
||||||
"homepage at ") + "<a href=\"" + homepage.toString() + "\">"
|
"homepage at %1.").arg("<a href=\"" + homepage.toString() + "\">"
|
||||||
+ homepage.toString(QUrl::RemoveScheme).mid(2)
|
+ homepage.toString(QUrl::RemoveScheme).mid(2) + "</a>")
|
||||||
+ "</a>.</td></tr></table>");
|
+ "</td></tr></table>");
|
||||||
|
|
||||||
QIcon icon = msgBox.windowIcon();
|
QIcon icon = msgBox.windowIcon();
|
||||||
QSize size = icon.actualSize(QSize(64, 64));
|
QSize size = icon.actualSize(QSize(64, 64));
|
||||||
@ -698,19 +693,15 @@ void GUI::paths()
|
|||||||
msgBox.setWindowTitle(tr("Paths"));
|
msgBox.setWindowTitle(tr("Paths"));
|
||||||
msgBox.setText("<h3>" + tr("Paths") + "</h3>");
|
msgBox.setText("<h3>" + tr("Paths") + "</h3>");
|
||||||
msgBox.setInformativeText(
|
msgBox.setInformativeText(
|
||||||
"<style>td {white-space: pre; padding-right: 1em;}</style><h4>"
|
"<style>td {white-space: pre; padding-right: 1em;}</style><table><tr><td>"
|
||||||
+ tr("Global") + "</h4><table><tr><td>" + tr("Map directory:")
|
+ tr("Map directory:") + "</td><td><code>"
|
||||||
+ "</td><td><code>" + QDir::cleanPath(GLOBAL_MAP_DIR)
|
+ QDir::cleanPath(ProgramPaths::mapDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ "</code></td></tr><tr><td>" + tr("POI directory:") + "</td><td><code>"
|
+ tr("POI directory:") + "</td><td><code>"
|
||||||
+ QDir::cleanPath(GLOBAL_POI_DIR) + "</code></td></tr><tr><td>"
|
+ QDir::cleanPath(ProgramPaths::poiDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ tr("GCS/PCS directory:") + "</td><td><code>"
|
+ tr("GCS/PCS directory:") + "</td><td><code>"
|
||||||
+ QDir::cleanPath(GLOBAL_CSV_DIR) + "</code></td></tr></table>"
|
+ QDir::cleanPath(ProgramPaths::csvDir(true)) + "</code></td></tr><tr><td>"
|
||||||
+ "<h4>" + tr("User-specific") + "</h4><table><tr><td>"
|
+ tr("Tile cache directory:") + "</td><td><code>"
|
||||||
+ tr("Map directory:") + "</td><td><code>" + QDir::cleanPath(USER_MAP_DIR)
|
+ QDir::cleanPath(ProgramPaths::tilesDir()) + "</code></td></tr></table>"
|
||||||
+ "</code></td></tr><tr><td>" + tr("POI directory:") + "</td><td><code>"
|
|
||||||
+ QDir::cleanPath(USER_POI_DIR) + "</code></td></tr><tr><td>"
|
|
||||||
+ tr("GCS/PCS directory:") + "</td><td><code>"
|
|
||||||
+ QDir::cleanPath(USER_CSV_DIR) + "</code></td></tr></table>"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
@ -838,7 +829,15 @@ bool GUI::openPOIFile(const QString &fileName)
|
|||||||
if (fileName.isEmpty() || _poi->files().contains(fileName))
|
if (fileName.isEmpty() || _poi->files().contains(fileName))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!_poi->loadFile(fileName)) {
|
if (_poi->loadFile(fileName)) {
|
||||||
|
_mapView->showPOI(true);
|
||||||
|
_showPOIAction->setChecked(true);
|
||||||
|
QAction *action = createPOIFileAction(fileName);
|
||||||
|
action->setChecked(true);
|
||||||
|
_poiFilesMenu->addAction(action);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
QString error = tr("Error loading POI file:") + "\n\n"
|
QString error = tr("Error loading POI file:") + "\n\n"
|
||||||
+ fileName + "\n\n" + _poi->errorString();
|
+ fileName + "\n\n" + _poi->errorString();
|
||||||
if (_poi->errorLine())
|
if (_poi->errorLine())
|
||||||
@ -846,14 +845,6 @@ bool GUI::openPOIFile(const QString &fileName)
|
|||||||
QMessageBox::critical(this, APP_NAME, error);
|
QMessageBox::critical(this, APP_NAME, error);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
_mapView->showPOI(true);
|
|
||||||
_showPOIAction->setChecked(true);
|
|
||||||
QAction *action = createPOIFileAction(_poi->files().indexOf(fileName));
|
|
||||||
action->setChecked(true);
|
|
||||||
_poiFilesMenu->addAction(action);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,8 +924,8 @@ void GUI::openOptions()
|
|||||||
#endif // ENABLE_HTTP2
|
#endif // ENABLE_HTTP2
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
if (options.hidpiMap != _options.hidpiMap)
|
if (options.hidpiMap != _options.hidpiMap)
|
||||||
_mapView->setDevicePixelRatio(options.hidpiMap ? devicePixelRatioF()
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||||
: 1.0);
|
options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
if (reload)
|
if (reload)
|
||||||
@ -1294,18 +1285,11 @@ bool GUI::loadMap(const QString &fileName)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_ml->loadFile(fileName)) {
|
if (_ml->loadFile(fileName)) {
|
||||||
QAction *a = new QAction(_ml->maps().last()->name(), this);
|
QAction *a = createMapAction(_ml->maps().last());
|
||||||
a->setMenuRole(QAction::NoRole);
|
|
||||||
a->setCheckable(true);
|
|
||||||
a->setActionGroup(_mapsActionGroup);
|
|
||||||
_mapsSignalMapper->setMapping(a, _ml->maps().size() - 1);
|
|
||||||
connect(a, SIGNAL(triggered()), _mapsSignalMapper, SLOT(map()));
|
|
||||||
_mapActions.append(a);
|
|
||||||
_mapMenu->insertAction(_mapsEnd, a);
|
_mapMenu->insertAction(_mapsEnd, a);
|
||||||
_showMapAction->setEnabled(true);
|
_showMapAction->setEnabled(true);
|
||||||
_clearMapCacheAction->setEnabled(true);
|
_clearMapCacheAction->setEnabled(true);
|
||||||
_mapActions.last()->trigger();
|
a->trigger();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
QString error = tr("Error loading map:") + "\n\n"
|
QString error = tr("Error loading map:") + "\n\n"
|
||||||
@ -1618,7 +1602,7 @@ void GUI::dropEvent(QDropEvent *event)
|
|||||||
|
|
||||||
void GUI::writeSettings()
|
void GUI::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings(APP_NAME, APP_NAME);
|
QSettings settings(qApp->applicationName(), qApp->applicationName());
|
||||||
settings.clear();
|
settings.clear();
|
||||||
|
|
||||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||||
@ -1813,7 +1797,7 @@ void GUI::writeSettings()
|
|||||||
void GUI::readSettings()
|
void GUI::readSettings()
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
QSettings settings(APP_NAME, APP_NAME);
|
QSettings settings(qApp->applicationName(), qApp->applicationName());
|
||||||
|
|
||||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||||
resize(settings.value(WINDOW_SIZE_SETTING, WINDOW_SIZE_DEFAULT).toSize());
|
resize(settings.value(WINDOW_SIZE_SETTING, WINDOW_SIZE_DEFAULT).toSize());
|
||||||
@ -2063,7 +2047,8 @@ void GUI::readSettings()
|
|||||||
if (_options.useOpenGL)
|
if (_options.useOpenGL)
|
||||||
_mapView->useOpenGL(true);
|
_mapView->useOpenGL(true);
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||||
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
for (int i = 0; i < _tabs.count(); i++) {
|
for (int i = 0; i < _tabs.count(); i++) {
|
||||||
@ -2089,10 +2074,6 @@ void GUI::readSettings()
|
|||||||
_poi->setRadius(_options.poiRadius);
|
_poi->setRadius(_options.poiRadius);
|
||||||
|
|
||||||
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
|
QPixmapCache::setCacheLimit(_options.pixmapCache * 1024);
|
||||||
Downloader::setTimeout(_options.connectionTimeout);
|
|
||||||
#ifdef ENABLE_HTTP2
|
|
||||||
Downloader::enableHTTP2(_options.enableHTTP2);
|
|
||||||
#endif // ENABLE_HTTP2
|
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
@ -2150,7 +2131,8 @@ void GUI::show()
|
|||||||
void GUI::screenChanged(QScreen *screen)
|
void GUI::screenChanged(QScreen *screen)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||||
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||||
|
|
||||||
disconnect(SIGNAL(logicalDotsPerInchChanged(qreal)), this,
|
disconnect(SIGNAL(logicalDotsPerInchChanged(qreal)), this,
|
||||||
SLOT(logicalDotsPerInchChanged(qreal)));
|
SLOT(logicalDotsPerInchChanged(qreal)));
|
||||||
@ -2166,6 +2148,7 @@ void GUI::logicalDotsPerInchChanged(qreal dpi)
|
|||||||
Q_UNUSED(dpi)
|
Q_UNUSED(dpi)
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_mapView->setDevicePixelRatio(_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
_mapView->setDevicePixelRatio(devicePixelRatioF(),
|
||||||
|
_options.hidpiMap ? devicePixelRatioF() : 1.0);
|
||||||
#endif // ENBLE_HIDPI
|
#endif // ENBLE_HIDPI
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,8 @@ private:
|
|||||||
void closeFiles();
|
void closeFiles();
|
||||||
void plot(QPrinter *printer);
|
void plot(QPrinter *printer);
|
||||||
|
|
||||||
QAction *createPOIFileAction(int index);
|
QAction *createPOIFileAction(const QString &fileName);
|
||||||
|
QAction *createMapAction(const Map *map);
|
||||||
void createPOIFilesActions();
|
void createPOIFilesActions();
|
||||||
void createMapActions();
|
void createMapActions();
|
||||||
void createActions();
|
void createActions();
|
||||||
|
@ -7,9 +7,14 @@ HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
|
|||||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
_max = graph.first().y();
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++)
|
for (int i = 1; i < graph.size(); i++) {
|
||||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
qreal y = graph.at(i).y();
|
||||||
|
sum += y * (graph.at(i).s() - graph.at(i-1).s());
|
||||||
|
if (y > _max)
|
||||||
|
_max = y;
|
||||||
|
}
|
||||||
_avg = sum/graph.last().s();
|
_avg = sum/graph.last().s();
|
||||||
|
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
|
@ -11,13 +11,13 @@ public:
|
|||||||
HeartRateGraphItem(const Graph &graph, GraphType type,
|
HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
qreal _avg;
|
qreal _avg, _max;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HEARTRATEGRAPHITEM_H
|
#endif // HEARTRATEGRAPHITEM_H
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "font.h"
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
|
|
||||||
#define PADDING 10
|
#define PADDING 10
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "kv.h"
|
#include "common/kv.h"
|
||||||
|
|
||||||
class InfoItem : public QGraphicsItem
|
class InfoItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
|
@ -18,9 +18,10 @@
|
|||||||
|
|
||||||
#define MAX_DIGITAL_ZOOM 2
|
#define MAX_DIGITAL_ZOOM 2
|
||||||
#define MIN_DIGITAL_ZOOM -3
|
#define MIN_DIGITAL_ZOOM -3
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10
|
||||||
#define SCALE_OFFSET 7
|
#define SCALE_OFFSET 7
|
||||||
|
|
||||||
|
|
||||||
MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
@ -72,7 +73,8 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
|
|||||||
_poiColor = Qt::black;
|
_poiColor = Qt::black;
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_ratio = 1.0;
|
_deviceRatio = 1.0;
|
||||||
|
_mapRatio = 1.0;
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
_opengl = false;
|
_opengl = false;
|
||||||
_plot = false;
|
_plot = false;
|
||||||
@ -270,7 +272,7 @@ void MapView::setMap(Map *map)
|
|||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_map->setDevicePixelRatio(_ratio);
|
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
@ -438,10 +440,10 @@ void MapView::zoom(int zoom, const QPoint &pos)
|
|||||||
digitalZoom(zoom);
|
digitalZoom(zoom);
|
||||||
} else {
|
} else {
|
||||||
Coordinates c = _map->xy2ll(mapToScene(pos));
|
Coordinates c = _map->xy2ll(mapToScene(pos));
|
||||||
qreal os = _map->zoom();
|
int oz = _map->zoom();
|
||||||
qreal ns = (zoom > 0) ? _map->zoomIn() : _map->zoomOut();
|
int nz = (zoom > 0) ? _map->zoomIn() : _map->zoomOut();
|
||||||
|
|
||||||
if (ns != os) {
|
if (nz != oz) {
|
||||||
rescale();
|
rescale();
|
||||||
centerOn(_map->ll2xy(c) - (pos - viewport()->rect().center()));
|
centerOn(_map->ll2xy(c) - (pos - viewport()->rect().center()));
|
||||||
} else {
|
} else {
|
||||||
@ -505,7 +507,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
|
|||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
_plot = true;
|
_plot = true;
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_map->setDevicePixelRatio(1.0);
|
_map->setDevicePixelRatio(_deviceRatio, 1.0);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
// Compute sizes & ratios
|
// Compute sizes & ratios
|
||||||
@ -566,7 +568,7 @@ void MapView::plot(QPainter *painter, const QRectF &target, qreal scale,
|
|||||||
|
|
||||||
// Exit plot mode
|
// Exit plot mode
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
_map->setDevicePixelRatio(_ratio);
|
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
_plot = false;
|
_plot = false;
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
@ -844,19 +846,21 @@ void MapView::reloadMap()
|
|||||||
_scene->invalidate();
|
_scene->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView::setDevicePixelRatio(qreal ratio)
|
void MapView::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
if (_ratio == ratio)
|
if (_deviceRatio == deviceRatio && _mapRatio == mapRatio)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_ratio = ratio;
|
_deviceRatio = deviceRatio;
|
||||||
|
_mapRatio = mapRatio;
|
||||||
|
QPixmapCache::clear();
|
||||||
|
|
||||||
QRectF vr(mapToScene(viewport()->rect()).boundingRect()
|
QRectF vr(mapToScene(viewport()->rect()).boundingRect()
|
||||||
.intersected(_map->bounds()));
|
.intersected(_map->bounds()));
|
||||||
RectC cr(_map->xy2ll(vr.topLeft()), _map->xy2ll(vr.bottomRight()));
|
RectC cr(_map->xy2ll(vr.topLeft()), _map->xy2ll(vr.bottomRight()));
|
||||||
|
|
||||||
_map->setDevicePixelRatio(_ratio);
|
_map->setDevicePixelRatio(_deviceRatio, _mapRatio);
|
||||||
_scene->setSceneRect(_map->bounds());
|
_scene->setSceneRect(_map->bounds());
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++)
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
@ -877,6 +881,7 @@ void MapView::setDevicePixelRatio(qreal ratio)
|
|||||||
|
|
||||||
reloadMap();
|
reloadMap();
|
||||||
#else // ENABLE_HIDPI
|
#else // ENABLE_HIDPI
|
||||||
Q_UNUSED(ratio);
|
Q_UNUSED(deviceRatio);
|
||||||
|
Q_UNUSED(mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
|
#include "common/config.h"
|
||||||
#include "data/waypoint.h"
|
#include "data/waypoint.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 "config.h"
|
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
class POI;
|
class POI;
|
||||||
@ -69,7 +69,7 @@ public slots:
|
|||||||
void showRouteWaypoints(bool show);
|
void showRouteWaypoints(bool show);
|
||||||
void clearMapCache();
|
void clearMapCache();
|
||||||
void setCoordinatesFormat(CoordinatesFormat format);
|
void setCoordinatesFormat(CoordinatesFormat format);
|
||||||
void setDevicePixelRatio(qreal ratio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePOI();
|
void updatePOI();
|
||||||
@ -140,7 +140,8 @@ private:
|
|||||||
bool _plot;
|
bool _plot;
|
||||||
|
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
qreal _ratio;
|
qreal _deviceRatio;
|
||||||
|
qreal _mapRatio;
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
bool _opengl;
|
bool _opengl;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef MISC_H
|
|
||||||
#define MISC_H
|
|
||||||
|
|
||||||
double niceNum(double x, int round);
|
|
||||||
|
|
||||||
#endif // MISC_H
|
|
@ -2,10 +2,9 @@
|
|||||||
#define OPTIONSDIALOG_H
|
#define OPTIONSDIALOG_H
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include "common/config.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
|
|
||||||
class ColorBox;
|
class ColorBox;
|
||||||
class StyleComboBox;
|
class StyleComboBox;
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QApplication>
|
|
||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/greatcircle.h"
|
#include "common/greatcircle.h"
|
||||||
#include "map/map.h"
|
#include "map/map.h"
|
||||||
#include "tooltip.h"
|
|
||||||
#include "nicenum.h"
|
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
@ -50,6 +47,7 @@ void PathItem::updateShape()
|
|||||||
void PathItem::addSegment(const Coordinates &c1, const Coordinates &c2)
|
void PathItem::addSegment(const Coordinates &c1, const Coordinates &c2)
|
||||||
{
|
{
|
||||||
if (fabs(c1.lon() - c2.lon()) > 180.0) {
|
if (fabs(c1.lon() - c2.lon()) > 180.0) {
|
||||||
|
// Split segment on date line crossing
|
||||||
QPointF p;
|
QPointF p;
|
||||||
|
|
||||||
if (c2.lon() < 0) {
|
if (c2.lon() < 0) {
|
||||||
|
@ -7,9 +7,14 @@ PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type,
|
|||||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
_max = graph.first().y();
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++)
|
for (int i = 1; i < graph.size(); i++) {
|
||||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
qreal y = graph.at(i).y();
|
||||||
|
sum += y * (graph.at(i).s() - graph.at(i-1).s());
|
||||||
|
if (y > _max)
|
||||||
|
_max = y;
|
||||||
|
}
|
||||||
_avg = sum/graph.last().s();
|
_avg = sum/graph.last().s();
|
||||||
|
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
|
@ -11,13 +11,13 @@ public:
|
|||||||
PowerGraphItem(const Graph &graph, GraphType type,
|
PowerGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
qreal _avg;
|
qreal _avg, _max;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // POWERGRAPHITEM_H
|
#endif // POWERGRAPHITEM_H
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "common/util.h"
|
||||||
#include "nicenum.h"
|
#include "font.h"
|
||||||
#include "scaleitem.h"
|
#include "scaleitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "font.h"
|
||||||
#include "sliderinfoitem.h"
|
#include "sliderinfoitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include "data/data.h"
|
#include "data/data.h"
|
||||||
#include "config.h"
|
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "speedgraphitem.h"
|
#include "speedgraphitem.h"
|
||||||
|
@ -13,6 +13,13 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
|
|||||||
_avg = graph.last().s() / graph.last().t();
|
_avg = graph.last().s() / graph.last().t();
|
||||||
_mavg = graph.last().s() / movingTime;
|
_mavg = graph.last().s() / movingTime;
|
||||||
|
|
||||||
|
_max = graph.first().y();
|
||||||
|
for (int i = 1; i < graph.size(); i++) {
|
||||||
|
qreal y = graph.at(i).y();
|
||||||
|
if (y > _max)
|
||||||
|
_max = y;
|
||||||
|
}
|
||||||
|
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public:
|
|||||||
SpeedGraphItem(const Graph &graph, GraphType type, qreal movingTime,
|
SpeedGraphItem(const Graph &graph, GraphType type, qreal movingTime,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
qreal mavg() const {return _mavg;}
|
qreal mavg() const {return _mavg;}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString toolTip() const;
|
QString toolTip() const;
|
||||||
|
|
||||||
qreal _avg, _mavg;
|
qreal _avg, _mavg, _max;
|
||||||
|
|
||||||
Units _units;
|
Units _units;
|
||||||
TimeType _timeType;
|
TimeType _timeType;
|
||||||
|
@ -7,9 +7,18 @@ TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
|
|||||||
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
{
|
{
|
||||||
qreal sum = 0;
|
qreal sum = 0;
|
||||||
|
_min = _max = graph.first().y();
|
||||||
|
|
||||||
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
|
qreal y = graph.at(j).y();
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++)
|
|
||||||
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||||
|
|
||||||
|
if (y > _max)
|
||||||
|
_max = y;
|
||||||
|
if (y < _min)
|
||||||
|
_min = y;
|
||||||
|
}
|
||||||
_avg = sum/graph.last().s();
|
_avg = sum/graph.last().s();
|
||||||
|
|
||||||
setToolTip(toolTip(Metric));
|
setToolTip(toolTip(Metric));
|
||||||
|
@ -11,8 +11,8 @@ public:
|
|||||||
TemperatureGraphItem(const Graph &graph, GraphType type,
|
TemperatureGraphItem(const Graph &graph, GraphType type,
|
||||||
QGraphicsItem *parent = 0);
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
qreal max() const {return -bounds().top();}
|
qreal max() const {return _max;}
|
||||||
qreal min() const {return -bounds().bottom();}
|
qreal min() const {return _min;}
|
||||||
qreal avg() const {return _avg;}
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
@ -20,7 +20,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString toolTip(Units units) const;
|
QString toolTip(Units units) const;
|
||||||
|
|
||||||
qreal _avg;
|
qreal _avg, _min, _max;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEMPERATUREGRAPHITEM_H
|
#endif // TEMPERATUREGRAPHITEM_H
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
void ToolTip::insert(const QString &key, const QString &value)
|
void ToolTip::insert(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
QPair<QString, QString> entry(key, value);
|
_list.append(KV(key, value));
|
||||||
_list.append(entry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ToolTip::toString()
|
QString ToolTip::toString()
|
||||||
@ -11,8 +10,8 @@ QString ToolTip::toString()
|
|||||||
QString ret = "<table>";
|
QString ret = "<table>";
|
||||||
|
|
||||||
for (int i = 0; i < _list.count(); i++)
|
for (int i = 0; i < _list.count(); i++)
|
||||||
ret += "<tr><td align=\"right\"><b>" + _list.at(i).first
|
ret += "<tr><td align=\"right\"><b>" + _list.at(i).key()
|
||||||
+ ": </b></td><td>" + _list.at(i).second + "</td></tr>";
|
+ ": </b></td><td>" + _list.at(i).value() + "</td></tr>";
|
||||||
|
|
||||||
ret += "</table>";
|
ret += "</table>";
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QPair>
|
#include "common/kv.h"
|
||||||
|
|
||||||
class ToolTip
|
class ToolTip
|
||||||
{
|
{
|
||||||
@ -12,7 +12,7 @@ public:
|
|||||||
QString toString();
|
QString toString();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QPair<QString, QString> > _list;
|
QList<KV> _list;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOOLTIP_H
|
#endif // TOOLTIP_H
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QPaintDevice>
|
#include <QPaintDevice>
|
||||||
#include "config.h"
|
|
||||||
#include "infoitem.h"
|
#include "infoitem.h"
|
||||||
#include "trackinfo.h"
|
#include "trackinfo.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "config.h"
|
#include "font.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
|
||||||
|
17
src/common/config.h
Normal file
17
src/common/config.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef CONFIG_H
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#define APP_NAME "GPXSee"
|
||||||
|
#define APP_HOMEPAGE "http://www.gpxsee.org"
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 1)
|
||||||
|
#define ENABLE_HTTP2
|
||||||
|
#endif // QT >= 5.10.1
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||||
|
#define ENABLE_HIDPI
|
||||||
|
#endif // QT >= 5.6
|
||||||
|
|
||||||
|
#endif /* CONFIG_H */
|
@ -32,6 +32,8 @@ private:
|
|||||||
double _lat, _lon;
|
double _lat, _lon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_TYPEINFO(Coordinates, Q_PRIMITIVE_TYPE);
|
||||||
|
|
||||||
inline bool operator==(const Coordinates &c1, const Coordinates &c2)
|
inline bool operator==(const Coordinates &c1, const Coordinates &c2)
|
||||||
{return (c1.lat() == c2.lat() && c1.lon() == c2.lon());}
|
{return (c1.lat() == c2.lat() && c1.lon() == c2.lon());}
|
||||||
inline bool operator!=(const Coordinates &c1, const Coordinates &c2)
|
inline bool operator!=(const Coordinates &c1, const Coordinates &c2)
|
||||||
|
174
src/common/programpaths.cpp
Normal file
174
src/common/programpaths.cpp
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
#include <QtGlobal>
|
||||||
|
#include <QDir>
|
||||||
|
#include "programpaths.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MAP_DIR "maps"
|
||||||
|
#define POI_DIR "POI"
|
||||||
|
#define CSV_DIR "csv"
|
||||||
|
#define TILES_DIR "tiles"
|
||||||
|
#define TRANSLATIONS_DIR "translations"
|
||||||
|
#define ELLIPSOID_FILE "ellipsoids.csv"
|
||||||
|
#define GCS_FILE "gcs.csv"
|
||||||
|
#define PCS_FILE "pcs.csv"
|
||||||
|
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
#define USER_DIR QDir::homePath() + QString("/AppData/Roaming/") \
|
||||||
|
+ qApp->applicationName()
|
||||||
|
#define GLOBAL_DIR QApplication::applicationDirPath()
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
#define USER_DIR QDir::homePath() \
|
||||||
|
+ QString("/Library/Application Support/") \
|
||||||
|
+ qApp->applicationName()
|
||||||
|
#define GLOBAL_DIR QApplication::applicationDirPath() \
|
||||||
|
+ QString("/../Resources")
|
||||||
|
#else
|
||||||
|
#define USER_DIR QDir::homePath() + QString("/.local/share/") \
|
||||||
|
+ qApp->applicationName()
|
||||||
|
#define GLOBAL_DIR QString("/usr/share/") + qApp->applicationName()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static QString dir(const QString &dirName, bool writable = false)
|
||||||
|
{
|
||||||
|
QDir userDir(QDir(USER_DIR).filePath(dirName));
|
||||||
|
|
||||||
|
if (writable || userDir.exists())
|
||||||
|
return userDir.absolutePath();
|
||||||
|
else {
|
||||||
|
QDir globalDir(QDir(GLOBAL_DIR).filePath(dirName));
|
||||||
|
|
||||||
|
if (globalDir.exists())
|
||||||
|
return globalDir.absolutePath();
|
||||||
|
else
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString file(const QString &path, const QString &fileName)
|
||||||
|
{
|
||||||
|
if (path.isNull())
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
QFileInfo fi(QDir(path).filePath(fileName));
|
||||||
|
return fi.exists() ? fi.absoluteFilePath() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::mapDir(bool writable)
|
||||||
|
{
|
||||||
|
return dir(MAP_DIR, writable);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::poiDir(bool writable)
|
||||||
|
{
|
||||||
|
return dir(POI_DIR, writable);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::csvDir(bool writable)
|
||||||
|
{
|
||||||
|
return dir(CSV_DIR, writable);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::tilesDir()
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
return QDir::homePath() + QString("/AppData/Local/")
|
||||||
|
+ qApp->applicationName() + QString("/cache/") + QString(TILES_DIR);
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
return QDir::homePath() + QString("/Library/Caches/")
|
||||||
|
+ qApp->applicationName() + QString("/" TILES_DIR);
|
||||||
|
#else
|
||||||
|
return QDir::homePath() + QString("/.cache/") + qApp->applicationName()
|
||||||
|
+ QString("/" TILES_DIR);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::translationsDir()
|
||||||
|
{
|
||||||
|
return dir(TRANSLATIONS_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::ellipsoidsFile()
|
||||||
|
{
|
||||||
|
return file(dir(CSV_DIR), ELLIPSOID_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::gcsFile()
|
||||||
|
{
|
||||||
|
return file(dir(CSV_DIR), GCS_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::pcsFile()
|
||||||
|
{
|
||||||
|
return file(dir(CSV_DIR), PCS_FILE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
QString ProgramPaths::mapDir(bool writable)
|
||||||
|
{
|
||||||
|
if (writable)
|
||||||
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::AppDataLocation)).filePath(MAP_DIR);
|
||||||
|
else
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
MAP_DIR, QStandardPaths::LocateDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::poiDir(bool writable)
|
||||||
|
{
|
||||||
|
if (writable)
|
||||||
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::AppDataLocation)).filePath(POI_DIR);
|
||||||
|
else
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
POI_DIR, QStandardPaths::LocateDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::csvDir(bool writable)
|
||||||
|
{
|
||||||
|
if (writable)
|
||||||
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::AppDataLocation)).filePath(CSV_DIR);
|
||||||
|
else
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
CSV_DIR, QStandardPaths::LocateDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::tilesDir()
|
||||||
|
{
|
||||||
|
return QDir(QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::CacheLocation)).filePath(TILES_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::translationsDir()
|
||||||
|
{
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
TRANSLATIONS_DIR, QStandardPaths::LocateDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::ellipsoidsFile()
|
||||||
|
{
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
CSV_DIR "/" ELLIPSOID_FILE, QStandardPaths::LocateFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::gcsFile()
|
||||||
|
{
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
CSV_DIR "/" GCS_FILE, QStandardPaths::LocateFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProgramPaths::pcsFile()
|
||||||
|
{
|
||||||
|
return QStandardPaths::locate(QStandardPaths::AppDataLocation,
|
||||||
|
CSV_DIR "/" PCS_FILE, QStandardPaths::LocateFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QT_VERSION < 5
|
18
src/common/programpaths.h
Normal file
18
src/common/programpaths.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#ifndef PROGRAMPATHS_H
|
||||||
|
#define PROGRAMPATHS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
namespace ProgramPaths
|
||||||
|
{
|
||||||
|
QString mapDir(bool writable = false);
|
||||||
|
QString poiDir(bool writable = false);
|
||||||
|
QString csvDir(bool writable = false);
|
||||||
|
QString tilesDir();
|
||||||
|
QString translationsDir();
|
||||||
|
QString ellipsoidsFile();
|
||||||
|
QString gcsFile();
|
||||||
|
QString pcsFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PROGRAMPATHS_H
|
@ -8,7 +8,7 @@ class Range
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Range() {_min = 0; _max = 0;}
|
Range() {_min = 0; _max = 0;}
|
||||||
Range(int min, int max) {_min = min, _max = max;}
|
Range(int min, int max) : _min(min), _max(max) {}
|
||||||
|
|
||||||
int min() const {return _min;}
|
int min() const {return _min;}
|
||||||
int max() const {return _max;}
|
int max() const {return _max;}
|
||||||
@ -29,7 +29,7 @@ class RangeF
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RangeF() {_min = 0; _max = 0;}
|
RangeF() {_min = 0; _max = 0;}
|
||||||
RangeF(qreal min, qreal max) {_min = min, _max = max;}
|
RangeF(qreal min, qreal max) : _min(min), _max(max) {}
|
||||||
|
|
||||||
RangeF operator&(const RangeF &r) const;
|
RangeF operator&(const RangeF &r) const;
|
||||||
RangeF &operator&=(const RangeF &r) {*this = *this & r; return *this;}
|
RangeF &operator&=(const RangeF &r) {*this = *this & r; return *this;}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#include <cctype>
|
|
||||||
#include "str2int.h"
|
|
||||||
|
|
||||||
int str2int(const char *str, int len)
|
|
||||||
{
|
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
for (const char *sp = str; sp < str + len; sp++) {
|
|
||||||
if (::isdigit(*sp))
|
|
||||||
res = res * 10 + *sp - '0';
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef MISC_H
|
|
||||||
#define MISC_H
|
|
||||||
|
|
||||||
int str2int(const char *str, int len);
|
|
||||||
|
|
||||||
#endif // MISC_H
|
|
@ -1,5 +1,21 @@
|
|||||||
|
#include <cctype>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "nicenum.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
|
int str2int(const char *str, int len)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
for (const char *sp = str; sp < str + len; sp++) {
|
||||||
|
if (::isdigit(*sp))
|
||||||
|
res = res * 10 + *sp - '0';
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
double niceNum(double x, int round)
|
double niceNum(double x, int round)
|
||||||
{
|
{
|
7
src/common/util.h
Normal file
7
src/common/util.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef UTIL_H
|
||||||
|
#define UTIL_H
|
||||||
|
|
||||||
|
int str2int(const char *str, int len);
|
||||||
|
double niceNum(double x, int round);
|
||||||
|
|
||||||
|
#endif // UTIL_H
|
58
src/config.h
58
src/config.h
@ -1,58 +0,0 @@
|
|||||||
#ifndef CONFIG_H
|
|
||||||
#define CONFIG_H
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#define APP_NAME "GPXSee"
|
|
||||||
#define APP_HOMEPAGE "http://www.gpxsee.org"
|
|
||||||
|
|
||||||
#define FONT_FAMILY "Arial"
|
|
||||||
#define FONT_SIZE 12 // px
|
|
||||||
|
|
||||||
#define MAP_DIR QString("maps")
|
|
||||||
#define POI_DIR QString("POI")
|
|
||||||
#define CSV_DIR QString("csv")
|
|
||||||
#define ELLIPSOID_FILE QString("ellipsoids.csv")
|
|
||||||
#define GCS_FILE QString("gcs.csv")
|
|
||||||
#define PCS_FILE QString("pcs.csv")
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
|
||||||
#define USER_DIR QDir::homePath() + QString("/GPXSee")
|
|
||||||
#define GLOBAL_DIR QApplication::applicationDirPath()
|
|
||||||
#elif defined(Q_OS_MAC)
|
|
||||||
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
|
||||||
#define GLOBAL_DIR QApplication::applicationDirPath() \
|
|
||||||
+ QString("/../Resources")
|
|
||||||
#else
|
|
||||||
#define USER_DIR QDir::homePath() + QString("/.gpxsee")
|
|
||||||
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define USER_CSV_DIR USER_DIR + QString("/") + CSV_DIR
|
|
||||||
#define USER_ELLIPSOID_FILE USER_CSV_DIR + QString("/") + ELLIPSOID_FILE
|
|
||||||
#define USER_GCS_FILE USER_CSV_DIR + QString("/") + GCS_FILE
|
|
||||||
#define USER_PCS_FILE USER_CSV_DIR + QString("/") + PCS_FILE
|
|
||||||
#define USER_MAP_DIR USER_DIR + QString("/") + MAP_DIR
|
|
||||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
|
||||||
#define GLOBAL_CSV_DIR GLOBAL_DIR + QString("/") + CSV_DIR
|
|
||||||
#define GLOBAL_ELLIPSOID_FILE GLOBAL_CSV_DIR + QString("/") + ELLIPSOID_FILE
|
|
||||||
#define GLOBAL_GCS_FILE GLOBAL_CSV_DIR + QString("/") + GCS_FILE
|
|
||||||
#define GLOBAL_PCS_FILE GLOBAL_CSV_DIR + QString("/") + PCS_FILE
|
|
||||||
#define GLOBAL_MAP_DIR GLOBAL_DIR + QString("/") + MAP_DIR
|
|
||||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
|
||||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
|
||||||
#define TRANSLATIONS_DIR GLOBAL_DIR + QString("/translations")
|
|
||||||
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 1)
|
|
||||||
#define ENABLE_HTTP2
|
|
||||||
#endif // QT >= 5.10.1
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
|
||||||
#define ENABLE_HIDPI
|
|
||||||
#endif // QT >= 5.6
|
|
||||||
|
|
||||||
#endif /* CONFIG_H */
|
|
@ -98,9 +98,9 @@ bool Data::loadFile(const QString &fileName)
|
|||||||
file.reset();
|
file.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
qWarning("Error loading data file: %s:\n", qPrintable(fileName));
|
qWarning("Error loading data file: %s:", qPrintable(fileName));
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
qWarning("%s: line %d: %s\n", qPrintable(it.key()),
|
qWarning("%s: line %d: %s", qPrintable(it.key()),
|
||||||
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||||
|
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "common/str2int.h"
|
#include "common/util.h"
|
||||||
#include "igcparser.h"
|
#include "igcparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "common/str2int.h"
|
#include "common/util.h"
|
||||||
#include "nmeaparser.h"
|
#include "nmeaparser.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
class WaypointItem;
|
|
||||||
|
|
||||||
class POI : public QObject
|
class POI : public QObject
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
void SLFParser::warning(const char *text) const
|
void SLFParser::warning(const char *text) const
|
||||||
{
|
{
|
||||||
const QFile *file = static_cast<QFile *>(_reader.device());
|
const QFile *file = static_cast<QFile *>(_reader.device());
|
||||||
qWarning("%s:%lld: %s\n", qPrintable(file->fileName()),
|
qWarning("%s:%lld: %s", qPrintable(file->fileName()),
|
||||||
_reader.lineNumber(), text);
|
_reader.lineNumber(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
void TCXParser::warning(const char *text) const
|
void TCXParser::warning(const char *text) const
|
||||||
{
|
{
|
||||||
const QFile *file = static_cast<QFile *>(_reader.device());
|
const QFile *file = static_cast<QFile *>(_reader.device());
|
||||||
qWarning("%s:%lld: %s\n", qPrintable(file->fileName()),
|
qWarning("%s:%lld: %s", qPrintable(file->fileName()),
|
||||||
_reader.lineNumber(), text);
|
_reader.lineNumber(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
#include "common/config.h"
|
||||||
#include "GUI/app.h"
|
#include "GUI/app.h"
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -9,7 +9,5 @@ int main(int argc, char *argv[])
|
|||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
|
||||||
App app(argc, argv);
|
App app(argc, argv);
|
||||||
app.run();
|
return app.run();
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
#include "common/str2int.h"
|
#include "common/util.h"
|
||||||
#include "angularunits.h"
|
#include "angularunits.h"
|
||||||
|
|
||||||
static double sDMS2deg(double val)
|
static double sDMS2deg(double val)
|
||||||
|
@ -145,10 +145,10 @@ Atlas::Atlas(const QString &fileName, QObject *parent)
|
|||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Atlas::setDevicePixelRatio(qreal ratio)
|
void Atlas::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _maps.size(); i++)
|
for (int i = 0; i < _maps.size(); i++)
|
||||||
_maps[i]->setDevicePixelRatio(ratio);
|
_maps[i]->setDevicePixelRatio(deviceRatio, mapRatio);
|
||||||
|
|
||||||
computeBounds();
|
computeBounds();
|
||||||
}
|
}
|
||||||
@ -297,9 +297,9 @@ bool Atlas::isAtlas(const QString &path)
|
|||||||
{
|
{
|
||||||
QFileInfo fi(path);
|
QFileInfo fi(path);
|
||||||
QString suffix = fi.suffix().toLower();
|
QString suffix = fi.suffix().toLower();
|
||||||
Tar tar(path);
|
|
||||||
|
|
||||||
if (suffix == "tar") {
|
if (suffix == "tar") {
|
||||||
|
Tar tar(path);
|
||||||
if (!tar.open())
|
if (!tar.open())
|
||||||
return false;
|
return false;
|
||||||
QString tbaFileName = fi.completeBaseName() + ".tba";
|
QString tbaFileName = fi.completeBaseName() + ".tba";
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
void setDevicePixelRatio(qreal ratio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
void unload();
|
void unload();
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QBasicTimer>
|
#include <QBasicTimer>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QTimerEvent>
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
|
|
||||||
|
|
||||||
@ -20,8 +22,10 @@
|
|||||||
|
|
||||||
#define ATTR_REDIRECT QNetworkRequest::RedirectionTargetAttribute
|
#define ATTR_REDIRECT QNetworkRequest::RedirectionTargetAttribute
|
||||||
#define ATTR_FILE QNetworkRequest::User
|
#define ATTR_FILE QNetworkRequest::User
|
||||||
#define ATTR_ORIGIN (QNetworkRequest::Attribute)(QNetworkRequest::User + 1)
|
#define ATTR_ORIGIN \
|
||||||
#define ATTR_LEVEL (QNetworkRequest::Attribute)(QNetworkRequest::User + 2)
|
static_cast<QNetworkRequest::Attribute>(QNetworkRequest::User + 1)
|
||||||
|
#define ATTR_LEVEL \
|
||||||
|
static_cast<QNetworkRequest::Attribute>(QNetworkRequest::User + 2)
|
||||||
|
|
||||||
#define MAX_REDIRECT_LEVEL 5
|
#define MAX_REDIRECT_LEVEL 5
|
||||||
#define RETRIES 3
|
#define RETRIES 3
|
||||||
@ -77,7 +81,6 @@ private:
|
|||||||
int _level;
|
int _level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QNetworkAccessManager *Downloader::_manager = 0;
|
QNetworkAccessManager *Downloader::_manager = 0;
|
||||||
int Downloader::_timeout = 30;
|
int Downloader::_timeout = 30;
|
||||||
#ifdef ENABLE_HTTP2
|
#ifdef ENABLE_HTTP2
|
||||||
@ -87,10 +90,11 @@ bool Downloader::_http2 = true;
|
|||||||
bool Downloader::doDownload(const Download &dl,
|
bool Downloader::doDownload(const Download &dl,
|
||||||
const QByteArray &authorization, const Redirect *redirect)
|
const QByteArray &authorization, const Redirect *redirect)
|
||||||
{
|
{
|
||||||
QUrl url(dl.url());
|
const QUrl &url = dl.url();
|
||||||
|
|
||||||
if (!url.isValid() || !(url.scheme() == "http" || url.scheme() == "https")) {
|
if (!url.isValid() || !(url.scheme() == QLatin1String("http")
|
||||||
qWarning("%s: Invalid URL\n", qPrintable(url.toString()));
|
|| url.scheme() == QLatin1String("https"))) {
|
||||||
|
qWarning("%s: Invalid URL", qPrintable(url.toString()));
|
||||||
if (redirect)
|
if (redirect)
|
||||||
_errorDownloads.insert(redirect->origin(), RETRIES);
|
_errorDownloads.insert(redirect->origin(), RETRIES);
|
||||||
return false;
|
return false;
|
||||||
@ -115,6 +119,7 @@ bool Downloader::doDownload(const Download &dl,
|
|||||||
QVariant(_http2));
|
QVariant(_http2));
|
||||||
#endif // ENABLE_HTTP2
|
#endif // ENABLE_HTTP2
|
||||||
|
|
||||||
|
Q_ASSERT(_manager);
|
||||||
QNetworkReply *reply = _manager->get(request);
|
QNetworkReply *reply = _manager->get(request);
|
||||||
if (reply && reply->isRunning()) {
|
if (reply && reply->isRunning()) {
|
||||||
_currentDownloads.insert(url);
|
_currentDownloads.insert(url);
|
||||||
@ -138,7 +143,7 @@ bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
|||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
qWarning("Error writing file: %s: %s\n",
|
qWarning("Error writing file: %s: %s",
|
||||||
qPrintable(filename), qPrintable(file.errorString()));
|
qPrintable(filename), qPrintable(file.errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -159,34 +164,33 @@ void Downloader::insertError(const QUrl &url, QNetworkReply::NetworkError error)
|
|||||||
|
|
||||||
void Downloader::downloadFinished(QNetworkReply *reply)
|
void Downloader::downloadFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
QUrl url = reply->request().url();
|
QUrl url(reply->request().url());
|
||||||
QNetworkReply::NetworkError error = reply->error();
|
QNetworkReply::NetworkError error = reply->error();
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
QUrl origin(reply->request().attribute(ATTR_ORIGIN).toUrl());
|
||||||
if (origin.isEmpty()) {
|
if (origin.isEmpty()) {
|
||||||
insertError(url, error);
|
insertError(url, error);
|
||||||
qWarning("Error downloading file: %s: %s\n",
|
qWarning("Error downloading file: %s: %s",
|
||||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||||
} else {
|
} else {
|
||||||
insertError(origin, error);
|
insertError(origin, error);
|
||||||
qWarning("Error downloading file: %s -> %s: %s\n",
|
qWarning("Error downloading file: %s -> %s: %s",
|
||||||
origin.toEncoded().constData(), url.toEncoded().constData(),
|
origin.toEncoded().constData(), url.toEncoded().constData(),
|
||||||
qPrintable(reply->errorString()));
|
qPrintable(reply->errorString()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
QUrl location = reply->attribute(ATTR_REDIRECT).toUrl();
|
QUrl location(reply->attribute(ATTR_REDIRECT).toUrl());
|
||||||
QString filename = reply->request().attribute(ATTR_FILE)
|
QString filename(reply->request().attribute(ATTR_FILE).toString());
|
||||||
.toString();
|
|
||||||
|
|
||||||
if (!location.isEmpty()) {
|
if (!location.isEmpty()) {
|
||||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
QUrl origin(reply->request().attribute(ATTR_ORIGIN).toUrl());
|
||||||
int level = reply->request().attribute(ATTR_LEVEL).toInt();
|
int level = reply->request().attribute(ATTR_LEVEL).toInt();
|
||||||
|
|
||||||
if (level >= MAX_REDIRECT_LEVEL) {
|
if (level >= MAX_REDIRECT_LEVEL) {
|
||||||
_errorDownloads.insert(origin, RETRIES);
|
_errorDownloads.insert(origin, RETRIES);
|
||||||
qWarning("Error downloading file: %s: "
|
qWarning("Error downloading file: %s: "
|
||||||
"redirect level limit reached (redirect loop?)\n",
|
"redirect level limit reached (redirect loop?)",
|
||||||
origin.toEncoded().constData());
|
origin.toEncoded().constData());
|
||||||
} else {
|
} else {
|
||||||
QUrl redirectUrl;
|
QUrl redirectUrl;
|
||||||
@ -225,3 +229,12 @@ bool Downloader::get(const QList<Download> &list,
|
|||||||
|
|
||||||
return finishEmitted;
|
return finishEmitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_HTTP2
|
||||||
|
void Downloader::enableHTTP2(bool enable)
|
||||||
|
{
|
||||||
|
Q_ASSERT(_manager);
|
||||||
|
_http2 = enable;
|
||||||
|
_manager->clearConnectionCache();
|
||||||
|
}
|
||||||
|
#endif // ENABLE_HTTP2
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include "config.h"
|
#include "common/config.h"
|
||||||
|
|
||||||
|
|
||||||
class Download
|
class Download
|
||||||
@ -15,8 +15,8 @@ class Download
|
|||||||
public:
|
public:
|
||||||
Download(const QUrl &url, const QString &file) : _url(url), _file(file) {}
|
Download(const QUrl &url, const QString &file) : _url(url), _file(file) {}
|
||||||
|
|
||||||
const QUrl& url() const {return _url;}
|
const QUrl &url() const {return _url;}
|
||||||
const QString& file() const {return _file;}
|
const QString &file() const {return _file;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
@ -46,12 +46,12 @@ public:
|
|||||||
= Authorization());
|
= Authorization());
|
||||||
void clearErrors() {_errorDownloads.clear();}
|
void clearErrors() {_errorDownloads.clear();}
|
||||||
|
|
||||||
|
static void setNetworkManager(QNetworkAccessManager *manager)
|
||||||
|
{_manager = manager;}
|
||||||
static void setTimeout(int timeout) {_timeout = timeout;}
|
static void setTimeout(int timeout) {_timeout = timeout;}
|
||||||
#ifdef ENABLE_HTTP2
|
#ifdef ENABLE_HTTP2
|
||||||
static void enableHTTP2(bool enable) {_http2 = enable;}
|
static void enableHTTP2(bool enable);
|
||||||
#endif // ENABLE_HTTP2
|
#endif // ENABLE_HTTP2
|
||||||
static void setNetworkAccessManager(QNetworkAccessManager *manager)
|
|
||||||
{_manager = manager;}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished();
|
void finished();
|
||||||
@ -72,11 +72,11 @@ private:
|
|||||||
QSet<QUrl> _currentDownloads;
|
QSet<QUrl> _currentDownloads;
|
||||||
QHash<QUrl, int> _errorDownloads;
|
QHash<QUrl, int> _errorDownloads;
|
||||||
|
|
||||||
|
static QNetworkAccessManager *_manager;
|
||||||
static int _timeout;
|
static int _timeout;
|
||||||
#ifdef ENABLE_HTTP2
|
#ifdef ENABLE_HTTP2
|
||||||
static bool _http2;
|
static bool _http2;
|
||||||
#endif // ENABLE_HTTP2
|
#endif // ENABLE_HTTP2
|
||||||
static QNetworkAccessManager *_manager;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOWNLOADER_H
|
#endif // DOWNLOADER_H
|
||||||
|
@ -1,41 +1,18 @@
|
|||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/coordinates.h"
|
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "common/wgs84.h"
|
#include "osm.h"
|
||||||
#include "emptymap.h"
|
#include "emptymap.h"
|
||||||
|
|
||||||
|
|
||||||
#define ZOOM_MIN 0
|
|
||||||
#define ZOOM_MAX 19
|
|
||||||
#define TILE_SIZE 256
|
#define TILE_SIZE 256
|
||||||
|
|
||||||
static QPointF ll2m(const Coordinates &c)
|
|
||||||
{
|
|
||||||
return QPointF(c.lon(), rad2deg(log(tan(M_PI_4 + deg2rad(c.lat())/2.0))));
|
|
||||||
}
|
|
||||||
|
|
||||||
static Coordinates m2ll(const QPointF &p)
|
|
||||||
{
|
|
||||||
return Coordinates(p.x(), rad2deg(2.0 * atan(exp(deg2rad(p.y()))) - M_PI_2));
|
|
||||||
}
|
|
||||||
|
|
||||||
static qreal zoom2scale(int zoom)
|
|
||||||
{
|
|
||||||
return (360.0/(qreal)((1<<zoom) * TILE_SIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int scale2zoom(qreal scale)
|
|
||||||
{
|
|
||||||
return (int)log2(360.0/(scale * (qreal)TILE_SIZE));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int limitZoom(int zoom)
|
static int limitZoom(int zoom)
|
||||||
{
|
{
|
||||||
if (zoom < ZOOM_MIN)
|
if (zoom < OSM::ZOOMS.min())
|
||||||
return ZOOM_MIN;
|
return OSM::ZOOMS.min();
|
||||||
if (zoom > ZOOM_MAX)
|
if (zoom > OSM::ZOOMS.max())
|
||||||
return ZOOM_MAX;
|
return OSM::ZOOMS.max();
|
||||||
|
|
||||||
return zoom;
|
return zoom;
|
||||||
}
|
}
|
||||||
@ -43,23 +20,23 @@ static int limitZoom(int zoom)
|
|||||||
|
|
||||||
EmptyMap::EmptyMap(QObject *parent) : Map(parent)
|
EmptyMap::EmptyMap(QObject *parent) : Map(parent)
|
||||||
{
|
{
|
||||||
_zoom = ZOOM_MAX;
|
_zoom = OSM::ZOOMS.max();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF EmptyMap::bounds()
|
QRectF EmptyMap::bounds()
|
||||||
{
|
{
|
||||||
return QRectF(ll2xy(Coordinates(-180, 85)), ll2xy(Coordinates(180, -85)));
|
return QRectF(ll2xy(OSM::BOUNDS.topLeft()), ll2xy(OSM::BOUNDS.bottomRight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int EmptyMap::zoomFit(const QSize &size, const RectC &rect)
|
int EmptyMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
{
|
{
|
||||||
if (!rect.isValid())
|
if (!rect.isValid())
|
||||||
_zoom = ZOOM_MAX;
|
_zoom = OSM::ZOOMS.max();
|
||||||
else {
|
else {
|
||||||
QRectF tbr(ll2m(rect.topLeft()), ll2m(rect.bottomRight()));
|
QRectF tbr(OSM::ll2m(rect.topLeft()), OSM::ll2m(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
|
|
||||||
_zoom = limitZoom(scale2zoom(qMax(sc.x(), -sc.y())));
|
_zoom = limitZoom(OSM::scale2zoom(qMax(sc.x(), -sc.y()), TILE_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _zoom;
|
return _zoom;
|
||||||
@ -67,21 +44,18 @@ int EmptyMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
|
|
||||||
qreal EmptyMap::resolution(const QRectF &rect)
|
qreal EmptyMap::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
return OSM::resolution(rect.center(), _zoom, TILE_SIZE);
|
||||||
|
|
||||||
return (WGS84_RADIUS * 2.0 * M_PI * scale / 360.0
|
|
||||||
* cos(2.0 * atan(exp(deg2rad(-rect.center().y() * scale))) - M_PI/2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int EmptyMap::zoomIn()
|
int EmptyMap::zoomIn()
|
||||||
{
|
{
|
||||||
_zoom = qMin(_zoom + 1, ZOOM_MAX);
|
_zoom = qMin(_zoom + 1, OSM::ZOOMS.max());
|
||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EmptyMap::zoomOut()
|
int EmptyMap::zoomOut()
|
||||||
{
|
{
|
||||||
_zoom = qMax(_zoom - 1, ZOOM_MIN);
|
_zoom = qMax(_zoom - 1, OSM::ZOOMS.min());
|
||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,13 +68,13 @@ void EmptyMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
|
|
||||||
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = OSM::zoom2scale(_zoom, TILE_SIZE);
|
||||||
QPointF m = ll2m(c);
|
QPointF m = OSM::ll2m(c);
|
||||||
return QPointF(m.x() / scale, m.y() / -scale);
|
return QPointF(m.x() / scale, m.y() / -scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates EmptyMap::xy2ll(const QPointF &p)
|
Coordinates EmptyMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = OSM::zoom2scale(_zoom, TILE_SIZE);
|
||||||
return m2ll(QPointF(p.x() * scale, -p.y() * scale));
|
return OSM::m2ll(QPointF(p.x() * scale, -p.y() * scale));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include "config.h"
|
#include "common/config.h"
|
||||||
#include "geotiff.h"
|
#include "geotiff.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "geotiffmap.h"
|
#include "geotiffmap.h"
|
||||||
@ -61,9 +61,11 @@ void GeoTIFFMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
_img->draw(painter, rect, flags);
|
_img->draw(painter, rect, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeoTIFFMap::setDevicePixelRatio(qreal ratio)
|
void GeoTIFFMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||||
{
|
{
|
||||||
_ratio = ratio;
|
Q_UNUSED(deviceRatio);
|
||||||
|
|
||||||
|
_ratio = mapRatio;
|
||||||
if (_img)
|
if (_img)
|
||||||
_img->setDevicePixelRatio(_ratio);
|
_img->setDevicePixelRatio(_ratio);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
|
|
||||||
void load();
|
void load();
|
||||||
void unload();
|
void unload();
|
||||||
void setDevicePixelRatio(qreal ratio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include "config.h"
|
#include "common/config.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
|
#include "common/config.h"
|
||||||
#include "rectd.h"
|
#include "rectd.h"
|
||||||
#include "gcs.h"
|
#include "gcs.h"
|
||||||
#include "pcs.h"
|
#include "pcs.h"
|
||||||
#include "config.h"
|
|
||||||
#include "jnxmap.h"
|
#include "jnxmap.h"
|
||||||
|
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ bool JNXMap::readTiles()
|
|||||||
}
|
}
|
||||||
|
|
||||||
JNXMap::JNXMap(const QString &fileName, QObject *parent)
|
JNXMap::JNXMap(const QString &fileName, QObject *parent)
|
||||||
: Map(parent), _file(fileName), _zoom(0), _ratio(1.0), _valid(false)
|
: Map(parent), _file(fileName), _zoom(0), _mapRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
_name = QFileInfo(fileName).fileName();
|
_name = QFileInfo(fileName).fileName();
|
||||||
|
|
||||||
@ -162,13 +162,13 @@ JNXMap::JNXMap(const QString &fileName, QObject *parent)
|
|||||||
QPointF JNXMap::ll2xy(const Coordinates &c)
|
QPointF JNXMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
const Zoom &z = _zooms.at(_zoom);
|
const Zoom &z = _zooms.at(_zoom);
|
||||||
return z.transform.proj2img(_projection.ll2xy(c)) / _ratio;
|
return z.transform.proj2img(_projection.ll2xy(c)) / _mapRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates JNXMap::xy2ll(const QPointF &p)
|
Coordinates JNXMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
const Zoom &z = _zooms.at(_zoom);
|
const Zoom &z = _zooms.at(_zoom);
|
||||||
return _projection.xy2ll(z.transform.img2proj(p * _ratio));
|
return _projection.xy2ll(z.transform.img2proj(p * _mapRatio));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF JNXMap::bounds()
|
QRectF JNXMap::bounds()
|
||||||
@ -249,8 +249,8 @@ void JNXMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(flags);
|
Q_UNUSED(flags);
|
||||||
const RTree<Tile*, qreal, 2> &tree = _zooms.at(_zoom).tree;
|
const RTree<Tile*, qreal, 2> &tree = _zooms.at(_zoom).tree;
|
||||||
Ctx ctx(painter, &_file, _ratio);
|
Ctx ctx(painter, &_file, _mapRatio);
|
||||||
QRectF rr(rect.topLeft() * _ratio, rect.size() * _ratio);
|
QRectF rr(rect.topLeft() * _mapRatio, rect.size() * _mapRatio);
|
||||||
|
|
||||||
qreal min[2], max[2];
|
qreal min[2], max[2];
|
||||||
min[0] = rr.left();
|
min[0] = rr.left();
|
||||||
|
@ -32,7 +32,8 @@ public:
|
|||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
void setDevicePixelRatio(qreal ratio) {_ratio = ratio;}
|
void setDevicePixelRatio(qreal /*deviceRatio*/, qreal mapRatio)
|
||||||
|
{_mapRatio = mapRatio;}
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
@ -63,7 +64,7 @@ private:
|
|||||||
int _zoom;
|
int _zoom;
|
||||||
RectC _bounds;
|
RectC _bounds;
|
||||||
Projection _projection;
|
Projection _projection;
|
||||||
qreal _ratio;
|
qreal _mapRatio;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
virtual void clearCache() {}
|
virtual void clearCache() {}
|
||||||
virtual void load() {}
|
virtual void load() {}
|
||||||
virtual void unload() {}
|
virtual void unload() {}
|
||||||
virtual void setDevicePixelRatio(qreal) {}
|
virtual void setDevicePixelRatio(qreal, qreal) {}
|
||||||
|
|
||||||
virtual bool isValid() const {return true;}
|
virtual bool isValid() const {return true;}
|
||||||
virtual QString errorString() const {return QString();}
|
virtual QString errorString() const {return QString();}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include "config.h"
|
#include "common/config.h"
|
||||||
#include "onlinemap.h"
|
#include "onlinemap.h"
|
||||||
#include "wmtsmap.h"
|
#include "wmtsmap.h"
|
||||||
#include "wmsmap.h"
|
#include "wmsmap.h"
|
||||||
@ -8,8 +8,9 @@
|
|||||||
#include "mapsource.h"
|
#include "mapsource.h"
|
||||||
|
|
||||||
|
|
||||||
MapSource::Config::Config() : type(OSM), zooms(osm::zooms), bounds(osm::bounds),
|
MapSource::Config::Config() : type(OSM), zooms(OSM::ZOOMS), bounds(OSM::BOUNDS),
|
||||||
format("image/png"), rest(false), tileRatio(1.0) {}
|
format("image/png"), rest(false), tileRatio(1.0), tileSize(256),
|
||||||
|
scalable(false) {}
|
||||||
|
|
||||||
|
|
||||||
static CoordinateSystem coordinateSystem(QXmlStreamReader &reader)
|
static CoordinateSystem coordinateSystem(QXmlStreamReader &reader)
|
||||||
@ -31,21 +32,21 @@ Range MapSource::zooms(QXmlStreamReader &reader)
|
|||||||
|
|
||||||
if (attr.hasAttribute("min")) {
|
if (attr.hasAttribute("min")) {
|
||||||
min = attr.value("min").toString().toInt(&res);
|
min = attr.value("min").toString().toInt(&res);
|
||||||
if (!res || !osm::zooms.contains(min)) {
|
if (!res || !OSM::ZOOMS.contains(min)) {
|
||||||
reader.raiseError("Invalid minimal zoom level");
|
reader.raiseError("Invalid minimal zoom level");
|
||||||
return Range();
|
return Range();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
min = osm::zooms.min();
|
min = OSM::ZOOMS.min();
|
||||||
|
|
||||||
if (attr.hasAttribute("max")) {
|
if (attr.hasAttribute("max")) {
|
||||||
max = attr.value("max").toString().toInt(&res);
|
max = attr.value("max").toString().toInt(&res);
|
||||||
if (!res || !osm::zooms.contains(max)) {
|
if (!res || !OSM::ZOOMS.contains(max)) {
|
||||||
reader.raiseError("Invalid maximal zoom level");
|
reader.raiseError("Invalid maximal zoom level");
|
||||||
return Range();
|
return Range();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
max = osm::zooms.max();
|
max = OSM::ZOOMS.max();
|
||||||
|
|
||||||
if (min > max) {
|
if (min > max) {
|
||||||
reader.raiseError("Invalid maximal/minimal zoom level combination");
|
reader.raiseError("Invalid maximal/minimal zoom level combination");
|
||||||
@ -63,41 +64,41 @@ RectC MapSource::bounds(QXmlStreamReader &reader)
|
|||||||
|
|
||||||
if (attr.hasAttribute("top")) {
|
if (attr.hasAttribute("top")) {
|
||||||
top = attr.value("top").toString().toDouble(&res);
|
top = attr.value("top").toString().toDouble(&res);
|
||||||
if (!res || (top < osm::bounds.bottom() || top > osm::bounds.top())) {
|
if (!res || (top < OSM::BOUNDS.bottom() || top > OSM::BOUNDS.top())) {
|
||||||
reader.raiseError("Invalid bounds top value");
|
reader.raiseError("Invalid bounds top value");
|
||||||
return RectC();
|
return RectC();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
top = osm::bounds.top();
|
top = OSM::BOUNDS.top();
|
||||||
|
|
||||||
if (attr.hasAttribute("bottom")) {
|
if (attr.hasAttribute("bottom")) {
|
||||||
bottom = attr.value("bottom").toString().toDouble(&res);
|
bottom = attr.value("bottom").toString().toDouble(&res);
|
||||||
if (!res || (bottom < osm::bounds.bottom()
|
if (!res || (bottom < OSM::BOUNDS.bottom()
|
||||||
|| bottom > osm::bounds.top())) {
|
|| bottom > OSM::BOUNDS.top())) {
|
||||||
reader.raiseError("Invalid bounds bottom value");
|
reader.raiseError("Invalid bounds bottom value");
|
||||||
return RectC();
|
return RectC();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
bottom = osm::bounds.bottom();
|
bottom = OSM::BOUNDS.bottom();
|
||||||
|
|
||||||
if (attr.hasAttribute("left")) {
|
if (attr.hasAttribute("left")) {
|
||||||
left = attr.value("left").toString().toDouble(&res);
|
left = attr.value("left").toString().toDouble(&res);
|
||||||
if (!res || (left < osm::bounds.left() || left > osm::bounds.right())) {
|
if (!res || (left < OSM::BOUNDS.left() || left > OSM::BOUNDS.right())) {
|
||||||
reader.raiseError("Invalid bounds left value");
|
reader.raiseError("Invalid bounds left value");
|
||||||
return RectC();
|
return RectC();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
left = osm::bounds.left();
|
left = OSM::BOUNDS.left();
|
||||||
|
|
||||||
if (attr.hasAttribute("right")) {
|
if (attr.hasAttribute("right")) {
|
||||||
right = attr.value("right").toString().toDouble(&res);
|
right = attr.value("right").toString().toDouble(&res);
|
||||||
if (!res || (right < osm::bounds.left()
|
if (!res || (right < OSM::BOUNDS.left()
|
||||||
|| right > osm::bounds.right())) {
|
|| right > OSM::BOUNDS.right())) {
|
||||||
reader.raiseError("Invalid bounds right value");
|
reader.raiseError("Invalid bounds right value");
|
||||||
return RectC();
|
return RectC();
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
right = osm::bounds.right();
|
right = OSM::BOUNDS.right();
|
||||||
|
|
||||||
if (bottom >= top) {
|
if (bottom >= top) {
|
||||||
reader.raiseError("Invalid bottom/top bounds combination");
|
reader.raiseError("Invalid bottom/top bounds combination");
|
||||||
@ -111,6 +112,43 @@ RectC MapSource::bounds(QXmlStreamReader &reader)
|
|||||||
return RectC(Coordinates(left, top), Coordinates(right, bottom));
|
return RectC(Coordinates(left, top), Coordinates(right, bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapSource::tile(QXmlStreamReader &reader, Config &config)
|
||||||
|
{
|
||||||
|
QXmlStreamAttributes attr = reader.attributes();
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
if (attr.hasAttribute("size")) {
|
||||||
|
int size = attr.value("size").toString().toInt(&ok);
|
||||||
|
if (!ok || size < 0) {
|
||||||
|
reader.raiseError("Invalid tile size");
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
config.tileSize = size;
|
||||||
|
}
|
||||||
|
if (attr.hasAttribute("type")) {
|
||||||
|
if (attr.value("type") == "raster")
|
||||||
|
config.scalable = false;
|
||||||
|
else if (attr.value("type") == "vector")
|
||||||
|
config.scalable = true;
|
||||||
|
else {
|
||||||
|
reader.raiseError("Invalid tile type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attr.hasAttribute("pixelRatio")) {
|
||||||
|
#ifdef ENABLE_HIDPI
|
||||||
|
qreal ratio = attr.value("pixelRatio").toString().toDouble(&ok);
|
||||||
|
if (!ok || ratio < 0) {
|
||||||
|
reader.raiseError("Invalid tile pixelRatio");
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
config.tileRatio = ratio;
|
||||||
|
#else // ENABLE_HIDPI
|
||||||
|
reader.raiseError("HiDPI maps not supported");
|
||||||
|
#endif // ENABLE_HIDPI
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MapSource::map(QXmlStreamReader &reader, Config &config)
|
void MapSource::map(QXmlStreamReader &reader, Config &config)
|
||||||
{
|
{
|
||||||
const QXmlStreamAttributes &attr = reader.attributes();
|
const QXmlStreamAttributes &attr = reader.attributes();
|
||||||
@ -156,8 +194,8 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
|||||||
if (!attr.hasAttribute("id"))
|
if (!attr.hasAttribute("id"))
|
||||||
reader.raiseError("Missing dimension id");
|
reader.raiseError("Missing dimension id");
|
||||||
else
|
else
|
||||||
config.dimensions.append(QPair<QString, QString>(
|
config.dimensions.append(KV(attr.value("id").toString(),
|
||||||
attr.value("id").toString(), reader.readElementText()));
|
reader.readElementText()));
|
||||||
} else if (reader.name() == "crs") {
|
} else if (reader.name() == "crs") {
|
||||||
config.coordinateSystem = coordinateSystem(reader);
|
config.coordinateSystem = coordinateSystem(reader);
|
||||||
config.crs = reader.readElementText();
|
config.crs = reader.readElementText();
|
||||||
@ -168,16 +206,20 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
|
|||||||
attr.value("password").toString());
|
attr.value("password").toString());
|
||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
} else if (reader.name() == "tilePixelRatio") {
|
} else if (reader.name() == "tilePixelRatio") {
|
||||||
|
// Legacy tilePixelRatio tag support
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
bool res;
|
bool ok;
|
||||||
qreal val = reader.readElementText().toDouble(&res);
|
qreal ratio = reader.readElementText().toDouble(&ok);
|
||||||
if (!res)
|
if (!ok || ratio <= 0)
|
||||||
reader.raiseError("Invalid tilePixelRatio");
|
reader.raiseError("Invalid tilePixelRatio");
|
||||||
else
|
else
|
||||||
config.tileRatio = val;
|
config.tileRatio = ratio;
|
||||||
#else // ENABLE_HIDPI
|
#else // ENABLE_HIDPI
|
||||||
reader.raiseError("HiDPI maps not supported");
|
reader.raiseError("HiDPI maps not supported");
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
|
} else if (reader.name() == "tile") {
|
||||||
|
tile(reader, config);
|
||||||
|
reader.skipCurrentElement();
|
||||||
} else
|
} else
|
||||||
reader.skipCurrentElement();
|
reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
@ -250,10 +292,12 @@ Map *MapSource::loadMap(const QString &path, QString &errorString)
|
|||||||
config.dimensions, config.authorization));
|
config.dimensions, config.authorization));
|
||||||
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, true);
|
config.bounds, config.tileRatio, config.authorization,
|
||||||
|
config.tileSize, config.scalable, true);
|
||||||
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, false);
|
config.bounds, config.tileRatio, config.authorization,
|
||||||
|
config.tileSize, config.scalable, false);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
|
#include "common/kv.h"
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
#include "coordinatesystem.h"
|
#include "coordinatesystem.h"
|
||||||
|
|
||||||
@ -36,9 +37,11 @@ private:
|
|||||||
QString crs;
|
QString crs;
|
||||||
CoordinateSystem coordinateSystem;
|
CoordinateSystem coordinateSystem;
|
||||||
bool rest;
|
bool rest;
|
||||||
QList<QPair<QString, QString> > dimensions;
|
QList<KV> dimensions;
|
||||||
Authorization authorization;
|
Authorization authorization;
|
||||||
qreal tileRatio;
|
qreal tileRatio;
|
||||||
|
int tileSize;
|
||||||
|
bool scalable;
|
||||||
|
|
||||||
Config();
|
Config();
|
||||||
};
|
};
|
||||||
@ -46,6 +49,7 @@ private:
|
|||||||
static RectC bounds(QXmlStreamReader &reader);
|
static RectC bounds(QXmlStreamReader &reader);
|
||||||
static Range zooms(QXmlStreamReader &reader);
|
static Range zooms(QXmlStreamReader &reader);
|
||||||
static void map(QXmlStreamReader &reader, Config &config);
|
static void map(QXmlStreamReader &reader, Config &config);
|
||||||
|
static void tile(QXmlStreamReader &reader, Config &config);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPSOURCE_H
|
#endif // MAPSOURCE_H
|
||||||
|
@ -4,23 +4,64 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
|
#include <QImageReader>
|
||||||
|
#include <QBuffer>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
#include <QtCore>
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
#include <QtConcurrent>
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "common/wgs84.h"
|
#include "common/config.h"
|
||||||
#include "osm.h"
|
#include "osm.h"
|
||||||
#include "config.h"
|
|
||||||
#include "mbtilesmap.h"
|
#include "mbtilesmap.h"
|
||||||
|
|
||||||
|
|
||||||
|
class MBTile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MBTile(int zoom, int scaledSize, const QPoint &xy, const QByteArray &data,
|
||||||
|
const QString &key) : _zoom(zoom), _scaledSize(scaledSize), _xy(xy),
|
||||||
|
_data(data), _key(key) {}
|
||||||
|
|
||||||
|
const QPoint &xy() const {return _xy;}
|
||||||
|
const QString &key() const {return _key;}
|
||||||
|
QPixmap pixmap() const {return QPixmap::fromImage(_image);}
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
QByteArray z(QString::number(_zoom).toLatin1());
|
||||||
|
|
||||||
|
QBuffer buffer(&_data);
|
||||||
|
QImageReader reader(&buffer, z);
|
||||||
|
if (_scaledSize)
|
||||||
|
reader.setScaledSize(QSize(_scaledSize, _scaledSize));
|
||||||
|
reader.read(&_image);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
int _zoom;
|
||||||
|
int _scaledSize;
|
||||||
|
QPoint _xy;
|
||||||
|
QByteArray _data;
|
||||||
|
QString _key;
|
||||||
|
QImage _image;
|
||||||
|
};
|
||||||
|
|
||||||
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
#define META_TYPE(type) static_cast<QMetaType::Type>(type)
|
||||||
|
|
||||||
|
static void render(MBTile &tile)
|
||||||
|
{
|
||||||
|
tile.load();
|
||||||
|
}
|
||||||
|
|
||||||
static double index2mercator(int index, int zoom)
|
static double index2mercator(int index, int zoom)
|
||||||
{
|
{
|
||||||
return rad2deg(-M_PI + 2 * M_PI * ((double)index / (1<<zoom)));
|
return rad2deg(-M_PI + 2 * M_PI * ((double)index / (1<<zoom)));
|
||||||
}
|
}
|
||||||
|
|
||||||
MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
|
MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
|
||||||
: Map(parent), _fileName(fileName), _deviceRatio(1.0), _tileRatio(1.0),
|
: Map(parent), _fileName(fileName), _mapRatio(1.0), _tileRatio(1.0),
|
||||||
_valid(false)
|
_scalable(false), _scaledSize(0), _valid(false)
|
||||||
{
|
{
|
||||||
_db = QSqlDatabase::addDatabase("QSQLITE", fileName);
|
_db = QSqlDatabase::addDatabase("QSQLITE", fileName);
|
||||||
_db.setDatabaseName(fileName);
|
_db.setDatabaseName(fileName);
|
||||||
@ -74,11 +115,11 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
|
|||||||
qMax(0, query.value(2).toInt())) + 1, _zooms.min());
|
qMax(0, query.value(2).toInt())) + 1, _zooms.min());
|
||||||
double maxY = index2mercator(qMin((1<<_zooms.min()) - 1,
|
double maxY = index2mercator(qMin((1<<_zooms.min()) - 1,
|
||||||
qMax(0, query.value(3).toInt())) + 1, _zooms.min());
|
qMax(0, query.value(3).toInt())) + 1, _zooms.min());
|
||||||
Coordinates tl(osm::m2ll(QPointF(minX, maxY)));
|
Coordinates tl(OSM::m2ll(QPointF(minX, maxY)));
|
||||||
Coordinates br(osm::m2ll(QPointF(maxX, minY)));
|
Coordinates br(OSM::m2ll(QPointF(maxX, minY)));
|
||||||
// Workaround of broken zoom levels 0 and 1 due to numerical instability
|
// Workaround of broken zoom levels 0 and 1 due to numerical instability
|
||||||
tl.rlat() = qMin(tl.lat(), osm::bounds.top());
|
tl.rlat() = qMin(tl.lat(), OSM::BOUNDS.top());
|
||||||
br.rlat() = qMax(br.lat(), osm::bounds.bottom());
|
br.rlat() = qMax(br.lat(), OSM::BOUNDS.bottom());
|
||||||
_bounds = RectC(tl, br);
|
_bounds = RectC(tl, br);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,12 +127,26 @@ MBTilesMap::MBTilesMap(const QString &fileName, QObject *parent)
|
|||||||
QString sql = QString("SELECT tile_data FROM tiles LIMIT 1");
|
QString sql = QString("SELECT tile_data FROM tiles LIMIT 1");
|
||||||
QSqlQuery query(sql, _db);
|
QSqlQuery query(sql, _db);
|
||||||
query.first();
|
query.first();
|
||||||
QImage tile = QImage::fromData(query.value(0).toByteArray());
|
|
||||||
if (tile.isNull() || tile.size().width() != tile.size().height()) {
|
QByteArray data = query.value(0).toByteArray();
|
||||||
|
QBuffer buffer(&data);
|
||||||
|
QImageReader reader(&buffer);
|
||||||
|
QSize tileSize(reader.size());
|
||||||
|
|
||||||
|
if (!tileSize.isValid() || tileSize.width() != tileSize.height()) {
|
||||||
_errorString = "Unsupported/invalid tile images";
|
_errorString = "Unsupported/invalid tile images";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_tileSize = tile.size().width();
|
_tileSize = tileSize.width();
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QSqlQuery query("SELECT value FROM metadata WHERE name = 'format'", _db);
|
||||||
|
if (query.first()) {
|
||||||
|
if (query.value(0).toString() == "pbf")
|
||||||
|
_scalable = true;
|
||||||
|
} else
|
||||||
|
qWarning("%s: missing map name", qPrintable(_fileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -152,9 +207,9 @@ int MBTilesMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
if (!rect.isValid())
|
if (!rect.isValid())
|
||||||
_zoom = _zooms.max();
|
_zoom = _zooms.max();
|
||||||
else {
|
else {
|
||||||
QRectF tbr(osm::ll2m(rect.topLeft()), osm::ll2m(rect.bottomRight()));
|
QRectF tbr(OSM::ll2m(rect.topLeft()), OSM::ll2m(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
_zoom = limitZoom(osm::scale2zoom(qMax(sc.x(), -sc.y())
|
_zoom = limitZoom(OSM::scale2zoom(qMax(sc.x(), -sc.y())
|
||||||
/ coordinatesRatio(), _tileSize));
|
/ coordinatesRatio(), _tileSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,10 +218,7 @@ int MBTilesMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
|
|
||||||
qreal MBTilesMap::resolution(const QRectF &rect)
|
qreal MBTilesMap::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, _tileSize);
|
return OSM::resolution(rect.center(), _zoom, _tileSize);
|
||||||
|
|
||||||
return (WGS84_RADIUS * 2.0 * M_PI * scale / 360.0
|
|
||||||
* cos(2.0 * atan(exp(deg2rad(-rect.center().y() * scale))) - M_PI/2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MBTilesMap::zoomIn()
|
int MBTilesMap::zoomIn()
|
||||||
@ -181,14 +233,24 @@ int MBTilesMap::zoomOut()
|
|||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MBTilesMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||||
|
{
|
||||||
|
_mapRatio = mapRatio;
|
||||||
|
|
||||||
|
if (_scalable) {
|
||||||
|
_scaledSize = _tileSize * deviceRatio;
|
||||||
|
_tileRatio = deviceRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qreal MBTilesMap::coordinatesRatio() const
|
qreal MBTilesMap::coordinatesRatio() const
|
||||||
{
|
{
|
||||||
return _deviceRatio > 1.0 ? _deviceRatio / _tileRatio : 1.0;
|
return _mapRatio > 1.0 ? _mapRatio / _tileRatio : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal MBTilesMap::imageRatio() const
|
qreal MBTilesMap::imageRatio() const
|
||||||
{
|
{
|
||||||
return _deviceRatio > 1.0 ? _deviceRatio : _tileRatio;
|
return _mapRatio > 1.0 ? _mapRatio : _tileRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal MBTilesMap::tileSize() const
|
qreal MBTilesMap::tileSize() const
|
||||||
@ -215,50 +277,78 @@ QByteArray MBTilesMap::tileData(int zoom, const QPoint &tile) const
|
|||||||
void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void MBTilesMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
{
|
{
|
||||||
Q_UNUSED(flags);
|
Q_UNUSED(flags);
|
||||||
qreal scale = osm::zoom2scale(_zoom, _tileSize);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
QRectF b(bounds());
|
QRectF b(bounds());
|
||||||
|
|
||||||
|
|
||||||
QPoint tile = osm::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||||
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
|
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
|
||||||
QPointF tl(floor(rect.left() / tileSize())
|
QPointF tl(floor(rect.left() / tileSize())
|
||||||
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
||||||
|
|
||||||
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
|
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
|
||||||
qMin(rect.bottom() - tl.y(), b.height()));
|
qMin(rect.bottom() - tl.y(), b.height()));
|
||||||
for (int i = 0; i < ceil(s.width() / tileSize()); i++) {
|
int width = ceil(s.width() / tileSize());
|
||||||
for (int j = 0; j < ceil(s.height() / tileSize()); j++) {
|
int height = ceil(s.height() / tileSize());
|
||||||
|
|
||||||
|
|
||||||
|
QList<MBTile> tiles;
|
||||||
|
|
||||||
|
for (int i = 0; i < width; i++) {
|
||||||
|
for (int j = 0; j < height; j++) {
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
QPoint t(tile.x() + i, tile.y() + j);
|
QPoint t(tile.x() + i, tile.y() + j);
|
||||||
QString key = _fileName + "-" + QString::number(_zoom) + "_"
|
QString key = _fileName + "-" + QString::number(_zoom) + "_"
|
||||||
+ QString::number(t.x()) + "_" + QString::number(t.y());
|
+ QString::number(t.x()) + "_" + QString::number(t.y());
|
||||||
|
|
||||||
if (!QPixmapCache::find(key, &pm))
|
if (QPixmapCache::find(key, pm)) {
|
||||||
if (pm.loadFromData(tileData(_zoom, t)))
|
QPointF tp(qMax(tl.x(), b.left()) + (t.x() - tile.x())
|
||||||
QPixmapCache::insert(key, pm);
|
* tileSize(), qMax(tl.y(), b.top()) + (t.y() - tile.y())
|
||||||
|
* tileSize());
|
||||||
QPointF tp(qMax(tl.x(), b.left()) + (t.x() - tile.x()) * tileSize(),
|
drawTile(painter, pm, tp);
|
||||||
qMax(tl.y(), b.top()) + (t.y() - tile.y()) * tileSize());
|
} else {
|
||||||
if (!pm.isNull()) {
|
tiles.append(MBTile(_zoom, _scaledSize, t, tileData(_zoom, t),
|
||||||
#ifdef ENABLE_HIDPI
|
key));
|
||||||
pm.setDevicePixelRatio(imageRatio());
|
|
||||||
#endif // ENABLE_HIDPI
|
|
||||||
painter->drawPixmap(tp, pm);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QFuture<void> future = QtConcurrent::map(tiles, render);
|
||||||
|
future.waitForFinished();
|
||||||
|
|
||||||
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
|
const MBTile &mt = tiles.at(i);
|
||||||
|
QPixmap pm(mt.pixmap());
|
||||||
|
if (pm.isNull())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QPixmapCache::insert(mt.key(), pm);
|
||||||
|
|
||||||
|
QPointF tp(qMax(tl.x(), b.left()) + (mt.xy().x() - tile.x())
|
||||||
|
* tileSize(), qMax(tl.y(), b.top()) + (mt.xy().y() - tile.y())
|
||||||
|
* tileSize());
|
||||||
|
drawTile(painter, pm, tp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MBTilesMap::drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp)
|
||||||
|
{
|
||||||
|
#ifdef ENABLE_HIDPI
|
||||||
|
pixmap.setDevicePixelRatio(imageRatio());
|
||||||
|
#endif // ENABLE_HIDPI
|
||||||
|
painter->drawPixmap(tp, pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF MBTilesMap::ll2xy(const Coordinates &c)
|
QPointF MBTilesMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, _tileSize);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
QPointF m = osm::ll2m(c);
|
QPointF m = OSM::ll2m(c);
|
||||||
return QPointF(m.x() / scale, m.y() / -scale) / coordinatesRatio();
|
return QPointF(m.x() / scale, m.y() / -scale) / coordinatesRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates MBTilesMap::xy2ll(const QPointF &p)
|
Coordinates MBTilesMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, _tileSize);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
return osm::m2ll(QPointF(p.x() * scale, -p.y() * scale)
|
return OSM::m2ll(QPointF(p.x() * scale, -p.y() * scale)
|
||||||
* coordinatesRatio());
|
* coordinatesRatio());
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
|
|
||||||
void load();
|
void load();
|
||||||
void unload();
|
void unload();
|
||||||
void setDevicePixelRatio(qreal ratio) {_deviceRatio = ratio;}
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
bool isValid() const {return _valid;}
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
@ -40,6 +40,7 @@ private:
|
|||||||
qreal coordinatesRatio() const;
|
qreal coordinatesRatio() const;
|
||||||
qreal imageRatio() const;
|
qreal imageRatio() const;
|
||||||
QByteArray tileData(int zoom, const QPoint &tile) const;
|
QByteArray tileData(int zoom, const QPoint &tile) const;
|
||||||
|
void drawTile(QPainter *painter, QPixmap &pixmap, QPointF &tp);
|
||||||
|
|
||||||
QSqlDatabase _db;
|
QSqlDatabase _db;
|
||||||
|
|
||||||
@ -48,7 +49,9 @@ private:
|
|||||||
Range _zooms;
|
Range _zooms;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
int _tileSize;
|
int _tileSize;
|
||||||
qreal _deviceRatio, _tileRatio;
|
qreal _mapRatio, _tileRatio;
|
||||||
|
bool _scalable;
|
||||||
|
int _scaledSize;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -1,36 +1,26 @@
|
|||||||
|
#include <QtCore>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "common/coordinates.h"
|
#include <QDir>
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
#include "common/wgs84.h"
|
#include "common/programpaths.h"
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
#include "osm.h"
|
#include "osm.h"
|
||||||
#include "config.h"
|
|
||||||
#include "onlinemap.h"
|
#include "onlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
#define TILE_SIZE 256
|
|
||||||
|
|
||||||
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, bool invertY, QObject *parent)
|
const Authorization &authorization, int tileSize, bool scalable, bool invertY,
|
||||||
|
QObject *parent)
|
||||||
: Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
: Map(parent), _name(name), _zooms(zooms), _bounds(bounds),
|
||||||
_zoom(_zooms.max()), _deviceRatio(1.0), _tileRatio(tileRatio),
|
_zoom(_zooms.max()), _mapRatio(1.0), _tileRatio(tileRatio),
|
||||||
_invertY(invertY), _valid(false)
|
_tileSize(tileSize), _scalable(scalable), _invertY(invertY), _scaledSize(0)
|
||||||
{
|
{
|
||||||
QString dir(TILES_DIR + "/" + _name);
|
_tileLoader = new TileLoader(QDir(ProgramPaths::tilesDir()).filePath(_name),
|
||||||
|
this);
|
||||||
_tileLoader = new TileLoader(this);
|
|
||||||
_tileLoader->setUrl(url);
|
_tileLoader->setUrl(url);
|
||||||
_tileLoader->setDir(dir);
|
|
||||||
_tileLoader->setAuthorization(authorization);
|
_tileLoader->setAuthorization(authorization);
|
||||||
connect(_tileLoader, SIGNAL(finished()), this, SIGNAL(loaded()));
|
connect(_tileLoader, SIGNAL(finished()), this, SIGNAL(loaded()));
|
||||||
|
|
||||||
if (!QDir().mkpath(dir)) {
|
|
||||||
_errorString = "Error creating tiles dir";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_valid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF OnlineMap::bounds()
|
QRectF OnlineMap::bounds()
|
||||||
@ -53,10 +43,10 @@ int OnlineMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
if (!rect.isValid())
|
if (!rect.isValid())
|
||||||
_zoom = _zooms.max();
|
_zoom = _zooms.max();
|
||||||
else {
|
else {
|
||||||
QRectF tbr(osm::ll2m(rect.topLeft()), osm::ll2m(rect.bottomRight()));
|
QRectF tbr(OSM::ll2m(rect.topLeft()), OSM::ll2m(rect.bottomRight()));
|
||||||
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
_zoom = limitZoom(osm::scale2zoom(qMax(sc.x(), -sc.y())
|
_zoom = limitZoom(OSM::scale2zoom(qMax(sc.x(), -sc.y())
|
||||||
/ coordinatesRatio(), TILE_SIZE));
|
/ coordinatesRatio(), _tileSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
return _zoom;
|
return _zoom;
|
||||||
@ -64,10 +54,7 @@ int OnlineMap::zoomFit(const QSize &size, const RectC &rect)
|
|||||||
|
|
||||||
qreal OnlineMap::resolution(const QRectF &rect)
|
qreal OnlineMap::resolution(const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, TILE_SIZE);
|
return OSM::resolution(rect.center(), _zoom, _tileSize);
|
||||||
|
|
||||||
return (WGS84_RADIUS * 2.0 * M_PI * scale / 360.0
|
|
||||||
* cos(2.0 * atan(exp(deg2rad(-rect.center().y() * scale))) - M_PI/2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int OnlineMap::zoomIn()
|
int OnlineMap::zoomIn()
|
||||||
@ -82,38 +69,50 @@ int OnlineMap::zoomOut()
|
|||||||
return _zoom;
|
return _zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnlineMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||||
|
{
|
||||||
|
_mapRatio = mapRatio;
|
||||||
|
|
||||||
|
if (_scalable) {
|
||||||
|
_scaledSize = _tileSize * deviceRatio;
|
||||||
|
_tileRatio = deviceRatio;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qreal OnlineMap::coordinatesRatio() const
|
qreal OnlineMap::coordinatesRatio() const
|
||||||
{
|
{
|
||||||
return _deviceRatio > 1.0 ? _deviceRatio / _tileRatio : 1.0;
|
return _mapRatio > 1.0 ? _mapRatio / _tileRatio : 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OnlineMap::imageRatio() const
|
qreal OnlineMap::imageRatio() const
|
||||||
{
|
{
|
||||||
return _deviceRatio > 1.0 ? _deviceRatio : _tileRatio;
|
return _mapRatio > 1.0 ? _mapRatio : _tileRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal OnlineMap::tileSize() const
|
qreal OnlineMap::tileSize() const
|
||||||
{
|
{
|
||||||
return (TILE_SIZE / coordinatesRatio());
|
return (_tileSize / coordinatesRatio());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, TILE_SIZE);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
QRectF b(bounds());
|
|
||||||
|
|
||||||
QPoint tile = osm::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
QPoint tile = OSM::mercator2tile(QPointF(rect.topLeft().x() * scale,
|
||||||
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
|
-rect.topLeft().y() * scale) * coordinatesRatio(), _zoom);
|
||||||
QPointF tl(floor(rect.left() / tileSize())
|
QPointF tl(floor(rect.left() / tileSize())
|
||||||
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
* tileSize(), floor(rect.top() / tileSize()) * tileSize());
|
||||||
|
|
||||||
QList<Tile> tiles;
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
QSizeF s(qMin(rect.right() - tl.x(), b.width()),
|
int width = _zoom ? qCeil(s.width() / tileSize()) : 1;
|
||||||
qMin(rect.bottom() - tl.y(), b.height()));
|
int height = _zoom ? qCeil(s.height() / tileSize()) : 1;
|
||||||
for (int i = 0; i < ceil(s.width() / tileSize()); i++)
|
|
||||||
for (int j = 0; j < ceil(s.height() / tileSize()); j++)
|
QVector<Tile> tiles;
|
||||||
tiles.append(Tile(QPoint(tile.x() + i,
|
tiles.reserve(width * height);
|
||||||
_invertY ? (1<<_zoom) - (tile.y() + j) - 1 : tile.y() + j), _zoom));
|
for (int i = 0; i < width; i++)
|
||||||
|
for (int j = 0; j < height; j++)
|
||||||
|
tiles.append(Tile(QPoint(tile.x() + i, _invertY ? (1<<_zoom)
|
||||||
|
- (tile.y() + j) - 1 : tile.y() + j), _zoom, _scaledSize));
|
||||||
|
|
||||||
if (flags & Map::Block)
|
if (flags & Map::Block)
|
||||||
_tileLoader->loadTilesSync(tiles);
|
_tileLoader->loadTilesSync(tiles);
|
||||||
@ -122,9 +121,10 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
Tile &t = tiles[i];
|
Tile &t = tiles[i];
|
||||||
QPointF tp(qMax(tl.x(), b.left()) + (t.xy().x() - tile.x()) * tileSize(),
|
QPointF tp = _zoom ? QPointF(tl.x() + (t.xy().x() - tile.x())
|
||||||
qMax(tl.y(), b.top()) + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
* tileSize(), tl.y() + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
|
||||||
t.xy().y()) - tile.y()) * tileSize());
|
t.xy().y()) - tile.y()) * tileSize()) : QPointF(-128, -128);
|
||||||
|
|
||||||
if (!t.pixmap().isNull()) {
|
if (!t.pixmap().isNull()) {
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
t.pixmap().setDevicePixelRatio(imageRatio());
|
t.pixmap().setDevicePixelRatio(imageRatio());
|
||||||
@ -136,14 +136,14 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
|
|
||||||
QPointF OnlineMap::ll2xy(const Coordinates &c)
|
QPointF OnlineMap::ll2xy(const Coordinates &c)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, TILE_SIZE);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
QPointF m = osm::ll2m(c);
|
QPointF m = OSM::ll2m(c);
|
||||||
return QPointF(m.x() / scale, m.y() / -scale) / coordinatesRatio();
|
return QPointF(m.x() / scale, m.y() / -scale) / coordinatesRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OnlineMap::xy2ll(const QPointF &p)
|
Coordinates OnlineMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
qreal scale = osm::zoom2scale(_zoom, TILE_SIZE);
|
qreal scale = OSM::zoom2scale(_zoom, _tileSize);
|
||||||
return osm::m2ll(QPointF(p.x() * scale, -p.y() * scale)
|
return OSM::m2ll(QPointF(p.x() * scale, -p.y() * scale)
|
||||||
* coordinatesRatio());
|
* coordinatesRatio());
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ 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,
|
||||||
bool invertY, QObject *parent = 0);
|
int tileSize, bool scalable, bool invertY, QObject *parent = 0);
|
||||||
|
|
||||||
QString name() const {return _name;}
|
QString name() const {return _name;}
|
||||||
|
|
||||||
@ -31,12 +31,9 @@ public:
|
|||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
void setDevicePixelRatio(qreal ratio) {_deviceRatio = ratio;}
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
void clearCache() {_tileLoader->clearCache();}
|
void clearCache() {_tileLoader->clearCache();}
|
||||||
|
|
||||||
bool isValid() const {return _valid;}
|
|
||||||
QString errorString() const {return _errorString;}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int limitZoom(int zoom) const;
|
int limitZoom(int zoom) const;
|
||||||
qreal tileSize() const;
|
qreal tileSize() const;
|
||||||
@ -48,11 +45,11 @@ private:
|
|||||||
Range _zooms;
|
Range _zooms;
|
||||||
RectC _bounds;
|
RectC _bounds;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
qreal _deviceRatio, _tileRatio;
|
qreal _mapRatio, _tileRatio;
|
||||||
|
int _tileSize;
|
||||||
|
bool _scalable;
|
||||||
bool _invertY;
|
bool _invertY;
|
||||||
|
int _scaledSize;
|
||||||
bool _valid;
|
|
||||||
QString _errorString;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ONLINEMAP_H
|
#endif // ONLINEMAP_H
|
||||||
|
@ -1,29 +1,40 @@
|
|||||||
|
#include <QtCore>
|
||||||
|
#include "common/wgs84.h"
|
||||||
#include "osm.h"
|
#include "osm.h"
|
||||||
|
|
||||||
|
|
||||||
#define EPSILON 1e-6
|
#define EPSILON 1e-6
|
||||||
|
|
||||||
QPointF osm::ll2m(const Coordinates &c)
|
QPointF OSM::ll2m(const Coordinates &c)
|
||||||
{
|
{
|
||||||
return QPointF(c.lon(), rad2deg(log(tan(M_PI_4 + deg2rad(c.lat())/2.0))));
|
return QPointF(c.lon(), rad2deg(log(tan(M_PI_4 + deg2rad(c.lat())/2.0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates osm::m2ll(const QPointF &p)
|
Coordinates OSM::m2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
return Coordinates(p.x(), rad2deg(2.0 * atan(exp(deg2rad(p.y()))) - M_PI_2));
|
return Coordinates(p.x(), rad2deg(2.0 * atan(exp(deg2rad(p.y()))) - M_PI_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint osm::mercator2tile(const QPointF &m, int z)
|
QPoint OSM::mercator2tile(const QPointF &m, int zoom)
|
||||||
{
|
{
|
||||||
return QPoint((int)(floor((m.x() + 180.0) / 360.0 * (1<<z))),
|
return QPoint(qFloor((m.x() + 180.0) / 360.0 * (1<<zoom)),
|
||||||
(int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<z))));
|
qFloor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<zoom)));
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal osm::zoom2scale(int zoom, int tileSize)
|
qreal OSM::zoom2scale(int zoom, int tileSize)
|
||||||
{
|
{
|
||||||
return (360.0/(qreal)((1<<zoom) * tileSize));
|
return (360.0/(qreal)((1<<zoom) * tileSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
int osm::scale2zoom(qreal scale, int tileSize)
|
int OSM::scale2zoom(qreal scale, int tileSize)
|
||||||
{
|
{
|
||||||
return (int)(log2(360.0/(scale * (qreal)tileSize)) + EPSILON);
|
return (int)(log2(360.0/(scale * (qreal)tileSize)) + EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal OSM::resolution(const QPointF &p, int zoom, int tileSize)
|
||||||
|
{
|
||||||
|
qreal scale = zoom2scale(zoom, tileSize);
|
||||||
|
|
||||||
|
return (WGS84_RADIUS * 2.0 * M_PI * scale / 360.0
|
||||||
|
* cos(2.0 * atan(exp(deg2rad(-p.y() * scale))) - M_PI/2));
|
||||||
|
}
|
||||||
|
@ -6,17 +6,18 @@
|
|||||||
#include <common/rectc.h>
|
#include <common/rectc.h>
|
||||||
#include <common/range.h>
|
#include <common/range.h>
|
||||||
|
|
||||||
namespace osm
|
namespace OSM
|
||||||
{
|
{
|
||||||
static const RectC bounds(Coordinates(-180, 85.0511),
|
static const RectC BOUNDS(Coordinates(-180, 85.0511),
|
||||||
Coordinates(180, -85.0511));
|
Coordinates(180, -85.0511));
|
||||||
static const Range zooms(0, 19);
|
static const Range ZOOMS(0, 19);
|
||||||
|
|
||||||
QPointF ll2m(const Coordinates &c);
|
QPointF ll2m(const Coordinates &c);
|
||||||
Coordinates m2ll(const QPointF &p);
|
Coordinates m2ll(const QPointF &p);
|
||||||
QPoint mercator2tile(const QPointF &m, int z);
|
QPoint mercator2tile(const QPointF &m, int zoom);
|
||||||
qreal zoom2scale(int zoom, int tileSize);
|
qreal zoom2scale(int zoom, int tileSize);
|
||||||
int scale2zoom(qreal scale, int tileSize);
|
int scale2zoom(qreal scale, int tileSize);
|
||||||
|
qreal resolution(const QPointF &p, int zoom, int tileSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OSM_H
|
#endif // OSM_H
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
|
#include "common/config.h"
|
||||||
#include "tar.h"
|
#include "tar.h"
|
||||||
#include "ozf.h"
|
#include "ozf.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "mapfile.h"
|
#include "mapfile.h"
|
||||||
#include "config.h"
|
|
||||||
#include "ozimap.h"
|
#include "ozimap.h"
|
||||||
|
|
||||||
|
|
||||||
OziMap::OziMap(const QString &fileName, QObject *parent)
|
OziMap::OziMap(const QString &fileName, QObject *parent)
|
||||||
: Map(parent), _img(0), _tar(0), _ozf(0), _zoom(0), _ratio(1.0), _valid(false)
|
: Map(parent), _img(0), _tar(0), _ozf(0), _zoom(0), _mapRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
QString suffix = fi.suffix().toLower();
|
QString suffix = fi.suffix().toLower();
|
||||||
@ -78,7 +78,7 @@ OziMap::OziMap(const QString &fileName, QObject *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
OziMap::OziMap(const QString &fileName, Tar &tar, QObject *parent)
|
OziMap::OziMap(const QString &fileName, Tar &tar, QObject *parent)
|
||||||
: Map(parent), _img(0), _tar(0), _ozf(0), _zoom(0), _ratio(1.0), _valid(false)
|
: Map(parent), _img(0), _tar(0), _ozf(0), _zoom(0), _mapRatio(1.0), _valid(false)
|
||||||
{
|
{
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
QFileInfo map(fi.absolutePath());
|
QFileInfo map(fi.absolutePath());
|
||||||
@ -217,15 +217,15 @@ void OziMap::unload()
|
|||||||
|
|
||||||
void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const
|
void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const
|
||||||
{
|
{
|
||||||
QSizeF ts(_tile.size.width() / _ratio, _tile.size.height() / _ratio);
|
QSizeF ts(_tile.size.width() / _mapRatio, _tile.size.height() / _mapRatio);
|
||||||
QPointF tl(floor(rect.left() / ts.width()) * ts.width(),
|
QPointF tl(floor(rect.left() / ts.width()) * ts.width(),
|
||||||
floor(rect.top() / ts.height()) * ts.height());
|
floor(rect.top() / ts.height()) * ts.height());
|
||||||
|
|
||||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
for (int i = 0; i < ceil(s.width() / ts.width()); i++) {
|
for (int i = 0; i < ceil(s.width() / ts.width()); i++) {
|
||||||
for (int j = 0; j < ceil(s.height() / ts.height()); j++) {
|
for (int j = 0; j < ceil(s.height() / ts.height()); j++) {
|
||||||
int x = round(tl.x() * _ratio + i * _tile.size.width());
|
int x = round(tl.x() * _mapRatio + i * _tile.size.width());
|
||||||
int y = round(tl.y() * _ratio + j * _tile.size.height());
|
int y = round(tl.y() * _mapRatio + j * _tile.size.height());
|
||||||
|
|
||||||
QString tileName(_tile.path.arg(QString::number(x),
|
QString tileName(_tile.path.arg(QString::number(x),
|
||||||
QString::number(y)));
|
QString::number(y)));
|
||||||
@ -247,7 +247,7 @@ void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const
|
|||||||
_tile.path.arg(QString::number(x), QString::number(y))));
|
_tile.path.arg(QString::number(x), QString::number(y))));
|
||||||
else {
|
else {
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
pixmap.setDevicePixelRatio(_ratio);
|
pixmap.setDevicePixelRatio(_mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height());
|
QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height());
|
||||||
painter->drawPixmap(tp, pixmap);
|
painter->drawPixmap(tp, pixmap);
|
||||||
@ -258,16 +258,16 @@ void OziMap::drawTiled(QPainter *painter, const QRectF &rect) const
|
|||||||
|
|
||||||
void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const
|
void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const
|
||||||
{
|
{
|
||||||
QSizeF ts(_ozf->tileSize().width() / _ratio, _ozf->tileSize().height()
|
QSizeF ts(_ozf->tileSize().width() / _mapRatio, _ozf->tileSize().height()
|
||||||
/ _ratio);
|
/ _mapRatio);
|
||||||
QPointF tl(floor(rect.left() / ts.width()) * ts.width(),
|
QPointF tl(floor(rect.left() / ts.width()) * ts.width(),
|
||||||
floor(rect.top() / ts.height()) * ts.height());
|
floor(rect.top() / ts.height()) * ts.height());
|
||||||
|
|
||||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
for (int i = 0; i < ceil(s.width() / ts.width()); i++) {
|
for (int i = 0; i < ceil(s.width() / ts.width()); i++) {
|
||||||
for (int j = 0; j < ceil(s.height() / ts.height()); j++) {
|
for (int j = 0; j < ceil(s.height() / ts.height()); j++) {
|
||||||
int x = round(tl.x() * _ratio + i * _ozf->tileSize().width());
|
int x = round(tl.x() * _mapRatio + i * _ozf->tileSize().width());
|
||||||
int y = round(tl.y() * _ratio + j * _ozf->tileSize().height());
|
int y = round(tl.y() * _mapRatio + j * _ozf->tileSize().height());
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
QString key = _ozf->fileName() + "/" + QString::number(_zoom) + "_"
|
QString key = _ozf->fileName() + "/" + QString::number(_zoom) + "_"
|
||||||
@ -282,7 +282,7 @@ void OziMap::drawOZF(QPainter *painter, const QRectF &rect) const
|
|||||||
qWarning("%s: error loading tile image", qPrintable(key));
|
qWarning("%s: error loading tile image", qPrintable(key));
|
||||||
else {
|
else {
|
||||||
#ifdef ENABLE_HIDPI
|
#ifdef ENABLE_HIDPI
|
||||||
pixmap.setDevicePixelRatio(_ratio);
|
pixmap.setDevicePixelRatio(_mapRatio);
|
||||||
#endif // ENABLE_HIDPI
|
#endif // ENABLE_HIDPI
|
||||||
QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height());
|
QPointF tp(tl.x() + i * ts.width(), tl.y() + j * ts.height());
|
||||||
painter->drawPixmap(tp, pixmap);
|
painter->drawPixmap(tp, pixmap);
|
||||||
@ -307,23 +307,23 @@ QPointF OziMap::ll2xy(const Coordinates &c)
|
|||||||
{
|
{
|
||||||
QPointF p(_transform.proj2img(_projection.ll2xy(c)));
|
QPointF p(_transform.proj2img(_projection.ll2xy(c)));
|
||||||
return _ozf
|
return _ozf
|
||||||
? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) / _ratio
|
? QPointF(p.x() * _scale.x(), p.y() * _scale.y()) / _mapRatio
|
||||||
: p / _ratio;
|
: p / _mapRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
Coordinates OziMap::xy2ll(const QPointF &p)
|
Coordinates OziMap::xy2ll(const QPointF &p)
|
||||||
{
|
{
|
||||||
return _ozf
|
return _ozf
|
||||||
? _projection.xy2ll(_transform.img2proj(QPointF(p.x() / _scale.x(),
|
? _projection.xy2ll(_transform.img2proj(QPointF(p.x() / _scale.x(),
|
||||||
p.y() / _scale.y()) * _ratio))
|
p.y() / _scale.y()) * _mapRatio))
|
||||||
: _projection.xy2ll(_transform.img2proj(p * _ratio));
|
: _projection.xy2ll(_transform.img2proj(p * _mapRatio));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF OziMap::bounds()
|
QRectF OziMap::bounds()
|
||||||
{
|
{
|
||||||
return _ozf
|
return _ozf
|
||||||
? QRectF(QPointF(0, 0), _ozf->size(_zoom) / _ratio)
|
? QRectF(QPointF(0, 0), _ozf->size(_zoom) / _mapRatio)
|
||||||
: QRectF(QPointF(0, 0), _map.size / _ratio);
|
: QRectF(QPointF(0, 0), _map.size / _mapRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int OziMap::zoomFit(const QSize &size, const RectC &rect)
|
int OziMap::zoomFit(const QSize &size, const RectC &rect)
|
||||||
@ -371,9 +371,11 @@ void OziMap::rescale(int zoom)
|
|||||||
_scale = _ozf->scale(zoom);
|
_scale = _ozf->scale(zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OziMap::setDevicePixelRatio(qreal ratio)
|
void OziMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
||||||
{
|
{
|
||||||
_ratio = ratio;
|
Q_UNUSED(deviceRatio);
|
||||||
|
|
||||||
|
_mapRatio = mapRatio;
|
||||||
if (_img)
|
if (_img)
|
||||||
_img->setDevicePixelRatio(_ratio);
|
_img->setDevicePixelRatio(_mapRatio);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
|
|
||||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||||
|
|
||||||
void setDevicePixelRatio(qreal ratio);
|
void setDevicePixelRatio(qreal deviceRatio, qreal mapRatio);
|
||||||
void load();
|
void load();
|
||||||
void unload();
|
void unload();
|
||||||
|
|
||||||
@ -43,9 +43,9 @@ public:
|
|||||||
PointD ll2pp(const Coordinates &c) const
|
PointD ll2pp(const Coordinates &c) const
|
||||||
{return _projection.ll2xy(c);}
|
{return _projection.ll2xy(c);}
|
||||||
PointD xy2pp(const QPointF &p) const
|
PointD xy2pp(const QPointF &p) const
|
||||||
{return _transform.img2proj(p * _ratio);}
|
{return _transform.img2proj(p * _mapRatio);}
|
||||||
QPointF pp2xy(const PointD &p) const
|
QPointF pp2xy(const PointD &p) const
|
||||||
{return _transform.proj2img(p) / _ratio;}
|
{return _transform.proj2img(p) / _mapRatio;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ImageInfo {
|
struct ImageInfo {
|
||||||
@ -73,7 +73,7 @@ private:
|
|||||||
ImageInfo _map, _tile;
|
ImageInfo _map, _tile;
|
||||||
int _zoom;
|
int _zoom;
|
||||||
QPointF _scale;
|
QPointF _scale;
|
||||||
qreal _ratio;
|
qreal _mapRatio;
|
||||||
|
|
||||||
bool _valid;
|
bool _valid;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -96,7 +96,7 @@ bool Tar::loadTmi(const QString &path)
|
|||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
int pos = line.indexOf(':');
|
int pos = line.indexOf(':');
|
||||||
if (line.size() < 10 || pos < 7 || !line.startsWith("block")) {
|
if (line.size() < 10 || pos < 7 || !line.startsWith("block")) {
|
||||||
qWarning("%s:%d: syntax error\n", qPrintable(path), ln);
|
qWarning("%s:%d: syntax error", qPrintable(path), ln);
|
||||||
_index.clear();
|
_index.clear();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -10,17 +10,21 @@
|
|||||||
class Tile
|
class Tile
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Tile(const QPoint &xy, const QVariant &zoom, const RectD &bbox = RectD())
|
Tile() {}
|
||||||
{_xy = xy; _zoom = zoom; _bbox = bbox;}
|
Tile(const QPoint &xy, const QVariant &zoom, int scaledSize = 0,
|
||||||
|
const RectD &bbox = RectD()) : _xy(xy), _zoom(zoom),
|
||||||
|
_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:
|
||||||
QVariant _zoom;
|
|
||||||
QPoint _xy;
|
QPoint _xy;
|
||||||
|
QVariant _zoom;
|
||||||
|
int _scaledSize;
|
||||||
RectD _bbox;
|
RectD _bbox;
|
||||||
QPixmap _pixmap;
|
QPixmap _pixmap;
|
||||||
};
|
};
|
||||||
|
@ -1,82 +1,145 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
#include <QPixmapCache>
|
||||||
|
#include <QImageReader>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
|
#include <QtCore>
|
||||||
|
#else // QT_VERSION < 5
|
||||||
|
#include <QtConcurrent>
|
||||||
|
#endif // QT_VERSION < 5
|
||||||
#include "tileloader.h"
|
#include "tileloader.h"
|
||||||
|
|
||||||
|
|
||||||
static bool loadTileFile(Tile &tile, const QString &file)
|
class TileImage
|
||||||
{
|
{
|
||||||
if (!tile.pixmap().load(file)) {
|
public:
|
||||||
qWarning("%s: error loading tile file\n", qPrintable(file));
|
TileImage() : _tile(0) {}
|
||||||
return false;
|
TileImage(const QString &file, Tile *tile)
|
||||||
|
: _file(file), _tile(tile) {}
|
||||||
|
|
||||||
|
void createPixmap()
|
||||||
|
{
|
||||||
|
_tile->pixmap().convertFromImage(_image);
|
||||||
|
}
|
||||||
|
void load()
|
||||||
|
{
|
||||||
|
QByteArray z(_tile->zoom().toString().toLatin1());
|
||||||
|
QImageReader reader(_file, z);
|
||||||
|
if (_tile->scaledSize())
|
||||||
|
reader.setScaledSize(QSize(_tile->scaledSize(), _tile->scaledSize()));
|
||||||
|
reader.read(&_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
const QString &file() const {return _file;}
|
||||||
|
Tile *tile() {return _tile;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _file;
|
||||||
|
Tile *_tile;
|
||||||
|
QImage _image;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void render(TileImage &ti)
|
||||||
|
{
|
||||||
|
ti.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
TileLoader::TileLoader(QObject *parent) : QObject(parent)
|
TileLoader::TileLoader(const QString &dir, QObject *parent)
|
||||||
|
: QObject(parent), _dir(dir)
|
||||||
{
|
{
|
||||||
|
if (!QDir().mkpath(_dir))
|
||||||
|
qWarning("%s: %s", qPrintable(_dir), "Error creating tiles directory");
|
||||||
|
|
||||||
_downloader = new Downloader(this);
|
_downloader = new Downloader(this);
|
||||||
connect(_downloader, SIGNAL(finished()), this, SIGNAL(finished()));
|
connect(_downloader, SIGNAL(finished()), this, SIGNAL(finished()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileLoader::loadTilesAsync(QList<Tile> &list)
|
void TileLoader::loadTilesAsync(QVector<Tile> &list)
|
||||||
{
|
{
|
||||||
QList<Download> dl;
|
QList<Download> dl;
|
||||||
|
QList<TileImage> imgs;
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Tile &t = list[i];
|
Tile &t = list[i];
|
||||||
QString file(tileFile(t));
|
QString file(tileFile(t));
|
||||||
QFileInfo fi(file);
|
|
||||||
QUrl url(tileUrl(t));
|
|
||||||
|
|
||||||
if (url.isLocalFile())
|
if (QPixmapCache::find(file, t.pixmap()))
|
||||||
loadTileFile(t, url.toLocalFile());
|
continue;
|
||||||
else if (fi.exists())
|
|
||||||
loadTileFile(t, file);
|
QFileInfo fi(file);
|
||||||
else
|
|
||||||
dl.append(Download(tileUrl(t), file));
|
if (fi.exists())
|
||||||
|
imgs.append(TileImage(file, &t));
|
||||||
|
else {
|
||||||
|
QUrl url(tileUrl(t));
|
||||||
|
if (url.isLocalFile())
|
||||||
|
imgs.append(TileImage(url.toLocalFile(), &t));
|
||||||
|
else
|
||||||
|
dl.append(Download(url, file));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dl.empty())
|
if (!dl.empty())
|
||||||
_downloader->get(dl, _authorization);
|
_downloader->get(dl, _authorization);
|
||||||
|
|
||||||
|
QFuture<void> future = QtConcurrent::map(imgs, render);
|
||||||
|
future.waitForFinished();
|
||||||
|
|
||||||
|
for (int i = 0; i < imgs.size(); i++) {
|
||||||
|
TileImage &ti = imgs[i];
|
||||||
|
ti.createPixmap();
|
||||||
|
QPixmapCache::insert(ti.file(), ti.tile()->pixmap());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileLoader::loadTilesSync(QList<Tile> &list)
|
void TileLoader::loadTilesSync(QVector<Tile> &list)
|
||||||
{
|
{
|
||||||
QList<Download> dl;
|
QList<Download> dl;
|
||||||
|
QList<Tile *> tl;
|
||||||
|
QList<TileImage> imgs;
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
Tile &t = list[i];
|
Tile &t = list[i];
|
||||||
QString file(tileFile(t));
|
QString file(tileFile(t));
|
||||||
|
|
||||||
|
if (QPixmapCache::find(file, t.pixmap()))
|
||||||
|
continue;
|
||||||
|
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
QUrl url(tileUrl(t));
|
|
||||||
|
|
||||||
if (url.isLocalFile())
|
if (fi.exists())
|
||||||
loadTileFile(t, url.toLocalFile());
|
imgs.append(TileImage(file, &t));
|
||||||
else if (fi.exists())
|
else {
|
||||||
loadTileFile(t, file);
|
QUrl url(tileUrl(t));
|
||||||
else
|
if (url.isLocalFile())
|
||||||
dl.append(Download(tileUrl(t), file));
|
imgs.append(TileImage(url.toLocalFile(), &t));
|
||||||
}
|
else {
|
||||||
|
dl.append(Download(url, file));
|
||||||
if (dl.empty())
|
tl.append(&t);
|
||||||
return;
|
}
|
||||||
|
|
||||||
QEventLoop wait;
|
|
||||||
QObject::connect(_downloader, SIGNAL(finished()), &wait, SLOT(quit()));
|
|
||||||
if (_downloader->get(dl, _authorization))
|
|
||||||
wait.exec();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
|
|
||||||
if (t.pixmap().isNull()) {
|
|
||||||
QString file = tileFile(t);
|
|
||||||
if (QFileInfo(file).exists())
|
|
||||||
loadTileFile(t, file);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dl.empty()) {
|
||||||
|
QEventLoop wait;
|
||||||
|
QObject::connect(_downloader, SIGNAL(finished()), &wait, SLOT(quit()));
|
||||||
|
if (_downloader->get(dl, _authorization))
|
||||||
|
wait.exec();
|
||||||
|
|
||||||
|
for (int i = 0; i < tl.size(); i++) {
|
||||||
|
Tile *t = tl[i];
|
||||||
|
QString file = tileFile(*t);
|
||||||
|
if (QFileInfo(file).exists())
|
||||||
|
imgs.append(TileImage(file, t));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QFuture<void> future = QtConcurrent::map(imgs, render);
|
||||||
|
future.waitForFinished();
|
||||||
|
|
||||||
|
for (int i = 0; i < imgs.size(); i++)
|
||||||
|
imgs[i].createPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileLoader::clearCache()
|
void TileLoader::clearCache()
|
||||||
@ -112,8 +175,7 @@ QUrl TileLoader::tileUrl(const Tile &tile) const
|
|||||||
|
|
||||||
QString TileLoader::tileFile(const Tile &tile) const
|
QString TileLoader::tileFile(const Tile &tile) const
|
||||||
{
|
{
|
||||||
QString file = _dir + QString("/%1-%2-%3").arg(tile.zoom().toString())
|
return _dir + QLatin1Char('/') + tile.zoom().toString() + QLatin1Char('-')
|
||||||
.arg(tile.xy().x()).arg(tile.xy().y());
|
+ QString::number(tile.xy().x()) + QLatin1Char('-')
|
||||||
|
+ QString::number(tile.xy().y());
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,14 @@ class TileLoader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileLoader(QObject *parent = 0);
|
TileLoader(const QString &dir, QObject *parent = 0);
|
||||||
|
|
||||||
void setUrl(const QString &url) {_url = url;}
|
void setUrl(const QString &url) {_url = url;}
|
||||||
void setDir(const QString &dir) {_dir = dir;}
|
|
||||||
void setAuthorization(const Authorization &authorization)
|
void setAuthorization(const Authorization &authorization)
|
||||||
{_authorization = authorization;}
|
{_authorization = authorization;}
|
||||||
|
|
||||||
void loadTilesAsync(QList<Tile> &list);
|
void loadTilesAsync(QVector<Tile> &list);
|
||||||
void loadTilesSync(QList<Tile> &list);
|
void loadTilesSync(QVector<Tile> &list);
|
||||||
void clearCache();
|
void clearCache();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "common/rectc.h"
|
#include "common/rectc.h"
|
||||||
|
#include "common/kv.h"
|
||||||
#include "projection.h"
|
#include "projection.h"
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
#include "coordinatesystem.h"
|
#include "coordinatesystem.h"
|
||||||
@ -18,9 +19,8 @@ public:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Setup(const QString &url, const QString &layer, const QString &style,
|
Setup(const QString &url, const QString &layer, const QString &style,
|
||||||
const QString &format, const QString &crs,
|
const QString &format, const QString &crs, const CoordinateSystem &cs,
|
||||||
const CoordinateSystem &cs,
|
const QList<KV> &dimensions,
|
||||||
const QList<QPair<QString, QString> > &dimensions,
|
|
||||||
const Authorization &authorization = Authorization())
|
const Authorization &authorization = Authorization())
|
||||||
: _url(url), _layer(layer), _style(style), _format(format),
|
: _url(url), _layer(layer), _style(style), _format(format),
|
||||||
_crs(crs), _cs(cs), _dimensions(dimensions),
|
_crs(crs), _cs(cs), _dimensions(dimensions),
|
||||||
@ -33,8 +33,7 @@ public:
|
|||||||
const QString &format() const {return _format;}
|
const QString &format() const {return _format;}
|
||||||
const QString &crs() const {return _crs;}
|
const QString &crs() const {return _crs;}
|
||||||
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
const CoordinateSystem &coordinateSystem() const {return _cs;}
|
||||||
const QList<QPair<QString, QString> > &dimensions() const
|
const QList<KV> &dimensions() const {return _dimensions;}
|
||||||
{return _dimensions;}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _url;
|
QString _url;
|
||||||
@ -43,7 +42,7 @@ public:
|
|||||||
QString _format;
|
QString _format;
|
||||||
QString _crs;
|
QString _crs;
|
||||||
CoordinateSystem _cs;
|
CoordinateSystem _cs;
|
||||||
QList<QPair<QString, QString> > _dimensions;
|
QList<KV> _dimensions;
|
||||||
Authorization _authorization;
|
Authorization _authorization;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user