mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-02 05:49:15 +02:00
Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
106d4c6e0b | |||
8f815a6af0 | |||
60f107d7cd | |||
e87fff4bf8 | |||
e6547d92f0 | |||
bfcc577f64 | |||
a56ad8a933 | |||
b1748c848b | |||
3763d44662 | |||
b3e8081942 | |||
b3dc886afc | |||
431002fd62 | |||
63c3a50ca6 | |||
7fd30bbda3 | |||
c1844f9557 | |||
0c7601c831 | |||
19eb3fba7f | |||
bde3c8cc3d | |||
b0ce471ea8 | |||
bd23120c2c | |||
ac4ef0631e | |||
60d9a172b6 | |||
b8eede21c0 | |||
70ddbe192f | |||
d8477571cc | |||
92545acba0 | |||
2bf66ea912 | |||
b21c2267cf | |||
278aa904c1 | |||
b369985f0a | |||
6a5781771f | |||
1b616f3c81 | |||
99dfbc1d2f | |||
f83e3376b4 | |||
311aeecb27 | |||
338ace6dff | |||
51e9ef4416 | |||
ebefe54510 | |||
1ec732c78d | |||
ff733b2705 | |||
99e32b1a15 | |||
f4a992a66f | |||
f52fa9a9ef | |||
61f3a1c932 | |||
93313da01d | |||
a253ac1796 | |||
e6a0eeefcc | |||
214d7c40dc | |||
cd89706d74 | |||
961eac9324 | |||
ddacac8d2e | |||
bd9b5dbc6a | |||
8b813b5879 | |||
b79de29464 | |||
ae2765528d | |||
0356917790 | |||
7352b24473 | |||
3a9ec6247c | |||
e74ac78138 | |||
5fa91be4ac | |||
536b4fd121 | |||
0556ae0f58 | |||
e38fdb26d7 | |||
e420602c69 | |||
211a4e4cef |
@ -12,7 +12,7 @@ KML, FIT, IGC and NMEA files.
|
|||||||
* Native GUI for Windows, Mac OS X and Linux.
|
* Native GUI for Windows, Mac OS X and Linux.
|
||||||
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
### Linux/OS X
|
### Linux/OS X
|
||||||
@ -29,8 +29,8 @@ nmake release
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Binaries
|
## Binaries
|
||||||
* Windows & OS X builds: http://sourceforge.net/projects/gpxsee
|
* [Windows & OS X builds](http://sourceforge.net/projects/gpxsee)
|
||||||
* Linux packages: https://build.opensuse.org/project/repositories/home:tumic:GPXSee
|
* [Linux packages](http://software.opensuse.org/download.html?project=home%3Atumic%3AGPXSee&package=gpxsee)
|
||||||
|
|
||||||
## Homepage
|
## Homepage
|
||||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
|
|
||||||
set PATH=C:\qt\qtbase\bin;%PATH%
|
|
||||||
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
|
|
||||||
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
|
|
||||||
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;%LIB%
|
|
||||||
set CL=/D_USING_V110_SDK71_
|
|
@ -1,6 +0,0 @@
|
|||||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
|
||||||
set PATH=C:\qt64\qtbase\bin;%PATH%
|
|
||||||
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
|
|
||||||
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
|
|
||||||
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;%LIB%
|
|
||||||
set CL=/D_USING_V110_SDK71_
|
|
33
gpxsee.pro
33
gpxsee.pro
@ -1,5 +1,5 @@
|
|||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
VERSION = 3.6
|
VERSION = 4.0
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
network
|
network
|
||||||
@ -22,6 +22,7 @@ HEADERS += src/config.h \
|
|||||||
src/sliderinfoitem.h \
|
src/sliderinfoitem.h \
|
||||||
src/filebrowser.h \
|
src/filebrowser.h \
|
||||||
src/map.h \
|
src/map.h \
|
||||||
|
src/onlinemap.h \
|
||||||
src/maplist.h \
|
src/maplist.h \
|
||||||
src/downloader.h \
|
src/downloader.h \
|
||||||
src/units.h \
|
src/units.h \
|
||||||
@ -76,7 +77,19 @@ HEADERS += src/config.h \
|
|||||||
src/optionsdialog.h \
|
src/optionsdialog.h \
|
||||||
src/colorbox.h \
|
src/colorbox.h \
|
||||||
src/stylecombobox.h \
|
src/stylecombobox.h \
|
||||||
src/opengl.h
|
src/opengl.h \
|
||||||
|
src/timetype.h \
|
||||||
|
src/emptymap.h \
|
||||||
|
src/offlinemap.h \
|
||||||
|
src/mapdir.h \
|
||||||
|
src/matrix.h \
|
||||||
|
src/tar.h \
|
||||||
|
src/atlas.h \
|
||||||
|
src/projection.h \
|
||||||
|
src/mercator.h \
|
||||||
|
src/transversemercator.h \
|
||||||
|
src/latlon.h \
|
||||||
|
src/utm.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/gui.cpp \
|
src/gui.cpp \
|
||||||
src/poi.cpp \
|
src/poi.cpp \
|
||||||
@ -88,7 +101,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/speedgraph.cpp \
|
src/speedgraph.cpp \
|
||||||
src/sliderinfoitem.cpp \
|
src/sliderinfoitem.cpp \
|
||||||
src/filebrowser.cpp \
|
src/filebrowser.cpp \
|
||||||
src/map.cpp \
|
src/onlinemap.cpp \
|
||||||
src/maplist.cpp \
|
src/maplist.cpp \
|
||||||
src/downloader.cpp \
|
src/downloader.cpp \
|
||||||
src/scaleitem.cpp \
|
src/scaleitem.cpp \
|
||||||
@ -130,9 +143,19 @@ SOURCES += src/main.cpp \
|
|||||||
src/nmeaparser.cpp \
|
src/nmeaparser.cpp \
|
||||||
src/optionsdialog.cpp \
|
src/optionsdialog.cpp \
|
||||||
src/colorbox.cpp \
|
src/colorbox.cpp \
|
||||||
src/stylecombobox.cpp
|
src/stylecombobox.cpp \
|
||||||
|
src/emptymap.cpp \
|
||||||
|
src/offlinemap.cpp \
|
||||||
|
src/mapdir.cpp \
|
||||||
|
src/matrix.cpp \
|
||||||
|
src/tar.cpp \
|
||||||
|
src/atlas.cpp \
|
||||||
|
src/mercator.cpp \
|
||||||
|
src/transversemercator.cpp \
|
||||||
|
src/utm.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||||
|
lang/gpxsee_sv.ts
|
||||||
macx {
|
macx {
|
||||||
ICON = icons/gpxsee.icns
|
ICON = icons/gpxsee.icns
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
|
@ -20,5 +20,6 @@
|
|||||||
<file>icons/system-run.png</file>
|
<file>icons/system-run.png</file>
|
||||||
<file>icons/document-print-preview.png</file>
|
<file>icons/document-print-preview.png</file>
|
||||||
<file>lang/gpxsee_cs.qm</file>
|
<file>lang/gpxsee_cs.qm</file>
|
||||||
|
<file>lang/gpxsee_sv.qm</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -190,290 +190,326 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>GUI</name>
|
<name>GUI</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="552"/>
|
<location filename="../src/gui.cpp" line="578"/>
|
||||||
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
<source>GPXSee is distributed under the terms of the GNU General Public License version 3. For more info about GPXSee visit the project homepage at </source>
|
||||||
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
<translation>Program GPXSee je distribuován pod podmínkami licence GNU General Public License verze 3. Pro více informací navštivte stránky programu na adrese </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="616"/>
|
<location filename="../src/gui.cpp" line="650"/>
|
||||||
<source>Open file</source>
|
<source>Open file</source>
|
||||||
<translation>Otevřít soubor</translation>
|
<translation>Otevřít soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="705"/>
|
<location filename="../src/gui.cpp" line="740"/>
|
||||||
<source>Open POI file</source>
|
<source>Open POI file</source>
|
||||||
<translation>Otevřít POI soubor</translation>
|
<translation>Otevřít POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="223"/>
|
<location filename="../src/gui.cpp" line="237"/>
|
||||||
<source>Open</source>
|
<source>Open</source>
|
||||||
<translation>Otevřít</translation>
|
<translation>Otevřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="207"/>
|
<location filename="../src/gui.cpp" line="221"/>
|
||||||
<source>Quit</source>
|
<source>Quit</source>
|
||||||
<translation>Ukončit</translation>
|
<translation>Ukončit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="215"/>
|
<location filename="../src/gui.cpp" line="229"/>
|
||||||
<location filename="../src/gui.cpp" line="568"/>
|
<location filename="../src/gui.cpp" line="594"/>
|
||||||
<location filename="../src/gui.cpp" line="569"/>
|
<location filename="../src/gui.cpp" line="595"/>
|
||||||
<source>Keyboard controls</source>
|
<source>Keyboard controls</source>
|
||||||
<translation>Ovládací klávesy</translation>
|
<translation>Ovládací klávesy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="239"/>
|
<location filename="../src/gui.cpp" line="253"/>
|
||||||
<source>Close</source>
|
<source>Close</source>
|
||||||
<translation>Zavřít</translation>
|
<translation>Zavřít</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="245"/>
|
<location filename="../src/gui.cpp" line="259"/>
|
||||||
<source>Reload</source>
|
<source>Reload</source>
|
||||||
<translation>Znovu načíst</translation>
|
<translation>Znovu načíst</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="478"/>
|
<location filename="../src/gui.cpp" line="508"/>
|
||||||
<source>Show</source>
|
<source>Show</source>
|
||||||
<translation>Zobrazit</translation>
|
<translation>Zobrazit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="399"/>
|
<location filename="../src/gui.cpp" line="426"/>
|
||||||
<location filename="../src/gui.cpp" line="472"/>
|
<location filename="../src/gui.cpp" line="502"/>
|
||||||
<source>File</source>
|
<source>File</source>
|
||||||
<translation>Soubor</translation>
|
<translation>Soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="102"/>
|
<location filename="../src/gui.cpp" line="105"/>
|
||||||
<source>FIT files (*.fit)</source>
|
<source>FIT files (*.fit)</source>
|
||||||
<translation>Soubory FIT (*.fit)</translation>
|
<translation>Soubory FIT (*.fit)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="103"/>
|
<location filename="../src/gui.cpp" line="106"/>
|
||||||
<source>IGC files (*.igc)</source>
|
<source>IGC files (*.igc)</source>
|
||||||
<translation>Soubory IGC (*.igc)</translation>
|
<translation>Soubory IGC (*.igc)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="104"/>
|
<location filename="../src/gui.cpp" line="107"/>
|
||||||
<source>NMEA files (*.nmea)</source>
|
<source>NMEA files (*.nmea)</source>
|
||||||
<translation>Soubory NMEA (*.nmea)</translation>
|
<translation>Soubory NMEA (*.nmea)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="213"/>
|
<location filename="../src/gui.cpp" line="227"/>
|
||||||
<location filename="../src/gui.cpp" line="591"/>
|
<location filename="../src/gui.cpp" line="617"/>
|
||||||
<location filename="../src/gui.cpp" line="592"/>
|
<location filename="../src/gui.cpp" line="618"/>
|
||||||
<source>Data sources</source>
|
<source>Data sources</source>
|
||||||
<translation>Zdroje dat</translation>
|
<translation>Zdroje dat</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="253"/>
|
<location filename="../src/gui.cpp" line="267"/>
|
||||||
<source>Load POI file</source>
|
<source>Load POI file</source>
|
||||||
<translation>Nahrát POI soubor</translation>
|
<translation>Nahrát POI soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="256"/>
|
<location filename="../src/gui.cpp" line="270"/>
|
||||||
<source>Close POI files</source>
|
<source>Close POI files</source>
|
||||||
<translation>Zavřit POI soubory</translation>
|
<translation>Zavřit POI soubory</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="258"/>
|
<location filename="../src/gui.cpp" line="272"/>
|
||||||
<source>Overlap POIs</source>
|
<source>Overlap POIs</source>
|
||||||
<translation>Překrývat POI</translation>
|
<translation>Překrývat POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="262"/>
|
<location filename="../src/gui.cpp" line="276"/>
|
||||||
<source>Show POI labels</source>
|
<source>Show POI labels</source>
|
||||||
<translation>Zobrazovat názvy POI</translation>
|
<translation>Zobrazit názvy POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="267"/>
|
<location filename="../src/gui.cpp" line="281"/>
|
||||||
<source>Show POIs</source>
|
<source>Show POIs</source>
|
||||||
<translation>Zobrazit POI</translation>
|
<translation>Zobrazit POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="276"/>
|
<location filename="../src/gui.cpp" line="290"/>
|
||||||
<source>Show map</source>
|
<source>Show map</source>
|
||||||
<translation>Zobrazit mapu</translation>
|
<translation>Zobrazit mapu</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="282"/>
|
<location filename="../src/gui.cpp" line="297"/>
|
||||||
<source>Clear tile cache</source>
|
<source>Clear tile cache</source>
|
||||||
<translation>Vymazat mezipaměť dlaždic</translation>
|
<translation>Vymazat mezipaměť dlaždic</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="291"/>
|
<location filename="../src/gui.cpp" line="306"/>
|
||||||
<location filename="../src/gui.cpp" line="295"/>
|
<location filename="../src/gui.cpp" line="310"/>
|
||||||
<location filename="../src/gui.cpp" line="578"/>
|
<location filename="../src/gui.cpp" line="606"/>
|
||||||
<source>Next map</source>
|
<source>Next map</source>
|
||||||
<translation>Následující mapa</translation>
|
<translation>Následující mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="302"/>
|
<location filename="../src/gui.cpp" line="317"/>
|
||||||
<source>Show tracks</source>
|
<source>Show tracks</source>
|
||||||
<translation>Zobrazit cesty</translation>
|
<translation>Zobrazit cesty</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="306"/>
|
<location filename="../src/gui.cpp" line="321"/>
|
||||||
<source>Show routes</source>
|
<source>Show routes</source>
|
||||||
<translation>Zobrazit trasy</translation>
|
<translation>Zobrazit trasy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="310"/>
|
<location filename="../src/gui.cpp" line="325"/>
|
||||||
<source>Show waypoints</source>
|
<source>Show waypoints</source>
|
||||||
<translation>Zobrazit navigační body</translation>
|
<translation>Zobrazit navigační body</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="314"/>
|
<location filename="../src/gui.cpp" line="329"/>
|
||||||
<source>Waypoint labels</source>
|
<source>Waypoint labels</source>
|
||||||
<translation>Názvy navigačních bodů</translation>
|
<translation>Názvy navigačních bodů</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="325"/>
|
<location filename="../src/gui.cpp" line="340"/>
|
||||||
<source>Show graphs</source>
|
<source>Show graphs</source>
|
||||||
<translation>Zobrazovat grafy</translation>
|
<translation>Zobrazit grafy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="347"/>
|
<location filename="../src/gui.cpp" line="362"/>
|
||||||
<source>Show grid</source>
|
<source>Show grid</source>
|
||||||
<translation>Zobrazit mřížku</translation>
|
<translation>Zobrazit mřížku</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="353"/>
|
<location filename="../src/gui.cpp" line="368"/>
|
||||||
<source>Show toolbars</source>
|
<source>Show toolbars</source>
|
||||||
<translation>Zobrazovat nástrojové lišty</translation>
|
<translation>Zobrazovat nástrojové lišty</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="359"/>
|
<location filename="../src/gui.cpp" line="374"/>
|
||||||
|
<source>Total time</source>
|
||||||
|
<translation>Celkový čas</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="379"/>
|
||||||
|
<location filename="../src/gui.cpp" line="893"/>
|
||||||
|
<source>Moving time</source>
|
||||||
|
<translation>Čistý čas</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="386"/>
|
||||||
<source>Metric</source>
|
<source>Metric</source>
|
||||||
<translation>Metrické</translation>
|
<translation>Metrické</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="364"/>
|
<location filename="../src/gui.cpp" line="391"/>
|
||||||
<source>Imperial</source>
|
<source>Imperial</source>
|
||||||
<translation>Imperiální</translation>
|
<translation>Imperiální</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="370"/>
|
<location filename="../src/gui.cpp" line="397"/>
|
||||||
<source>Fullscreen mode</source>
|
<source>Fullscreen mode</source>
|
||||||
<translation>Celoobrazovkový režim</translation>
|
<translation>Celoobrazovkový režim</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="376"/>
|
<location filename="../src/gui.cpp" line="403"/>
|
||||||
<source>Options...</source>
|
<source>Options...</source>
|
||||||
<translation>Nastavení...</translation>
|
<translation>Nastavení...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="381"/>
|
<location filename="../src/gui.cpp" line="408"/>
|
||||||
<source>Next</source>
|
<source>Next</source>
|
||||||
<translation>Následující</translation>
|
<translation>Následující</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="384"/>
|
<location filename="../src/gui.cpp" line="411"/>
|
||||||
<source>Previous</source>
|
<source>Previous</source>
|
||||||
<translation>Předchozí</translation>
|
<translation>Předchozí</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="388"/>
|
<location filename="../src/gui.cpp" line="415"/>
|
||||||
<source>Last</source>
|
<source>Last</source>
|
||||||
<translation>Poslední</translation>
|
<translation>Poslední</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="391"/>
|
<location filename="../src/gui.cpp" line="418"/>
|
||||||
<source>First</source>
|
<source>First</source>
|
||||||
<translation>První</translation>
|
<translation>První</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="413"/>
|
<location filename="../src/gui.cpp" line="440"/>
|
||||||
<source>Map</source>
|
<source>Map</source>
|
||||||
<translation>Mapa</translation>
|
<translation>Mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="420"/>
|
<location filename="../src/gui.cpp" line="447"/>
|
||||||
<source>Graph</source>
|
<source>Graph</source>
|
||||||
<translation>Graf</translation>
|
<translation>Graf</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="428"/>
|
<location filename="../src/gui.cpp" line="455"/>
|
||||||
<source>POI</source>
|
<source>POI</source>
|
||||||
<translation>POI</translation>
|
<translation>POI</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="429"/>
|
<location filename="../src/gui.cpp" line="456"/>
|
||||||
<source>POI files</source>
|
<source>POI files</source>
|
||||||
<translation>POI soubory</translation>
|
<translation>POI soubory</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="440"/>
|
<location filename="../src/gui.cpp" line="467"/>
|
||||||
<source>Data</source>
|
<source>Data</source>
|
||||||
<translation>Data</translation>
|
<translation>Data</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="441"/>
|
<location filename="../src/gui.cpp" line="468"/>
|
||||||
<source>Display</source>
|
<source>Display</source>
|
||||||
<translation>Zobrazit</translation>
|
<translation>Zobrazit</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="449"/>
|
<location filename="../src/gui.cpp" line="476"/>
|
||||||
<source>Settings</source>
|
<source>Settings</source>
|
||||||
<translation>Nastavení</translation>
|
<translation>Nastavení</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="450"/>
|
<location filename="../src/gui.cpp" line="480"/>
|
||||||
<source>Units</source>
|
<source>Units</source>
|
||||||
<translation>Jednotky</translation>
|
<translation>Jednotky</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="459"/>
|
<location filename="../src/gui.cpp" line="489"/>
|
||||||
<source>Help</source>
|
<source>Help</source>
|
||||||
<translation>Nápověda</translation>
|
<translation>Nápověda</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="580"/>
|
<location filename="../src/gui.cpp" line="607"/>
|
||||||
<source>Previous map</source>
|
<source>Previous map</source>
|
||||||
<translation>Předchozí mapa</translation>
|
<translation>Předchozí mapa</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="103"/>
|
<location filename="../src/gui.cpp" line="620"/>
|
||||||
|
<source>Online maps</source>
|
||||||
|
<translation>Online mapy</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="621"/>
|
||||||
|
<source>Online map URLs are read on program startup from the following file:</source>
|
||||||
|
<translation>URL online map jsou načteny při startu programu z následujícího souboru:</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="631"/>
|
||||||
|
<source>Ofline maps</source>
|
||||||
|
<translation>Offline mapy</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="632"/>
|
||||||
|
<source>Offline maps are loaded on program startup from the following directory:</source>
|
||||||
|
<translation>Offline mapy jsou načítány při startu aplikace z následujícího adresáře:</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="635"/>
|
||||||
|
<source>The expected structure is one map/atlas in a separate subdirectory. Supported map formats are OziMap image-based maps and tiled TrekBuddy maps/atlases (tared and non-tared).</source>
|
||||||
|
<translation>Očekávaná struktura je jedna mapa/atlas v samostatném podadresáři. Podporované mapové formáty jsou OziMap mapy a TrekBuddy mapy/atlasy (včetně tar varianty).</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="1091"/>
|
||||||
|
<source>No files loaded</source>
|
||||||
|
<translation>Nejsou načteny žádné soubory</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/gui.cpp" line="106"/>
|
||||||
<source>GPX files (*.gpx)</source>
|
<source>GPX files (*.gpx)</source>
|
||||||
<translation>Soubory GPX (*.gpx)</translation>
|
<translation>Soubory GPX (*.gpx)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="105"/>
|
<location filename="../src/gui.cpp" line="108"/>
|
||||||
<source>TCX files (*.tcx)</source>
|
<source>TCX files (*.tcx)</source>
|
||||||
<translation>Soubory TCX (*.tcx)</translation>
|
<translation>Soubory TCX (*.tcx)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="104"/>
|
<location filename="../src/gui.cpp" line="107"/>
|
||||||
<source>KML files (*.kml)</source>
|
<source>KML files (*.kml)</source>
|
||||||
<translation>Soubory KML (*.kml)</translation>
|
<translation>Soubory KML (*.kml)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="102"/>
|
<location filename="../src/gui.cpp" line="105"/>
|
||||||
<source>CSV files (*.csv)</source>
|
<source>CSV files (*.csv)</source>
|
||||||
<translation>Soubory CSV (*.csv)</translation>
|
<translation>Soubory CSV (*.csv)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="105"/>
|
<location filename="../src/gui.cpp" line="108"/>
|
||||||
<source>All files (*)</source>
|
<source>All files (*)</source>
|
||||||
<translation>Všechny soubory (*)</translation>
|
<translation>Všechny soubory (*)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="844"/>
|
<location filename="../src/gui.cpp" line="879"/>
|
||||||
<location filename="../src/gui.cpp" line="847"/>
|
<location filename="../src/gui.cpp" line="882"/>
|
||||||
<source>Date</source>
|
<source>Date</source>
|
||||||
<translation>Datum</translation>
|
<translation>Datum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="836"/>
|
<location filename="../src/gui.cpp" line="871"/>
|
||||||
<source>Routes</source>
|
<source>Routes</source>
|
||||||
<translation>Trasy</translation>
|
<translation>Trasy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="1060"/>
|
|
||||||
<source>No GPX files loaded</source>
|
|
||||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
|
||||||
</message>
|
|
||||||
<message numerus="yes">
|
<message numerus="yes">
|
||||||
<location filename="../src/gui.cpp" line="1064"/>
|
<location filename="../src/gui.cpp" line="1095"/>
|
||||||
<source>%n files</source>
|
<source>%n files</source>
|
||||||
<translation>
|
<translation>
|
||||||
<numerusform>%n soubor</numerusform>
|
<numerusform>%n soubor</numerusform>
|
||||||
@ -482,131 +518,122 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="571"/>
|
<location filename="../src/gui.cpp" line="597"/>
|
||||||
<source>Next file</source>
|
<source>Next file</source>
|
||||||
<translation>Následující soubor</translation>
|
<translation>Následující soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="548"/>
|
<location filename="../src/gui.cpp" line="575"/>
|
||||||
<source>Version </source>
|
<source>Version </source>
|
||||||
<translation>Verze </translation>
|
<translation>Verze </translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="228"/>
|
<location filename="../src/gui.cpp" line="242"/>
|
||||||
<source>Print...</source>
|
<source>Print...</source>
|
||||||
<translation>Tisknout...</translation>
|
<translation>Tisknout...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="233"/>
|
<location filename="../src/gui.cpp" line="247"/>
|
||||||
<source>Export to PDF...</source>
|
<source>Export to PDF...</source>
|
||||||
<translation>Exportovat do PDF...</translation>
|
<translation>Exportovat do PDF...</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="838"/>
|
<location filename="../src/gui.cpp" line="873"/>
|
||||||
<source>Waypoints</source>
|
<source>Waypoints</source>
|
||||||
<translation>Navigační body</translation>
|
<translation>Navigační body</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="572"/>
|
<location filename="../src/gui.cpp" line="599"/>
|
||||||
<source>Previous file</source>
|
<source>Previous file</source>
|
||||||
<translation>Předchozí soubor</translation>
|
<translation>Předchozí soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="101"/>
|
<location filename="../src/gui.cpp" line="104"/>
|
||||||
<source>Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</source>
|
<source>Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</source>
|
||||||
<translation>Podporované soubory (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</translation>
|
<translation>Podporované soubory (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="318"/>
|
<location filename="../src/gui.cpp" line="333"/>
|
||||||
<source>Route waypoints</source>
|
<source>Route waypoints</source>
|
||||||
<translation>Body tras</translation>
|
<translation>Body tras</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="574"/>
|
<location filename="../src/gui.cpp" line="601"/>
|
||||||
<source>First file</source>
|
<source>First file</source>
|
||||||
<translation>První soubor</translation>
|
<translation>První soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="575"/>
|
<location filename="../src/gui.cpp" line="603"/>
|
||||||
<source>Last file</source>
|
<source>Last file</source>
|
||||||
<translation>Poslední soubor</translation>
|
<translation>Poslední soubor</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="576"/>
|
<location filename="../src/gui.cpp" line="604"/>
|
||||||
<source>Append modifier</source>
|
<source>Append modifier</source>
|
||||||
<translation>Modifikátor nahradit/přidat</translation>
|
<translation>Modifikátor nahradit/přidat</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="595"/>
|
<location filename="../src/gui.cpp" line="624"/>
|
||||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
|
||||||
<translation>URL mapových zdrojů (dlaždic) jsou načteny při startu programu z následujícího souboru:</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="598"/>
|
|
||||||
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
<source>The file format is one map entry per line, consisting of the map name and tiles URL delimited by a TAB character. The tile X and Y coordinates are replaced with $x and $y in the URL and the zoom level is replaced with $z. An example map file could look like:</source>
|
||||||
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
<translation>Formát souboru je jeden mapový záznam na řádku, kde mapový záznam sestává ze jména mapy a URL dlaždic navzájem oddělených tabulátorem. Souřadnice dlaždice jsou v URL nahrazeny řetězci $x a $y, úroven přiblížení (zoom) pak řetězcem $z. Příklad:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="606"/>
|
<location filename="../src/gui.cpp" line="640"/>
|
||||||
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||||
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
<translation>POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="694"/>
|
<location filename="../src/gui.cpp" line="729"/>
|
||||||
<source>Error loading data file:</source>
|
<source>Error loading data file:</source>
|
||||||
<translation>Datový soubor nelze načíst:</translation>
|
<translation>Datový soubor nelze načíst:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="697"/>
|
<location filename="../src/gui.cpp" line="732"/>
|
||||||
<location filename="../src/gui.cpp" line="722"/>
|
<location filename="../src/gui.cpp" line="757"/>
|
||||||
<source>Line: %1</source>
|
<source>Line: %1</source>
|
||||||
<translation>Řádka: %1</translation>
|
<translation>Řádka: %1</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="719"/>
|
<location filename="../src/gui.cpp" line="754"/>
|
||||||
<source>Error loading POI file:</source>
|
<source>Error loading POI file:</source>
|
||||||
<translation>Soubor POI nelze načíst:</translation>
|
<translation>Soubor POI nelze načíst:</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="830"/>
|
<location filename="../src/gui.cpp" line="865"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation>Název</translation>
|
<translation>Název</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="834"/>
|
<location filename="../src/gui.cpp" line="869"/>
|
||||||
<source>Tracks</source>
|
<source>Tracks</source>
|
||||||
<translation>Cesty</translation>
|
<translation>Cesty</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="218"/>
|
<location filename="../src/gui.cpp" line="232"/>
|
||||||
<location filename="../src/gui.cpp" line="546"/>
|
<location filename="../src/gui.cpp" line="574"/>
|
||||||
<source>About GPXSee</source>
|
<source>About GPXSee</source>
|
||||||
<translation>O aplikaci GPXSee</translation>
|
<translation>O aplikaci GPXSee</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="483"/>
|
<location filename="../src/gui.cpp" line="513"/>
|
||||||
<source>Navigation</source>
|
<source>Navigation</source>
|
||||||
<translation>Navigace</translation>
|
<translation>Navigace</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="594"/>
|
<location filename="../src/gui.cpp" line="639"/>
|
||||||
<source>Map sources</source>
|
|
||||||
<translation>Mapové zdroje</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<location filename="../src/gui.cpp" line="605"/>
|
|
||||||
<source>POIs</source>
|
<source>POIs</source>
|
||||||
<translation>POI body</translation>
|
<translation>POI body</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="333"/>
|
<location filename="../src/gui.cpp" line="348"/>
|
||||||
<location filename="../src/gui.cpp" line="854"/>
|
<location filename="../src/gui.cpp" line="889"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/gui.cpp" line="340"/>
|
<location filename="../src/gui.cpp" line="355"/>
|
||||||
<location filename="../src/gui.cpp" line="856"/>
|
<location filename="../src/gui.cpp" line="477"/>
|
||||||
|
<location filename="../src/gui.cpp" line="891"/>
|
||||||
<source>Time</source>
|
<source>Time</source>
|
||||||
<translation>Čas</translation>
|
<translation>Čas</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -749,7 +776,7 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="115"/>
|
<location filename="../src/optionsdialog.cpp" line="115"/>
|
||||||
<location filename="../src/optionsdialog.cpp" line="180"/>
|
<location filename="../src/optionsdialog.cpp" line="183"/>
|
||||||
<source>Graphs</source>
|
<source>Graphs</source>
|
||||||
<translation>Grafy</translation>
|
<translation>Grafy</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -770,7 +797,7 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="140"/>
|
<location filename="../src/optionsdialog.cpp" line="140"/>
|
||||||
<location filename="../src/optionsdialog.cpp" line="221"/>
|
<location filename="../src/optionsdialog.cpp" line="224"/>
|
||||||
<source>POI</source>
|
<source>POI</source>
|
||||||
<translation>POI</translation>
|
<translation>POI</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -796,42 +823,47 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="155"/>
|
<location filename="../src/optionsdialog.cpp" line="155"/>
|
||||||
|
<source>Moving time</source>
|
||||||
|
<translation>Čistý čas</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/optionsdialog.cpp" line="157"/>
|
||||||
<source>Item count (>1)</source>
|
<source>Item count (>1)</source>
|
||||||
<translation>Počet objektů (>1)</translation>
|
<translation>Počet objektů (>1)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="169"/>
|
<location filename="../src/optionsdialog.cpp" line="172"/>
|
||||||
<source>Separate graph page</source>
|
<source>Separate graph page</source>
|
||||||
<translation>Samostatná stránka s grafy</translation>
|
<translation>Samostatná stránka s grafy</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="179"/>
|
<location filename="../src/optionsdialog.cpp" line="182"/>
|
||||||
<source>Header</source>
|
<source>Header</source>
|
||||||
<translation>Záhlaví</translation>
|
<translation>Záhlaví</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="187"/>
|
<location filename="../src/optionsdialog.cpp" line="190"/>
|
||||||
<source>Use OpenGL</source>
|
<source>Use OpenGL</source>
|
||||||
<translation>Používat OpenGL</translation>
|
<translation>Používat OpenGL</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="203"/>
|
<location filename="../src/optionsdialog.cpp" line="206"/>
|
||||||
<location filename="../src/optionsdialog.cpp" line="224"/>
|
<location filename="../src/optionsdialog.cpp" line="227"/>
|
||||||
<source>System</source>
|
<source>System</source>
|
||||||
<translation>Systém</translation>
|
<translation>Systém</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="219"/>
|
<location filename="../src/optionsdialog.cpp" line="222"/>
|
||||||
<source>Appearance</source>
|
<source>Appearance</source>
|
||||||
<translation>Vzhled</translation>
|
<translation>Vzhled</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="222"/>
|
<location filename="../src/optionsdialog.cpp" line="225"/>
|
||||||
<source>Print & Export</source>
|
<source>Print & Export</source>
|
||||||
<translation>Tisk a export</translation>
|
<translation>Tisk a export</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/optionsdialog.cpp" line="251"/>
|
<location filename="../src/optionsdialog.cpp" line="254"/>
|
||||||
<source>Options</source>
|
<source>Options</source>
|
||||||
<translation>Nastavení</translation>
|
<translation>Nastavení</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -863,17 +895,17 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>RouteItem</name>
|
<name>RouteItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/routeitem.cpp" line="14"/>
|
<location filename="../src/routeitem.cpp" line="15"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation>Název</translation>
|
<translation>Název</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/routeitem.cpp" line="16"/>
|
<location filename="../src/routeitem.cpp" line="17"/>
|
||||||
<source>Description</source>
|
<source>Description</source>
|
||||||
<translation>Popis</translation>
|
<translation>Popis</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/routeitem.cpp" line="17"/>
|
<location filename="../src/routeitem.cpp" line="18"/>
|
||||||
<source>Distance</source>
|
<source>Distance</source>
|
||||||
<translation>Vzdálenost</translation>
|
<translation>Vzdálenost</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -881,22 +913,22 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>ScaleItem</name>
|
<name>ScaleItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="90"/>
|
<location filename="../src/scaleitem.cpp" line="81"/>
|
||||||
<source>mi</source>
|
<source>mi</source>
|
||||||
<translation>mi</translation>
|
<translation>mi</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="91"/>
|
<location filename="../src/scaleitem.cpp" line="82"/>
|
||||||
<source>ft</source>
|
<source>ft</source>
|
||||||
<translation>ft</translation>
|
<translation>ft</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="93"/>
|
<location filename="../src/scaleitem.cpp" line="84"/>
|
||||||
<source>km</source>
|
<source>km</source>
|
||||||
<translation>km</translation>
|
<translation>km</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/scaleitem.cpp" line="94"/>
|
<location filename="../src/scaleitem.cpp" line="85"/>
|
||||||
<source>m</source>
|
<source>m</source>
|
||||||
<translation>m</translation>
|
<translation>m</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -904,28 +936,28 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>SpeedGraph</name>
|
<name>SpeedGraph</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||||
<location filename="../src/speedgraph.h" line="14"/>
|
<location filename="../src/speedgraph.h" line="14"/>
|
||||||
<source>Speed</source>
|
<source>Speed</source>
|
||||||
<translation>Rychlost</translation>
|
<translation>Rychlost</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="74"/>
|
<location filename="../src/speedgraph.cpp" line="79"/>
|
||||||
<source>km/h</source>
|
<source>km/h</source>
|
||||||
<translation>km/h</translation>
|
<translation>km/h</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="20"/>
|
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||||
<source>Average</source>
|
<source>Average</source>
|
||||||
<translation>Průměr</translation>
|
<translation>Průměr</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="22"/>
|
<location filename="../src/speedgraph.cpp" line="23"/>
|
||||||
<source>Maximum</source>
|
<source>Maximum</source>
|
||||||
<translation>Maximum</translation>
|
<translation>Maximum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/speedgraph.cpp" line="77"/>
|
<location filename="../src/speedgraph.cpp" line="82"/>
|
||||||
<source>mi/h</source>
|
<source>mi/h</source>
|
||||||
<translation>mi/h</translation>
|
<translation>mi/h</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -983,11 +1015,16 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/trackitem.cpp" line="18"/>
|
<location filename="../src/trackitem.cpp" line="18"/>
|
||||||
<source>Time</source>
|
<source>Total time</source>
|
||||||
<translation>Čas</translation>
|
<translation>Celkový čas</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/trackitem.cpp" line="20"/>
|
<location filename="../src/trackitem.cpp" line="20"/>
|
||||||
|
<source>Moving time</source>
|
||||||
|
<translation>Čistý čas</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../src/trackitem.cpp" line="22"/>
|
||||||
<source>Date</source>
|
<source>Date</source>
|
||||||
<translation>Datum</translation>
|
<translation>Datum</translation>
|
||||||
</message>
|
</message>
|
||||||
@ -995,27 +1032,27 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>WaypointItem</name>
|
<name>WaypointItem</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="17"/>
|
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||||
<source>Name</source>
|
<source>Name</source>
|
||||||
<translation>Název</translation>
|
<translation>Název</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
<location filename="../src/waypointitem.cpp" line="19"/>
|
||||||
<source>Coordinates</source>
|
<source>Coordinates</source>
|
||||||
<translation>Souřadnice</translation>
|
<translation>Souřadnice</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="21"/>
|
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||||
<source>Elevation</source>
|
<source>Elevation</source>
|
||||||
<translation>Výška</translation>
|
<translation>Výška</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="24"/>
|
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||||
<source>Date</source>
|
<source>Date</source>
|
||||||
<translation>Datum</translation>
|
<translation>Datum</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../src/waypointitem.cpp" line="27"/>
|
<location filename="../src/waypointitem.cpp" line="28"/>
|
||||||
<source>Description</source>
|
<source>Description</source>
|
||||||
<translation>Popis</translation>
|
<translation>Popis</translation>
|
||||||
</message>
|
</message>
|
||||||
|
1059
lang/gpxsee_sv.ts
Normal file
1059
lang/gpxsee_sv.ts
Normal file
File diff suppressed because it is too large
Load Diff
BIN
pkg/gpxsee.cer
Normal file
BIN
pkg/gpxsee.cer
Normal file
Binary file not shown.
@ -1,10 +1,11 @@
|
|||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "x64.nsh"
|
!include "x64.nsh"
|
||||||
|
!include "WinVer.nsh"
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "3.6"
|
!define VERSION "4.0"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
@ -15,6 +16,14 @@ RequestExecutionLevel admin
|
|||||||
; The default installation directory
|
; The default installation directory
|
||||||
InstallDir "$PROGRAMFILES\GPXSee"
|
InstallDir "$PROGRAMFILES\GPXSee"
|
||||||
|
|
||||||
|
; Installer executable info
|
||||||
|
VIProductVersion "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductVersion" ${VERSION}
|
||||||
|
VIAddVersionKey "FileVersion" "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductName" "GPXSee"
|
||||||
|
VIAddVersionKey "LegalCopyright" "GPXSee project"
|
||||||
|
VIAddVersionKey "FileDescription" "GPXSee installer"
|
||||||
|
|
||||||
; Registry key to check for directory (so if you install again, it will
|
; Registry key to check for directory (so if you install again, it will
|
||||||
; overwrite the old one automatically)
|
; overwrite the old one automatically)
|
||||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||||
@ -55,9 +64,15 @@ Var StartMenuFolder
|
|||||||
; Languages
|
; Languages
|
||||||
!insertmacro MUI_LANGUAGE "English"
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
Function .onInit
|
||||||
|
${IfNot} ${AtLeastWin7}
|
||||||
|
MessageBox MB_OK "GPXSee can only be installed on Windows 7 or later."
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
; The stuff to install
|
; The stuff to install
|
||||||
Section "GPXSee (required)" SEC_APP
|
Section "GPXSee" SEC_APP
|
||||||
|
|
||||||
SectionIn RO
|
SectionIn RO
|
||||||
|
|
||||||
@ -122,16 +137,15 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "QT libs" SEC_QT
|
Section "QT framework" SEC_QT
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
File "Qt5Core.dll"
|
File "Qt5Core.dll"
|
||||||
File "Qt5Gui.dll"
|
File "Qt5Gui.dll"
|
||||||
File "Qt5Widgets.dll"
|
File "Qt5Widgets.dll"
|
||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "libGLESv2.dll"
|
|
||||||
File "libEGL.dll"
|
|
||||||
File "D3DCompiler_47.dll"
|
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -140,6 +154,8 @@ SectionEnd
|
|||||||
|
|
||||||
Section "MSVC runtime" SEC_MSVC
|
Section "MSVC runtime" SEC_MSVC
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
||||||
${If} ${RunningX64}
|
${If} ${RunningX64}
|
||||||
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
|
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
|
||||||
@ -155,10 +171,26 @@ Section "MSVC runtime" SEC_MSVC
|
|||||||
SetOutPath $TEMP
|
SetOutPath $TEMP
|
||||||
File "VC_redist.x86.exe"
|
File "VC_redist.x86.exe"
|
||||||
ExecWait '"$TEMP/VC_redist.x86.exe" /install /quiet /norestart'
|
ExecWait '"$TEMP/VC_redist.x86.exe" /install /quiet /norestart'
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
Section "OpenSSL" SEC_OPENSSL
|
||||||
|
|
||||||
|
File "libeay32.dll"
|
||||||
|
File "ssleay32.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "ANGLE" SEC_ANGLE
|
||||||
|
|
||||||
|
File "libGLESv2.dll"
|
||||||
|
File "libEGL.dll"
|
||||||
|
File "D3DCompiler_47.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
; Uninstaller
|
; Uninstaller
|
||||||
@ -201,15 +233,21 @@ SectionEnd
|
|||||||
|
|
||||||
;Language strings
|
;Language strings
|
||||||
LangString DESC_QT ${LANG_ENGLISH} \
|
LangString DESC_QT ${LANG_ENGLISH} \
|
||||||
"QT Library. Unselct only if you have QT already installed!"
|
"QT cross-platform application framework."
|
||||||
LangString DESC_MSVC ${LANG_ENGLISH} \
|
LangString DESC_MSVC ${LANG_ENGLISH} \
|
||||||
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
|
"Visual C++ 2015 runtime components. If already installed, will be skipped."
|
||||||
|
LangString DESC_OPENSSL ${LANG_ENGLISH} \
|
||||||
|
"OpenSSL library. Required for HTTPS to work."
|
||||||
|
LangString DESC_ANGLE ${LANG_ENGLISH} \
|
||||||
|
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
|
||||||
LangString DESC_APP ${LANG_ENGLISH} \
|
LangString DESC_APP ${LANG_ENGLISH} \
|
||||||
"GPXSee application"
|
"GPXSee application"
|
||||||
|
|
||||||
;Assign language strings to sections
|
;Assign language strings to sections
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_OPENSSL} $(DESC_OPENSSL)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
@ -1,10 +1,11 @@
|
|||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "x64.nsh"
|
!include "x64.nsh"
|
||||||
|
!include "WinVer.nsh"
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "3.6"
|
!define VERSION "4.0"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
@ -15,6 +16,14 @@ RequestExecutionLevel admin
|
|||||||
; The default installation directory
|
; The default installation directory
|
||||||
InstallDir "$PROGRAMFILES64\GPXSee"
|
InstallDir "$PROGRAMFILES64\GPXSee"
|
||||||
|
|
||||||
|
; Installer executable info
|
||||||
|
VIProductVersion "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductVersion" ${VERSION}
|
||||||
|
VIAddVersionKey "FileVersion" "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductName" "GPXSee"
|
||||||
|
VIAddVersionKey "LegalCopyright" "GPXSee project"
|
||||||
|
VIAddVersionKey "FileDescription" "GPXSee installer (x64)"
|
||||||
|
|
||||||
; Registry key to check for directory (so if you install again, it will
|
; Registry key to check for directory (so if you install again, it will
|
||||||
; overwrite the old one automatically)
|
; overwrite the old one automatically)
|
||||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||||
@ -56,6 +65,11 @@ Var StartMenuFolder
|
|||||||
!insertmacro MUI_LANGUAGE "English"
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
Function .onInit
|
Function .onInit
|
||||||
|
${IfNot} ${AtLeastWin7}
|
||||||
|
MessageBox MB_OK "GPXSee can only be installed on Windows 7 or later."
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
${If} ${RunningX64}
|
${If} ${RunningX64}
|
||||||
SetRegView 64
|
SetRegView 64
|
||||||
${Else}
|
${Else}
|
||||||
@ -65,7 +79,7 @@ Function .onInit
|
|||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
; The stuff to install
|
; The stuff to install
|
||||||
Section "GPXSee (required)" SEC_APP
|
Section "GPXSee" SEC_APP
|
||||||
|
|
||||||
SectionIn RO
|
SectionIn RO
|
||||||
|
|
||||||
@ -92,7 +106,7 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||||
|
|
||||||
; Write the uninstall keys for Windows
|
; Write the uninstall keys for Windows
|
||||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee (x64)"
|
||||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||||
@ -130,16 +144,15 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "QT libs" SEC_QT
|
Section "QT framework" SEC_QT
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
File "Qt5Core.dll"
|
File "Qt5Core.dll"
|
||||||
File "Qt5Gui.dll"
|
File "Qt5Gui.dll"
|
||||||
File "Qt5Widgets.dll"
|
File "Qt5Widgets.dll"
|
||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "libGLESv2.dll"
|
|
||||||
File "libEGL.dll"
|
|
||||||
File "D3DCompiler_47.dll"
|
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -148,6 +161,8 @@ SectionEnd
|
|||||||
|
|
||||||
Section "MSVC runtime" SEC_MSVC
|
Section "MSVC runtime" SEC_MSVC
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
||||||
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
||||||
StrCmp $R0 "1" 0 +3
|
StrCmp $R0 "1" 0 +3
|
||||||
@ -158,10 +173,26 @@ Section "MSVC runtime" SEC_MSVC
|
|||||||
SetOutPath $TEMP
|
SetOutPath $TEMP
|
||||||
File "VC_redist.x64.exe"
|
File "VC_redist.x64.exe"
|
||||||
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
|
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
Section "OpenSSL" SEC_OPENSSL
|
||||||
|
|
||||||
|
File "libeay32.dll"
|
||||||
|
File "ssleay32.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "ANGLE" SEC_ANGLE
|
||||||
|
|
||||||
|
File "libGLESv2.dll"
|
||||||
|
File "libEGL.dll"
|
||||||
|
File "D3DCompiler_47.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
; Uninstaller
|
; Uninstaller
|
||||||
@ -205,15 +236,21 @@ SectionEnd
|
|||||||
|
|
||||||
;Language strings
|
;Language strings
|
||||||
LangString DESC_QT ${LANG_ENGLISH} \
|
LangString DESC_QT ${LANG_ENGLISH} \
|
||||||
"QT Library. Unselct only if you have QT already installed!"
|
"QT cross-platform application framework."
|
||||||
LangString DESC_MSVC ${LANG_ENGLISH} \
|
LangString DESC_MSVC ${LANG_ENGLISH} \
|
||||||
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
|
"Visual C++ 2015 runtime components. If already installed, will be skipped."
|
||||||
|
LangString DESC_OPENSSL ${LANG_ENGLISH} \
|
||||||
|
"OpenSSL library. Required for HTTPS to work."
|
||||||
|
LangString DESC_ANGLE ${LANG_ENGLISH} \
|
||||||
|
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
|
||||||
LangString DESC_APP ${LANG_ENGLISH} \
|
LangString DESC_APP ${LANG_ENGLISH} \
|
||||||
"GPXSee application"
|
"GPXSee application"
|
||||||
|
|
||||||
;Assign language strings to sections
|
;Assign language strings to sections
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_OPENSSL} $(DESC_OPENSSL)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
@ -1,2 +1,3 @@
|
|||||||
|
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png
|
||||||
Thunderforest http://tile.thunderforest.com/outdoors/$z/$x/$y.png
|
Thunderforest http://tile.thunderforest.com/outdoors/$z/$x/$y.png
|
||||||
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
|
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
|
||||||
|
10
src/app.cpp
10
src/app.cpp
@ -6,23 +6,26 @@
|
|||||||
#include <QPixmapCache>
|
#include <QPixmapCache>
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
#include "onlinemap.h"
|
||||||
|
#include "downloader.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)
|
||||||
{
|
{
|
||||||
_translator = new QTranslator();
|
QTranslator *translator = new QTranslator(this);
|
||||||
|
|
||||||
QString locale = QLocale::system().name();
|
QString locale = QLocale::system().name();
|
||||||
_translator->load(QString(":/lang/gpxsee_") + locale);
|
translator->load(QString(":/lang/gpxsee_") + locale);
|
||||||
installTranslator(_translator);
|
installTranslator(translator);
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
QPixmapCache::setCacheLimit(65536);
|
QPixmapCache::setCacheLimit(65536);
|
||||||
|
OnlineMap::setDownloader(new Downloader(this));
|
||||||
OPENGL_SET_SAMPLES(4);
|
OPENGL_SET_SAMPLES(4);
|
||||||
|
|
||||||
_gui = new GUI();
|
_gui = new GUI();
|
||||||
@ -31,7 +34,6 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
|||||||
App::~App()
|
App::~App()
|
||||||
{
|
{
|
||||||
delete _gui;
|
delete _gui;
|
||||||
delete _translator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::run()
|
void App::run()
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
class GUI;
|
class GUI;
|
||||||
class QTranslator;
|
|
||||||
|
|
||||||
class App : QApplication
|
class App : QApplication
|
||||||
{
|
{
|
||||||
@ -22,7 +21,6 @@ private:
|
|||||||
int &_argc;
|
int &_argc;
|
||||||
char **_argv;
|
char **_argv;
|
||||||
GUI *_gui;
|
GUI *_gui;
|
||||||
QTranslator *_translator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APP_H
|
#endif // APP_H
|
||||||
|
282
src/atlas.cpp
Normal file
282
src/atlas.cpp
Normal file
@ -0,0 +1,282 @@
|
|||||||
|
#include <QDir>
|
||||||
|
#include <QtAlgorithms>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "tar.h"
|
||||||
|
#include "atlas.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define ZOOM_THRESHOLD 0.9
|
||||||
|
|
||||||
|
#define TL(m) ((m)->xy2pp((m)->bounds().topLeft()))
|
||||||
|
#define BR(m) ((m)->xy2pp((m)->bounds().bottomRight()))
|
||||||
|
|
||||||
|
static bool resCmp(const OfflineMap *m1, const OfflineMap *m2)
|
||||||
|
{
|
||||||
|
qreal r1, r2;
|
||||||
|
|
||||||
|
r1 = m1->resolution(m1->bounds().center());
|
||||||
|
r2 = m2->resolution(m2->bounds().center());
|
||||||
|
|
||||||
|
return r1 > r2;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool xCmp(const OfflineMap *m1, const OfflineMap *m2)
|
||||||
|
{
|
||||||
|
return TL(m1).x() < TL(m2).x();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool yCmp(const OfflineMap *m1, const OfflineMap *m2)
|
||||||
|
{
|
||||||
|
return TL(m1).y() > TL(m2).y();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Atlas::isAtlas(const QFileInfoList &files)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < files.count(); i++) {
|
||||||
|
const QString &fileName = files.at(i).fileName();
|
||||||
|
if (fileName.endsWith(".tar")) {
|
||||||
|
if (!_tar.load(files.at(i).absoluteFilePath())) {
|
||||||
|
qWarning("%s: %s: error loading tar file", qPrintable(_name),
|
||||||
|
qPrintable(fileName));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QStringList tarFiles = _tar.files();
|
||||||
|
for (int j = 0; j < tarFiles.size(); j++)
|
||||||
|
if (tarFiles.at(j).endsWith(".tba"))
|
||||||
|
return true;
|
||||||
|
} else if (fileName.endsWith(".tba"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Atlas::computeZooms()
|
||||||
|
{
|
||||||
|
qSort(_maps.begin(), _maps.end(), resCmp);
|
||||||
|
|
||||||
|
_zooms.append(QPair<int, int>(0, _maps.count() - 1));
|
||||||
|
for (int i = 1; i < _maps.count(); i++) {
|
||||||
|
qreal last = _maps.at(i-1)->resolution(_maps.at(i)->bounds().center());
|
||||||
|
qreal cur = _maps.at(i)->resolution(_maps.at(i)->bounds().center());
|
||||||
|
if (cur < last * ZOOM_THRESHOLD) {
|
||||||
|
_zooms.last().second = i-1;
|
||||||
|
_zooms.append(QPair<int, int>(i, _maps.count() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Atlas::computeBounds()
|
||||||
|
{
|
||||||
|
QList<QPointF> offsets;
|
||||||
|
|
||||||
|
for (int i = 0; i < _maps.count(); i++)
|
||||||
|
offsets.append(QPointF());
|
||||||
|
|
||||||
|
for (int z = 0; z < _zooms.count(); z++) {
|
||||||
|
qreal w = 0, h = 0;
|
||||||
|
|
||||||
|
QList<OfflineMap*> m;
|
||||||
|
for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++)
|
||||||
|
m.append(_maps.at(i));
|
||||||
|
|
||||||
|
qSort(m.begin(), m.end(), xCmp);
|
||||||
|
offsets[_maps.indexOf(m.first())].setX(w);
|
||||||
|
for (int i = 1; i < m.size(); i++) {
|
||||||
|
if (TL(m.at(i)).x() > TL(m.at(i-1)).x()) {
|
||||||
|
w += round(m.at(i-1)->pp2xy(TL(m.at(i))).x());
|
||||||
|
offsets[_maps.indexOf(m.at(i))].setX(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qSort(m.begin(), m.end(), yCmp);
|
||||||
|
offsets[_maps.indexOf(m.first())].setY(h);
|
||||||
|
for (int i = 1; i < m.size(); i++) {
|
||||||
|
if (TL(m.at(i)).y() < TL(m.at(i-1)).y()) {
|
||||||
|
h += round(m.at(i-1)->pp2xy(TL(m.at(i))).y());
|
||||||
|
offsets[_maps.indexOf(m.at(i))].setY(h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _maps.count(); i++)
|
||||||
|
_bounds.append(QPair<QRectF, QRectF>(QRectF(TL(_maps.at(i)),
|
||||||
|
BR(_maps.at(i))), QRectF(offsets.at(i), _maps.at(i)->bounds().size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
Atlas::Atlas(const QString &path, QObject *parent) : Map(parent)
|
||||||
|
{
|
||||||
|
_valid = false;
|
||||||
|
|
||||||
|
QFileInfo fi(path);
|
||||||
|
_name = fi.fileName();
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
QFileInfoList files = dir.entryInfoList(QDir::Files);
|
||||||
|
if (!isAtlas(files))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QFileInfoList layers = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
for (int n = 0; n < layers.count(); n++) {
|
||||||
|
QDir zdir(layers.at(n).absoluteFilePath());
|
||||||
|
QFileInfoList maps = zdir.entryInfoList(QDir::Dirs
|
||||||
|
| QDir::NoDotAndDotDot);
|
||||||
|
for (int i = 0; i < maps.count(); i++) {
|
||||||
|
OfflineMap *map;
|
||||||
|
if (_tar.isOpen())
|
||||||
|
map = new OfflineMap(_tar, maps.at(i).absoluteFilePath(), this);
|
||||||
|
else
|
||||||
|
map = new OfflineMap(maps.at(i).absoluteFilePath(), this);
|
||||||
|
if (map->isValid())
|
||||||
|
_maps.append(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_maps.isEmpty()) {
|
||||||
|
qWarning("%s: No usable maps available", qPrintable(_name));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
computeZooms();
|
||||||
|
computeBounds();
|
||||||
|
|
||||||
|
_zoom = 0;
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Atlas::~Atlas()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _maps.size(); i++)
|
||||||
|
delete _maps.at(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF Atlas::bounds() const
|
||||||
|
{
|
||||||
|
QSizeF s(0, 0);
|
||||||
|
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
if (_bounds.at(i).second.right() > s.width())
|
||||||
|
s.setWidth(_bounds.at(i).second.right());
|
||||||
|
if (_bounds.at(i).second.bottom() > s.height())
|
||||||
|
s.setHeight(_bounds.at(i).second.bottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
return QRectF(QPointF(0, 0), s);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal Atlas::resolution(const QPointF &p) const
|
||||||
|
{
|
||||||
|
int idx = _zooms.at(_zoom).first;
|
||||||
|
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
if (_bounds.at(i).second.contains(_maps.at(i)->xy2pp(p))) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _maps.at(idx)->resolution(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal Atlas::zoom() const
|
||||||
|
{
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal Atlas::zoomFit(const QSize &size, const QRectF &br)
|
||||||
|
{
|
||||||
|
_zoom = 0;
|
||||||
|
|
||||||
|
for (int z = 0; z < _zooms.count(); z++) {
|
||||||
|
for (int i = _zooms.at(z).first; i <= _zooms.at(z).second; i++) {
|
||||||
|
if (_bounds.at(i).first.contains(_maps.at(i)->ll2pp(br.center())))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
QRect sbr = QRectF(_maps.at(i)->ll2xy(br.topLeft()),
|
||||||
|
_maps.at(i)->ll2xy(br.bottomRight())).toRect().normalized();
|
||||||
|
|
||||||
|
if (sbr.size().width() > size.width()
|
||||||
|
|| sbr.size().height() > size.height())
|
||||||
|
return _zoom;
|
||||||
|
|
||||||
|
_zoom = z;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal Atlas::zoomIn()
|
||||||
|
{
|
||||||
|
_zoom = qMin(_zoom + 1, _zooms.size() - 1);
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal Atlas::zoomOut()
|
||||||
|
{
|
||||||
|
_zoom = qMax(_zoom - 1, 0);
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF Atlas::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
int idx = _zooms.at(_zoom).first;
|
||||||
|
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
if (_bounds.at(i).first.contains(_maps.at(i)->ll2pp(c))) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF p = _maps.at(idx)->ll2xy(c);
|
||||||
|
return p + _bounds.at(idx).second.topLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Atlas::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
int idx = _zooms.at(_zoom).first;
|
||||||
|
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
if (_bounds.at(i).second.contains(_maps.at(i)->xy2pp(p))) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF p2 = p - _bounds.at(idx).second.topLeft();
|
||||||
|
return _maps.at(idx)->xy2ll(p2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Atlas::draw(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
// All in one map
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
QRectF ir = rect.intersected(_bounds.at(i).second);
|
||||||
|
if (ir == rect) {
|
||||||
|
draw(painter, rect, i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiple maps
|
||||||
|
painter->fillRect(rect, Qt::white);
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
QRectF ir = rect.intersected(_bounds.at(i).second);
|
||||||
|
if (!ir.isNull())
|
||||||
|
draw(painter, ir, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Atlas::draw(QPainter *painter, const QRectF &rect, int mapIndex)
|
||||||
|
{
|
||||||
|
OfflineMap *map = _maps.at(mapIndex);
|
||||||
|
const QPointF offset = _bounds.at(mapIndex).second.topLeft();
|
||||||
|
QRectF pr = QRectF(rect.topLeft() - offset, rect.size());
|
||||||
|
|
||||||
|
map->load();
|
||||||
|
|
||||||
|
painter->translate(offset);
|
||||||
|
map->draw(painter, pr);
|
||||||
|
painter->translate(-offset);
|
||||||
|
}
|
50
src/atlas.h
Normal file
50
src/atlas.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#ifndef ATLAS_H
|
||||||
|
#define ATLAS_H
|
||||||
|
|
||||||
|
#include <QFileInfoList>
|
||||||
|
#include "map.h"
|
||||||
|
#include "offlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Atlas : public Map
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Atlas(const QString &path, QObject *parent = 0);
|
||||||
|
~Atlas();
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
QRectF bounds() const;
|
||||||
|
qreal resolution(const QPointF &p) const;
|
||||||
|
|
||||||
|
qreal zoom() const;
|
||||||
|
qreal zoomFit(const QSize &size, const QRectF &br);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
bool isValid() {return _valid;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void draw(QPainter *painter, const QRectF &rect, int mapIndex);
|
||||||
|
bool isAtlas(const QFileInfoList &files);
|
||||||
|
void computeZooms();
|
||||||
|
void computeBounds();
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
bool _valid;
|
||||||
|
|
||||||
|
Tar _tar;
|
||||||
|
QList<OfflineMap*> _maps;
|
||||||
|
QVector<QPair<int, int> > _zooms;
|
||||||
|
QVector<QPair<QRectF, QRectF> > _bounds;
|
||||||
|
int _zoom;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ATLAS_H
|
@ -14,6 +14,7 @@
|
|||||||
#define SCREEN_DPI 96.0
|
#define SCREEN_DPI 96.0
|
||||||
|
|
||||||
#define MAP_FILE QString("maps.txt")
|
#define MAP_FILE QString("maps.txt")
|
||||||
|
#define MAP_DIR QString("maps")
|
||||||
#define POI_DIR QString("POI")
|
#define POI_DIR QString("POI")
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
@ -28,8 +29,10 @@
|
|||||||
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define USER_MAP_DIR USER_DIR + QString("/") + MAP_DIR
|
||||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
||||||
|
#define GLOBAL_MAP_DIR GLOBAL_DIR + QString("/") + MAP_DIR
|
||||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
||||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
||||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
#define TILES_DIR USER_DIR + QString("/tiles")
|
||||||
|
@ -17,27 +17,12 @@ qreal Coordinates::distanceTo(const Coordinates &c) const
|
|||||||
return (WGS84_RADIUS * (2.0 * atan2(sqrt(a), sqrt(1.0 - a))));
|
return (WGS84_RADIUS * (2.0 * atan2(sqrt(a), sqrt(1.0 - a))));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF Coordinates::toMercator() const
|
|
||||||
{
|
|
||||||
return QPointF(_lon, rad2deg(log(tan(M_PI/4.0 + deg2rad(_lat)/2.0))));
|
|
||||||
}
|
|
||||||
|
|
||||||
Coordinates Coordinates::fromMercator(const QPointF &m)
|
|
||||||
{
|
|
||||||
return Coordinates(m.x(), rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Coordinates &c1, const Coordinates &c2)
|
|
||||||
{
|
|
||||||
return (c1.lat() == c2.lat() && c1.lon() == c2.lon());
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
||||||
<< coordinates.lat() << ")";
|
<< coordinates.lat() << ")";
|
||||||
|
|
||||||
return dbg.maybeSpace();
|
return dbg.space();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
||||||
@ -64,6 +49,7 @@ QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
|||||||
maxLon = MAX_LON;
|
maxLon = MAX_LON;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPair<Coordinates, Coordinates>(Coordinates(rad2deg(minLon),
|
return QPair<Coordinates, Coordinates>(Coordinates(rad2deg(qMin(minLon,
|
||||||
rad2deg(minLat)), Coordinates(rad2deg(maxLon), rad2deg(maxLat)));
|
maxLon)), rad2deg(qMin(minLat, maxLat))), Coordinates(rad2deg(qMax(minLon,
|
||||||
|
maxLon)), rad2deg(qMax(minLat, maxLat))));
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,9 @@ public:
|
|||||||
Coordinates(const Coordinates &c) {_lon = c._lon; _lat = c._lat;}
|
Coordinates(const Coordinates &c) {_lon = c._lon; _lat = c._lat;}
|
||||||
Coordinates(qreal lon, qreal lat) {_lon = lon; _lat = lat;}
|
Coordinates(qreal lon, qreal lat) {_lon = lon; _lat = lat;}
|
||||||
|
|
||||||
|
Coordinates(const QPointF &p) {_lon = p.x(), _lat = p.y();}
|
||||||
|
QPointF toPointF() const {return QPointF(_lon, _lat);}
|
||||||
|
|
||||||
qreal &rlon() {return _lon;}
|
qreal &rlon() {return _lon;}
|
||||||
qreal &rlat() {return _lat;}
|
qreal &rlat() {return _lat;}
|
||||||
void setLon(qreal lon) {_lon = lon;}
|
void setLon(qreal lon) {_lon = lon;}
|
||||||
@ -28,14 +31,14 @@ public:
|
|||||||
qreal distanceTo(const Coordinates &c) const;
|
qreal distanceTo(const Coordinates &c) const;
|
||||||
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
||||||
|
|
||||||
QPointF toMercator() const;
|
|
||||||
static Coordinates fromMercator(const QPointF &m);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal _lat, _lon;
|
qreal _lat, _lon;
|
||||||
};
|
};
|
||||||
|
|
||||||
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());}
|
||||||
|
inline bool operator!=(const Coordinates &c1, const Coordinates &c2)
|
||||||
|
{return !(c1 == c2);}
|
||||||
QDebug operator<<(QDebug dbg, const Coordinates &trackpoint);
|
QDebug operator<<(QDebug dbg, const Coordinates &trackpoint);
|
||||||
|
|
||||||
#endif // COORDINATES_H
|
#endif // COORDINATES_H
|
||||||
|
@ -82,9 +82,9 @@ bool Data::loadFile(const QString &fileName)
|
|||||||
file.reset();
|
file.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Error loading data file: %s:\n", qPrintable(fileName));
|
qWarning("Error loading data file: %s:\n", qPrintable(fileName));
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
fprintf(stderr, "%s: line %d: %s\n", qPrintable(it.key()),
|
qWarning("%s: line %d: %s\n", qPrintable(it.key()),
|
||||||
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||||
|
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
|
|
||||||
@ -25,7 +27,7 @@
|
|||||||
#define MAX_REDIRECT_LEVEL 5
|
#define MAX_REDIRECT_LEVEL 5
|
||||||
|
|
||||||
|
|
||||||
Downloader::Downloader()
|
Downloader::Downloader(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(downloadFinished(QNetworkReply*)));
|
SLOT(downloadFinished(QNetworkReply*)));
|
||||||
@ -59,7 +61,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)) {
|
||||||
fprintf(stderr, "Error writing map tile: %s: %s\n",
|
qWarning("Error writing map tile: %s: %s\n",
|
||||||
qPrintable(filename), qPrintable(file.errorString()));
|
qPrintable(filename), qPrintable(file.errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -78,11 +80,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
|||||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||||
if (origin.isEmpty()) {
|
if (origin.isEmpty()) {
|
||||||
_errorDownloads.insert(url);
|
_errorDownloads.insert(url);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
qWarning("Error downloading map tile: %s: %s\n",
|
||||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||||
} else {
|
} else {
|
||||||
_errorDownloads.insert(origin);
|
_errorDownloads.insert(origin);
|
||||||
fprintf(stderr, "Error downloading map tile: %s -> %s: %s\n",
|
qWarning("Error downloading map tile: %s -> %s: %s\n",
|
||||||
origin.toEncoded().constData(), url.toEncoded().constData(),
|
origin.toEncoded().constData(), url.toEncoded().constData(),
|
||||||
qPrintable(reply->errorString()));
|
qPrintable(reply->errorString()));
|
||||||
}
|
}
|
||||||
@ -97,11 +99,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
|||||||
|
|
||||||
if (location == url) {
|
if (location == url) {
|
||||||
_errorDownloads.insert(url);
|
_errorDownloads.insert(url);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: "
|
qWarning("Error downloading map tile: %s: "
|
||||||
"redirect loop\n", url.toEncoded().constData());
|
"redirect loop\n", url.toEncoded().constData());
|
||||||
} else if (level >= MAX_REDIRECT_LEVEL) {
|
} else if (level >= MAX_REDIRECT_LEVEL) {
|
||||||
_errorDownloads.insert(origin);
|
_errorDownloads.insert(origin);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: "
|
qWarning("Error downloading map tile: %s: "
|
||||||
"redirect level limit reached\n",
|
"redirect level limit reached\n",
|
||||||
origin.toEncoded().constData());
|
origin.toEncoded().constData());
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,13 +2,14 @@
|
|||||||
#define DOWNLOADER_H
|
#define DOWNLOADER_H
|
||||||
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
|
||||||
class Download
|
class Download
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -28,8 +29,8 @@ class Downloader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Downloader& instance()
|
Downloader(QObject *parent = 0);
|
||||||
{static Downloader i; return i;}
|
|
||||||
bool get(const QList<Download> &list);
|
bool get(const QList<Download> &list);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -56,10 +57,6 @@ private:
|
|||||||
int _level;
|
int _level;
|
||||||
};
|
};
|
||||||
|
|
||||||
Downloader();
|
|
||||||
Downloader(Downloader const&);
|
|
||||||
void operator=(Downloader const&);
|
|
||||||
|
|
||||||
bool doDownload(const Download &dl, const Redirect &redirect = Redirect());
|
bool doDownload(const Download &dl, const Redirect &redirect = Redirect());
|
||||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||||
|
|
||||||
|
77
src/emptymap.cpp
Normal file
77
src/emptymap.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
#include <QtGlobal>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "misc.h"
|
||||||
|
#include "rd.h"
|
||||||
|
#include "wgs84.h"
|
||||||
|
#include "coordinates.h"
|
||||||
|
#include "mercator.h"
|
||||||
|
#include "emptymap.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define SCALE_MIN 0.5
|
||||||
|
#define SCALE_MAX 1.0E-6
|
||||||
|
|
||||||
|
EmptyMap::EmptyMap(QObject *parent) : Map(parent)
|
||||||
|
{
|
||||||
|
_scale = SCALE_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF EmptyMap::bounds() const
|
||||||
|
{
|
||||||
|
return scaled(QRectF(QPointF(-180, -180), QSizeF(360, 360)), 1.0/_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal EmptyMap::zoomFit(const QSize &size, const QRectF &br)
|
||||||
|
{
|
||||||
|
if (br.isNull())
|
||||||
|
_scale = SCALE_MAX;
|
||||||
|
else {
|
||||||
|
Coordinates topLeft(br.topLeft());
|
||||||
|
Coordinates bottomRight(br.bottomRight());
|
||||||
|
QRectF tbr(Mercator().ll2xy(topLeft), Mercator().ll2xy(bottomRight));
|
||||||
|
|
||||||
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
|
|
||||||
|
_scale = qMax(sc.x(), sc.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
_scale = qMax(_scale, SCALE_MAX);
|
||||||
|
_scale = qMin(_scale, SCALE_MIN);
|
||||||
|
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal EmptyMap::resolution(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return (WGS84_RADIUS * 2 * M_PI * _scale / 360.0
|
||||||
|
* cos(2.0 * atan(exp(deg2rad(-p.y() * _scale))) - M_PI/2));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal EmptyMap::zoomIn()
|
||||||
|
{
|
||||||
|
_scale = qMax(_scale / 2.0, SCALE_MAX);
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal EmptyMap::zoomOut()
|
||||||
|
{
|
||||||
|
_scale = qMin(_scale * 2.0, SCALE_MIN);
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
painter->fillRect(rect, Qt::white);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF EmptyMap::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
QPointF m = Mercator().ll2xy(c);
|
||||||
|
return QPointF(m.x() / _scale, m.y() / -_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates EmptyMap::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
QPointF m(p.x() * _scale, -p.y() * _scale);
|
||||||
|
return Mercator().xy2ll(m);
|
||||||
|
}
|
33
src/emptymap.h
Normal file
33
src/emptymap.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef EMPTYMAP_H
|
||||||
|
#define EMPTYMAP_H
|
||||||
|
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
class EmptyMap : public Map
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
EmptyMap(QObject *parent = 0);
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
QRectF bounds() const;
|
||||||
|
qreal resolution(const QPointF &p) const;
|
||||||
|
|
||||||
|
qreal zoom() const {return _scale;}
|
||||||
|
qreal zoomFit(const QSize &size, const QRectF &br);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _name;
|
||||||
|
qreal _scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EMPTYMAP_H
|
@ -36,8 +36,7 @@ void FITParser::clearDefinitions()
|
|||||||
void FITParser::warning(const char *text) const
|
void FITParser::warning(const char *text) const
|
||||||
{
|
{
|
||||||
const QFile *file = static_cast<QFile *>(_device);
|
const QFile *file = static_cast<QFile *>(_device);
|
||||||
fprintf(stderr, "%s:%d: %s\n", qPrintable(file->fileName()),
|
qWarning("%s:%d: %s\n", qPrintable(file->fileName()), _len, text);
|
||||||
_len, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::readData(char *data, size_t size)
|
bool FITParser::readData(char *data, size_t size)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "timetype.h"
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
@ -18,10 +19,11 @@ public:
|
|||||||
|
|
||||||
virtual QString label() const = 0;
|
virtual QString label() const = 0;
|
||||||
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() {}
|
||||||
virtual void setUnits(enum Units units) = 0;
|
virtual void setUnits(enum Units units) {Q_UNUSED(units)}
|
||||||
virtual void showTracks(bool show) = 0;
|
virtual void setTimeType(enum TimeType type) {Q_UNUSED(type)}
|
||||||
virtual void showRoutes(bool show) = 0;
|
virtual void showTracks(bool show) {Q_UNUSED(show)}
|
||||||
|
virtual void showRoutes(bool show) {Q_UNUSED(show)}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHTAB_H
|
#endif // GRAPHTAB_H
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QPaintDevice>
|
#include <QPaintDevice>
|
||||||
#include <QSysInfo>
|
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
@ -25,6 +24,7 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
_scene = new QGraphicsScene(this);
|
_scene = new QGraphicsScene(this);
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
|
|
||||||
|
setBackgroundBrush(QBrush(Qt::white));
|
||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
setRenderHint(QPainter::Antialiasing, true);
|
setRenderHint(QPainter::Antialiasing, true);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@ -458,11 +458,8 @@ void GraphView::setGraphWidth(int width)
|
|||||||
|
|
||||||
void GraphView::useOpenGL(bool use)
|
void GraphView::useOpenGL(bool use)
|
||||||
{
|
{
|
||||||
if (use) {
|
if (use)
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
|
||||||
#endif // Q_OS_WIN32
|
|
||||||
setViewport(new OPENGL_WIDGET);
|
setViewport(new OPENGL_WIDGET);
|
||||||
} else
|
else
|
||||||
setViewport(new QWidget);
|
setViewport(new QWidget);
|
||||||
}
|
}
|
||||||
|
222
src/gui.cpp
222
src/gui.cpp
@ -28,6 +28,8 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
|
#include "mapdir.h"
|
||||||
|
#include "emptymap.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
#include "speedgraph.h"
|
#include "speedgraph.h"
|
||||||
#include "heartrategraph.h"
|
#include "heartrategraph.h"
|
||||||
@ -43,7 +45,7 @@
|
|||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
|
|
||||||
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
GUI::GUI()
|
||||||
{
|
{
|
||||||
loadMaps();
|
loadMaps();
|
||||||
loadPOIs();
|
loadPOIs();
|
||||||
@ -78,6 +80,7 @@ GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
|||||||
_trackDistance = 0;
|
_trackDistance = 0;
|
||||||
_routeDistance = 0;
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
|
_movingTime = 0;
|
||||||
|
|
||||||
_sliderPos = 0;
|
_sliderPos = 0;
|
||||||
|
|
||||||
@ -116,10 +119,21 @@ void GUI::createBrowser()
|
|||||||
|
|
||||||
void GUI::loadMaps()
|
void GUI::loadMaps()
|
||||||
{
|
{
|
||||||
|
QList<Map*> online, offline;
|
||||||
|
|
||||||
if (QFile::exists(USER_MAP_FILE))
|
if (QFile::exists(USER_MAP_FILE))
|
||||||
_maps = MapList::load(this, USER_MAP_FILE);
|
online = MapList::load(USER_MAP_FILE, this);
|
||||||
else
|
else
|
||||||
_maps = MapList::load(this, GLOBAL_MAP_FILE);
|
online = MapList::load(GLOBAL_MAP_FILE, this);
|
||||||
|
|
||||||
|
if (QFile::exists(USER_MAP_DIR))
|
||||||
|
offline = MapDir::load(USER_MAP_DIR, this);
|
||||||
|
else
|
||||||
|
offline = MapDir::load(GLOBAL_MAP_DIR, this);
|
||||||
|
|
||||||
|
_maps = online + offline;
|
||||||
|
|
||||||
|
_map = _maps.isEmpty() ? new EmptyMap(this) : _maps.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::loadPOIs()
|
void GUI::loadPOIs()
|
||||||
@ -137,11 +151,11 @@ void GUI::loadPOIs()
|
|||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
if (!_poi->loadFile(list.at(i).absoluteFilePath())) {
|
if (!_poi->loadFile(list.at(i).absoluteFilePath())) {
|
||||||
fprintf(stderr, "Error loading POI file: %s: %s\n",
|
qWarning("Error loading POI file: %s: %s\n",
|
||||||
qPrintable(list.at(i).fileName()),
|
qPrintable(list.at(i).fileName()),
|
||||||
qPrintable(_poi->errorString()));
|
qPrintable(_poi->errorString()));
|
||||||
if (_poi->errorLine())
|
if (_poi->errorLine())
|
||||||
fprintf(stderr, "Line: %d\n", _poi->errorLine());
|
qWarning("Line: %d\n", _poi->errorLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,7 +291,8 @@ void GUI::createActions()
|
|||||||
this);
|
this);
|
||||||
_showMapAction->setCheckable(true);
|
_showMapAction->setCheckable(true);
|
||||||
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
|
_showMapAction->setShortcut(SHOW_MAP_SHORTCUT);
|
||||||
connect(_showMapAction, SIGNAL(triggered(bool)), this, SLOT(showMap(bool)));
|
connect(_showMapAction, SIGNAL(triggered(bool)), _pathView,
|
||||||
|
SLOT(showMap(bool)));
|
||||||
addAction(_showMapAction);
|
addAction(_showMapAction);
|
||||||
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
||||||
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
|
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
|
||||||
@ -356,6 +371,18 @@ void GUI::createActions()
|
|||||||
SLOT(showToolbars(bool)));
|
SLOT(showToolbars(bool)));
|
||||||
ag = new QActionGroup(this);
|
ag = new QActionGroup(this);
|
||||||
ag->setExclusive(true);
|
ag->setExclusive(true);
|
||||||
|
_totalTimeAction = new QAction(tr("Total time"), this);
|
||||||
|
_totalTimeAction->setCheckable(true);
|
||||||
|
_totalTimeAction->setActionGroup(ag);
|
||||||
|
connect(_totalTimeAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setTotalTime()));
|
||||||
|
_movingTimeAction = new QAction(tr("Moving time"), this);
|
||||||
|
_movingTimeAction->setCheckable(true);
|
||||||
|
_movingTimeAction->setActionGroup(ag);
|
||||||
|
connect(_movingTimeAction, SIGNAL(triggered()), this,
|
||||||
|
SLOT(setMovingTime()));
|
||||||
|
ag = new QActionGroup(this);
|
||||||
|
ag->setExclusive(true);
|
||||||
_metricUnitsAction = new QAction(tr("Metric"), this);
|
_metricUnitsAction = new QAction(tr("Metric"), this);
|
||||||
_metricUnitsAction->setCheckable(true);
|
_metricUnitsAction->setCheckable(true);
|
||||||
_metricUnitsAction->setActionGroup(ag);
|
_metricUnitsAction->setActionGroup(ag);
|
||||||
@ -447,6 +474,9 @@ void GUI::createMenus()
|
|||||||
dataMenu->addAction(_showWaypointsAction);
|
dataMenu->addAction(_showWaypointsAction);
|
||||||
|
|
||||||
QMenu *settingsMenu = menuBar()->addMenu(tr("Settings"));
|
QMenu *settingsMenu = menuBar()->addMenu(tr("Settings"));
|
||||||
|
QMenu *timeMenu = settingsMenu->addMenu(tr("Time"));
|
||||||
|
timeMenu->addAction(_totalTimeAction);
|
||||||
|
timeMenu->addAction(_movingTimeAction);
|
||||||
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||||
unitsMenu->addAction(_metricUnitsAction);
|
unitsMenu->addAction(_metricUnitsAction);
|
||||||
unitsMenu->addAction(_imperialUnitsAction);
|
unitsMenu->addAction(_imperialUnitsAction);
|
||||||
@ -489,15 +519,13 @@ void GUI::createToolBars()
|
|||||||
|
|
||||||
void GUI::createPathView()
|
void GUI::createPathView()
|
||||||
{
|
{
|
||||||
_pathView = new PathView(this);
|
_pathView = new PathView(_map, _poi, this);
|
||||||
_pathView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
_pathView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
||||||
QSizePolicy::Expanding));
|
QSizePolicy::Expanding));
|
||||||
_pathView->setMinimumHeight(200);
|
_pathView->setMinimumHeight(200);
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
_pathView->setFrameShape(QFrame::NoFrame);
|
_pathView->setFrameShape(QFrame::NoFrame);
|
||||||
#endif // Q_OS_WIN32
|
#endif // Q_OS_WIN32
|
||||||
|
|
||||||
_pathView->setPOI(_poi);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::createGraphTabs()
|
void GUI::createGraphTabs()
|
||||||
@ -544,15 +572,13 @@ void GUI::about()
|
|||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
|
|
||||||
msgBox.setWindowTitle(tr("About GPXSee"));
|
msgBox.setWindowTitle(tr("About GPXSee"));
|
||||||
msgBox.setText(QString("<h2>") + QString(APP_NAME) + QString("</h2><p>")
|
msgBox.setText("<h2>" + QString(APP_NAME) + "</h2><p><p>" + tr("Version ")
|
||||||
+ QString("<p>") + tr("Version ") + APP_VERSION + QString(" (")
|
+ APP_VERSION + " (" + CPU_ARCH + ", Qt " + QT_VERSION_STR + ")</p>");
|
||||||
+ CPU_ARCH + QString(", Qt ") + QString(QT_VERSION_STR)
|
msgBox.setInformativeText("<table width=\"300\"><tr><td>"
|
||||||
+ QString(")</p>"));
|
|
||||||
msgBox.setInformativeText(QString("<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 ") + QString("<a href=\"" APP_HOMEPAGE "\">" APP_HOMEPAGE
|
"homepage at ") + "<a href=\"" + APP_HOMEPAGE + "\">" + APP_HOMEPAGE
|
||||||
"</a>.</td></tr></table>"));
|
+ "</a>.</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));
|
||||||
@ -566,20 +592,20 @@ void GUI::keys()
|
|||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
|
|
||||||
msgBox.setWindowTitle(tr("Keyboard controls"));
|
msgBox.setWindowTitle(tr("Keyboard controls"));
|
||||||
msgBox.setText(QString("<h3>") + tr("Keyboard controls") + QString("</h3>"));
|
msgBox.setText("<h3>" + tr("Keyboard controls") + "</h3>");
|
||||||
msgBox.setInformativeText(
|
msgBox.setInformativeText(
|
||||||
QString("<div><table width=\"300\"><tr><td>") + tr("Next file")
|
"<div><table width=\"300\"><tr><td>" + tr("Next file")
|
||||||
+ QString("</td><td><i>SPACE</i></td></tr><tr><td>") + tr("Previous file")
|
+ "</td><td><i>" + QKeySequence(NEXT_KEY).toString()
|
||||||
+ QString("</td><td><i>BACKSPACE</i></td></tr><tr><td>")
|
+ "</i></td></tr><tr><td>" + tr("Previous file")
|
||||||
+ tr("First file") + QString("</td><td><i>HOME</i></td></tr><tr><td>")
|
+ "</td><td><i>" + QKeySequence(PREV_KEY).toString()
|
||||||
+ tr("Last file") + QString("</td><td><i>END</i></td></tr><tr><td>")
|
+ "</i></td></tr><tr><td>" + tr("First file") + "</td><td><i>"
|
||||||
+ tr("Append modifier") + QString("</td><td><i>SHIFT</i></td></tr>"
|
+ QKeySequence(FIRST_KEY).toString() + "</i></td></tr><tr><td>"
|
||||||
"<tr><td></td><td></td></tr><tr><td>")
|
+ tr("Last file") + "</td><td><i>" + QKeySequence(LAST_KEY).toString()
|
||||||
+ tr("Next map") + QString("</td><td><i>")
|
+ "</i></td></tr><tr><td>" + tr("Append modifier")
|
||||||
+ _nextMapAction->shortcut().toString() + QString("</i></td></tr><tr><td>")
|
+ "</td><td><i>SHIFT</i></td></tr><tr><td></td><td></td></tr><tr><td>"
|
||||||
+ tr("Previous map") + QString("</td><td><i>")
|
+ tr("Next map") + "</td><td><i>" + NEXT_MAP_SHORTCUT.toString()
|
||||||
+ _prevMapAction->shortcut().toString() + QString("</i></td></tr>"
|
+ "</i></td></tr><tr><td>" + tr("Previous map") + "</td><td><i>"
|
||||||
"</table></div>"));
|
+ PREV_MAP_SHORTCUT.toString() + "</i></td></tr></table></div>");
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
@ -589,23 +615,31 @@ void GUI::dataSources()
|
|||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
|
|
||||||
msgBox.setWindowTitle(tr("Data sources"));
|
msgBox.setWindowTitle(tr("Data sources"));
|
||||||
msgBox.setText(QString("<h3>") + tr("Data sources") + QString("</h3>"));
|
msgBox.setText("<h3>" + tr("Data sources") + "</h3>");
|
||||||
msgBox.setInformativeText(
|
msgBox.setInformativeText(
|
||||||
QString("<h4>") + tr("Map sources") + QString("</h4><p>")
|
"<h4>" + tr("Online maps") + "</h4><p>"
|
||||||
+ tr("Map (tiles) source URLs are read on program startup from the "
|
+ tr("Online map URLs are read on program startup from the "
|
||||||
"following file:")
|
"following file:")
|
||||||
+ QString("</p><p><code>") + USER_MAP_FILE + QString("</code></p><p>")
|
+ "</p><p><code>" + USER_MAP_FILE + "</code></p><p>"
|
||||||
+ tr("The file format is one map entry per line, consisting of the map "
|
+ tr("The file format is one map entry per line, consisting of the map "
|
||||||
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
"name and tiles URL delimited by a TAB character. The tile X and Y "
|
||||||
"coordinates are replaced with $x and $y in the URL and the zoom "
|
"coordinates are replaced with $x and $y in the URL and the zoom "
|
||||||
"level is replaced with $z. An example map file could look like:")
|
"level is replaced with $z. An example map file could look like:")
|
||||||
+ QString("</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
+ "</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
||||||
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>")
|
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>"
|
||||||
|
|
||||||
+ QString("<h4>") + tr("POIs") + QString("</h4><p>")
|
+ "<h4>" + tr("Ofline maps") + "</h4><p>"
|
||||||
|
+ tr("Offline maps are loaded on program startup from the following "
|
||||||
|
"directory:")
|
||||||
|
+ "</p><p><code>" + USER_MAP_DIR + "</code></p><p>"
|
||||||
|
+ tr("The expected structure is one map/atlas in a separate subdirectory."
|
||||||
|
" Supported map formats are OziMap image-based maps and tiled TrekBuddy"
|
||||||
|
" maps/atlases (tared and non-tared).") + "</p>"
|
||||||
|
|
||||||
|
+ "<h4>" + tr("POIs") + "</h4><p>"
|
||||||
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
+ tr("To make GPXSee load a POI file automatically on startup, add "
|
||||||
"the file to the following directory:")
|
"the file to the following directory:")
|
||||||
+ QString("</p><p><code>") + USER_POI_DIR + QString("</code></p>")
|
+ "</p><p><code>" + USER_POI_DIR + "</code></p>"
|
||||||
);
|
);
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
@ -661,6 +695,7 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
_trackDistance += data.tracks().at(i)->distance();
|
_trackDistance += data.tracks().at(i)->distance();
|
||||||
_time += data.tracks().at(i)->time();
|
_time += data.tracks().at(i)->time();
|
||||||
|
_movingTime += data.tracks().at(i)->movingTime();
|
||||||
const QDate &date = data.tracks().at(i)->date().date();
|
const QDate &date = data.tracks().at(i)->date().date();
|
||||||
if (_dateRange.first.isNull() || _dateRange.first > date)
|
if (_dateRange.first.isNull() || _dateRange.first > date)
|
||||||
_dateRange.first = date;
|
_dateRange.first = date;
|
||||||
@ -679,7 +714,7 @@ bool GUI::loadFile(const QString &fileName)
|
|||||||
if (data.tracks().count() == 1 && !data.routes().count())
|
if (data.tracks().count() == 1 && !data.routes().count())
|
||||||
_pathName = data.tracks().first()->name();
|
_pathName = data.tracks().first()->name();
|
||||||
else if (data.routes().count() == 1 && !data.tracks().count())
|
else if (data.routes().count() == 1 && !data.tracks().count())
|
||||||
_pathName = data.routes().first()->routeData().name();
|
_pathName = data.routes().first()->name();
|
||||||
} else
|
} else
|
||||||
_pathName = QString();
|
_pathName = QString();
|
||||||
|
|
||||||
@ -822,9 +857,9 @@ void GUI::plot(QPrinter *printer)
|
|||||||
QPainter p(printer);
|
QPainter p(printer);
|
||||||
TrackInfo info;
|
TrackInfo info;
|
||||||
qreal ih, gh, mh, ratio;
|
qreal ih, gh, mh, ratio;
|
||||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
|
||||||
qreal d = distance();
|
qreal d = distance();
|
||||||
qreal t = time();
|
qreal t = time();
|
||||||
|
qreal tm = movingTime();
|
||||||
|
|
||||||
if (!_pathName.isNull() && _options.printName)
|
if (!_pathName.isNull() && _options.printName)
|
||||||
info.insert(tr("Name"), _pathName);
|
info.insert(tr("Name"), _pathName);
|
||||||
@ -851,9 +886,11 @@ void GUI::plot(QPrinter *printer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (d > 0 && _options.printDistance)
|
if (d > 0 && _options.printDistance)
|
||||||
info.insert(tr("Distance"), Format::distance(d, units));
|
info.insert(tr("Distance"), Format::distance(d, units()));
|
||||||
if (t > 0 && _options.printTime)
|
if (t > 0 && _options.printTime)
|
||||||
info.insert(tr("Time"), Format::timeSpan(t));
|
info.insert(tr("Time"), Format::timeSpan(t));
|
||||||
|
if (tm > 0 && _options.printMovingTime)
|
||||||
|
info.insert(tr("Moving time"), Format::timeSpan(tm));
|
||||||
|
|
||||||
|
|
||||||
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
ratio = p.paintEngine()->paintDevice()->logicalDpiX() / SCREEN_DPI;
|
||||||
@ -908,6 +945,7 @@ void GUI::reloadFile()
|
|||||||
_trackDistance = 0;
|
_trackDistance = 0;
|
||||||
_routeDistance = 0;
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
|
_movingTime = 0;
|
||||||
_dateRange = DateRange(QDate(), QDate());
|
_dateRange = DateRange(QDate(), QDate());
|
||||||
_pathName = QString();
|
_pathName = QString();
|
||||||
|
|
||||||
@ -942,6 +980,7 @@ void GUI::closeFiles()
|
|||||||
_trackDistance = 0;
|
_trackDistance = 0;
|
||||||
_routeDistance = 0;
|
_routeDistance = 0;
|
||||||
_time = 0;
|
_time = 0;
|
||||||
|
_movingTime = 0;
|
||||||
_dateRange = DateRange(QDate(), QDate());
|
_dateRange = DateRange(QDate(), QDate());
|
||||||
_pathName = QString();
|
_pathName = QString();
|
||||||
|
|
||||||
@ -965,14 +1004,6 @@ void GUI::closeAll()
|
|||||||
updatePathView();
|
updatePathView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::showMap(bool show)
|
|
||||||
{
|
|
||||||
if (show)
|
|
||||||
_pathView->setMap(_currentMap);
|
|
||||||
else
|
|
||||||
_pathView->setMap(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::showGraphs(bool show)
|
void GUI::showGraphs(bool show)
|
||||||
{
|
{
|
||||||
_graphTabWidget->setHidden(!show);
|
_graphTabWidget->setHidden(!show);
|
||||||
@ -1050,55 +1081,60 @@ void GUI::showGraphGrids(bool show)
|
|||||||
|
|
||||||
void GUI::clearMapCache()
|
void GUI::clearMapCache()
|
||||||
{
|
{
|
||||||
_currentMap->clearCache();
|
_map->clearCache();
|
||||||
_pathView->redraw();
|
_pathView->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateStatusBarInfo()
|
void GUI::updateStatusBarInfo()
|
||||||
{
|
{
|
||||||
if (_files.count() == 0)
|
if (_files.count() == 0)
|
||||||
_fileNameLabel->setText(tr("No GPX files loaded"));
|
_fileNameLabel->setText(tr("No files loaded"));
|
||||||
else if (_files.count() == 1)
|
else if (_files.count() == 1)
|
||||||
_fileNameLabel->setText(_files.at(0));
|
_fileNameLabel->setText(_files.at(0));
|
||||||
else
|
else
|
||||||
_fileNameLabel->setText(tr("%n files", "", _files.count()));
|
_fileNameLabel->setText(tr("%n files", "", _files.count()));
|
||||||
|
|
||||||
qreal d = distance();
|
if (distance() > 0)
|
||||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
_distanceLabel->setText(Format::distance(distance(), units()));
|
||||||
if (d > 0)
|
|
||||||
_distanceLabel->setText(Format::distance(distance(), units));
|
|
||||||
else
|
else
|
||||||
_distanceLabel->clear();
|
_distanceLabel->clear();
|
||||||
|
|
||||||
qreal t = time();
|
if (time() > 0) {
|
||||||
if (t > 0)
|
if (_movingTimeAction->isChecked()) {
|
||||||
_timeLabel->setText(Format::timeSpan(time()));
|
_timeLabel->setText(Format::timeSpan(movingTime())
|
||||||
else
|
+ "<sub>M</sub>");
|
||||||
|
_timeLabel->setToolTip(Format::timeSpan(time()));
|
||||||
|
} else {
|
||||||
|
_timeLabel->setText(Format::timeSpan(time()));
|
||||||
|
_timeLabel->setToolTip(Format::timeSpan(movingTime())
|
||||||
|
+ "<sub>M</sub>");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
_timeLabel->clear();
|
_timeLabel->clear();
|
||||||
|
_timeLabel->setToolTip(QString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::updateWindowTitle()
|
void GUI::updateWindowTitle()
|
||||||
{
|
{
|
||||||
if (_files.count() == 1)
|
if (_files.count() == 1)
|
||||||
setWindowTitle(QFileInfo(_files.at(0)).fileName()
|
setWindowTitle(QFileInfo(_files.at(0)).fileName() + " - " + APP_NAME);
|
||||||
+ QString(" - " APP_NAME));
|
|
||||||
else
|
else
|
||||||
setWindowTitle(APP_NAME);
|
setWindowTitle(APP_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::mapChanged(int index)
|
void GUI::mapChanged(int index)
|
||||||
{
|
{
|
||||||
_currentMap = _maps.at(index);
|
_map = _maps.at(index);
|
||||||
|
_pathView->setMap(_map);
|
||||||
if (_showMapAction->isChecked())
|
|
||||||
_pathView->setMap(_currentMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::nextMap()
|
void GUI::nextMap()
|
||||||
{
|
{
|
||||||
if (_maps.count() < 2)
|
if (_maps.count() < 2)
|
||||||
return;
|
return;
|
||||||
int next = (_maps.indexOf(_currentMap) + 1) % _maps.count();
|
|
||||||
|
int next = (_maps.indexOf(_map) + 1) % _maps.count();
|
||||||
_mapActions.at(next)->setChecked(true);
|
_mapActions.at(next)->setChecked(true);
|
||||||
mapChanged(next);
|
mapChanged(next);
|
||||||
}
|
}
|
||||||
@ -1107,7 +1143,8 @@ void GUI::prevMap()
|
|||||||
{
|
{
|
||||||
if (_maps.count() < 2)
|
if (_maps.count() < 2)
|
||||||
return;
|
return;
|
||||||
int prev = (_maps.indexOf(_currentMap) + _maps.count() - 1) % _maps.count();
|
|
||||||
|
int prev = (_maps.indexOf(_map) + _maps.count() - 1) % _maps.count();
|
||||||
_mapActions.at(prev)->setChecked(true);
|
_mapActions.at(prev)->setChecked(true);
|
||||||
mapChanged(prev);
|
mapChanged(prev);
|
||||||
}
|
}
|
||||||
@ -1184,6 +1221,14 @@ void GUI::updatePathView()
|
|||||||
+ _pathView->waypointCount()));
|
+ _pathView->waypointCount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::setTimeType(TimeType type)
|
||||||
|
{
|
||||||
|
for (int i = 0; i <_tabs.count(); i++)
|
||||||
|
_tabs.at(i)->setTimeType(type);
|
||||||
|
|
||||||
|
updateStatusBarInfo();
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::setUnits(Units units)
|
void GUI::setUnits(Units units)
|
||||||
{
|
{
|
||||||
_export.units = units;
|
_export.units = units;
|
||||||
@ -1319,6 +1364,10 @@ void GUI::writeSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||||
|
if ((_movingTimeAction->isChecked() ? Moving : Total) !=
|
||||||
|
TIME_TYPE_DEFAULT)
|
||||||
|
settings.setValue(TIME_TYPE_SETTING, _movingTimeAction->isChecked()
|
||||||
|
? Moving : Total);
|
||||||
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
|
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
|
||||||
UNITS_DEFAULT)
|
UNITS_DEFAULT)
|
||||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||||
@ -1329,8 +1378,7 @@ void GUI::writeSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||||
if (_currentMap)
|
settings.setValue(CURRENT_MAP_SETTING, _map->name());
|
||||||
settings.setValue(CURRENT_MAP_SETTING, _currentMap->name());
|
|
||||||
if (_showMapAction->isChecked() != SHOW_MAP_DEFAULT)
|
if (_showMapAction->isChecked() != SHOW_MAP_DEFAULT)
|
||||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
@ -1429,6 +1477,8 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(PRINT_DISTANCE_SETTING, _options.printDistance);
|
settings.setValue(PRINT_DISTANCE_SETTING, _options.printDistance);
|
||||||
if (_options.printTime != PRINT_TIME_DEFAULT)
|
if (_options.printTime != PRINT_TIME_DEFAULT)
|
||||||
settings.setValue(PRINT_TIME_SETTING, _options.printTime);
|
settings.setValue(PRINT_TIME_SETTING, _options.printTime);
|
||||||
|
if (_options.printMovingTime != PRINT_MOVING_TIME_DEFAULT)
|
||||||
|
settings.setValue(PRINT_MOVING_TIME_SETTING, _options.printMovingTime);
|
||||||
if (_options.printItemCount != PRINT_ITEM_COUNT_DEFAULT)
|
if (_options.printItemCount != PRINT_ITEM_COUNT_DEFAULT)
|
||||||
settings.setValue(PRINT_ITEM_COUNT_SETTING, _options.printItemCount);
|
settings.setValue(PRINT_ITEM_COUNT_SETTING, _options.printItemCount);
|
||||||
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
|
if (_options.separateGraphPage != SEPARATE_GRAPH_PAGE_DEFAULT)
|
||||||
@ -1447,6 +1497,14 @@ void GUI::readSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
settings.beginGroup(SETTINGS_SETTINGS_GROUP);
|
||||||
|
if (settings.value(TIME_TYPE_SETTING, TIME_TYPE_DEFAULT).toInt()
|
||||||
|
== Moving) {
|
||||||
|
setTimeType(Moving);
|
||||||
|
_movingTimeAction->setChecked(true);
|
||||||
|
} else {
|
||||||
|
setTimeType(Total);
|
||||||
|
_totalTimeAction->setChecked(true);
|
||||||
|
}
|
||||||
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
|
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
|
||||||
setUnits(Imperial);
|
setUnits(Imperial);
|
||||||
_imperialUnitsAction->setChecked(true);
|
_imperialUnitsAction->setChecked(true);
|
||||||
@ -1466,11 +1524,9 @@ void GUI::readSettings()
|
|||||||
if (_maps.count()) {
|
if (_maps.count()) {
|
||||||
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
||||||
_mapActions.at(index)->setChecked(true);
|
_mapActions.at(index)->setChecked(true);
|
||||||
_currentMap = _maps.at(index);
|
_map = _maps.at(index);
|
||||||
if (_showMapAction->isChecked())
|
_pathView->setMap(_map);
|
||||||
_pathView->setMap(_currentMap);
|
}
|
||||||
} else
|
|
||||||
_currentMap = 0;
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||||
@ -1598,6 +1654,8 @@ void GUI::readSettings()
|
|||||||
PRINT_DISTANCE_DEFAULT).toBool();
|
PRINT_DISTANCE_DEFAULT).toBool();
|
||||||
_options.printTime = settings.value(PRINT_TIME_SETTING, PRINT_TIME_DEFAULT)
|
_options.printTime = settings.value(PRINT_TIME_SETTING, PRINT_TIME_DEFAULT)
|
||||||
.toBool();
|
.toBool();
|
||||||
|
_options.printMovingTime = settings.value(PRINT_MOVING_TIME_SETTING,
|
||||||
|
PRINT_MOVING_TIME_DEFAULT).toBool();
|
||||||
_options.printItemCount = settings.value(PRINT_ITEM_COUNT_SETTING,
|
_options.printItemCount = settings.value(PRINT_ITEM_COUNT_SETTING,
|
||||||
PRINT_ITEM_COUNT_DEFAULT).toBool();
|
PRINT_ITEM_COUNT_DEFAULT).toBool();
|
||||||
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
|
_options.separateGraphPage = settings.value(SEPARATE_GRAPH_PAGE_SETTING,
|
||||||
@ -1635,6 +1693,11 @@ int GUI::mapIndex(const QString &name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Units GUI::units() const
|
||||||
|
{
|
||||||
|
return _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||||
|
}
|
||||||
|
|
||||||
qreal GUI::distance() const
|
qreal GUI::distance() const
|
||||||
{
|
{
|
||||||
qreal dist = 0;
|
qreal dist = 0;
|
||||||
@ -1651,3 +1714,8 @@ qreal GUI::time() const
|
|||||||
{
|
{
|
||||||
return (_showTracksAction->isChecked()) ? _time : 0;
|
return (_showTracksAction->isChecked()) ? _time : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal GUI::movingTime() const
|
||||||
|
{
|
||||||
|
return (_showTracksAction->isChecked()) ? _movingTime : 0;
|
||||||
|
}
|
||||||
|
15
src/gui.h
15
src/gui.h
@ -7,6 +7,7 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "timetype.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
@ -30,7 +31,7 @@ class GUI : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GUI(QWidget *parent = 0);
|
GUI();
|
||||||
~GUI();
|
~GUI();
|
||||||
|
|
||||||
bool openFile(const QString &fileName);
|
bool openFile(const QString &fileName);
|
||||||
@ -46,7 +47,6 @@ private slots:
|
|||||||
void reloadFile();
|
void reloadFile();
|
||||||
void openPOIFile();
|
void openPOIFile();
|
||||||
void closePOIFiles();
|
void closePOIFiles();
|
||||||
void showMap(bool show);
|
|
||||||
void showGraphs(bool show);
|
void showGraphs(bool show);
|
||||||
void showGraphGrids(bool show);
|
void showGraphGrids(bool show);
|
||||||
void showToolbars(bool show);
|
void showToolbars(bool show);
|
||||||
@ -67,6 +67,8 @@ private slots:
|
|||||||
void last();
|
void last();
|
||||||
void first();
|
void first();
|
||||||
|
|
||||||
|
void setTotalTime() {setTimeType(Total);}
|
||||||
|
void setMovingTime() {setTimeType(Moving);}
|
||||||
void setMetricUnits() {setUnits(Metric);}
|
void setMetricUnits() {setUnits(Metric);}
|
||||||
void setImperialUnits() {setUnits(Imperial);}
|
void setImperialUnits() {setUnits(Imperial);}
|
||||||
void setDistanceGraph() {setGraphType(Distance);}
|
void setDistanceGraph() {setGraphType(Distance);}
|
||||||
@ -102,11 +104,15 @@ private:
|
|||||||
void updateGraphTabs();
|
void updateGraphTabs();
|
||||||
void updatePathView();
|
void updatePathView();
|
||||||
|
|
||||||
|
TimeType timeType() const;
|
||||||
|
Units units() const;
|
||||||
|
void setTimeType(TimeType type);
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
qreal time() const;
|
qreal time() const;
|
||||||
|
qreal movingTime() const;
|
||||||
int mapIndex(const QString &name);
|
int mapIndex(const QString &name);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
@ -154,6 +160,8 @@ private:
|
|||||||
QAction *_firstAction;
|
QAction *_firstAction;
|
||||||
QAction *_metricUnitsAction;
|
QAction *_metricUnitsAction;
|
||||||
QAction *_imperialUnitsAction;
|
QAction *_imperialUnitsAction;
|
||||||
|
QAction *_totalTimeAction;
|
||||||
|
QAction *_movingTimeAction;
|
||||||
QAction *_nextMapAction;
|
QAction *_nextMapAction;
|
||||||
QAction *_prevMapAction;
|
QAction *_prevMapAction;
|
||||||
QAction *_showTracksAction;
|
QAction *_showTracksAction;
|
||||||
@ -180,14 +188,15 @@ private:
|
|||||||
|
|
||||||
FileBrowser *_browser;
|
FileBrowser *_browser;
|
||||||
QList<QString> _files;
|
QList<QString> _files;
|
||||||
Map *_currentMap;
|
|
||||||
|
|
||||||
|
Map *_map;
|
||||||
int _trackCount;
|
int _trackCount;
|
||||||
int _routeCount;
|
int _routeCount;
|
||||||
int _waypointCount;
|
int _waypointCount;
|
||||||
qreal _trackDistance;
|
qreal _trackDistance;
|
||||||
qreal _routeDistance;
|
qreal _routeDistance;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
|
qreal _movingTime;
|
||||||
DateRange _dateRange;
|
DateRange _dateRange;
|
||||||
QString _pathName;
|
QString _pathName;
|
||||||
|
|
||||||
|
@ -13,9 +13,7 @@ public:
|
|||||||
QString label() const {return tr("Heart rate");}
|
QString label() const {return tr("Heart rate");}
|
||||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units) {}
|
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
|
@ -78,6 +78,7 @@ void InfoItem::insert(const QString &key, const QString &value)
|
|||||||
_list[i] = kv;
|
_list[i] = kv;
|
||||||
|
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoItem::clear()
|
void InfoItem::clear()
|
||||||
|
12
src/keys.h
12
src/keys.h
@ -10,15 +10,15 @@
|
|||||||
#define LAST_KEY Qt::Key_End
|
#define LAST_KEY Qt::Key_End
|
||||||
#define MODIFIER Qt::ShiftModifier
|
#define MODIFIER Qt::ShiftModifier
|
||||||
|
|
||||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
||||||
#define OPEN_SHORTCUT QKeySequence::Open
|
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
||||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
#define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close)
|
||||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
#define RELOAD_SHORTCUT QKeySequence(QKeySequence::Refresh)
|
||||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
|
||||||
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
|
||||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||||
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
|
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
|
||||||
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
|
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
|
||||||
|
15
src/latlon.h
Normal file
15
src/latlon.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef LATLON_H
|
||||||
|
#define LATLON_H
|
||||||
|
|
||||||
|
#include "projection.h"
|
||||||
|
|
||||||
|
class LatLon : public Projection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const
|
||||||
|
{return c.toPointF();}
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const
|
||||||
|
{return Coordinates(p);}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LATLON_H
|
134
src/map.cpp
134
src/map.cpp
@ -1,134 +0,0 @@
|
|||||||
#include <QFileInfo>
|
|
||||||
#include <QDir>
|
|
||||||
#include "downloader.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include "map.h"
|
|
||||||
|
|
||||||
|
|
||||||
Map::Map(QObject *parent, const QString &name, const QString &url)
|
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
_name = name;
|
|
||||||
_url = url;
|
|
||||||
|
|
||||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
|
||||||
SLOT(emitLoaded()));
|
|
||||||
|
|
||||||
QString path = TILES_DIR + QString("/") + _name;
|
|
||||||
if (!QDir().mkpath(path))
|
|
||||||
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::emitLoaded()
|
|
||||||
{
|
|
||||||
emit loaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::loadTiles(QList<Tile> &list, bool block)
|
|
||||||
{
|
|
||||||
if (block)
|
|
||||||
loadTilesSync(list);
|
|
||||||
else
|
|
||||||
loadTilesAsync(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::loadTilesAsync(QList<Tile> &list)
|
|
||||||
{
|
|
||||||
QList<Download> dl;
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
QString file = tileFile(t);
|
|
||||||
QFileInfo fi(file);
|
|
||||||
|
|
||||||
if (!fi.exists()) {
|
|
||||||
fillTile(t);
|
|
||||||
dl.append(Download(tileUrl(t), file));
|
|
||||||
} else
|
|
||||||
loadTileFile(t, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dl.empty())
|
|
||||||
Downloader::instance().get(dl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::loadTilesSync(QList<Tile> &list)
|
|
||||||
{
|
|
||||||
QList<Download> dl;
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
QString file = tileFile(t);
|
|
||||||
QFileInfo fi(file);
|
|
||||||
|
|
||||||
if (!fi.exists())
|
|
||||||
dl.append(Download(tileUrl(t), file));
|
|
||||||
else
|
|
||||||
loadTileFile(t, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dl.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QEventLoop wait;
|
|
||||||
connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit()));
|
|
||||||
if (Downloader::instance().get(dl))
|
|
||||||
wait.exec();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
|
|
||||||
if (t.pixmap().isNull()) {
|
|
||||||
QString file = tileFile(t);
|
|
||||||
QFileInfo fi(file);
|
|
||||||
|
|
||||||
if (!(fi.exists() && loadTileFile(t, file)))
|
|
||||||
fillTile(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::fillTile(Tile &tile)
|
|
||||||
{
|
|
||||||
tile.pixmap() = QPixmap(Tile::size(), Tile::size());
|
|
||||||
tile.pixmap().fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Map::loadTileFile(Tile &tile, const QString &file)
|
|
||||||
{
|
|
||||||
if (!tile.pixmap().load(file)) {
|
|
||||||
fprintf(stderr, "%s: error loading tile file\n", qPrintable(file));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Map::tileUrl(const Tile &tile)
|
|
||||||
{
|
|
||||||
QString url(_url);
|
|
||||||
|
|
||||||
url.replace("$z", QString::number(tile.zoom()));
|
|
||||||
url.replace("$x", QString::number(tile.xy().x()));
|
|
||||||
url.replace("$y", QString::number(tile.xy().y()));
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Map::tileFile(const Tile &tile)
|
|
||||||
{
|
|
||||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(_name)
|
|
||||||
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::clearCache()
|
|
||||||
{
|
|
||||||
QString path = TILES_DIR + QString("/") + _name;
|
|
||||||
QDir dir = QDir(path);
|
|
||||||
QStringList list = dir.entryList();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.count(); i++)
|
|
||||||
dir.remove(list.at(i));
|
|
||||||
}
|
|
47
src/map.h
47
src/map.h
@ -1,37 +1,42 @@
|
|||||||
#ifndef MAP_H
|
#ifndef MAP_H
|
||||||
#define MAP_H
|
#define MAP_H
|
||||||
|
|
||||||
#include "tile.h"
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QRectF>
|
||||||
|
|
||||||
|
class QPainter;
|
||||||
|
class Coordinates;
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Map(QObject *parent = 0, const QString &name = QString(),
|
Map(QObject *parent = 0) : QObject(parent) {}
|
||||||
const QString &url = QString());
|
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
virtual const QString &name() const = 0;
|
||||||
void loadTiles(QList<Tile> &list, bool block);
|
|
||||||
void clearCache();
|
virtual QRectF bounds() const = 0;
|
||||||
|
virtual qreal resolution(const QPointF &p) const = 0;
|
||||||
|
|
||||||
|
virtual qreal zoom() const = 0;
|
||||||
|
virtual qreal zoomFit(const QSize &size, const QRectF &br) = 0;
|
||||||
|
virtual qreal zoomIn() = 0;
|
||||||
|
virtual qreal zoomOut() = 0;
|
||||||
|
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const = 0;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const = 0;
|
||||||
|
|
||||||
|
virtual void draw(QPainter *painter, const QRectF &rect) = 0;
|
||||||
|
|
||||||
|
virtual void setBlockingMode(bool block) {Q_UNUSED(block);}
|
||||||
|
virtual void clearCache() {}
|
||||||
|
virtual void load() {}
|
||||||
|
virtual void unload() {}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loaded();
|
void loaded();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void emitLoaded();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString tileUrl(const Tile &tile);
|
|
||||||
QString tileFile(const Tile &tile);
|
|
||||||
bool loadTileFile(Tile &tile, const QString &file);
|
|
||||||
void fillTile(Tile &tile);
|
|
||||||
|
|
||||||
void loadTilesAsync(QList<Tile> &list);
|
|
||||||
void loadTilesSync(QList<Tile> &list);
|
|
||||||
|
|
||||||
QString _name;
|
|
||||||
QString _url;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAP_H
|
#endif // MAP_H
|
||||||
|
40
src/mapdir.cpp
Normal file
40
src/mapdir.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include <QDir>
|
||||||
|
#include "atlas.h"
|
||||||
|
#include "offlinemap.h"
|
||||||
|
#include "mapdir.h"
|
||||||
|
|
||||||
|
QList<Map*> MapDir::load(const QString &path, QObject *parent)
|
||||||
|
{
|
||||||
|
QList<Map*> maps;
|
||||||
|
QDir dir(path);
|
||||||
|
|
||||||
|
|
||||||
|
if (!dir.exists())
|
||||||
|
return maps;
|
||||||
|
|
||||||
|
if (!dir.isReadable()) {
|
||||||
|
qWarning("Map directory not readable: %s\n", qPrintable(path));
|
||||||
|
return maps;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
QFileInfo fileInfo = list.at(i);
|
||||||
|
|
||||||
|
Atlas *atlas = new Atlas(fileInfo.absoluteFilePath(), parent);
|
||||||
|
if (atlas->isValid())
|
||||||
|
maps.append(atlas);
|
||||||
|
else {
|
||||||
|
delete atlas;
|
||||||
|
|
||||||
|
OfflineMap *map = new OfflineMap(fileInfo.absoluteFilePath(),
|
||||||
|
parent);
|
||||||
|
if (map->isValid())
|
||||||
|
maps.append(map);
|
||||||
|
else
|
||||||
|
delete map;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return maps;
|
||||||
|
}
|
16
src/mapdir.h
Normal file
16
src/mapdir.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef MAPDIR_H
|
||||||
|
#define MAPDIR_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class QObject;
|
||||||
|
class Map;
|
||||||
|
|
||||||
|
class MapDir
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static QList<Map*> load(const QString &path, QObject *parent = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MAPDIR_H
|
@ -1,23 +1,23 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "map.h"
|
#include "onlinemap.h"
|
||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
|
|
||||||
|
|
||||||
QList<Map*> MapList::load(QObject *parent, const QString &fileName)
|
QList<Map*> MapList::load(const QString &fileName, QObject *parent)
|
||||||
{
|
{
|
||||||
QList<Map*> mapList;
|
QList<Map*> maps;
|
||||||
QFileInfo fi(fileName);
|
QFileInfo fi(fileName);
|
||||||
|
|
||||||
if (!fi.exists())
|
if (!fi.exists())
|
||||||
return mapList;
|
return maps;
|
||||||
|
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
fprintf(stderr, "Error opening map list file: %s: %s\n",
|
qWarning("Error opening map list file: %s: %s\n",
|
||||||
qPrintable(fileName), qPrintable(file.errorString()));
|
qPrintable(fileName), qPrintable(file.errorString()));
|
||||||
return mapList;
|
return maps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ln = 0;
|
int ln = 0;
|
||||||
@ -26,16 +26,16 @@ QList<Map*> MapList::load(QObject *parent, const QString &fileName)
|
|||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
QList<QByteArray> list = line.split('\t');
|
QList<QByteArray> list = line.split('\t');
|
||||||
if (list.size() != 2) {
|
if (list.size() != 2) {
|
||||||
fprintf(stderr, "Invalid map list entry on line %d\n", ln);
|
qWarning("Invalid map list entry on line %d\n", ln);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ba1 = list[0].trimmed();
|
QByteArray ba1 = list[0].trimmed();
|
||||||
QByteArray ba2 = list[1].trimmed();
|
QByteArray ba2 = list[1].trimmed();
|
||||||
|
|
||||||
mapList.append(new Map(parent, QString::fromUtf8(ba1.data(), ba1.size()),
|
maps.append(new OnlineMap(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||||
QString::fromLatin1(ba2.data(), ba2.size())));
|
QString::fromLatin1(ba2.data(), ba2.size()), parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapList;
|
return maps;
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,14 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
|
class QObject;
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
class MapList
|
class MapList
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QList<Map*> load(QObject *parent = 0,
|
static QList<Map*> load(const QString &fileName, QObject *parent = 0);
|
||||||
const QString &fileName = QString());
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPLIST_H
|
#endif // MAPLIST_H
|
||||||
|
117
src/matrix.cpp
Normal file
117
src/matrix.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define abs(x) ((x)<0 ? -(x) : (x))
|
||||||
|
|
||||||
|
Matrix::~Matrix()
|
||||||
|
{
|
||||||
|
if (isNull())
|
||||||
|
return;
|
||||||
|
|
||||||
|
delete[] _m;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix::Matrix(size_t h, size_t w)
|
||||||
|
{
|
||||||
|
_h = h; _w = w;
|
||||||
|
|
||||||
|
if (isNull())
|
||||||
|
_m = 0;
|
||||||
|
else
|
||||||
|
_m = new double[_h * _w];
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix::Matrix(const Matrix& M)
|
||||||
|
{
|
||||||
|
_h = M._h; _w = M._w;
|
||||||
|
|
||||||
|
if (isNull())
|
||||||
|
_m = 0;
|
||||||
|
else
|
||||||
|
_m = new double[_h * _w];
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _h; i++)
|
||||||
|
for (size_t j = 0; j < _w; j++)
|
||||||
|
m(i,j) = M.m(i,j);
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix &Matrix::operator=(const Matrix &M)
|
||||||
|
{
|
||||||
|
if (_h != M._h || _w != M._w) {
|
||||||
|
if (!isNull())
|
||||||
|
delete[] _m;
|
||||||
|
|
||||||
|
_h = M._h; _w = M._w;
|
||||||
|
if (isNull())
|
||||||
|
_m = 0;
|
||||||
|
else
|
||||||
|
_m = new double[_h * _w];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _h; i++)
|
||||||
|
for (size_t j = 0; j < _w; j++)
|
||||||
|
m(i,j) = M.m(i,j);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Matrix::eliminate(double epsilon)
|
||||||
|
{
|
||||||
|
size_t i, j, k, maxrow;
|
||||||
|
double temp;
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < _h; i++) {
|
||||||
|
maxrow = i;
|
||||||
|
for (j = i+1; j < _h; j++)
|
||||||
|
if (abs(m(j, i)) > abs(m(maxrow, i)))
|
||||||
|
maxrow = j;
|
||||||
|
for (j = 0; j < _w; j++) {
|
||||||
|
temp = m(i, j);
|
||||||
|
m(i, j) = m(maxrow, j);
|
||||||
|
m(maxrow, j) = temp;
|
||||||
|
}
|
||||||
|
if (abs(m(i, i)) <= epsilon)
|
||||||
|
return false;
|
||||||
|
for (j = i+1; j<_h; j++) {
|
||||||
|
temp = m(j, i) / m(i, i);
|
||||||
|
for (k = i; k < _w; k++)
|
||||||
|
m(j, k) -= m(i, k) * temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = _h-1; i < i+1; i--) {
|
||||||
|
temp = m(i, i);
|
||||||
|
for (j = 0; j < i; j++)
|
||||||
|
for (k = _w-1; k >= i; k--)
|
||||||
|
m(j, k) -= m(i, k) * m(j, i) / temp;
|
||||||
|
m(i, i) /= temp;
|
||||||
|
for (j = _h; j < _w; j++)
|
||||||
|
m(i, j) /= temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix Matrix::augemented(const Matrix &M) const
|
||||||
|
{
|
||||||
|
if (_h != M._h)
|
||||||
|
return Matrix();
|
||||||
|
|
||||||
|
Matrix A(_h, _w + M._w);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _h; i++)
|
||||||
|
for (size_t j = 0; j < _w; j++)
|
||||||
|
A.m(i, j) = m(i, j);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < _h; i++)
|
||||||
|
for (size_t j = _w; j < A._w; j++)
|
||||||
|
A.m(i, j) = M.m(i, j-_w);
|
||||||
|
|
||||||
|
return A;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Matrix::zeroize()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < _h * _w; i++)
|
||||||
|
_m[i] = 0;
|
||||||
|
}
|
33
src/matrix.h
Normal file
33
src/matrix.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef MATRIX_H
|
||||||
|
#define MATRIX_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cfloat>
|
||||||
|
|
||||||
|
class Matrix {
|
||||||
|
public:
|
||||||
|
Matrix() {_h = 0; _w = 0; _m = 0;}
|
||||||
|
Matrix(size_t h, size_t w);
|
||||||
|
Matrix(const Matrix& M);
|
||||||
|
~Matrix();
|
||||||
|
|
||||||
|
Matrix &operator=(const Matrix &M);
|
||||||
|
|
||||||
|
size_t h() const {return _h;}
|
||||||
|
size_t w() const {return _w;}
|
||||||
|
double &m(size_t i, size_t j) {return _m[_w * i + j];}
|
||||||
|
double const &m(size_t i, size_t j) const {return _m[_w * i + j];}
|
||||||
|
|
||||||
|
bool isNull() const {return (_h == 0 || _w == 0);}
|
||||||
|
|
||||||
|
void zeroize();
|
||||||
|
bool eliminate(double epsilon = DBL_EPSILON);
|
||||||
|
Matrix augemented(const Matrix &M) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
double *_m;
|
||||||
|
size_t _h;
|
||||||
|
size_t _w;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MATRIX_H
|
13
src/mercator.cpp
Normal file
13
src/mercator.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include "rd.h"
|
||||||
|
#include "mercator.h"
|
||||||
|
|
||||||
|
QPointF Mercator::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
return QPointF(c.lon(), rad2deg(log(tan(M_PI/4.0 + deg2rad(c.lat())/2.0))));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Mercator::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return Coordinates(p.x(), rad2deg(2 * atan(exp(deg2rad(p.y()))) - M_PI/2));
|
||||||
|
}
|
13
src/mercator.h
Normal file
13
src/mercator.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MERCATOR_H
|
||||||
|
#define MERCATOR_H
|
||||||
|
|
||||||
|
#include "projection.h"
|
||||||
|
|
||||||
|
class Mercator : public Projection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MERCATOR_H
|
@ -48,3 +48,9 @@ int str2int(const char *str, int len)
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF scaled(const QRectF &rect, qreal factor)
|
||||||
|
{
|
||||||
|
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
||||||
|
QSizeF(rect.width() * factor, rect.height() * factor));
|
||||||
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#ifndef MISC_H
|
#ifndef MISC_H
|
||||||
#define MISC_H
|
#define MISC_H
|
||||||
|
|
||||||
|
#include <QRectF>
|
||||||
|
|
||||||
double niceNum(double x, int round);
|
double niceNum(double x, int round);
|
||||||
int str2int(const char *str, int len);
|
int str2int(const char *str, int len);
|
||||||
|
QRectF scaled(const QRectF &rect, qreal factor);
|
||||||
|
|
||||||
#endif // MISC_H
|
#endif // MISC_H
|
||||||
|
578
src/offlinemap.cpp
Normal file
578
src/offlinemap.cpp
Normal file
@ -0,0 +1,578 @@
|
|||||||
|
#include <QtGlobal>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QBuffer>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QImageReader>
|
||||||
|
#include <QPixmapCache>
|
||||||
|
#include "misc.h"
|
||||||
|
#include "rd.h"
|
||||||
|
#include "wgs84.h"
|
||||||
|
#include "coordinates.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
#include "latlon.h"
|
||||||
|
#include "mercator.h"
|
||||||
|
#include "transversemercator.h"
|
||||||
|
#include "utm.h"
|
||||||
|
#include "offlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
|
int OfflineMap::parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||||
|
QString &projection, ProjectionSetup &setup)
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
int ln = 1;
|
||||||
|
|
||||||
|
|
||||||
|
if (!device.open(QIODevice::ReadOnly))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
while (!device.atEnd()) {
|
||||||
|
QByteArray line = device.readLine();
|
||||||
|
|
||||||
|
if (ln == 1) {
|
||||||
|
if (!line.trimmed().startsWith("OziExplorer Map Data File"))
|
||||||
|
return ln;
|
||||||
|
} else if (ln == 3)
|
||||||
|
_imgPath = line.trimmed();
|
||||||
|
else {
|
||||||
|
QList<QByteArray> list = line.split(',');
|
||||||
|
QString key(list.at(0).trimmed());
|
||||||
|
bool ll = true; bool pp = true;
|
||||||
|
|
||||||
|
if (key.startsWith("Point") && list.count() == 17
|
||||||
|
&& !list.at(2).trimmed().isEmpty()) {
|
||||||
|
int x = list.at(2).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
return ln;
|
||||||
|
int y = list.at(3).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
return ln;
|
||||||
|
|
||||||
|
int latd = list.at(6).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
ll = false;
|
||||||
|
qreal latm = list.at(7).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
ll = false;
|
||||||
|
int lond = list.at(9).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
ll = false;
|
||||||
|
qreal lonm = list.at(10).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
ll = false;
|
||||||
|
if (ll && list.at(8).trimmed() == "S")
|
||||||
|
latd = -latd;
|
||||||
|
if (ll && list.at(11).trimmed() == "W")
|
||||||
|
lond = -lond;
|
||||||
|
|
||||||
|
int zone = list.at(13).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
zone = 0;
|
||||||
|
qreal ppx = list.at(14).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
pp = false;
|
||||||
|
qreal ppy = list.at(15).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
pp = false;
|
||||||
|
if (list.at(16).trimmed() == "S")
|
||||||
|
zone = -zone;
|
||||||
|
|
||||||
|
ReferencePoint p;
|
||||||
|
p.xy = QPoint(x, y);
|
||||||
|
if (ll) {
|
||||||
|
p.ll = Coordinates(lond + lonm/60.0, latd + latm/60.0);
|
||||||
|
points.append(p);
|
||||||
|
} else if (pp) {
|
||||||
|
p.pp = QPointF(ppx, ppy);
|
||||||
|
setup.zone = zone;
|
||||||
|
points.append(p);
|
||||||
|
} else
|
||||||
|
return ln;
|
||||||
|
} else if (key == "IWH") {
|
||||||
|
int w = list.at(2).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
return ln;
|
||||||
|
int h = list.at(3).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
return ln;
|
||||||
|
_size = QSize(w, h);
|
||||||
|
} else if (key == "Map Projection") {
|
||||||
|
projection = list.at(1);
|
||||||
|
} else if (key == "Projection Setup") {
|
||||||
|
if (list.count() < 8)
|
||||||
|
return ln;
|
||||||
|
setup.centralMeridian = list.at(2).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
setup.centralMeridian = 0;
|
||||||
|
setup.scale = list.at(3).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
setup.scale = 0;
|
||||||
|
setup.falseEasting = list.at(4).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
setup.falseEasting = 0;
|
||||||
|
setup.falseNorthing = list.at(5).trimmed().toFloat(&res);
|
||||||
|
if (!res)
|
||||||
|
setup.falseNorthing = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ln++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::createProjection(const QString &projection,
|
||||||
|
const ProjectionSetup &setup, QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
if (points.count() < 2) {
|
||||||
|
qWarning("%s: insufficient number of reference points",
|
||||||
|
qPrintable(_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projection == "Mercator")
|
||||||
|
_projection = new Mercator();
|
||||||
|
else if (projection == "Transverse Mercator")
|
||||||
|
_projection = new TransverseMercator(setup.centralMeridian, setup.scale,
|
||||||
|
setup.falseEasting, setup.falseNorthing);
|
||||||
|
else if (projection == "Latitude/Longitude")
|
||||||
|
_projection = new LatLon();
|
||||||
|
else if (projection == "(UTM) Universal Transverse Mercator") {
|
||||||
|
if (setup.zone)
|
||||||
|
_projection = new UTM(setup.zone);
|
||||||
|
else if (!points.first().ll.isNull())
|
||||||
|
_projection = new UTM(points.first().ll);
|
||||||
|
else {
|
||||||
|
qWarning("%s: Can not determine UTM zone", qPrintable(_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
qWarning("%s: %s: unsupported map projection", qPrintable(_name),
|
||||||
|
qPrintable(projection));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < points.size(); i++)
|
||||||
|
if (points.at(i).ll.isNull())
|
||||||
|
points[i].ll = _projection->xy2ll(points.at(i).pp);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::computeTransformation(const QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
Q_ASSERT(points.count() >= 2);
|
||||||
|
|
||||||
|
Matrix c(3, 2);
|
||||||
|
c.zeroize();
|
||||||
|
for (size_t j = 0; j < c.w(); j++) {
|
||||||
|
for (size_t k = 0; k < c.h(); k++) {
|
||||||
|
for (int i = 0; i < points.size(); i++) {
|
||||||
|
double f[3], t[2];
|
||||||
|
QPointF p = _projection->ll2xy(points.at(i).ll);
|
||||||
|
|
||||||
|
f[0] = p.x();
|
||||||
|
f[1] = p.y();
|
||||||
|
f[2] = 1.0;
|
||||||
|
t[0] = points.at(i).xy.x();
|
||||||
|
t[1] = points.at(i).xy.y();
|
||||||
|
c.m(k,j) += f[k] * t[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix Q(3, 3);
|
||||||
|
Q.zeroize();
|
||||||
|
for (int qi = 0; qi < points.size(); qi++) {
|
||||||
|
double v[3];
|
||||||
|
QPointF p = _projection->ll2xy(points.at(qi).ll);
|
||||||
|
|
||||||
|
v[0] = p.x();
|
||||||
|
v[1] = p.y();
|
||||||
|
v[2] = 1.0;
|
||||||
|
for (size_t i = 0; i < Q.h(); i++)
|
||||||
|
for (size_t j = 0; j < Q.w(); j++)
|
||||||
|
Q.m(i,j) += v[i] * v[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix M = Q.augemented(c);
|
||||||
|
if (!M.eliminate()) {
|
||||||
|
qWarning("%s: singular transformation matrix", qPrintable(_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_transform = QTransform(M.m(0,3), M.m(0,4), M.m(1,3), M.m(1,4), M.m(2,3),
|
||||||
|
M.m(2,4));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::computeResolution(QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
Q_ASSERT(points.count() >= 2);
|
||||||
|
|
||||||
|
int maxLon = 0, minLon = 0, maxLat = 0, minLat = 0;
|
||||||
|
qreal dLon, pLon, dLat, pLat;
|
||||||
|
|
||||||
|
for (int i = 1; i < points.size(); i++) {
|
||||||
|
if (points.at(i).ll.lon() < points.at(minLon).ll.lon())
|
||||||
|
minLon = i;
|
||||||
|
if (points.at(i).ll.lon() > points.at(maxLon).ll.lon())
|
||||||
|
maxLon = i;
|
||||||
|
if (points.at(i).ll.lat() < points.at(minLat).ll.lon())
|
||||||
|
minLat = i;
|
||||||
|
if (points.at(i).ll.lat() > points.at(maxLat).ll.lon())
|
||||||
|
maxLat = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
dLon = points.at(minLon).ll.distanceTo(points.at(maxLon).ll);
|
||||||
|
pLon = QLineF(points.at(minLon).xy, points.at(maxLon).xy).length();
|
||||||
|
dLat = points.at(minLat).ll.distanceTo(points.at(maxLat).ll);
|
||||||
|
pLat = QLineF(points.at(minLat).xy, points.at(maxLat).xy).length();
|
||||||
|
|
||||||
|
_resolution = (dLon/pLon + dLat/pLat) / 2.0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::getImageInfo(const QString &path)
|
||||||
|
{
|
||||||
|
QFileInfo ii(_imgPath);
|
||||||
|
if (ii.isRelative())
|
||||||
|
_imgPath = path + "/" + _imgPath;
|
||||||
|
|
||||||
|
QImageReader img(_imgPath);
|
||||||
|
_size = img.size();
|
||||||
|
if (!_size.isValid()) {
|
||||||
|
qWarning("%s: %s: error reading map image", qPrintable(_name),
|
||||||
|
qPrintable(ii.absoluteFilePath()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::getTileInfo(const QStringList &tiles, const QString &path)
|
||||||
|
{
|
||||||
|
if (tiles.isEmpty()) {
|
||||||
|
qWarning("%s: empty tile set", qPrintable(_name));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QRegExp rx("_[0-9]+_[0-9]+\\.");
|
||||||
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
|
if (tiles.at(i).contains(rx)) {
|
||||||
|
_tileName = QString(tiles.at(i)).replace(rx, "_%1_%2.");
|
||||||
|
|
||||||
|
if (path.isNull()) {
|
||||||
|
QByteArray ba = _tar.file(tiles.at(i));
|
||||||
|
QBuffer buffer(&ba);
|
||||||
|
_tileSize = QImageReader(&buffer).size();
|
||||||
|
} else {
|
||||||
|
_tileName = path + "/" + _tileName;
|
||||||
|
_tileSize = QImageReader(path + "/" + tiles.at(i)).size();
|
||||||
|
}
|
||||||
|
if (!_tileSize.isValid()) {
|
||||||
|
qWarning("%s: error retrieving tile size: %s: invalid image",
|
||||||
|
qPrintable(_name), qPrintable(QFileInfo(tiles.at(i))
|
||||||
|
.fileName()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qWarning("%s: invalid tile names", qPrintable(_name));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::mapLoaded(int res)
|
||||||
|
{
|
||||||
|
if (res) {
|
||||||
|
if (res == -2)
|
||||||
|
qWarning("%s: no map file found", qPrintable(_name));
|
||||||
|
else if (res == -1)
|
||||||
|
qWarning("%s: error opening map file", qPrintable(_name));
|
||||||
|
else
|
||||||
|
qWarning("%s: map file parse error on line: %d", qPrintable(_name),
|
||||||
|
res);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::totalSizeSet()
|
||||||
|
{
|
||||||
|
if (!_size.isValid()) {
|
||||||
|
qWarning("%s: missing total image size (IWH)", qPrintable(_name));
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineMap::OfflineMap(const QString &path, QObject *parent) : Map(parent)
|
||||||
|
{
|
||||||
|
int errorLine = -2;
|
||||||
|
QList<ReferencePoint> points;
|
||||||
|
QString proj;
|
||||||
|
ProjectionSetup setup;
|
||||||
|
|
||||||
|
|
||||||
|
_valid = false;
|
||||||
|
_img = 0;
|
||||||
|
_projection = 0;
|
||||||
|
|
||||||
|
QFileInfo fi(path);
|
||||||
|
_name = fi.fileName();
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
QFileInfoList mapFiles = dir.entryInfoList(QDir::Files);
|
||||||
|
for (int i = 0; i < mapFiles.count(); i++) {
|
||||||
|
const QString &fileName = mapFiles.at(i).fileName();
|
||||||
|
if (fileName.endsWith(".tar")) {
|
||||||
|
if (!_tar.load(mapFiles.at(i).absoluteFilePath())) {
|
||||||
|
qWarning("%s: %s: error loading tar file", qPrintable(_name),
|
||||||
|
qPrintable(fileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QStringList tarFiles = _tar.files();
|
||||||
|
for (int j = 0; j < tarFiles.size(); j++) {
|
||||||
|
if (tarFiles.at(j).endsWith(".map")) {
|
||||||
|
QByteArray ba = _tar.file(tarFiles.at(j));
|
||||||
|
QBuffer buffer(&ba);
|
||||||
|
errorLine = parseMapFile(buffer, points, proj, setup);
|
||||||
|
_imgPath = QString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else if (fileName.endsWith(".map")) {
|
||||||
|
QFile mapFile(mapFiles.at(i).absoluteFilePath());
|
||||||
|
errorLine = parseMapFile(mapFile, points, proj, setup);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!mapLoaded(errorLine))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!createProjection(proj, setup, points))
|
||||||
|
return;
|
||||||
|
if (!computeTransformation(points))
|
||||||
|
return;
|
||||||
|
computeResolution(points);
|
||||||
|
|
||||||
|
if (_tar.isOpen()) {
|
||||||
|
if (!totalSizeSet())
|
||||||
|
return;
|
||||||
|
if (!getTileInfo(_tar.files()))
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
QDir set(fi.absoluteFilePath() + "/" + "set");
|
||||||
|
if (set.exists()) {
|
||||||
|
if (!totalSizeSet())
|
||||||
|
return;
|
||||||
|
if (!getTileInfo(set.entryList(), set.canonicalPath()))
|
||||||
|
return;
|
||||||
|
_imgPath = QString();
|
||||||
|
} else {
|
||||||
|
if (!getImageInfo(fi.absoluteFilePath()))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineMap::OfflineMap(Tar &tar, const QString &path, QObject *parent)
|
||||||
|
: Map(parent)
|
||||||
|
{
|
||||||
|
int errorLine = -2;
|
||||||
|
QList<ReferencePoint> points;
|
||||||
|
QString proj;
|
||||||
|
ProjectionSetup setup;
|
||||||
|
|
||||||
|
|
||||||
|
_valid = false;
|
||||||
|
_img = 0;
|
||||||
|
_projection = 0;
|
||||||
|
|
||||||
|
QFileInfo fi(path);
|
||||||
|
_name = fi.fileName();
|
||||||
|
|
||||||
|
QFileInfo li(fi.absoluteDir().dirName());
|
||||||
|
QString prefix = li.fileName() + "/" + fi.fileName() + "/";
|
||||||
|
QStringList tarFiles = tar.files();
|
||||||
|
for (int j = 0; j < tarFiles.size(); j++) {
|
||||||
|
if (tarFiles.at(j).startsWith(prefix)) {
|
||||||
|
QByteArray ba = tar.file(tarFiles.at(j));
|
||||||
|
QBuffer buffer(&ba);
|
||||||
|
errorLine = parseMapFile(buffer, points, proj, setup);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!mapLoaded(errorLine))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!createProjection(proj, setup, points))
|
||||||
|
return;
|
||||||
|
if (!totalSizeSet())
|
||||||
|
return;
|
||||||
|
if (!computeTransformation(points))
|
||||||
|
return;
|
||||||
|
computeResolution(points);
|
||||||
|
|
||||||
|
QDir dir(path);
|
||||||
|
QFileInfoList mapFiles = dir.entryInfoList(QDir::Files);
|
||||||
|
for (int i = 0; i < mapFiles.count(); i++) {
|
||||||
|
const QString &fileName = mapFiles.at(i).absoluteFilePath();
|
||||||
|
if (fileName.endsWith(".tar"))
|
||||||
|
_tarPath = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
_imgPath = QString();
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineMap::~OfflineMap()
|
||||||
|
{
|
||||||
|
if (_img)
|
||||||
|
delete _img;
|
||||||
|
if (_projection)
|
||||||
|
delete _projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OfflineMap::load()
|
||||||
|
{
|
||||||
|
if (!_tarPath.isNull() && !_tileSize.isValid()) {
|
||||||
|
if (!_tar.load(_tarPath)) {
|
||||||
|
qWarning("%s: %s: error loading tar file", qPrintable(_name),
|
||||||
|
qPrintable(_tarPath));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getTileInfo(_tar.files());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_img && !_imgPath.isNull()) {
|
||||||
|
_img = new QImage(_imgPath);
|
||||||
|
if (_img->isNull())
|
||||||
|
qWarning("%s: error loading map image", qPrintable(_imgPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OfflineMap::unload()
|
||||||
|
{
|
||||||
|
if (_img) {
|
||||||
|
delete _img;
|
||||||
|
_img = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF OfflineMap::bounds() const
|
||||||
|
{
|
||||||
|
return QRectF(QPointF(0, 0), _size);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomFit(const QSize &size, const QRectF &br)
|
||||||
|
{
|
||||||
|
Q_UNUSED(size);
|
||||||
|
Q_UNUSED(br);
|
||||||
|
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::resolution(const QPointF &p) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(p);
|
||||||
|
|
||||||
|
return _resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomIn()
|
||||||
|
{
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomOut()
|
||||||
|
{
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
if (_tileSize.isValid()) {
|
||||||
|
QPoint tl = QPoint((int)floor(rect.left() / (qreal)_tileSize.width())
|
||||||
|
* _tileSize.width(), (int)floor(rect.top() / _tileSize.height())
|
||||||
|
* _tileSize.height());
|
||||||
|
|
||||||
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
|
for (int i = 0; i < ceil(s.width() / _tileSize.width()); i++) {
|
||||||
|
for (int j = 0; j < ceil(s.height() / _tileSize.height()); j++) {
|
||||||
|
int x = tl.x() + i * _tileSize.width();
|
||||||
|
int y = tl.y() + j * _tileSize.height();
|
||||||
|
QString tileName(_tileName.arg(QString::number(x),
|
||||||
|
QString::number(y)));
|
||||||
|
QPixmap pixmap;
|
||||||
|
|
||||||
|
if (_tar.isOpen()) {
|
||||||
|
QString key = _tar.fileName() + "/" + tileName;
|
||||||
|
if (!QPixmapCache::find(key, &pixmap)) {
|
||||||
|
QByteArray ba = _tar.file(tileName);
|
||||||
|
pixmap = QPixmap::fromImage(QImage::fromData(ba));
|
||||||
|
if (!pixmap.isNull())
|
||||||
|
QPixmapCache::insert(key, pixmap);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
pixmap = QPixmap(tileName);
|
||||||
|
|
||||||
|
if (pixmap.isNull()) {
|
||||||
|
qWarning("%s: error loading tile image", qPrintable(
|
||||||
|
_tileName.arg(QString::number(x), QString::number(y))));
|
||||||
|
painter->fillRect(QRectF(QPoint(x, y), _tileSize),
|
||||||
|
Qt::white);
|
||||||
|
} else
|
||||||
|
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!_img || _img->isNull())
|
||||||
|
painter->fillRect(rect, Qt::white);
|
||||||
|
else {
|
||||||
|
QPoint p = rect.topLeft().toPoint();
|
||||||
|
QImage crop = _img->copy(QRect(p, rect.size().toSize()));
|
||||||
|
painter->drawImage(rect.topLeft(), crop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF OfflineMap::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
return _transform.map(_projection->ll2xy(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates OfflineMap::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return _projection->xy2ll(_transform.inverted().map(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF OfflineMap::ll2pp(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
return _projection->ll2xy(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF OfflineMap::xy2pp(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return _transform.inverted().map(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF OfflineMap::pp2xy(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return _transform.map(p);
|
||||||
|
}
|
88
src/offlinemap.h
Normal file
88
src/offlinemap.h
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#ifndef OFFLINEMAP_H
|
||||||
|
#define OFFLINEMAP_H
|
||||||
|
|
||||||
|
#include <QTransform>
|
||||||
|
#include "map.h"
|
||||||
|
#include "tar.h"
|
||||||
|
#include "coordinates.h"
|
||||||
|
|
||||||
|
class QIODevice;
|
||||||
|
class QImage;
|
||||||
|
class Projection;
|
||||||
|
|
||||||
|
class OfflineMap : public Map
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
OfflineMap(const QString &path, QObject *parent = 0);
|
||||||
|
OfflineMap(Tar &tar, const QString &path, QObject *parent = 0);
|
||||||
|
~OfflineMap();
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
QRectF bounds() const;
|
||||||
|
qreal resolution(const QPointF &p) const;
|
||||||
|
|
||||||
|
qreal zoom() const {return 1.0;}
|
||||||
|
qreal zoomFit(const QSize &size, const QRectF &br);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
void load();
|
||||||
|
void unload();
|
||||||
|
|
||||||
|
bool isValid() {return _valid;}
|
||||||
|
|
||||||
|
QPointF ll2pp(const Coordinates &c) const;
|
||||||
|
QPointF xy2pp(const QPointF &p) const;
|
||||||
|
QPointF pp2xy(const QPointF &p) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef struct {
|
||||||
|
QPoint xy;
|
||||||
|
Coordinates ll;
|
||||||
|
QPointF pp;
|
||||||
|
} ReferencePoint;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
double centralMeridian;
|
||||||
|
double scale;
|
||||||
|
double falseEasting;
|
||||||
|
double falseNorthing;
|
||||||
|
int zone;
|
||||||
|
} ProjectionSetup;
|
||||||
|
|
||||||
|
int parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||||
|
QString &projection, ProjectionSetup &setup);
|
||||||
|
bool mapLoaded(int res);
|
||||||
|
bool totalSizeSet();
|
||||||
|
bool createProjection(const QString &projection,
|
||||||
|
const ProjectionSetup &setup, QList<ReferencePoint> &points);
|
||||||
|
bool computeTransformation(const QList<ReferencePoint> &points);
|
||||||
|
bool computeResolution(QList<ReferencePoint> &points);
|
||||||
|
bool getTileInfo(const QStringList &tiles, const QString &path = QString());
|
||||||
|
bool getImageInfo(const QString &path);
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
QSize _size;
|
||||||
|
Projection *_projection;
|
||||||
|
QTransform _transform;
|
||||||
|
qreal _resolution;
|
||||||
|
|
||||||
|
Tar _tar;
|
||||||
|
QString _tarPath;
|
||||||
|
QImage *_img;
|
||||||
|
QString _imgPath;
|
||||||
|
QSize _tileSize;
|
||||||
|
QString _tileName;
|
||||||
|
|
||||||
|
bool _valid;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OFFLINEMAP_H
|
246
src/onlinemap.cpp
Normal file
246
src/onlinemap.cpp
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "downloader.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include "rd.h"
|
||||||
|
#include "wgs84.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include "coordinates.h"
|
||||||
|
#include "mercator.h"
|
||||||
|
#include "onlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define ZOOM_MAX 18
|
||||||
|
#define ZOOM_MIN 3
|
||||||
|
#define TILE_SIZE 256
|
||||||
|
|
||||||
|
static QPoint mercator2tile(const QPointF &m, int z)
|
||||||
|
{
|
||||||
|
QPoint tile;
|
||||||
|
|
||||||
|
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * (1<<z))));
|
||||||
|
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<z))));
|
||||||
|
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int scale2zoom(qreal scale)
|
||||||
|
{
|
||||||
|
int zoom = (int)log2(360.0/(scale * (qreal)TILE_SIZE));
|
||||||
|
|
||||||
|
if (zoom < ZOOM_MIN)
|
||||||
|
return ZOOM_MIN;
|
||||||
|
if (zoom > ZOOM_MAX)
|
||||||
|
return ZOOM_MAX;
|
||||||
|
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Downloader *OnlineMap::downloader;
|
||||||
|
|
||||||
|
OnlineMap::OnlineMap(const QString &name, const QString &url, QObject *parent)
|
||||||
|
: Map(parent)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
_url = url;
|
||||||
|
downloader = downloader;
|
||||||
|
_block = false;
|
||||||
|
_scale = ((360.0/(qreal)(1<<ZOOM_MAX))/(qreal)TILE_SIZE);
|
||||||
|
|
||||||
|
connect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
||||||
|
|
||||||
|
QString path = TILES_DIR + QString("/") + name;
|
||||||
|
if (!QDir().mkpath(path))
|
||||||
|
qWarning("Error creating tiles dir: %s\n", qPrintable(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::emitLoaded()
|
||||||
|
{
|
||||||
|
emit loaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::loadTilesAsync(QList<Tile> &list)
|
||||||
|
{
|
||||||
|
QList<Download> dl;
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Tile &t = list[i];
|
||||||
|
QString file = tileFile(t);
|
||||||
|
QFileInfo fi(file);
|
||||||
|
|
||||||
|
if (!fi.exists()) {
|
||||||
|
fillTile(t);
|
||||||
|
dl.append(Download(tileUrl(t), file));
|
||||||
|
} else
|
||||||
|
loadTileFile(t, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dl.empty())
|
||||||
|
downloader->get(dl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::loadTilesSync(QList<Tile> &list)
|
||||||
|
{
|
||||||
|
QList<Download> dl;
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Tile &t = list[i];
|
||||||
|
QString file = tileFile(t);
|
||||||
|
QFileInfo fi(file);
|
||||||
|
|
||||||
|
if (!fi.exists())
|
||||||
|
dl.append(Download(tileUrl(t), file));
|
||||||
|
else
|
||||||
|
loadTileFile(t, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dl.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QEventLoop wait;
|
||||||
|
connect(downloader, SIGNAL(finished()), &wait, SLOT(quit()));
|
||||||
|
if (downloader->get(dl))
|
||||||
|
wait.exec();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
Tile &t = list[i];
|
||||||
|
|
||||||
|
if (t.pixmap().isNull()) {
|
||||||
|
QString file = tileFile(t);
|
||||||
|
QFileInfo fi(file);
|
||||||
|
|
||||||
|
if (!(fi.exists() && loadTileFile(t, file)))
|
||||||
|
fillTile(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::fillTile(Tile &tile)
|
||||||
|
{
|
||||||
|
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||||
|
tile.pixmap().fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnlineMap::loadTileFile(Tile &tile, const QString &file)
|
||||||
|
{
|
||||||
|
if (!tile.pixmap().load(file)) {
|
||||||
|
qWarning("%s: error loading tile file\n", qPrintable(file));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OnlineMap::tileUrl(const Tile &tile)
|
||||||
|
{
|
||||||
|
QString url(_url);
|
||||||
|
|
||||||
|
url.replace("$z", QString::number(tile.zoom()));
|
||||||
|
url.replace("$x", QString::number(tile.xy().x()));
|
||||||
|
url.replace("$y", QString::number(tile.xy().y()));
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OnlineMap::tileFile(const Tile &tile)
|
||||||
|
{
|
||||||
|
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(name())
|
||||||
|
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::clearCache()
|
||||||
|
{
|
||||||
|
QString path = TILES_DIR + QString("/") + name();
|
||||||
|
QDir dir = QDir(path);
|
||||||
|
QStringList list = dir.entryList();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.count(); i++)
|
||||||
|
dir.remove(list.at(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF OnlineMap::bounds() const
|
||||||
|
{
|
||||||
|
return scaled(QRectF(QPointF(-180, -180), QSizeF(360, 360)), 1.0/_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomFit(const QSize &size, const QRectF &br)
|
||||||
|
{
|
||||||
|
if (br.isNull())
|
||||||
|
_scale = ((360.0/(qreal)(1<<ZOOM_MAX))/(qreal)TILE_SIZE);
|
||||||
|
else {
|
||||||
|
Coordinates topLeft(br.topLeft());
|
||||||
|
Coordinates bottomRight(br.bottomRight());
|
||||||
|
QRectF tbr(Mercator().ll2xy(topLeft), Mercator().ll2xy(bottomRight));
|
||||||
|
|
||||||
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
|
|
||||||
|
_scale = ((360.0/(qreal)(1<<scale2zoom(qMax(sc.x(), sc.y()))))
|
||||||
|
/ (qreal)TILE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::resolution(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return (WGS84_RADIUS * 2 * M_PI * _scale / 360.0
|
||||||
|
* cos(2.0 * atan(exp(deg2rad(-p.y() * _scale))) - M_PI/2));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomIn()
|
||||||
|
{
|
||||||
|
int zoom = qMin(scale2zoom(_scale) + 1, ZOOM_MAX);
|
||||||
|
_scale = ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomOut()
|
||||||
|
{
|
||||||
|
int zoom = qMax(scale2zoom(_scale) - 1, ZOOM_MIN);
|
||||||
|
_scale = ((360.0/(qreal)(1<<zoom))/(qreal)TILE_SIZE);
|
||||||
|
return _scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
int zoom = scale2zoom(_scale);
|
||||||
|
|
||||||
|
QPoint tile = mercator2tile(QPointF(rect.topLeft().x() * _scale,
|
||||||
|
-rect.topLeft().y() * _scale), zoom);
|
||||||
|
QPoint tl = QPoint((int)floor(rect.left() / (qreal)TILE_SIZE)
|
||||||
|
* TILE_SIZE, (int)floor(rect.top() / TILE_SIZE) * TILE_SIZE);
|
||||||
|
|
||||||
|
QList<Tile> tiles;
|
||||||
|
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||||
|
for (int i = 0; i < ceil(s.width() / TILE_SIZE); i++)
|
||||||
|
for (int j = 0; j < ceil(s.height() / TILE_SIZE); j++)
|
||||||
|
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), zoom));
|
||||||
|
|
||||||
|
if (_block)
|
||||||
|
loadTilesSync(tiles);
|
||||||
|
else
|
||||||
|
loadTilesAsync(tiles);
|
||||||
|
|
||||||
|
for (int i = 0; i < tiles.count(); i++) {
|
||||||
|
Tile &t = tiles[i];
|
||||||
|
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * TILE_SIZE,
|
||||||
|
tl.y() + (t.xy().y() - tile.y()) * TILE_SIZE);
|
||||||
|
painter->drawPixmap(tp, t.pixmap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF OnlineMap::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
QPointF m = Mercator().ll2xy(c);
|
||||||
|
return QPointF(m.x() / _scale, m.y() / -_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates OnlineMap::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
QPointF m(p.x() * _scale, -p.y() * _scale);
|
||||||
|
return Mercator().xy2ll(m);
|
||||||
|
}
|
56
src/onlinemap.h
Normal file
56
src/onlinemap.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef ONLINEMAP_H
|
||||||
|
#define ONLINEMAP_H
|
||||||
|
|
||||||
|
#include "map.h"
|
||||||
|
#include "tile.h"
|
||||||
|
|
||||||
|
class Downloader;
|
||||||
|
|
||||||
|
class OnlineMap : public Map
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
OnlineMap(const QString &name, const QString &url, QObject *parent = 0);
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
QRectF bounds() const;
|
||||||
|
qreal resolution(const QPointF &p) const;
|
||||||
|
|
||||||
|
qreal zoom() const {return _scale;}
|
||||||
|
qreal zoomFit(const QSize &size, const QRectF &br);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
void setBlockingMode(bool block) {_block = block;}
|
||||||
|
void clearCache();
|
||||||
|
|
||||||
|
static void setDownloader(Downloader *downloader)
|
||||||
|
{OnlineMap::downloader = downloader;}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void emitLoaded();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString tileUrl(const Tile &tile);
|
||||||
|
QString tileFile(const Tile &tile);
|
||||||
|
bool loadTileFile(Tile &tile, const QString &file);
|
||||||
|
void fillTile(Tile &tile);
|
||||||
|
void loadTilesAsync(QList<Tile> &list);
|
||||||
|
void loadTilesSync(QList<Tile> &list);
|
||||||
|
|
||||||
|
qreal _scale;
|
||||||
|
QString _name;
|
||||||
|
QString _url;
|
||||||
|
bool _block;
|
||||||
|
|
||||||
|
static Downloader *downloader;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ONLINEMAP_H
|
@ -152,6 +152,8 @@ QWidget *OptionsDialog::createExportPage()
|
|||||||
_distance->setChecked(_options->printDistance);
|
_distance->setChecked(_options->printDistance);
|
||||||
_time = new QCheckBox(tr("Time"));
|
_time = new QCheckBox(tr("Time"));
|
||||||
_time->setChecked(_options->printTime);
|
_time->setChecked(_options->printTime);
|
||||||
|
_movingTime = new QCheckBox(tr("Moving time"));
|
||||||
|
_movingTime->setChecked(_options->printMovingTime);
|
||||||
_itemCount = new QCheckBox(tr("Item count (>1)"));
|
_itemCount = new QCheckBox(tr("Item count (>1)"));
|
||||||
_itemCount->setChecked(_options->printItemCount);
|
_itemCount->setChecked(_options->printItemCount);
|
||||||
|
|
||||||
@ -160,6 +162,7 @@ QWidget *OptionsDialog::createExportPage()
|
|||||||
headerTabLayout->addWidget(_date);
|
headerTabLayout->addWidget(_date);
|
||||||
headerTabLayout->addWidget(_distance);
|
headerTabLayout->addWidget(_distance);
|
||||||
headerTabLayout->addWidget(_time);
|
headerTabLayout->addWidget(_time);
|
||||||
|
headerTabLayout->addWidget(_movingTime);
|
||||||
headerTabLayout->addItem(new QSpacerItem(10, 10));
|
headerTabLayout->addItem(new QSpacerItem(10, 10));
|
||||||
headerTabLayout->addWidget(_itemCount);
|
headerTabLayout->addWidget(_itemCount);
|
||||||
QWidget *headerTab = new QWidget();
|
QWidget *headerTab = new QWidget();
|
||||||
@ -277,6 +280,7 @@ void OptionsDialog::accept()
|
|||||||
_options->printDate = _date->isChecked();
|
_options->printDate = _date->isChecked();
|
||||||
_options->printDistance = _distance->isChecked();
|
_options->printDistance = _distance->isChecked();
|
||||||
_options->printTime = _time->isChecked();
|
_options->printTime = _time->isChecked();
|
||||||
|
_options->printMovingTime = _movingTime->isChecked();
|
||||||
_options->printItemCount = _itemCount->isChecked();
|
_options->printItemCount = _itemCount->isChecked();
|
||||||
_options->separateGraphPage = _separateGraphPage->isChecked();
|
_options->separateGraphPage = _separateGraphPage->isChecked();
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ struct Options {
|
|||||||
bool printDate;
|
bool printDate;
|
||||||
bool printDistance;
|
bool printDistance;
|
||||||
bool printTime;
|
bool printTime;
|
||||||
|
bool printMovingTime;
|
||||||
bool printItemCount;
|
bool printItemCount;
|
||||||
bool separateGraphPage;
|
bool separateGraphPage;
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ private:
|
|||||||
QCheckBox *_date;
|
QCheckBox *_date;
|
||||||
QCheckBox *_distance;
|
QCheckBox *_distance;
|
||||||
QCheckBox *_time;
|
QCheckBox *_time;
|
||||||
|
QCheckBox *_movingTime;
|
||||||
QCheckBox *_itemCount;
|
QCheckBox *_itemCount;
|
||||||
QCheckBox *_separateGraphPage;
|
QCheckBox *_separateGraphPage;
|
||||||
};
|
};
|
||||||
|
24
src/path.cpp
24
src/path.cpp
@ -1,5 +1,29 @@
|
|||||||
#include "path.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
QRectF Path::boundingRect() const
|
||||||
|
{
|
||||||
|
if (size() < 2)
|
||||||
|
return QRectF();
|
||||||
|
|
||||||
|
QPointF topLeft(at(0).coordinates().lon(), at(0).coordinates().lat());
|
||||||
|
QPointF bottomRight(topLeft);
|
||||||
|
|
||||||
|
for (int i = 1; i < size(); i++) {
|
||||||
|
qreal x = at(i).coordinates().lon();
|
||||||
|
qreal y = at(i).coordinates().lat();
|
||||||
|
|
||||||
|
if (x < topLeft.x())
|
||||||
|
topLeft.setX(x);
|
||||||
|
if (y < topLeft.y())
|
||||||
|
topLeft.setY(y);
|
||||||
|
if (x > bottomRight.x())
|
||||||
|
bottomRight.setX(x);
|
||||||
|
if (y > bottomRight.y())
|
||||||
|
bottomRight.setY(y);
|
||||||
|
}
|
||||||
|
return QRectF(topLeft, bottomRight);
|
||||||
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const PathPoint &point)
|
QDebug operator<<(QDebug dbg, const PathPoint &point)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "PathPoint(" << point.distance() << ", "
|
dbg.nospace() << "PathPoint(" << point.distance() << ", "
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define PATH_H
|
#define PATH_H
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QRectF>
|
||||||
#include "coordinates.h"
|
#include "coordinates.h"
|
||||||
|
|
||||||
class PathPoint
|
class PathPoint
|
||||||
@ -23,6 +24,11 @@ private:
|
|||||||
Q_DECLARE_TYPEINFO(PathPoint, Q_PRIMITIVE_TYPE);
|
Q_DECLARE_TYPEINFO(PathPoint, Q_PRIMITIVE_TYPE);
|
||||||
QDebug operator<<(QDebug dbg, const PathPoint &point);
|
QDebug operator<<(QDebug dbg, const PathPoint &point);
|
||||||
|
|
||||||
typedef QVector<PathPoint> Path;
|
|
||||||
|
class Path : public QVector<PathPoint>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QRectF boundingRect() const;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // PATH_H
|
#endif // PATH_H
|
||||||
|
@ -3,29 +3,47 @@
|
|||||||
#include <QCursor>
|
#include <QCursor>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
|
#include "map.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
|
||||||
|
|
||||||
|
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
|
||||||
|
: QGraphicsObject(parent)
|
||||||
|
{
|
||||||
|
Q_ASSERT(path.count() >= 2);
|
||||||
|
_path = path;
|
||||||
|
_map = map;
|
||||||
|
|
||||||
|
updatePainterPath(map);
|
||||||
|
updateShape();
|
||||||
|
|
||||||
|
_width = 3;
|
||||||
|
QBrush brush(Qt::SolidPattern);
|
||||||
|
_pen = QPen(brush, _width);
|
||||||
|
|
||||||
|
_marker = new MarkerItem(this);
|
||||||
|
_marker->setPos(position(_path.at(0).distance()));
|
||||||
|
_md = _path.at(0).distance();
|
||||||
|
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
void PathItem::updateShape()
|
void PathItem::updateShape()
|
||||||
{
|
{
|
||||||
QPainterPathStroker s;
|
QPainterPathStroker s;
|
||||||
s.setWidth((_width + 1) * 1.0/scale());
|
s.setWidth((_width + 1) * 1.0/scale());
|
||||||
_shape = s.createStroke(_path);
|
_shape = s.createStroke(_painterPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
PathItem::PathItem(QGraphicsItem *parent) : QGraphicsObject(parent)
|
void PathItem::updatePainterPath(Map *map)
|
||||||
{
|
{
|
||||||
_width = 3;
|
_painterPath = QPainterPath();
|
||||||
|
|
||||||
QBrush brush(Qt::SolidPattern);
|
_painterPath.moveTo(map->ll2xy(_path.first().coordinates()));
|
||||||
_pen = QPen(brush, _width);
|
for (int i = 1; i < _path.size(); i++)
|
||||||
|
_painterPath.lineTo(map->ll2xy(_path.at(i).coordinates()));
|
||||||
_units = Metric;
|
|
||||||
|
|
||||||
_marker = new MarkerItem(this);
|
|
||||||
|
|
||||||
setCursor(Qt::ArrowCursor);
|
|
||||||
setAcceptHoverEvents(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
@ -35,7 +53,7 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
Q_UNUSED(widget);
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
painter->setPen(_pen);
|
painter->setPen(_pen);
|
||||||
painter->drawPath(_path);
|
painter->drawPath(_painterPath);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QPen p = QPen(QBrush(Qt::red), 0);
|
QPen p = QPen(QBrush(Qt::red), 0);
|
||||||
@ -44,15 +62,15 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setScale(qreal scale)
|
void PathItem::setMap(Map *map)
|
||||||
{
|
{
|
||||||
|
_map = map;
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_pen.setWidthF(_width * 1.0/scale);
|
updatePainterPath(map);
|
||||||
QGraphicsItem::setScale(scale);
|
|
||||||
_marker->setScale(1.0/scale);
|
|
||||||
|
|
||||||
updateShape();
|
updateShape();
|
||||||
|
|
||||||
|
_marker->setPos(position(_md));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setColor(const QColor &color)
|
void PathItem::setColor(const QColor &color)
|
||||||
@ -77,41 +95,36 @@ void PathItem::setStyle(Qt::PenStyle style)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathItem::setUnits(enum Units units)
|
|
||||||
{
|
|
||||||
_units = units;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPointF PathItem::position(qreal x) const
|
QPointF PathItem::position(qreal x) const
|
||||||
{
|
{
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int high = _distance.count() - 1;
|
int high = _path.count() - 1;
|
||||||
int mid = 0;
|
int mid = 0;
|
||||||
|
|
||||||
|
|
||||||
Q_ASSERT(_distance.count() == _path.elementCount());
|
|
||||||
Q_ASSERT(high > low);
|
Q_ASSERT(high > low);
|
||||||
Q_ASSERT(x >= _distance.at(low) && x <= _distance.at(high));
|
Q_ASSERT(x >= _path.at(low).distance() && x <= _path.at(high).distance());
|
||||||
|
|
||||||
while (low <= high) {
|
while (low <= high) {
|
||||||
mid = low + ((high - low) / 2);
|
mid = low + ((high - low) / 2);
|
||||||
qreal val = _distance.at(mid);
|
qreal val = _path.at(mid).distance();
|
||||||
if (val > x)
|
if (val > x)
|
||||||
high = mid - 1;
|
high = mid - 1;
|
||||||
else if (val < x)
|
else if (val < x)
|
||||||
low = mid + 1;
|
low = mid + 1;
|
||||||
else
|
else
|
||||||
return _path.elementAt(mid);
|
return _map->ll2xy(_path.at(mid).coordinates());
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF l;
|
QLineF l;
|
||||||
qreal p1, p2;
|
qreal p1, p2;
|
||||||
if (_distance.at(mid) < x) {
|
if (_path.at(mid).distance() < x) {
|
||||||
l = QLineF(_path.elementAt(mid), _path.elementAt(mid+1));
|
l = QLineF(_map->ll2xy(_path.at(mid).coordinates()),
|
||||||
p1 = _distance.at(mid); p2 = _distance.at(mid+1);
|
_map->ll2xy(_path.at(mid+1).coordinates()));
|
||||||
|
p1 = _path.at(mid).distance(); p2 = _path.at(mid+1).distance();
|
||||||
} else {
|
} else {
|
||||||
l = QLineF(_path.elementAt(mid-1), _path.elementAt(mid));
|
l = QLineF(_map->ll2xy(_path.at(mid-1).coordinates()),
|
||||||
p1 = _distance.at(mid-1); p2 = _distance.at(mid);
|
_map->ll2xy(_path.at(mid).coordinates()));
|
||||||
|
p1 = _path.at(mid-1).distance(); p2 = _path.at(mid).distance();
|
||||||
}
|
}
|
||||||
|
|
||||||
return l.pointAt((x - p1) / (p2 - p1));
|
return l.pointAt((x - p1) / (p2 - p1));
|
||||||
@ -119,9 +132,11 @@ QPointF PathItem::position(qreal x) const
|
|||||||
|
|
||||||
void PathItem::moveMarker(qreal distance)
|
void PathItem::moveMarker(qreal distance)
|
||||||
{
|
{
|
||||||
if (distance >= _distance.first() && distance <= _distance.last()) {
|
if (distance >= _path.first().distance()
|
||||||
|
&& distance <= _path.last().distance()) {
|
||||||
_marker->setVisible(true);
|
_marker->setVisible(true);
|
||||||
_marker->setPos(position(distance));
|
_marker->setPos(position(distance));
|
||||||
|
_md = distance;
|
||||||
} else
|
} else
|
||||||
_marker->setVisible(false);
|
_marker->setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -4,29 +4,33 @@
|
|||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include "markeritem.h"
|
#include "markeritem.h"
|
||||||
#include "units.h"
|
#include "path.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
class PathItem : public QGraphicsObject
|
class PathItem : public QGraphicsObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PathItem(QGraphicsItem *parent = 0);
|
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
const QPainterPath &path() const {return _path;}
|
const Path &path() const {return _path;}
|
||||||
void showMarker(bool show) {_marker->setVisible(show);}
|
|
||||||
void setScale(qreal scale);
|
void setMap(Map *map);
|
||||||
void setUnits(enum Units units);
|
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
void setWidth(int width);
|
void setWidth(int width);
|
||||||
void setStyle(Qt::PenStyle style);
|
void setStyle(Qt::PenStyle style);
|
||||||
|
|
||||||
|
void showMarker(bool show) {_marker->setVisible(show);}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void moveMarker(qreal distance);
|
void moveMarker(qreal distance);
|
||||||
|
|
||||||
@ -34,22 +38,24 @@ signals:
|
|||||||
void selected(bool);
|
void selected(bool);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateShape();
|
Path _path;
|
||||||
|
|
||||||
QVector<qreal> _distance;
|
|
||||||
QPainterPath _path;
|
|
||||||
MarkerItem *_marker;
|
MarkerItem *_marker;
|
||||||
Units _units;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF position(qreal distance) const;
|
QPointF position(qreal distance) const;
|
||||||
|
void updatePainterPath(Map *map);
|
||||||
|
void updateShape();
|
||||||
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
|
Map *_map;
|
||||||
|
qreal _md;
|
||||||
|
|
||||||
int _width;
|
int _width;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
|
QPainterPath _painterPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PATHITEM_H
|
#endif // PATHITEM_H
|
||||||
|
349
src/pathview.cpp
349
src/pathview.cpp
@ -3,11 +3,11 @@
|
|||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "rd.h"
|
#include "misc.h"
|
||||||
#include "wgs84.h"
|
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "emptymap.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
@ -15,59 +15,9 @@
|
|||||||
#include "pathview.h"
|
#include "pathview.h"
|
||||||
|
|
||||||
|
|
||||||
#define ZOOM_MAX 18
|
|
||||||
#define ZOOM_MIN 3
|
|
||||||
#define MARGIN 10.0
|
#define MARGIN 10.0
|
||||||
#define SCALE_OFFSET 7
|
#define SCALE_OFFSET 7
|
||||||
|
|
||||||
static QPoint mercator2tile(const QPointF &m, int z)
|
|
||||||
{
|
|
||||||
QPoint tile;
|
|
||||||
|
|
||||||
tile.setX((int)(floor((m.x() + 180.0) / 360.0 * (1<<z))));
|
|
||||||
tile.setY((int)(floor((1.0 - (m.y() / 180.0)) / 2.0 * (1<<z))));
|
|
||||||
|
|
||||||
return tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QPointF tile2mercator(const QPoint &tile, int z)
|
|
||||||
{
|
|
||||||
QPointF m;
|
|
||||||
|
|
||||||
m.setX(((360.0 * tile.x()) / (qreal)(1<<z)) - 180.0);
|
|
||||||
m.setY((1.0 - (2.0 * tile.y()) / (qreal)(1<<z)) * 180.0);
|
|
||||||
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int scale2zoom(qreal scale)
|
|
||||||
{
|
|
||||||
int zoom = (int)log2(360.0/(scale * (qreal)Tile::size()));
|
|
||||||
|
|
||||||
if (zoom < ZOOM_MIN)
|
|
||||||
return ZOOM_MIN;
|
|
||||||
if (zoom > ZOOM_MAX)
|
|
||||||
return ZOOM_MAX;
|
|
||||||
|
|
||||||
return zoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal mapScale(int zoom)
|
|
||||||
{
|
|
||||||
return ((360.0/(qreal)(1<<zoom))/(qreal)Tile::size());
|
|
||||||
}
|
|
||||||
|
|
||||||
static QRectF mapBounds()
|
|
||||||
{
|
|
||||||
return QRectF(QPointF(-180, -180), QSizeF(360, 360));
|
|
||||||
}
|
|
||||||
|
|
||||||
static qreal zoom2resolution(int zoom, qreal y)
|
|
||||||
{
|
|
||||||
return (WGS84_RADIUS * 2 * M_PI / Tile::size()
|
|
||||||
* cos(2.0 * atan(exp(deg2rad(y))) - M_PI/2)) / (qreal)(1<<zoom);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void unite(QRectF &rect, const QPointF &p)
|
static void unite(QRectF &rect, const QPointF &p)
|
||||||
{
|
{
|
||||||
if (p.x() < rect.left())
|
if (p.x() < rect.left())
|
||||||
@ -80,16 +30,12 @@ static void unite(QRectF &rect, const QPointF &p)
|
|||||||
rect.setTop(p.y());
|
rect.setTop(p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
static QRectF scaled(const QRectF &rect, qreal factor)
|
PathView::PathView(Map *map, POI *poi, QWidget *parent)
|
||||||
{
|
|
||||||
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
|
||||||
QSizeF(rect.width() * factor, rect.height() * factor));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PathView::PathView(QWidget *parent)
|
|
||||||
: QGraphicsView(parent)
|
: QGraphicsView(parent)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(map != 0);
|
||||||
|
Q_ASSERT(poi != 0);
|
||||||
|
|
||||||
_scene = new QGraphicsScene(this);
|
_scene = new QGraphicsScene(this);
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
setCacheMode(QGraphicsView::CacheBackground);
|
setCacheMode(QGraphicsView::CacheBackground);
|
||||||
@ -103,13 +49,14 @@ PathView::PathView(QWidget *parent)
|
|||||||
_mapScale = new ScaleItem();
|
_mapScale = new ScaleItem();
|
||||||
_mapScale->setZValue(2.0);
|
_mapScale->setZValue(2.0);
|
||||||
|
|
||||||
_zoom = ZOOM_MAX;
|
_map = map;
|
||||||
_res = 1.0;
|
_poi = poi;
|
||||||
_map = 0;
|
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
_poi = 0;
|
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
|
||||||
|
_showMap = true;
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
_showRoutes = true;
|
_showRoutes = true;
|
||||||
_showWaypoints = true;
|
_showWaypoints = true;
|
||||||
@ -125,7 +72,8 @@ PathView::PathView(QWidget *parent)
|
|||||||
|
|
||||||
_plot = false;
|
_plot = false;
|
||||||
|
|
||||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / mapScale(_zoom)));
|
_scene->setSceneRect(_map->bounds());
|
||||||
|
_res = _map->resolution(_scene->sceneRect().center());
|
||||||
}
|
}
|
||||||
|
|
||||||
PathView::~PathView()
|
PathView::~PathView()
|
||||||
@ -141,19 +89,16 @@ PathItem *PathView::addTrack(const Track &track)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackItem *ti = new TrackItem(track);
|
TrackItem *ti = new TrackItem(track, _map);
|
||||||
_tracks.append(ti);
|
_tracks.append(ti);
|
||||||
_tr |= ti->path().boundingRect();
|
_tr |= ti->path().boundingRect();
|
||||||
_zoom = scale2zoom(contentsScale());
|
|
||||||
ti->setScale(1.0/mapScale(_zoom));
|
|
||||||
ti->setColor(_palette.nextColor());
|
ti->setColor(_palette.nextColor());
|
||||||
ti->setWidth(_trackWidth);
|
ti->setWidth(_trackWidth);
|
||||||
ti->setStyle(_trackStyle);
|
ti->setStyle(_trackStyle);
|
||||||
ti->setVisible(_showTracks);
|
ti->setVisible(_showTracks);
|
||||||
_scene->addItem(ti);
|
_scene->addItem(ti);
|
||||||
|
|
||||||
if (_poi)
|
addPOI(_poi->points(ti->path()));
|
||||||
addPOI(_poi->points(ti));
|
|
||||||
|
|
||||||
return ti;
|
return ti;
|
||||||
}
|
}
|
||||||
@ -165,11 +110,9 @@ PathItem *PathView::addRoute(const Route &route)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteItem *ri = new RouteItem(route);
|
RouteItem *ri = new RouteItem(route, _map);
|
||||||
_routes.append(ri);
|
_routes.append(ri);
|
||||||
_rr |= ri->path().boundingRect();
|
_rr |= ri->path().boundingRect();
|
||||||
_zoom = scale2zoom(contentsScale());
|
|
||||||
ri->setScale(1.0/mapScale(_zoom));
|
|
||||||
ri->setColor(_palette.nextColor());
|
ri->setColor(_palette.nextColor());
|
||||||
ri->setWidth(_routeWidth);
|
ri->setWidth(_routeWidth);
|
||||||
ri->setStyle(_routeStyle);
|
ri->setStyle(_routeStyle);
|
||||||
@ -178,61 +121,52 @@ PathItem *PathView::addRoute(const Route &route)
|
|||||||
ri->showWaypointLabels(_showWaypointLabels);
|
ri->showWaypointLabels(_showWaypointLabels);
|
||||||
_scene->addItem(ri);
|
_scene->addItem(ri);
|
||||||
|
|
||||||
if (_poi)
|
addPOI(_poi->points(ri->path()));
|
||||||
addPOI(_poi->points(ri));
|
|
||||||
|
|
||||||
return ri;
|
return ri;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
qreal scale = mapScale(_zoom);
|
|
||||||
|
|
||||||
for (int i = 0; i < waypoints.count(); i++) {
|
for (int i = 0; i < waypoints.count(); i++) {
|
||||||
const Waypoint &w = waypoints.at(i);
|
const Waypoint &w = waypoints.at(i);
|
||||||
|
|
||||||
WaypointItem *wi = new WaypointItem(w);
|
WaypointItem *wi = new WaypointItem(w, _map);
|
||||||
_waypoints.append(wi);
|
_waypoints.append(wi);
|
||||||
updateWaypointsBoundingRect(wi->coordinates());
|
Coordinates c = wi->waypoint().coordinates();
|
||||||
wi->setScale(1.0/scale);
|
updateWaypointsBoundingRect(QPointF(c.lon(), c.lat()));
|
||||||
wi->setZValue(1);
|
wi->setZValue(1);
|
||||||
wi->showLabel(_showWaypointLabels);
|
wi->showLabel(_showWaypointLabels);
|
||||||
wi->setVisible(_showWaypoints);
|
wi->setVisible(_showWaypoints);
|
||||||
_scene->addItem(wi);
|
_scene->addItem(wi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_poi)
|
addPOI(_poi->points(waypoints));
|
||||||
addPOI(_poi->points(waypoints));
|
|
||||||
|
|
||||||
_zoom = scale2zoom(contentsScale());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PathItem *> PathView::loadData(const Data &data)
|
QList<PathItem *> PathView::loadData(const Data &data)
|
||||||
{
|
{
|
||||||
QList<PathItem *> paths;
|
QList<PathItem *> paths;
|
||||||
int zoom = _zoom;
|
qreal scale = _map->zoom();
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < data.tracks().count(); i++)
|
for (int i = 0; i < data.tracks().count(); i++)
|
||||||
paths.append(addTrack(*(data.tracks().at(i))));
|
paths.append(addTrack(*(data.tracks().at(i))));
|
||||||
|
|
||||||
for (int i = 0; i < data.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
paths.append(addRoute(*(data.routes().at(i))));
|
paths.append(addRoute(*(data.routes().at(i))));
|
||||||
|
|
||||||
addWaypoints(data.waypoints());
|
addWaypoints(data.waypoints());
|
||||||
|
|
||||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||||
return paths;
|
return paths;
|
||||||
|
|
||||||
if (_zoom < zoom)
|
if (mapScale() != scale)
|
||||||
rescale(_zoom);
|
rescale();
|
||||||
else
|
else
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
|
|
||||||
QPointF center = contentsCenter();
|
QPointF center = contentCenter();
|
||||||
centerOn(center);
|
centerOn(center);
|
||||||
|
|
||||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
_res = _map->resolution(center);
|
||||||
_mapScale->setResolution(_res);
|
_mapScale->setResolution(_res);
|
||||||
if (_mapScale->scene() != _scene)
|
if (_mapScale->scene() != _scene)
|
||||||
_scene->addItem(_mapScale);
|
_scene->addItem(_mapScale);
|
||||||
@ -253,33 +187,25 @@ void PathView::updateWaypointsBoundingRect(const QPointF &wp)
|
|||||||
unite(_wr, wp);
|
unite(_wr, wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal PathView::contentsScale() const
|
qreal PathView::mapScale() const
|
||||||
{
|
{
|
||||||
QRectF br = _tr | _rr | _wr;
|
QRectF br = _tr | _rr | _wr;
|
||||||
if (!br.isNull() && !_wp.isNull())
|
if (!br.isNull() && !_wp.isNull())
|
||||||
unite(br, _wp);
|
unite(br, _wp);
|
||||||
|
|
||||||
if (br.isNull())
|
return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br);
|
||||||
return mapScale(ZOOM_MAX);
|
|
||||||
|
|
||||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
|
||||||
br.height() / (viewport()->height() - MARGIN/2));
|
|
||||||
|
|
||||||
return qMax(sc.x(), sc.y());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF PathView::contentsCenter() const
|
QPointF PathView::contentCenter() const
|
||||||
{
|
{
|
||||||
QRectF br = _tr | _rr | _wr;
|
QRectF br = _tr | _rr | _wr;
|
||||||
if (!br.isNull() && !_wp.isNull())
|
if (!br.isNull() && !_wp.isNull())
|
||||||
unite(br, _wp);
|
unite(br, _wp);
|
||||||
|
|
||||||
qreal scale = mapScale(_zoom);
|
|
||||||
|
|
||||||
if (br.isNull())
|
if (br.isNull())
|
||||||
return _wp / scale;
|
return _map->ll2xy(_wp);
|
||||||
else
|
else
|
||||||
return scaled(br, 1.0/scale).center();
|
return _map->ll2xy(br.center());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::updatePOIVisibility()
|
void PathView::updatePOIVisibility()
|
||||||
@ -303,25 +229,21 @@ void PathView::updatePOIVisibility()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::rescale(int zoom)
|
void PathView::rescale()
|
||||||
{
|
{
|
||||||
_zoom = zoom;
|
_scene->setSceneRect(_map->bounds());
|
||||||
qreal scale = mapScale(zoom);
|
resetCachedContent();
|
||||||
|
|
||||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / scale));
|
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++)
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
_tracks.at(i)->setScale(1.0/scale);
|
_tracks.at(i)->setMap(_map);
|
||||||
|
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
_routes.at(i)->setScale(1.0/scale);
|
_routes.at(i)->setMap(_map);
|
||||||
|
|
||||||
for (int i = 0; i < _waypoints.size(); i++)
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
_waypoints.at(i)->setScale(1.0/scale);
|
_waypoints.at(i)->setMap(_map);
|
||||||
|
|
||||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||||
it.value()->setScale(1.0/scale);
|
it.value()->setMap(_map);
|
||||||
|
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
}
|
}
|
||||||
@ -337,16 +259,41 @@ void PathView::setPalette(const Palette &palette)
|
|||||||
_routes.at(i)->setColor(_palette.nextColor());
|
_routes.at(i)->setColor(_palette.nextColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathView::setMap(Map *map)
|
||||||
|
{
|
||||||
|
_map->unload();
|
||||||
|
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
|
|
||||||
|
_map = map;
|
||||||
|
_map->load();
|
||||||
|
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||||
|
|
||||||
|
mapScale();
|
||||||
|
_scene->setSceneRect(_map->bounds());
|
||||||
|
|
||||||
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
|
_tracks.at(i)->setMap(map);
|
||||||
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
|
_routes.at(i)->setMap(map);
|
||||||
|
for (int i = 0; i < _waypoints.size(); i++)
|
||||||
|
_waypoints.at(i)->setMap(map);
|
||||||
|
|
||||||
|
QPointF center = contentCenter();
|
||||||
|
centerOn(center);
|
||||||
|
|
||||||
|
_res = _map->resolution(center);
|
||||||
|
_mapScale->setResolution(_res);
|
||||||
|
|
||||||
|
resetCachedContent();
|
||||||
|
}
|
||||||
|
|
||||||
void PathView::setPOI(POI *poi)
|
void PathView::setPOI(POI *poi)
|
||||||
{
|
{
|
||||||
if (_poi)
|
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
disconnect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
connect(poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||||
|
|
||||||
_poi = poi;
|
_poi = poi;
|
||||||
|
|
||||||
if (_poi)
|
|
||||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
|
||||||
|
|
||||||
updatePOI();
|
updatePOI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,13 +307,10 @@ void PathView::updatePOI()
|
|||||||
}
|
}
|
||||||
_pois.clear();
|
_pois.clear();
|
||||||
|
|
||||||
if (!_poi)
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.size(); i++)
|
for (int i = 0; i < _tracks.size(); i++)
|
||||||
addPOI(_poi->points(_tracks.at(i)));
|
addPOI(_poi->points(_tracks.at(i)->path()));
|
||||||
for (int i = 0; i < _routes.size(); i++)
|
for (int i = 0; i < _routes.size(); i++)
|
||||||
addPOI(_poi->points(_routes.at(i)));
|
addPOI(_poi->points(_routes.at(i)->path()));
|
||||||
addPOI(_poi->points(_waypoints));
|
addPOI(_poi->points(_waypoints));
|
||||||
|
|
||||||
updatePOIVisibility();
|
updatePOIVisibility();
|
||||||
@ -374,16 +318,13 @@ void PathView::updatePOI()
|
|||||||
|
|
||||||
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
qreal scale = mapScale(_zoom);
|
|
||||||
|
|
||||||
for (int i = 0; i < waypoints.size(); i++) {
|
for (int i = 0; i < waypoints.size(); i++) {
|
||||||
const Waypoint &w = waypoints.at(i);
|
const Waypoint &w = waypoints.at(i);
|
||||||
|
|
||||||
if (_pois.contains(w))
|
if (_pois.contains(w))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
WaypointItem *pi = new WaypointItem(w);
|
WaypointItem *pi = new WaypointItem(w, _map);
|
||||||
pi->setScale(1.0/scale);
|
|
||||||
pi->setZValue(1);
|
pi->setZValue(1);
|
||||||
pi->showLabel(_showPOILabels);
|
pi->showLabel(_showPOILabels);
|
||||||
pi->setVisible(_showPOI);
|
pi->setVisible(_showPOI);
|
||||||
@ -393,19 +334,6 @@ void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::setMap(Map *map)
|
|
||||||
{
|
|
||||||
if (_map)
|
|
||||||
disconnect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
|
||||||
|
|
||||||
_map = map;
|
|
||||||
|
|
||||||
if (_map)
|
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
|
||||||
|
|
||||||
resetCachedContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PathView::setUnits(enum Units units)
|
void PathView::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
@ -429,60 +357,71 @@ void PathView::redraw()
|
|||||||
resetCachedContent();
|
resetCachedContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::zoom(int z, const QPoint &pos)
|
void PathView::zoom(const QPoint &pos, const Coordinates &c)
|
||||||
{
|
{
|
||||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QPoint offset = pos - viewport()->rect().center();
|
QPoint offset = pos - viewport()->rect().center();
|
||||||
QPointF spos = mapToScene(pos);
|
|
||||||
|
|
||||||
qreal os = mapScale(_zoom);
|
rescale();
|
||||||
_zoom = z;
|
|
||||||
|
|
||||||
rescale(_zoom);
|
QPointF center = _map->ll2xy(c) - offset;
|
||||||
|
|
||||||
QPointF center = (spos * (os/mapScale(_zoom))) - offset;
|
|
||||||
centerOn(center);
|
centerOn(center);
|
||||||
|
|
||||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
_res = _map->resolution(center);
|
||||||
_mapScale->setResolution(_res);
|
_mapScale->setResolution(_res);
|
||||||
|
|
||||||
resetCachedContent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::wheelEvent(QWheelEvent *event)
|
void PathView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
int z = (event->delta() > 0) ?
|
qreal os, ns;
|
||||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
static int deg = 0;
|
||||||
|
|
||||||
zoom(z, event->pos());
|
deg += event->delta() / 8;
|
||||||
|
if (qAbs(deg) < 15)
|
||||||
|
return;
|
||||||
|
deg = 0;
|
||||||
|
|
||||||
|
os = _map->zoom();
|
||||||
|
Coordinates c = _map->xy2ll(mapToScene(event->pos()));
|
||||||
|
|
||||||
|
ns = (event->delta() > 0) ? _map->zoomIn() : _map->zoomOut();
|
||||||
|
if (ns != os)
|
||||||
|
zoom(event->pos(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::mouseDoubleClickEvent(QMouseEvent *event)
|
void PathView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
qreal os, ns;
|
||||||
|
|
||||||
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
|
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int z = (event->button() == Qt::LeftButton) ?
|
os = _map->zoom();
|
||||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
Coordinates c = _map->xy2ll(mapToScene(event->pos()));
|
||||||
|
|
||||||
zoom(z, event->pos());
|
ns = (event->button() == Qt::LeftButton) ? _map->zoomIn() : _map->zoomOut();
|
||||||
|
if (ns != os)
|
||||||
|
zoom(event->pos(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::keyPressEvent(QKeyEvent *event)
|
void PathView::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
int z = -1;
|
qreal os, ns;
|
||||||
|
|
||||||
|
os = _map->zoom();
|
||||||
|
QPoint pos = QRect(QPoint(), viewport()->size()).center();
|
||||||
|
Coordinates c = _map->xy2ll(mapToScene(pos));
|
||||||
|
|
||||||
if (event->matches(QKeySequence::ZoomIn))
|
if (event->matches(QKeySequence::ZoomIn))
|
||||||
z = qMin(_zoom + 1, ZOOM_MAX);
|
ns = _map->zoomIn();
|
||||||
if (event->matches(QKeySequence::ZoomOut))
|
else if (event->matches(QKeySequence::ZoomOut))
|
||||||
z = qMax(_zoom - 1, ZOOM_MIN);
|
ns = _map->zoomOut();
|
||||||
|
else {
|
||||||
if (z >= 0)
|
|
||||||
zoom(z, QRect(QPoint(), size()).center());
|
|
||||||
else
|
|
||||||
QWidget::keyPressEvent(event);
|
QWidget::keyPressEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ns != os)
|
||||||
|
zoom(pos, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::plot(QPainter *painter, const QRectF &target)
|
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||||
@ -494,7 +433,7 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
|||||||
orig = viewport()->rect();
|
orig = viewport()->rect();
|
||||||
|
|
||||||
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
|
if (orig.height() * (target.width() / target.height()) - orig.width() < 0) {
|
||||||
ratio = target.height()/target.width();
|
ratio = target.height() / target.width();
|
||||||
diff = (orig.width() * ratio) - orig.height();
|
diff = (orig.width() * ratio) - orig.height();
|
||||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||||
} else {
|
} else {
|
||||||
@ -505,6 +444,7 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
|||||||
|
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
_plot = true;
|
_plot = true;
|
||||||
|
_map->setBlockingMode(true);
|
||||||
|
|
||||||
QPointF pos = _mapScale->pos();
|
QPointF pos = _mapScale->pos();
|
||||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||||
@ -515,6 +455,7 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
|||||||
|
|
||||||
_mapScale->setPos(pos);
|
_mapScale->setPos(pos);
|
||||||
|
|
||||||
|
_map->setBlockingMode(false);
|
||||||
_plot = false;
|
_plot = false;
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
}
|
}
|
||||||
@ -531,12 +472,8 @@ void PathView::clear()
|
|||||||
_scene->clear();
|
_scene->clear();
|
||||||
_palette.reset();
|
_palette.reset();
|
||||||
|
|
||||||
_zoom = ZOOM_MAX;
|
|
||||||
_res = 1.0;
|
|
||||||
_tr = QRectF(); _rr = QRectF(); _wr = QRectF();
|
_tr = QRectF(); _rr = QRectF(); _wr = QRectF();
|
||||||
_wp = QPointF();
|
_wp = QPointF();
|
||||||
|
|
||||||
_scene->setSceneRect(QRectF());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::showTracks(bool show)
|
void PathView::showTracks(bool show)
|
||||||
@ -582,6 +519,12 @@ void PathView::showRouteWaypoints(bool show)
|
|||||||
_routes.at(i)->showWaypoints(show);
|
_routes.at(i)->showWaypoints(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PathView::showMap(bool show)
|
||||||
|
{
|
||||||
|
_showMap = show;
|
||||||
|
resetCachedContent();
|
||||||
|
}
|
||||||
|
|
||||||
void PathView::showPOI(bool show)
|
void PathView::showPOI(bool show)
|
||||||
{
|
{
|
||||||
_showPOI = show;
|
_showPOI = show;
|
||||||
@ -645,54 +588,25 @@ void PathView::setRouteStyle(Qt::PenStyle style)
|
|||||||
|
|
||||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
if (_showMap)
|
||||||
|| !_map) {
|
_map->draw(painter, rect);
|
||||||
|
else
|
||||||
painter->fillRect(rect, Qt::white);
|
painter->fillRect(rect, Qt::white);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal scale = mapScale(_zoom);
|
|
||||||
QRectF rr(rect.topLeft() * scale, rect.size());
|
|
||||||
QPoint tile = mercator2tile(QPointF(rr.topLeft().x(), -rr.topLeft().y()),
|
|
||||||
_zoom);
|
|
||||||
QPointF tm = tile2mercator(tile, _zoom);
|
|
||||||
QPoint tl = QPoint((int)(tm.x() / scale), (int)(-tm.y() / scale));
|
|
||||||
|
|
||||||
|
|
||||||
QList<Tile> tiles;
|
|
||||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
|
||||||
for (int i = 0; i < ceil(s.width() / Tile::size()); i++)
|
|
||||||
for (int j = 0; j < ceil(s.height() / Tile::size()); j++)
|
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
|
||||||
|
|
||||||
_map->loadTiles(tiles, _plot);
|
|
||||||
|
|
||||||
for (int i = 0; i < tiles.count(); i++) {
|
|
||||||
Tile &t = tiles[i];
|
|
||||||
QPoint tp(tl.x() + (t.xy().x() - tile.x()) * Tile::size(),
|
|
||||||
tl.y() + (t.xy().y() - tile.y()) * Tile::size());
|
|
||||||
painter->drawPixmap(tp, t.pixmap());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::resizeEvent(QResizeEvent *event)
|
void PathView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
qreal scale = _map->zoom();
|
||||||
|
if (mapScale() != scale)
|
||||||
|
rescale();
|
||||||
|
|
||||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
QPointF center = contentCenter();
|
||||||
return;
|
|
||||||
|
|
||||||
int zoom = scale2zoom(contentsScale());
|
|
||||||
if (zoom != _zoom)
|
|
||||||
rescale(zoom);
|
|
||||||
|
|
||||||
QPointF center = contentsCenter();
|
|
||||||
centerOn(center);
|
centerOn(center);
|
||||||
|
|
||||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
_res = _map->resolution(center);
|
||||||
_mapScale->setResolution(_res);
|
_mapScale->setResolution(_res);
|
||||||
|
|
||||||
resetCachedContent();
|
QGraphicsView::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathView::paintEvent(QPaintEvent *event)
|
void PathView::paintEvent(QPaintEvent *event)
|
||||||
@ -711,7 +625,7 @@ void PathView::scrollContentsBy(int dx, int dy)
|
|||||||
QGraphicsView::scrollContentsBy(dx, dy);
|
QGraphicsView::scrollContentsBy(dx, dy);
|
||||||
|
|
||||||
QPointF center = mapToScene(viewport()->rect().center());
|
QPointF center = mapToScene(viewport()->rect().center());
|
||||||
qreal res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
qreal res = _map->resolution(center);
|
||||||
|
|
||||||
if (qMax(res, _res) / qMin(res, _res) > 1.1) {
|
if (qMax(res, _res) / qMin(res, _res) > 1.1) {
|
||||||
_mapScale->setResolution(res);
|
_mapScale->setResolution(res);
|
||||||
@ -721,11 +635,8 @@ void PathView::scrollContentsBy(int dx, int dy)
|
|||||||
|
|
||||||
void PathView::useOpenGL(bool use)
|
void PathView::useOpenGL(bool use)
|
||||||
{
|
{
|
||||||
if (use) {
|
if (use)
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
|
||||||
#endif // Q_OS_WIN32
|
|
||||||
setViewport(new OPENGL_WIDGET);
|
setViewport(new OPENGL_WIDGET);
|
||||||
} else
|
else
|
||||||
setViewport(new QWidget);
|
setViewport(new QWidget);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ class PathView : public QGraphicsView
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PathView(QWidget *parent = 0);
|
PathView(Map *map, POI *poi, QWidget *parent = 0);
|
||||||
~PathView();
|
~PathView();
|
||||||
|
|
||||||
QList<PathItem*> loadData(const Data &data);
|
QList<PathItem*> loadData(const Data &data);
|
||||||
@ -48,6 +48,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void redraw();
|
void redraw();
|
||||||
|
|
||||||
|
void showMap(bool show);
|
||||||
void showPOI(bool show);
|
void showPOI(bool show);
|
||||||
void setPOIOverlap(bool overlap);
|
void setPOIOverlap(bool overlap);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
@ -72,10 +73,10 @@ private:
|
|||||||
void loadPOI();
|
void loadPOI();
|
||||||
void clearPOI();
|
void clearPOI();
|
||||||
|
|
||||||
qreal contentsScale() const;
|
qreal mapScale() const;
|
||||||
QPointF contentsCenter() const;
|
QPointF contentCenter() const;
|
||||||
void rescale(int zoom);
|
void rescale();
|
||||||
void zoom(int z, const QPoint &pos);
|
void zoom(const QPoint &pos, const Coordinates &c);
|
||||||
void updatePOIVisibility();
|
void updatePOIVisibility();
|
||||||
void updateWaypointsBoundingRect(const QPointF &wp);
|
void updateWaypointsBoundingRect(const QPointF &wp);
|
||||||
|
|
||||||
@ -94,7 +95,6 @@ private:
|
|||||||
QList<WaypointItem*> _waypoints;
|
QList<WaypointItem*> _waypoints;
|
||||||
QHash<Waypoint, WaypointItem*> _pois;
|
QHash<Waypoint, WaypointItem*> _pois;
|
||||||
|
|
||||||
int _zoom;
|
|
||||||
QRectF _tr, _rr, _wr;
|
QRectF _tr, _rr, _wr;
|
||||||
QPointF _wp;
|
QPointF _wp;
|
||||||
qreal _res;
|
qreal _res;
|
||||||
@ -104,6 +104,7 @@ private:
|
|||||||
Palette _palette;
|
Palette _palette;
|
||||||
Units _units;
|
Units _units;
|
||||||
|
|
||||||
|
bool _showMap;
|
||||||
bool _showTracks;
|
bool _showTracks;
|
||||||
bool _showRoutes;
|
bool _showRoutes;
|
||||||
bool _showWaypoints;
|
bool _showWaypoints;
|
||||||
|
11
src/poi.cpp
11
src/poi.cpp
@ -58,18 +58,15 @@ static bool cb(size_t data, void* context)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Waypoint> POI::points(const PathItem *path) const
|
QVector<Waypoint> POI::points(const Path &path) const
|
||||||
{
|
{
|
||||||
QVector<Waypoint> ret;
|
QVector<Waypoint> ret;
|
||||||
QSet<int> set;
|
QSet<int> set;
|
||||||
qreal min[2], max[2];
|
qreal min[2], max[2];
|
||||||
const QPainterPath &pp = path->path();
|
|
||||||
|
|
||||||
for (int i = 0; i < pp.elementCount(); i++) {
|
for (int i = 0; i < path.count(); i++) {
|
||||||
const QPainterPath::Element &pe = pp.elementAt(i);
|
const Coordinates &c = path.at(i).coordinates();
|
||||||
Coordinates p = Coordinates::fromMercator(QPointF(pe.x, -pe.y));
|
QPair<Coordinates, Coordinates> br = c.boundingRect(_radius);
|
||||||
|
|
||||||
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
|
||||||
min[0] = br.first.lon();
|
min[0] = br.first.lon();
|
||||||
min[1] = br.first.lat();
|
min[1] = br.first.lat();
|
||||||
max[0] = br.second.lon();
|
max[0] = br.second.lon();
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "rtree.h"
|
#include "rtree.h"
|
||||||
|
#include "path.h"
|
||||||
|
|
||||||
class PathItem;
|
|
||||||
class WaypointItem;
|
class WaypointItem;
|
||||||
|
|
||||||
class POI : public QObject
|
class POI : public QObject
|
||||||
@ -25,7 +25,7 @@ public:
|
|||||||
unsigned radius() const {return _radius;}
|
unsigned radius() const {return _radius;}
|
||||||
void setRadius(unsigned radius);
|
void setRadius(unsigned radius);
|
||||||
|
|
||||||
QVector<Waypoint> points(const PathItem *path) const;
|
QVector<Waypoint> points(const Path &path) const;
|
||||||
QVector<Waypoint> points(const QList<WaypointItem*> &list) const;
|
QVector<Waypoint> points(const QList<WaypointItem*> &list) const;
|
||||||
QVector<Waypoint> points(const QList<Waypoint> &list) const;
|
QVector<Waypoint> points(const QList<Waypoint> &list) const;
|
||||||
|
|
||||||
|
@ -13,9 +13,7 @@ public:
|
|||||||
QString label() const {return tr("Power");}
|
QString label() const {return tr("Power");}
|
||||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units) {}
|
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
|
15
src/projection.h
Normal file
15
src/projection.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef PROJECTION_H
|
||||||
|
#define PROJECTION_H
|
||||||
|
|
||||||
|
#include <QPointF>
|
||||||
|
#include "coordinates.h"
|
||||||
|
|
||||||
|
class Projection {
|
||||||
|
public:
|
||||||
|
virtual ~Projection() {}
|
||||||
|
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const = 0;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROJECTION_H
|
@ -11,6 +11,16 @@ Route::Route(const RouteData &data) : _data(data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path Route::path() const
|
||||||
|
{
|
||||||
|
Path ret;
|
||||||
|
|
||||||
|
for (int i = 0; i < _data.size(); i++)
|
||||||
|
ret.append(PathPoint(_data.at(i).coordinates(), _distance.at(i)));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
Graph Route::elevation() const
|
Graph Route::elevation() const
|
||||||
{
|
{
|
||||||
Graph graph;
|
Graph graph;
|
||||||
|
@ -11,13 +11,17 @@ class Route
|
|||||||
public:
|
public:
|
||||||
Route(const RouteData &data);
|
Route(const RouteData &data);
|
||||||
|
|
||||||
const RouteData &routeData() const {return _data;}
|
Path path() const;
|
||||||
const QVector<qreal> &distanceData() const {return _distance;}
|
|
||||||
|
const QVector<Waypoint> &waypoints() const {return _data;}
|
||||||
|
|
||||||
Graph elevation() const;
|
Graph elevation() const;
|
||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
|
|
||||||
|
const QString &name() const {return _data.name();}
|
||||||
|
const QString &description() const {return _data.description();}
|
||||||
|
|
||||||
bool isNull() const {return (_data.count() < 2);}
|
bool isNull() const {return (_data.count() < 2);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -3,10 +3,11 @@
|
|||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
|
#include "map.h"
|
||||||
#include "routeitem.h"
|
#include "routeitem.h"
|
||||||
|
|
||||||
|
|
||||||
QString RouteItem::toolTip()
|
QString RouteItem::toolTip(Units units)
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
@ -14,58 +15,41 @@ QString RouteItem::toolTip()
|
|||||||
tt.insert(tr("Name"), _name);
|
tt.insert(tr("Name"), _name);
|
||||||
if (!_desc.isEmpty())
|
if (!_desc.isEmpty())
|
||||||
tt.insert(tr("Description"), _desc);
|
tt.insert(tr("Description"), _desc);
|
||||||
tt.insert(tr("Distance"), Format::distance(_distance.last(), _units));
|
tt.insert(tr("Distance"), Format::distance(_path.last().distance(), units));
|
||||||
|
|
||||||
return tt.toString();
|
return tt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
||||||
: PathItem(parent)
|
: PathItem(route.path(), map, parent)
|
||||||
{
|
{
|
||||||
const RouteData &r = route.routeData();
|
const QVector<Waypoint> &waypoints = route.waypoints();
|
||||||
const QVector<qreal> &d = route.distanceData();
|
|
||||||
QPointF p;
|
|
||||||
|
|
||||||
|
for (int i = 0; i < waypoints.size(); i++)
|
||||||
|
new WaypointItem(waypoints.at(i), map, this);
|
||||||
|
|
||||||
Q_ASSERT(r.count() >= 2);
|
_name = route.name();
|
||||||
Q_ASSERT(r.size() == d.size());
|
_desc = route.description();
|
||||||
|
|
||||||
_name = r.name();
|
setToolTip(toolTip(Metric));
|
||||||
_desc = r.description();
|
|
||||||
|
|
||||||
new WaypointItem(r.first(), this);
|
|
||||||
p = r.first().coordinates().toMercator();
|
|
||||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
|
||||||
_distance.append(d.first());
|
|
||||||
for (int i = 1; i < r.size(); i++) {
|
|
||||||
if (r.at(i).coordinates() == r.at(i-1).coordinates())
|
|
||||||
continue;
|
|
||||||
p = r.at(i).coordinates().toMercator();
|
|
||||||
_path.lineTo(QPointF(p.x(), -p.y()));
|
|
||||||
_distance.append(d.at(i));
|
|
||||||
new WaypointItem(r.at(i), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateShape();
|
|
||||||
|
|
||||||
_marker->setPos(_path.elementAt(0));
|
|
||||||
|
|
||||||
setToolTip(toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setScale(qreal scale)
|
void RouteItem::setMap(Map *map)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> childs = childItems();
|
QList<QGraphicsItem *> childs = childItems();
|
||||||
for (int i = 0; i < childs.count(); i++)
|
for (int i = 0; i < childs.count(); i++) {
|
||||||
childs.at(i)->setScale(1.0/scale);
|
if (childs.at(i) != _marker) {
|
||||||
|
WaypointItem *wi = static_cast<WaypointItem*>(childs.at(i));
|
||||||
|
wi->setMap(map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PathItem::setScale(scale);
|
PathItem::setMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::setUnits(enum Units units)
|
void RouteItem::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
PathItem::setUnits(units);
|
setToolTip(toolTip(units));
|
||||||
setToolTip(toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouteItem::showWaypoints(bool show)
|
void RouteItem::showWaypoints(bool show)
|
||||||
|
@ -3,23 +3,26 @@
|
|||||||
|
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
class RouteItem : public PathItem
|
class RouteItem : public PathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RouteItem(const Route &route, QGraphicsItem *parent = 0);
|
RouteItem(const Route &route, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
void setUnits(enum Units units);
|
//void setScale(qreal scale);
|
||||||
void setScale(qreal scale);
|
void setMap(Map *map);
|
||||||
|
|
||||||
|
void setUnits(Units units);
|
||||||
void showWaypoints(bool show);
|
void showWaypoints(bool show);
|
||||||
void showWaypointLabels(bool show);
|
void showWaypointLabels(bool show);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip();
|
QString toolTip(Units units);
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _desc;
|
QString _desc;
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#define WINDOW_POS_DEFAULT QPoint(10, 10)
|
#define WINDOW_POS_DEFAULT QPoint(10, 10)
|
||||||
|
|
||||||
#define SETTINGS_SETTINGS_GROUP "Settings"
|
#define SETTINGS_SETTINGS_GROUP "Settings"
|
||||||
|
#define TIME_TYPE_SETTING "timeType"
|
||||||
|
#define TIME_TYPE_DEFAULT Total
|
||||||
#define UNITS_SETTING "units"
|
#define UNITS_SETTING "units"
|
||||||
#define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric)
|
#define UNITS_DEFAULT (IMPERIAL_UNITS() ? Imperial : Metric)
|
||||||
#define SHOW_TOOLBARS_SETTING "toolbar"
|
#define SHOW_TOOLBARS_SETTING "toolbar"
|
||||||
@ -100,6 +102,8 @@
|
|||||||
#define PRINT_DISTANCE_DEFAULT true
|
#define PRINT_DISTANCE_DEFAULT true
|
||||||
#define PRINT_TIME_SETTING "printTime"
|
#define PRINT_TIME_SETTING "printTime"
|
||||||
#define PRINT_TIME_DEFAULT true
|
#define PRINT_TIME_DEFAULT true
|
||||||
|
#define PRINT_MOVING_TIME_SETTING "printMovingTime"
|
||||||
|
#define PRINT_MOVING_TIME_DEFAULT false
|
||||||
#define PRINT_ITEM_COUNT_SETTING "printItemCount"
|
#define PRINT_ITEM_COUNT_SETTING "printItemCount"
|
||||||
#define PRINT_ITEM_COUNT_DEFAULT true
|
#define PRINT_ITEM_COUNT_DEFAULT true
|
||||||
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
|
#define SEPARATE_GRAPH_PAGE_SETTING "separateGraphPage"
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_units = Metric;
|
||||||
|
_timeType = Total;
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
setYUnits();
|
setYUnits();
|
||||||
@ -36,6 +37,8 @@ void SpeedGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(),
|
_avg.append(QPointF(data.tracks().at(i)->distance(),
|
||||||
data.tracks().at(i)->distance() / data.tracks().at(i)->time()));
|
data.tracks().at(i)->distance() / data.tracks().at(i)->time()));
|
||||||
|
_avgM.append(QPointF(data.tracks().at(i)->distance(),
|
||||||
|
data.tracks().at(i)->distance() / data.tracks().at(i)->movingTime()));
|
||||||
|
|
||||||
GraphView::loadGraph(graph, paths.at(i));
|
GraphView::loadGraph(graph, paths.at(i));
|
||||||
}
|
}
|
||||||
@ -52,8 +55,9 @@ qreal SpeedGraph::avg() const
|
|||||||
{
|
{
|
||||||
qreal sum = 0, w = 0;
|
qreal sum = 0, w = 0;
|
||||||
QList<QPointF>::const_iterator it;
|
QList<QPointF>::const_iterator it;
|
||||||
|
const QList<QPointF> &list = (_timeType == Moving) ? _avgM : _avg;
|
||||||
|
|
||||||
for (it = _avg.begin(); it != _avg.end(); it++) {
|
for (it = list.begin(); it != list.end(); it++) {
|
||||||
sum += it->y() * it->x();
|
sum += it->y() * it->x();
|
||||||
w += it->x();
|
w += it->x();
|
||||||
}
|
}
|
||||||
@ -64,6 +68,7 @@ qreal SpeedGraph::avg() const
|
|||||||
void SpeedGraph::clear()
|
void SpeedGraph::clear()
|
||||||
{
|
{
|
||||||
_avg.clear();
|
_avg.clear();
|
||||||
|
_avgM.clear();
|
||||||
|
|
||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
@ -90,6 +95,14 @@ void SpeedGraph::setUnits(enum Units units)
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpeedGraph::setTimeType(enum TimeType type)
|
||||||
|
{
|
||||||
|
_timeType = type;
|
||||||
|
|
||||||
|
setInfo();
|
||||||
|
redraw();
|
||||||
|
}
|
||||||
|
|
||||||
void SpeedGraph::showTracks(bool show)
|
void SpeedGraph::showTracks(bool show)
|
||||||
{
|
{
|
||||||
_showTracks = show;
|
_showTracks = show;
|
||||||
|
@ -15,8 +15,8 @@ public:
|
|||||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
|
void setTimeType(enum TimeType type);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
@ -25,8 +25,10 @@ private:
|
|||||||
void setInfo();
|
void setInfo();
|
||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
QList<QPointF> _avgM;
|
||||||
|
|
||||||
enum Units _units;
|
enum Units _units;
|
||||||
|
enum TimeType _timeType;
|
||||||
bool _showTracks;
|
bool _showTracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
80
src/tar.cpp
Normal file
80
src/tar.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#include <cctype>
|
||||||
|
#include <QFile>
|
||||||
|
#include "tar.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define BLOCKSIZE 512
|
||||||
|
|
||||||
|
#define BLOCKCOUNT(size) \
|
||||||
|
((size)/BLOCKSIZE + ((size) % BLOCKSIZE > 0 ? 1 : 0))
|
||||||
|
|
||||||
|
struct Header
|
||||||
|
{
|
||||||
|
char name[100]; /* 0 */
|
||||||
|
char mode[8]; /* 100 */
|
||||||
|
char uid[8]; /* 108 */
|
||||||
|
char gid[8]; /* 116 */
|
||||||
|
char size[12]; /* 124 */
|
||||||
|
char mtime[12]; /* 136 */
|
||||||
|
char chksum[8]; /* 148 */
|
||||||
|
char typeflag; /* 156 */
|
||||||
|
char linkname[100]; /* 157 */
|
||||||
|
char magic[6]; /* 257 */
|
||||||
|
char version[2]; /* 263 */
|
||||||
|
char uname[32]; /* 265 */
|
||||||
|
char gname[32]; /* 297 */
|
||||||
|
char devmajor[8]; /* 329 */
|
||||||
|
char devminor[8]; /* 337 */
|
||||||
|
char prefix[155]; /* 345 */
|
||||||
|
/* 500 */
|
||||||
|
};
|
||||||
|
|
||||||
|
static quint64 number(const char* data, size_t size)
|
||||||
|
{
|
||||||
|
const char *sp;
|
||||||
|
quint64 val = 0;
|
||||||
|
|
||||||
|
for (sp = data; sp < data + size; sp++)
|
||||||
|
if (isdigit(*sp))
|
||||||
|
break;
|
||||||
|
for (; sp < data + size && isdigit(*sp); sp++)
|
||||||
|
val = val * 8 + *sp - '0';
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Tar::load(const QString &path)
|
||||||
|
{
|
||||||
|
char buffer[BLOCKSIZE];
|
||||||
|
struct Header *hdr = (struct Header*)&buffer;
|
||||||
|
quint64 size;
|
||||||
|
qint64 ret;
|
||||||
|
|
||||||
|
_file.setFileName(path);
|
||||||
|
if (!_file.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while ((ret = _file.read(buffer, BLOCKSIZE)) > 0) {
|
||||||
|
if (ret < BLOCKSIZE)
|
||||||
|
return false;
|
||||||
|
size = number(hdr->size, sizeof(hdr->size));
|
||||||
|
if (size)
|
||||||
|
_index.insert(hdr->name, Info(size, _file.pos()));
|
||||||
|
if (!_file.seek(_file.pos() + BLOCKCOUNT(size) * BLOCKSIZE))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray Tar::file(const QString &name)
|
||||||
|
{
|
||||||
|
QMap<QString, Tar::Info>::const_iterator it = _index.find(name);
|
||||||
|
if (it == _index.end())
|
||||||
|
return QByteArray();
|
||||||
|
|
||||||
|
if (_file.seek(it.value().offset()))
|
||||||
|
return _file.read(it.value().size());
|
||||||
|
else
|
||||||
|
return QByteArray();
|
||||||
|
}
|
36
src/tar.h
Normal file
36
src/tar.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef TAR_H
|
||||||
|
#define TAR_H
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QMap>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
class Tar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool load(const QString &path);
|
||||||
|
|
||||||
|
QStringList files() const {return _index.keys();}
|
||||||
|
QByteArray file(const QString &name);
|
||||||
|
|
||||||
|
QString fileName() const {return _file.fileName();}
|
||||||
|
bool isOpen() const {return _file.isOpen();}
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Info
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Info(quint64 size, quint64 offset) : _size(size), _offset(offset) {}
|
||||||
|
quint64 size() const {return _size;}
|
||||||
|
quint64 offset() const {return _offset;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
quint64 _size;
|
||||||
|
quint64 _offset;
|
||||||
|
};
|
||||||
|
|
||||||
|
QFile _file;
|
||||||
|
QMap<QString, Info> _index;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TAR_H
|
@ -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());
|
||||||
fprintf(stderr, "%s:%lld: %s\n", qPrintable(file->fileName()),
|
qWarning("%s:%lld: %s\n", qPrintable(file->fileName()),
|
||||||
_reader.lineNumber(), text);
|
_reader.lineNumber(), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ public:
|
|||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units units);
|
void setUnits(enum Units units);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
|
@ -14,8 +14,6 @@ public:
|
|||||||
const QPoint& xy() const {return _xy;}
|
const QPoint& xy() const {return _xy;}
|
||||||
QPixmap& pixmap() {return _pixmap;}
|
QPixmap& pixmap() {return _pixmap;}
|
||||||
|
|
||||||
static int size() {return 256;}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _zoom;
|
int _zoom;
|
||||||
QPoint _xy;
|
QPoint _xy;
|
||||||
|
9
src/timetype.h
Normal file
9
src/timetype.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#ifndef TIMETYPE_H
|
||||||
|
#define TIMETYPE_H
|
||||||
|
|
||||||
|
enum TimeType {
|
||||||
|
Total,
|
||||||
|
Moving
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TIMETYPE_H
|
132
src/track.cpp
132
src/track.cpp
@ -9,6 +9,9 @@
|
|||||||
#define WINDOW_CF 3
|
#define WINDOW_CF 3
|
||||||
#define WINDOW_PF 3
|
#define WINDOW_PF 3
|
||||||
|
|
||||||
|
#define PAUSE_SPEED 0.5
|
||||||
|
#define PAUSE_TIME_DIFF 10
|
||||||
|
|
||||||
|
|
||||||
static qreal median(QVector<qreal> v)
|
static qreal median(QVector<qreal> v)
|
||||||
{
|
{
|
||||||
@ -43,30 +46,31 @@ static QSet<int> eliminate(const QVector<qreal> &v, int window)
|
|||||||
return rm;
|
return rm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Graph filter(const Graph &v, int window)
|
static Graph filter(const Graph &g, int window)
|
||||||
{
|
{
|
||||||
qreal acc = 0;
|
qreal acc = 0;
|
||||||
Graph ret;
|
Graph ret;
|
||||||
|
|
||||||
if (v.size() < window)
|
if (g.size() < window)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (int i = 0; i < window; i++)
|
for (int i = 0; i < window; i++)
|
||||||
acc += v.at(i).y();
|
acc += g.at(i).y();
|
||||||
for (int i = 0; i <= window/2; i++)
|
for (int i = 0; i <= window/2; i++)
|
||||||
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
ret.append(GraphPoint(g.at(i).s(), g.at(i).t(), acc/window));
|
||||||
|
|
||||||
for (int i = window/2 + 1; i < v.size() - window/2; i++) {
|
for (int i = window/2 + 1; i < g.size() - window/2; i++) {
|
||||||
acc += v.at(i + window/2).y() - v.at(i - (window/2 + 1)).y();
|
acc += g.at(i + window/2).y() - g.at(i - (window/2 + 1)).y();
|
||||||
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
ret.append(GraphPoint(g.at(i).s(), g.at(i).t(), acc/window));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = v.size() - window/2; i < v.size(); i++)
|
for (int i = g.size() - window/2; i < g.size(); i++)
|
||||||
ret.append(GraphPoint(v.at(i).s(), v.at(i).t(), acc/window));
|
ret.append(GraphPoint(g.at(i).s(), g.at(i).t(), acc/window));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Track::Track(const TrackData &data) : _data(data)
|
Track::Track(const TrackData &data) : _data(data)
|
||||||
{
|
{
|
||||||
qreal dt, ds, total;
|
qreal dt, ds, total;
|
||||||
@ -98,13 +102,28 @@ Track::Track(const TrackData &data) : _data(data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_pause = 0;
|
||||||
|
for (int i = 1; i < data.count(); i++) {
|
||||||
|
if (_time.at(i) > _time.at(i-1) + PAUSE_TIME_DIFF
|
||||||
|
&& _speed.at(i) < PAUSE_SPEED) {
|
||||||
|
_pause += _time.at(i) - _time.at(i-1);
|
||||||
|
_stop.insert(i-1);
|
||||||
|
_stop.insert(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_outliers = eliminate(_speed, WINDOW_OE);
|
_outliers = eliminate(_speed, WINDOW_OE);
|
||||||
|
|
||||||
|
QSet<int>::const_iterator it;
|
||||||
|
for (it = _stop.constBegin(); it != _stop.constEnd(); ++it)
|
||||||
|
_outliers.remove(*it);
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
for (int i = 0; i < _data.size(); i++) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_outliers.contains(i))
|
if (_outliers.contains(i))
|
||||||
continue;
|
continue;
|
||||||
total += _distance.at(i);
|
if (!discardStopPoint(i))
|
||||||
|
total += _distance.at(i);
|
||||||
_distance[i] = total;
|
_distance[i] = total;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,9 +132,6 @@ Graph Track::elevation() const
|
|||||||
{
|
{
|
||||||
Graph raw;
|
Graph raw;
|
||||||
|
|
||||||
if (!_data.size())
|
|
||||||
return raw;
|
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++)
|
||||||
if (_data.at(i).hasElevation() && !_outliers.contains(i))
|
if (_data.at(i).hasElevation() && !_outliers.contains(i))
|
||||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
@ -126,14 +142,16 @@ Graph Track::elevation() const
|
|||||||
|
|
||||||
Graph Track::speed() const
|
Graph Track::speed() const
|
||||||
{
|
{
|
||||||
Graph raw;
|
Graph raw, filtered;
|
||||||
qreal v;
|
qreal v;
|
||||||
|
QSet<int> stop;
|
||||||
if (!_data.size())
|
|
||||||
return raw;
|
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasSpeed() && !_outliers.contains(i))
|
if (_stop.contains(i) && (!std::isnan(_speed.at(i))
|
||||||
|
|| _data.at(i).hasSpeed())) {
|
||||||
|
v = 0;
|
||||||
|
stop.insert(raw.size());
|
||||||
|
} else if (_data.at(i).hasSpeed() && !_outliers.contains(i))
|
||||||
v = _data.at(i).speed();
|
v = _data.at(i).speed();
|
||||||
else if (!std::isnan(_speed.at(i)) && !_outliers.contains(i))
|
else if (!std::isnan(_speed.at(i)) && !_outliers.contains(i))
|
||||||
v = _speed.at(i);
|
v = _speed.at(i);
|
||||||
@ -143,16 +161,19 @@ Graph Track::speed() const
|
|||||||
raw.append(GraphPoint(_distance.at(i), _time.at(i), v));
|
raw.append(GraphPoint(_distance.at(i), _time.at(i), v));
|
||||||
}
|
}
|
||||||
|
|
||||||
return filter(raw, WINDOW_SF);
|
filtered = filter(raw, WINDOW_SF);
|
||||||
|
|
||||||
|
QSet<int>::const_iterator it;
|
||||||
|
for (it = stop.constBegin(); it != stop.constEnd(); ++it)
|
||||||
|
filtered[*it].setY(0);
|
||||||
|
|
||||||
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
Graph Track::heartRate() const
|
Graph Track::heartRate() const
|
||||||
{
|
{
|
||||||
Graph raw;
|
Graph raw;
|
||||||
|
|
||||||
if (!_data.size())
|
|
||||||
return raw;
|
|
||||||
|
|
||||||
for (int i = 0; i < _data.count(); i++)
|
for (int i = 0; i < _data.count(); i++)
|
||||||
if (_data.at(i).hasHeartRate() && !_outliers.contains(i))
|
if (_data.at(i).hasHeartRate() && !_outliers.contains(i))
|
||||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
||||||
@ -175,26 +196,56 @@ Graph Track::temperature() const
|
|||||||
|
|
||||||
Graph Track::cadence() const
|
Graph Track::cadence() const
|
||||||
{
|
{
|
||||||
Graph raw;
|
Graph raw, filtered;
|
||||||
|
QSet<int> stop;
|
||||||
|
qreal c;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasCadence() && !_outliers.contains(i))
|
if (_data.at(i).hasCadence() && _stop.contains(i)) {
|
||||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
c = 0;
|
||||||
_data.at(i).cadence()));
|
stop.insert(raw.size());
|
||||||
|
} else if (_data.at(i).hasCadence() && !_outliers.contains(i))
|
||||||
|
c = _data.at(i).cadence();
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
return filter(raw, WINDOW_CF);
|
raw.append(GraphPoint(_distance.at(i), _time.at(i), c));
|
||||||
|
}
|
||||||
|
|
||||||
|
filtered = filter(raw, WINDOW_CF);
|
||||||
|
|
||||||
|
QSet<int>::const_iterator it;
|
||||||
|
for (it = stop.constBegin(); it != stop.constEnd(); ++it)
|
||||||
|
filtered[*it].setY(0);
|
||||||
|
|
||||||
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
Graph Track::power() const
|
Graph Track::power() const
|
||||||
{
|
{
|
||||||
Graph raw;
|
Graph raw, filtered;
|
||||||
|
QSet<int> stop;
|
||||||
|
qreal p;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
if (_data.at(i).hasPower() && !_outliers.contains(i))
|
if (_data.at(i).hasPower() && _stop.contains(i)) {
|
||||||
raw.append(GraphPoint(_distance.at(i), _time.at(i),
|
p = 0;
|
||||||
_data.at(i).power()));
|
stop.insert(raw.size());
|
||||||
|
} else if (_data.at(i).hasPower() && !_outliers.contains(i))
|
||||||
|
p = _data.at(i).power();
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
return filter(raw, WINDOW_PF);
|
raw.append(GraphPoint(_distance.at(i), _time.at(i), p));
|
||||||
|
}
|
||||||
|
|
||||||
|
filtered = filter(raw, WINDOW_PF);
|
||||||
|
|
||||||
|
QSet<int>::const_iterator it;
|
||||||
|
for (it = stop.constBegin(); it != stop.constEnd(); ++it)
|
||||||
|
filtered[*it].setY(0);
|
||||||
|
|
||||||
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal Track::distance() const
|
qreal Track::distance() const
|
||||||
@ -208,6 +259,11 @@ qreal Track::time() const
|
|||||||
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
|
(_data.first().timestamp().msecsTo(_data.last().timestamp()) / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal Track::movingTime() const
|
||||||
|
{
|
||||||
|
return (time() - _pause);
|
||||||
|
}
|
||||||
|
|
||||||
QDateTime Track::date() const
|
QDateTime Track::date() const
|
||||||
{
|
{
|
||||||
return (_data.size()) ? _data.first().timestamp() : QDateTime();
|
return (_data.size()) ? _data.first().timestamp() : QDateTime();
|
||||||
@ -218,8 +274,14 @@ Path Track::path() const
|
|||||||
Path ret;
|
Path ret;
|
||||||
|
|
||||||
for (int i = 0; i < _data.size(); i++)
|
for (int i = 0; i < _data.size(); i++)
|
||||||
if (!_outliers.contains(i))
|
if (!_outliers.contains(i) && !discardStopPoint(i))
|
||||||
ret.append(PathPoint(_data.at(i).coordinates(), _distance.at(i)));
|
ret.append(PathPoint(_data.at(i).coordinates(), _distance.at(i)));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Track::discardStopPoint(int i) const
|
||||||
|
{
|
||||||
|
return (_stop.contains(i) && i > 0 && _stop.contains(i-1)
|
||||||
|
&& i < _data.size() - 1 && _stop.contains(i+1));
|
||||||
|
}
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
Track(const TrackData &data);
|
Track(const TrackData &data);
|
||||||
|
|
||||||
Path path() const;
|
Path path() const;
|
||||||
|
|
||||||
Graph elevation() const;
|
Graph elevation() const;
|
||||||
Graph speed() const;
|
Graph speed() const;
|
||||||
Graph heartRate() const;
|
Graph heartRate() const;
|
||||||
@ -24,6 +25,7 @@ public:
|
|||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
qreal time() const;
|
qreal time() const;
|
||||||
|
qreal movingTime() const;
|
||||||
QDateTime date() const;
|
QDateTime date() const;
|
||||||
|
|
||||||
const QString &name() const {return _data.name();}
|
const QString &name() const {return _data.name();}
|
||||||
@ -32,6 +34,8 @@ public:
|
|||||||
bool isNull() const {return (_data.size() < 2);}
|
bool isNull() const {return (_data.size() < 2);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool discardStopPoint(int i) const;
|
||||||
|
|
||||||
const TrackData &_data;
|
const TrackData &_data;
|
||||||
|
|
||||||
QVector<qreal> _distance;
|
QVector<qreal> _distance;
|
||||||
@ -39,6 +43,9 @@ private:
|
|||||||
QVector<qreal> _speed;
|
QVector<qreal> _speed;
|
||||||
|
|
||||||
QSet<int> _outliers;
|
QSet<int> _outliers;
|
||||||
|
QSet<int> _stop;
|
||||||
|
|
||||||
|
qreal _pause;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACK_H
|
#endif // TRACK_H
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
|
#include "map.h"
|
||||||
#include "trackitem.h"
|
#include "trackitem.h"
|
||||||
|
|
||||||
|
|
||||||
QString TrackItem::toolTip()
|
QString TrackItem::toolTip(Units units)
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
@ -12,47 +13,30 @@ QString TrackItem::toolTip()
|
|||||||
tt.insert(tr("Name"), _name);
|
tt.insert(tr("Name"), _name);
|
||||||
if (!_desc.isEmpty())
|
if (!_desc.isEmpty())
|
||||||
tt.insert(tr("Description"), _desc);
|
tt.insert(tr("Description"), _desc);
|
||||||
tt.insert(tr("Distance"), Format::distance(_distance.last(), _units));
|
tt.insert(tr("Distance"), Format::distance(_path.last().distance(), units));
|
||||||
if (_time > 0)
|
if (_time > 0)
|
||||||
tt.insert(tr("Time"), Format::timeSpan(_time));
|
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
||||||
|
if (_movingTime > 0)
|
||||||
|
tt.insert(tr("Moving time"), Format::timeSpan(_movingTime));
|
||||||
if (!_date.isNull())
|
if (!_date.isNull())
|
||||||
tt.insert(tr("Date"), _date.toString(Qt::SystemLocaleShortDate));
|
tt.insert(tr("Date"), _date.toString(Qt::SystemLocaleShortDate));
|
||||||
|
|
||||||
return tt.toString();
|
return tt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
|
||||||
: PathItem(parent)
|
: PathItem(track.path(), map, parent)
|
||||||
{
|
{
|
||||||
QPointF p;
|
|
||||||
const Path &path = track.path();
|
|
||||||
Q_ASSERT(path.count() >= 2);
|
|
||||||
|
|
||||||
p = path.first().coordinates().toMercator();
|
|
||||||
_path.moveTo(QPointF(p.x(), -p.y()));
|
|
||||||
_distance.append(path.first().distance());
|
|
||||||
for (int i = 1; i < path.size(); i++) {
|
|
||||||
if (path.at(i).coordinates() == path.at(i-1).coordinates())
|
|
||||||
continue;
|
|
||||||
p = path.at(i).coordinates().toMercator();
|
|
||||||
_path.lineTo(QPointF(p.x(), -p.y()));
|
|
||||||
_distance.append(path.at(i).distance());
|
|
||||||
}
|
|
||||||
|
|
||||||
updateShape();
|
|
||||||
|
|
||||||
_name = track.name();
|
_name = track.name();
|
||||||
_desc = track.description();
|
_desc = track.description();
|
||||||
_date = track.date();
|
_date = track.date();
|
||||||
_time = track.time();
|
_time = track.time();
|
||||||
|
_movingTime = track.movingTime();
|
||||||
|
|
||||||
_marker->setPos(_path.elementAt(0));
|
setToolTip(toolTip(Metric));
|
||||||
|
|
||||||
setToolTip(toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackItem::setUnits(enum Units units)
|
void TrackItem::setUnits(Units units)
|
||||||
{
|
{
|
||||||
PathItem::setUnits(units);
|
setToolTip(toolTip(units));
|
||||||
setToolTip(toolTip());
|
|
||||||
}
|
}
|
||||||
|
@ -5,24 +5,27 @@
|
|||||||
#include <QPen>
|
#include <QPen>
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
#include "units.h"
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
class TrackItem : public PathItem
|
class TrackItem : public PathItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TrackItem(const Track &track, QGraphicsItem *parent = 0);
|
TrackItem(const Track &track, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
void setUnits(enum Units units);
|
void setUnits(Units units);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString toolTip();
|
QString toolTip(Units units);
|
||||||
|
|
||||||
QString _name;
|
QString _name;
|
||||||
QString _desc;
|
QString _desc;
|
||||||
QDateTime _date;
|
QDateTime _date;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
|
qreal _movingTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TRACKITEM_H
|
#endif // TRACKITEM_H
|
||||||
|
106
src/transversemercator.cpp
Normal file
106
src/transversemercator.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include "rd.h"
|
||||||
|
#include "wgs84.h"
|
||||||
|
#include "transversemercator.h"
|
||||||
|
|
||||||
|
|
||||||
|
TransverseMercator::TransverseMercator()
|
||||||
|
{
|
||||||
|
_centralMeridian = 0;
|
||||||
|
_scale = 1.0;
|
||||||
|
_falseEasting = 0;
|
||||||
|
_falseNorthing = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
TransverseMercator::TransverseMercator(double centralMeridian, double scale,
|
||||||
|
double falseEasting, double falseNorthing)
|
||||||
|
{
|
||||||
|
_centralMeridian = centralMeridian;
|
||||||
|
_scale = scale;
|
||||||
|
_falseEasting = falseEasting;
|
||||||
|
_falseNorthing = falseNorthing;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF TransverseMercator::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
QPointF p;
|
||||||
|
|
||||||
|
const double e2 = WGS84_FLATTENING * (2 - WGS84_FLATTENING);
|
||||||
|
const double n = WGS84_FLATTENING / (2 - WGS84_FLATTENING);
|
||||||
|
const double rectifyingRadius = WGS84_RADIUS / (1 + n)
|
||||||
|
* (1 + 0.25*pow(n, 2) + 0.015625*pow(n, 4));
|
||||||
|
|
||||||
|
double A = e2;
|
||||||
|
double B = (5 * pow(e2, 2) - pow(e2, 3)) / 6.0;
|
||||||
|
double C = (104 * pow(e2, 3) - 45 * pow(e2, 4)) / 120.0;
|
||||||
|
double D = (1237 * pow(e2, 4)) / 1260.0;
|
||||||
|
|
||||||
|
double phi = deg2rad(c.lat());
|
||||||
|
double lambda = deg2rad(c.lon());
|
||||||
|
double lambda0 = deg2rad(_centralMeridian);
|
||||||
|
|
||||||
|
double deltaLambda = lambda - lambda0;
|
||||||
|
|
||||||
|
double phiStar = phi - sin(phi) * cos(phi) * (A + B*pow(sin(phi), 2)
|
||||||
|
+ C*pow(sin(phi), 4) + D*pow(sin(phi), 6));
|
||||||
|
|
||||||
|
double xiPrim = atan(tan(phiStar) / cos(deltaLambda));
|
||||||
|
double etaPrim = atanh(cos(phiStar) * sin(deltaLambda));
|
||||||
|
|
||||||
|
double beta1 = 1/2.0 * n - 2/3.0 * pow(n, 2) + 5/16.0 * pow(n, 3)
|
||||||
|
+ 41/180.0 * pow(n, 4);
|
||||||
|
double beta2 = 13/48.0 * pow(n, 2) - 3/5.0 * pow(n, 3) + 557/1440.0
|
||||||
|
* pow(n, 4);
|
||||||
|
double beta3 = 61/240.0 * pow(n, 3) - 103/140.0 * pow(n, 4);
|
||||||
|
double beta4 = 49561/161280.0 * pow(n, 4);
|
||||||
|
|
||||||
|
p.ry() = _falseNorthing + _scale * rectifyingRadius * (xiPrim + beta1
|
||||||
|
* sin(2*xiPrim) * cosh(2*etaPrim) + beta2 * sin(4*xiPrim)
|
||||||
|
* cosh(4*etaPrim) + beta3 * sin(6*xiPrim) * cosh(6*etaPrim) + beta4
|
||||||
|
* sin(8*xiPrim) * cosh(8*etaPrim));
|
||||||
|
p.rx() = _falseEasting + _scale * rectifyingRadius * (etaPrim + beta1
|
||||||
|
* cos(2*xiPrim) * sinh(2*etaPrim) + beta2 * cos(4*xiPrim)
|
||||||
|
* sinh(4*etaPrim) + beta3 * cos(6*xiPrim) * sinh(6*etaPrim) + beta4
|
||||||
|
* cos(8*xiPrim) * sinh(8*etaPrim));
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates TransverseMercator::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
const double e2 = WGS84_FLATTENING * (2 - WGS84_FLATTENING);
|
||||||
|
const double n = WGS84_FLATTENING / (2 - WGS84_FLATTENING);
|
||||||
|
const double rectifyingRadius = WGS84_RADIUS / (1 + n)
|
||||||
|
* (1 + 0.25*pow(n, 2) + 0.015625*pow(n, 4));
|
||||||
|
|
||||||
|
double xi = (p.y() - _falseNorthing) / (_scale * rectifyingRadius);
|
||||||
|
double eta = (p.x() - _falseEasting) / (_scale * rectifyingRadius);
|
||||||
|
|
||||||
|
double delta1 = 1/2.0 * n - 2/3.0 * pow(n, 2) + 37/96.0 * pow(n, 3)
|
||||||
|
- 1/360.0 * pow(n, 4);
|
||||||
|
double delta2 = 1/48.0 * pow(n, 2) + 1/15.0 * pow(n, 3) - 437/1440.0
|
||||||
|
* pow(n, 4);
|
||||||
|
double delta3 = 17/480.0 * pow(n, 3) - 37/840.0 * pow(n, 4);
|
||||||
|
double delta4 = 4397/161280.0 * pow(n, 4);
|
||||||
|
|
||||||
|
double xiPrim = xi - delta1 * sin(2*xi) * cosh(2*eta) - delta2 * sin(4*xi)
|
||||||
|
* cosh(4*eta) - delta3 * sin(6*xi) * cosh(6*eta) - delta4 * sin(8*xi)
|
||||||
|
* cosh(8*eta);
|
||||||
|
double etaPrim = eta - delta1 * cos(2*xi) * sinh(2*eta) - delta2 * cos(4*xi)
|
||||||
|
* sinh(4*eta) - delta3 * cos(6*xi) * sinh(6*eta) - delta4 * cos(8*xi)
|
||||||
|
* sinh(8*eta);
|
||||||
|
|
||||||
|
double phiStar = asin(sin(xiPrim) / cosh(etaPrim));
|
||||||
|
double deltaLambda = atan(sinh(etaPrim) / cos(xiPrim));
|
||||||
|
|
||||||
|
double AStar = e2 + pow(e2, 2) + pow(e2, 3) + pow(e2, 4);
|
||||||
|
double BStar = (7 * pow(e2, 2) + 17 * pow(e2, 3) + 30 * pow(e2, 4)) / -6;
|
||||||
|
double CStar = (224 * pow(e2, 3) + 889 * pow(e2, 4)) / 120;
|
||||||
|
double DStar = (4279 * pow(e2, 4)) / -1260;
|
||||||
|
|
||||||
|
double phi = phiStar + sin(phiStar) * cos(phiStar) * (AStar + BStar
|
||||||
|
* pow(sin(phiStar), 2) + CStar * pow(sin(phiStar), 4) + DStar
|
||||||
|
* pow(sin(phiStar), 6));
|
||||||
|
|
||||||
|
return Coordinates(_centralMeridian + rad2deg(deltaLambda), rad2deg(phi));
|
||||||
|
}
|
23
src/transversemercator.h
Normal file
23
src/transversemercator.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef TRANSVERSEMERCATOR_H
|
||||||
|
#define TRANSVERSEMERCATOR_H
|
||||||
|
|
||||||
|
#include "projection.h"
|
||||||
|
|
||||||
|
class TransverseMercator : public Projection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TransverseMercator();
|
||||||
|
TransverseMercator(double centralMeridian, double scale,
|
||||||
|
double falseEasting, double falseNorthing);
|
||||||
|
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
double _centralMeridian;
|
||||||
|
double _scale;
|
||||||
|
double _falseEasting;
|
||||||
|
double _falseNorthing;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TRANSVERSEMERCATOR_H
|
22
src/utm.cpp
Normal file
22
src/utm.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "utm.h"
|
||||||
|
|
||||||
|
UTM::UTM(const Coordinates &c)
|
||||||
|
{
|
||||||
|
int zone = int((c.lon() + 180)/6) + 1;
|
||||||
|
|
||||||
|
if (c.lat() >= 56.0 && c.lat() < 64.0 && c.lon() >= 3.0 && c.lon() < 12.0)
|
||||||
|
zone = 32;
|
||||||
|
if (c.lat() >= 72.0 && c.lat() < 84.0) {
|
||||||
|
if (c.lon() >= 0.0 && c.lon() < 9.0)
|
||||||
|
zone = 31;
|
||||||
|
else if (c.lon() >= 9.0 && c.lon() < 21.0)
|
||||||
|
zone = 33;
|
||||||
|
else if (c.lon() >= 21.0 && c.lon() < 33.0)
|
||||||
|
zone = 35;
|
||||||
|
else if (c.lon() >= 33.0 && c.lon() < 42.0)
|
||||||
|
zone = 37;
|
||||||
|
}
|
||||||
|
double cm = (zone - 1)*6 - 180 + 3;
|
||||||
|
|
||||||
|
_tm = TransverseMercator(cm, 0.9996, 500000, (c.lat() < 0) ? 10000000 : 0);
|
||||||
|
}
|
23
src/utm.h
Normal file
23
src/utm.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef UTM_H
|
||||||
|
#define UTM_H
|
||||||
|
|
||||||
|
#include "projection.h"
|
||||||
|
#include "transversemercator.h"
|
||||||
|
|
||||||
|
class UTM : public Projection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UTM(int zone) : _tm((qAbs(zone) - 1)*6 - 180 + 3, 0.9996, 500000,
|
||||||
|
zone < 0 ? 10000000 : 0) {}
|
||||||
|
UTM(const Coordinates &c);
|
||||||
|
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const
|
||||||
|
{return _tm.ll2xy(c);}
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const
|
||||||
|
{return _tm.xy2ll(p);}
|
||||||
|
|
||||||
|
private:
|
||||||
|
TransverseMercator _tm;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // UTM_H
|
@ -3,23 +3,24 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "tooltip.h"
|
#include "tooltip.h"
|
||||||
|
#include "map.h"
|
||||||
#include "waypointitem.h"
|
#include "waypointitem.h"
|
||||||
|
|
||||||
|
|
||||||
#define POINT_SIZE 8
|
#define POINT_SIZE 8
|
||||||
#define HOVER_SIZE 10
|
#define HOVER_SIZE 10
|
||||||
|
|
||||||
QString WaypointItem::toolTip()
|
QString WaypointItem::toolTip(Units units)
|
||||||
{
|
{
|
||||||
ToolTip tt;
|
ToolTip tt;
|
||||||
|
|
||||||
if (!_waypoint.name().isEmpty() && !_showLabel)
|
if (!_waypoint.name().isEmpty())
|
||||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||||
Format::coordinates(_waypoint.coordinates()));
|
Format::coordinates(_waypoint.coordinates()));
|
||||||
if (!std::isnan(_waypoint.elevation()))
|
if (!std::isnan(_waypoint.elevation()))
|
||||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||||
Format::elevation(_waypoint.elevation(), _units));
|
Format::elevation(_waypoint.elevation(), units));
|
||||||
if (!_waypoint.timestamp().isNull())
|
if (!_waypoint.timestamp().isNull())
|
||||||
tt.insert(qApp->translate("WaypointItem", "Date"),
|
tt.insert(qApp->translate("WaypointItem", "Date"),
|
||||||
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
||||||
@ -30,25 +31,26 @@ QString WaypointItem::toolTip()
|
|||||||
return tt.toString();
|
return tt.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
|
WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
||||||
: QGraphicsItem(parent)
|
QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
_waypoint = waypoint;
|
||||||
_showLabel = true;
|
_showLabel = true;
|
||||||
_hover = false;
|
_hover = false;
|
||||||
|
|
||||||
_waypoint = waypoint;
|
|
||||||
QPointF p = waypoint.coordinates().toMercator();
|
|
||||||
_coordinates = QPointF(p.x(), -p.y());
|
|
||||||
|
|
||||||
updateShape();
|
updateShape();
|
||||||
|
|
||||||
setPos(_coordinates);
|
setPos(map->ll2xy(waypoint.coordinates()));
|
||||||
setToolTip(toolTip());
|
setToolTip(toolTip(Metric));
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaypointItem::setMap(Map *map)
|
||||||
|
{
|
||||||
|
setPos(map->ll2xy(_waypoint.coordinates()));
|
||||||
|
}
|
||||||
|
|
||||||
void WaypointItem::updateShape()
|
void WaypointItem::updateShape()
|
||||||
{
|
{
|
||||||
QPainterPath p;
|
QPainterPath p;
|
||||||
@ -104,15 +106,17 @@ void WaypointItem::paint(QPainter *painter,
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void WaypointItem::setScale(qreal scale)
|
void WaypointItem::setScale(qreal scale)
|
||||||
{
|
{
|
||||||
setPos(_coordinates * scale);
|
QPointF p = _map->ll2xy(_waypoint.coordinates());
|
||||||
|
setPos(QPointF(p.x(), -p.y()) * scale);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void WaypointItem::setUnits(enum Units units)
|
void WaypointItem::setUnits(enum Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
setToolTip(toolTip(units));
|
||||||
setToolTip(toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::showLabel(bool show)
|
void WaypointItem::showLabel(bool show)
|
||||||
@ -120,7 +124,6 @@ void WaypointItem::showLabel(bool show)
|
|||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
_showLabel = show;
|
_showLabel = show;
|
||||||
updateShape();
|
updateShape();
|
||||||
setToolTip(toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
@ -5,16 +5,17 @@
|
|||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
||||||
|
class Map;
|
||||||
|
|
||||||
class WaypointItem : public QGraphicsItem
|
class WaypointItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent = 0);
|
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
const Waypoint &waypoint() const {return _waypoint;}
|
const Waypoint &waypoint() const {return _waypoint;}
|
||||||
const QPointF &coordinates() const {return _coordinates;}
|
|
||||||
|
|
||||||
void setUnits(enum Units units);
|
void setMap(Map *map);
|
||||||
void setScale(qreal scale);
|
void setUnits(Units units);
|
||||||
void showLabel(bool show);
|
void showLabel(bool show);
|
||||||
|
|
||||||
QPainterPath shape() const {return _shape;}
|
QPainterPath shape() const {return _shape;}
|
||||||
@ -27,12 +28,10 @@ private:
|
|||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
void updateShape();
|
void updateShape();
|
||||||
QString toolTip();
|
QString toolTip(Units units);
|
||||||
|
|
||||||
QPainterPath _shape;
|
QPainterPath _shape;
|
||||||
QPointF _coordinates;
|
|
||||||
Waypoint _waypoint;
|
Waypoint _waypoint;
|
||||||
Units _units;
|
|
||||||
|
|
||||||
bool _hover;
|
bool _hover;
|
||||||
bool _showLabel;
|
bool _showLabel;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef WGS84_H
|
#ifndef WGS84_H
|
||||||
#define WGS84_H
|
#define WGS84_H
|
||||||
|
|
||||||
#define WGS84_RADIUS 6378137.0
|
#define WGS84_RADIUS 6378137.0
|
||||||
|
#define WGS84_FLATTENING (1.0/298.257223563)
|
||||||
|
|
||||||
#endif // WGS84_H
|
#endif // WGS84_H
|
||||||
|
Reference in New Issue
Block a user