mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 13:29:16 +02:00
Compare commits
81 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d719fdcc8 | |||
1746e1cf08 | |||
5d5a5365cd | |||
7dfdeac1da | |||
1ff13ee9f8 | |||
34b1fb6b5d | |||
02bf85780a | |||
47199348d8 | |||
3b55bc0efc | |||
4de3ddf71b | |||
e26fa92ce6 | |||
dfb69b2755 | |||
c2a30738cb | |||
fd53e89ea5 | |||
ccf91bb29f | |||
75bd388be0 | |||
aef0357204 | |||
d073d606d0 | |||
8822bf7e5f | |||
051a3ed303 | |||
96437ae6ab | |||
89c25bbc3a | |||
322792ea04 | |||
ce1c76a315 | |||
804e9594ad | |||
651973c524 | |||
533af66080 | |||
bab5750cf7 | |||
0d6f3ea162 | |||
b915302e2f | |||
03ef7a9147 | |||
33cb944e36 | |||
8bc575aef2 | |||
f0b7abdb72 | |||
6ce14734cd | |||
925a0e2951 | |||
e46bba18f2 | |||
a56aa4e706 | |||
c4b3a81b0b | |||
957cc6f4f3 | |||
ebad0832ee | |||
186c135ad5 | |||
72b5b1ea97 | |||
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 |
21
README.md
21
README.md
@ -3,7 +3,8 @@ GPXSee is a Qt-based GPS log file viewer and analyzer that supports GPX, TCX,
|
||||
KML, FIT, IGC and NMEA files.
|
||||
|
||||
## Features
|
||||
* User-definable map sources.
|
||||
* User-definable online maps.
|
||||
* Offline maps (OziExplorer maps and TrekBuddy maps/atlases).
|
||||
* Elevation, speed, heart rate, cadence, power and temperature graphs.
|
||||
* Support for multiple tracks in one view.
|
||||
* Support for POI files.
|
||||
@ -12,25 +13,21 @@ KML, FIT, IGC and NMEA files.
|
||||
* Native GUI for Windows, Mac OS X and Linux.
|
||||
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
||||
|
||||

|
||||

|
||||
|
||||
## Build
|
||||
### Linux/OS X
|
||||
```shell
|
||||
lrelease gpxsee.pro
|
||||
qmake gpxsee.pro
|
||||
make
|
||||
```
|
||||
### Windows
|
||||
```shell
|
||||
lrelease gpxsee.pro
|
||||
qmake gpxsee.pro
|
||||
nmake release
|
||||
```
|
||||
|
||||
## Binaries
|
||||
* Windows & OS X builds: http://sourceforge.net/projects/gpxsee
|
||||
* Linux packages: https://build.opensuse.org/project/repositories/home:tumic:GPXSee
|
||||
## Download
|
||||
* [Windows & OS X builds](http://sourceforge.net/projects/gpxsee)
|
||||
* [Linux packages](http://software.opensuse.org/download.html?project=home%3Atumic%3AGPXSee&package=gpxsee)
|
||||
|
||||
## Changelog
|
||||
[Changelog](https://build.opensuse.org/package/view_file/home:tumic:GPXSee/gpxsee/gpxsee.changes)
|
||||
|
||||
## Homepage
|
||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
||||
|
44
gpxsee.pro
44
gpxsee.pro
@ -1,5 +1,5 @@
|
||||
TARGET = GPXSee
|
||||
VERSION = 3.9
|
||||
VERSION = 4.4
|
||||
QT += core \
|
||||
gui \
|
||||
network
|
||||
@ -22,6 +22,7 @@ HEADERS += src/config.h \
|
||||
src/sliderinfoitem.h \
|
||||
src/filebrowser.h \
|
||||
src/map.h \
|
||||
src/onlinemap.h \
|
||||
src/maplist.h \
|
||||
src/downloader.h \
|
||||
src/units.h \
|
||||
@ -77,7 +78,22 @@ HEADERS += src/config.h \
|
||||
src/colorbox.h \
|
||||
src/stylecombobox.h \
|
||||
src/opengl.h \
|
||||
src/timetype.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 \
|
||||
src/lambertconic.h \
|
||||
src/ellipsoid.h \
|
||||
src/ozf.h \
|
||||
src/datum.h
|
||||
SOURCES += src/main.cpp \
|
||||
src/gui.cpp \
|
||||
src/poi.cpp \
|
||||
@ -89,7 +105,7 @@ SOURCES += src/main.cpp \
|
||||
src/speedgraph.cpp \
|
||||
src/sliderinfoitem.cpp \
|
||||
src/filebrowser.cpp \
|
||||
src/map.cpp \
|
||||
src/onlinemap.cpp \
|
||||
src/maplist.cpp \
|
||||
src/downloader.cpp \
|
||||
src/scaleitem.cpp \
|
||||
@ -131,10 +147,24 @@ SOURCES += src/main.cpp \
|
||||
src/nmeaparser.cpp \
|
||||
src/optionsdialog.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 \
|
||||
src/lambertconic.cpp \
|
||||
src/ellipsoid.cpp \
|
||||
src/ozf.cpp \
|
||||
src/datum.cpp
|
||||
RESOURCES += gpxsee.qrc
|
||||
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||
lang/gpxsee_sv.ts
|
||||
lang/gpxsee_sv.ts \
|
||||
lang/gpxsee_de.ts
|
||||
macx {
|
||||
ICON = icons/gpxsee.icns
|
||||
QMAKE_INFO_PLIST = Info.plist
|
||||
@ -144,7 +174,9 @@ macx {
|
||||
icons/fit.icns \
|
||||
icons/igc.icns \
|
||||
icons/nmea.icns \
|
||||
pkg/maps.txt
|
||||
pkg/maps.txt \
|
||||
pkg/ellipsoids.csv \
|
||||
pkg/datums.csv
|
||||
APP_RESOURCES.path = Contents/Resources
|
||||
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
||||
}
|
||||
|
@ -21,5 +21,6 @@
|
||||
<file>icons/document-print-preview.png</file>
|
||||
<file>lang/gpxsee_cs.qm</file>
|
||||
<file>lang/gpxsee_sv.qm</file>
|
||||
<file>lang/gpxsee_de.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -190,301 +190,351 @@
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="569"/>
|
||||
<location filename="../src/gui.cpp" line="625"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="633"/>
|
||||
<location filename="../src/gui.cpp" line="703"/>
|
||||
<source>Open file</source>
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="723"/>
|
||||
<location filename="../src/gui.cpp" line="793"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="227"/>
|
||||
<location filename="../src/gui.cpp" line="284"/>
|
||||
<source>Open</source>
|
||||
<translation>Otevřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="211"/>
|
||||
<location filename="../src/gui.cpp" line="268"/>
|
||||
<source>Quit</source>
|
||||
<translation>Ukončit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="219"/>
|
||||
<location filename="../src/gui.cpp" line="585"/>
|
||||
<location filename="../src/gui.cpp" line="586"/>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<location filename="../src/gui.cpp" line="641"/>
|
||||
<location filename="../src/gui.cpp" line="642"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Ovládací klávesy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="243"/>
|
||||
<location filename="../src/gui.cpp" line="300"/>
|
||||
<source>Close</source>
|
||||
<translation>Zavřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="249"/>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<source>Reload</source>
|
||||
<translation>Znovu načíst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="497"/>
|
||||
<location filename="../src/gui.cpp" line="555"/>
|
||||
<source>Show</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="415"/>
|
||||
<location filename="../src/gui.cpp" line="491"/>
|
||||
<location filename="../src/gui.cpp" line="473"/>
|
||||
<location filename="../src/gui.cpp" line="549"/>
|
||||
<source>File</source>
|
||||
<translation>Soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="104"/>
|
||||
<location filename="../src/gui.cpp" line="108"/>
|
||||
<source>FIT files (*.fit)</source>
|
||||
<translation>Soubory FIT (*.fit)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="105"/>
|
||||
<location filename="../src/gui.cpp" line="109"/>
|
||||
<source>IGC files (*.igc)</source>
|
||||
<translation>Soubory IGC (*.igc)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="106"/>
|
||||
<location filename="../src/gui.cpp" line="110"/>
|
||||
<source>NMEA files (*.nmea)</source>
|
||||
<translation>Soubory NMEA (*.nmea)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="217"/>
|
||||
<location filename="../src/gui.cpp" line="608"/>
|
||||
<location filename="../src/gui.cpp" line="609"/>
|
||||
<location filename="../src/gui.cpp" line="274"/>
|
||||
<location filename="../src/gui.cpp" line="670"/>
|
||||
<location filename="../src/gui.cpp" line="671"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Zdroje dat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="257"/>
|
||||
<location filename="../src/gui.cpp" line="314"/>
|
||||
<source>Load POI file</source>
|
||||
<translation>Nahrát POI soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="260"/>
|
||||
<location filename="../src/gui.cpp" line="317"/>
|
||||
<source>Close POI files</source>
|
||||
<translation>Zavřit POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="262"/>
|
||||
<location filename="../src/gui.cpp" line="319"/>
|
||||
<source>Overlap POIs</source>
|
||||
<translation>Překrývat POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="266"/>
|
||||
<location filename="../src/gui.cpp" line="323"/>
|
||||
<source>Show POI labels</source>
|
||||
<translation>Zobrazit názvy POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="271"/>
|
||||
<location filename="../src/gui.cpp" line="328"/>
|
||||
<source>Show POIs</source>
|
||||
<translation>Zobrazit POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="280"/>
|
||||
<location filename="../src/gui.cpp" line="337"/>
|
||||
<source>Show map</source>
|
||||
<translation>Zobrazit mapu</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="286"/>
|
||||
<location filename="../src/gui.cpp" line="344"/>
|
||||
<source>Clear tile cache</source>
|
||||
<translation>Vymazat mezipaměť dlaždic</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="295"/>
|
||||
<location filename="../src/gui.cpp" line="299"/>
|
||||
<location filename="../src/gui.cpp" line="597"/>
|
||||
<location filename="../src/gui.cpp" line="353"/>
|
||||
<location filename="../src/gui.cpp" line="357"/>
|
||||
<location filename="../src/gui.cpp" line="653"/>
|
||||
<source>Next map</source>
|
||||
<translation>Následující mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<location filename="../src/gui.cpp" line="364"/>
|
||||
<source>Show tracks</source>
|
||||
<translation>Zobrazit cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="310"/>
|
||||
<location filename="../src/gui.cpp" line="368"/>
|
||||
<source>Show routes</source>
|
||||
<translation>Zobrazit trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="314"/>
|
||||
<location filename="../src/gui.cpp" line="372"/>
|
||||
<source>Show waypoints</source>
|
||||
<translation>Zobrazit navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="318"/>
|
||||
<location filename="../src/gui.cpp" line="376"/>
|
||||
<source>Waypoint labels</source>
|
||||
<translation>Názvy navigačních bodů</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="329"/>
|
||||
<location filename="../src/gui.cpp" line="387"/>
|
||||
<source>Show graphs</source>
|
||||
<translation>Zobrazit grafy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="351"/>
|
||||
<location filename="../src/gui.cpp" line="409"/>
|
||||
<source>Show grid</source>
|
||||
<translation>Zobrazit mřížku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="357"/>
|
||||
<location filename="../src/gui.cpp" line="415"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Zobrazovat nástrojové lišty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="363"/>
|
||||
<location filename="../src/gui.cpp" line="421"/>
|
||||
<source>Total time</source>
|
||||
<translation>Celkový čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="368"/>
|
||||
<location filename="../src/gui.cpp" line="876"/>
|
||||
<location filename="../src/gui.cpp" line="426"/>
|
||||
<location filename="../src/gui.cpp" line="946"/>
|
||||
<source>Moving time</source>
|
||||
<translation>Čistý čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="375"/>
|
||||
<location filename="../src/gui.cpp" line="433"/>
|
||||
<source>Metric</source>
|
||||
<translation>Metrické</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="380"/>
|
||||
<location filename="../src/gui.cpp" line="438"/>
|
||||
<source>Imperial</source>
|
||||
<translation>Imperiální</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="386"/>
|
||||
<location filename="../src/gui.cpp" line="444"/>
|
||||
<source>Fullscreen mode</source>
|
||||
<translation>Celoobrazovkový režim</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="392"/>
|
||||
<location filename="../src/gui.cpp" line="450"/>
|
||||
<source>Options...</source>
|
||||
<translation>Nastavení...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="397"/>
|
||||
<location filename="../src/gui.cpp" line="455"/>
|
||||
<source>Next</source>
|
||||
<translation>Následující</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="400"/>
|
||||
<location filename="../src/gui.cpp" line="458"/>
|
||||
<source>Previous</source>
|
||||
<translation>Předchozí</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="404"/>
|
||||
<location filename="../src/gui.cpp" line="462"/>
|
||||
<source>Last</source>
|
||||
<translation>Poslední</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="407"/>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<source>First</source>
|
||||
<translation>První</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="429"/>
|
||||
<location filename="../src/gui.cpp" line="487"/>
|
||||
<source>Map</source>
|
||||
<translation>Mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="436"/>
|
||||
<location filename="../src/gui.cpp" line="494"/>
|
||||
<source>Graph</source>
|
||||
<translation>Graf</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="444"/>
|
||||
<location filename="../src/gui.cpp" line="502"/>
|
||||
<source>POI</source>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="445"/>
|
||||
<location filename="../src/gui.cpp" line="503"/>
|
||||
<source>POI files</source>
|
||||
<translation>POI soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="456"/>
|
||||
<location filename="../src/gui.cpp" line="514"/>
|
||||
<source>Data</source>
|
||||
<translation>Data</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="457"/>
|
||||
<location filename="../src/gui.cpp" line="515"/>
|
||||
<source>Display</source>
|
||||
<translation>Zobrazit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<location filename="../src/gui.cpp" line="523"/>
|
||||
<source>Settings</source>
|
||||
<translation>Nastavení</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="469"/>
|
||||
<location filename="../src/gui.cpp" line="527"/>
|
||||
<source>Units</source>
|
||||
<translation>Jednotky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="478"/>
|
||||
<location filename="../src/gui.cpp" line="536"/>
|
||||
<source>Help</source>
|
||||
<translation>Nápověda</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="598"/>
|
||||
<location filename="../src/gui.cpp" line="651"/>
|
||||
<source>Append file</source>
|
||||
<translation>Přidat soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="652"/>
|
||||
<source>Next/Previous</source>
|
||||
<translation>Následující/Předchozí</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="655"/>
|
||||
<source>Previous map</source>
|
||||
<translation>Předchozí mapa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="1082"/>
|
||||
<location filename="../src/gui.cpp" line="656"/>
|
||||
<source>Zoom in</source>
|
||||
<translation>Přiblížit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="658"/>
|
||||
<source>Zoom out</source>
|
||||
<translation>Oddálit</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="660"/>
|
||||
<source>Digital zoom</source>
|
||||
<translation>Digitální zoom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="661"/>
|
||||
<source>Zoom</source>
|
||||
<translation>Zoom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="673"/>
|
||||
<source>Online maps</source>
|
||||
<translation>Online mapy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="674"/>
|
||||
<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="685"/>
|
||||
<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="688"/>
|
||||
<source>The expected structure is one map/atlas in a separate subdirectory. Supported map formats are OziExplorer 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 OziExplorer mapy a TrekBuddy mapy/atlasy (včetně tar varianty).</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="1144"/>
|
||||
<source>No files loaded</source>
|
||||
<translation>Nejsou načteny žádné soubory</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="105"/>
|
||||
<location filename="../src/gui.cpp" line="109"/>
|
||||
<source>GPX files (*.gpx)</source>
|
||||
<translation>Soubory GPX (*.gpx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="107"/>
|
||||
<location filename="../src/gui.cpp" line="111"/>
|
||||
<source>TCX files (*.tcx)</source>
|
||||
<translation>Soubory TCX (*.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="106"/>
|
||||
<location filename="../src/gui.cpp" line="110"/>
|
||||
<source>KML files (*.kml)</source>
|
||||
<translation>Soubory KML (*.kml)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="104"/>
|
||||
<location filename="../src/gui.cpp" line="108"/>
|
||||
<source>CSV files (*.csv)</source>
|
||||
<translation>Soubory CSV (*.csv)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="107"/>
|
||||
<location filename="../src/gui.cpp" line="111"/>
|
||||
<source>All files (*)</source>
|
||||
<translation>Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="862"/>
|
||||
<location filename="../src/gui.cpp" line="865"/>
|
||||
<location filename="../src/gui.cpp" line="932"/>
|
||||
<location filename="../src/gui.cpp" line="935"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="854"/>
|
||||
<location filename="../src/gui.cpp" line="924"/>
|
||||
<source>Routes</source>
|
||||
<translation>Trasy</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../src/gui.cpp" line="1086"/>
|
||||
<location filename="../src/gui.cpp" line="1148"/>
|
||||
<source>%n files</source>
|
||||
<translation>
|
||||
<numerusform>%n soubor</numerusform>
|
||||
@ -493,132 +543,122 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="588"/>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<source>Next file</source>
|
||||
<translation>Následující soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="566"/>
|
||||
<location filename="../src/gui.cpp" line="622"/>
|
||||
<source>Version </source>
|
||||
<translation>Verze </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="232"/>
|
||||
<location filename="../src/gui.cpp" line="289"/>
|
||||
<source>Print...</source>
|
||||
<translation>Tisknout...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="237"/>
|
||||
<location filename="../src/gui.cpp" line="294"/>
|
||||
<source>Export to PDF...</source>
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="856"/>
|
||||
<location filename="../src/gui.cpp" line="926"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Navigační body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="590"/>
|
||||
<location filename="../src/gui.cpp" line="646"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Předchozí soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="103"/>
|
||||
<location filename="../src/gui.cpp" line="107"/>
|
||||
<source>Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</source>
|
||||
<translation>Podporované soubory (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="322"/>
|
||||
<location filename="../src/gui.cpp" line="380"/>
|
||||
<source>Route waypoints</source>
|
||||
<translation>Body tras</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="592"/>
|
||||
<location filename="../src/gui.cpp" line="648"/>
|
||||
<source>First file</source>
|
||||
<translation>První soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="594"/>
|
||||
<location filename="../src/gui.cpp" line="650"/>
|
||||
<source>Last file</source>
|
||||
<translation>Poslední soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="595"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Modifikátor nahradit/přidat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="612"/>
|
||||
<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="615"/>
|
||||
<location filename="../src/gui.cpp" line="677"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="623"/>
|
||||
<location filename="../src/gui.cpp" line="684"/>
|
||||
<source>Offline maps</source>
|
||||
<translation>Offline mapy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="693"/>
|
||||
<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>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="712"/>
|
||||
<location filename="../src/gui.cpp" line="782"/>
|
||||
<source>Error loading data file:</source>
|
||||
<translation>Datový soubor nelze načíst:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="715"/>
|
||||
<location filename="../src/gui.cpp" line="740"/>
|
||||
<location filename="../src/gui.cpp" line="785"/>
|
||||
<location filename="../src/gui.cpp" line="810"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="737"/>
|
||||
<location filename="../src/gui.cpp" line="807"/>
|
||||
<source>Error loading POI file:</source>
|
||||
<translation>Soubor POI nelze načíst:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="848"/>
|
||||
<location filename="../src/gui.cpp" line="918"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="852"/>
|
||||
<location filename="../src/gui.cpp" line="922"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="222"/>
|
||||
<location filename="../src/gui.cpp" line="565"/>
|
||||
<location filename="../src/gui.cpp" line="279"/>
|
||||
<location filename="../src/gui.cpp" line="621"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>O aplikaci GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="502"/>
|
||||
<location filename="../src/gui.cpp" line="560"/>
|
||||
<source>Navigation</source>
|
||||
<translation>Navigace</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="611"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Mapové zdroje</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="622"/>
|
||||
<location filename="../src/gui.cpp" line="692"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI body</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="337"/>
|
||||
<location filename="../src/gui.cpp" line="872"/>
|
||||
<location filename="../src/gui.cpp" line="395"/>
|
||||
<location filename="../src/gui.cpp" line="942"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="344"/>
|
||||
<location filename="../src/gui.cpp" line="466"/>
|
||||
<location filename="../src/gui.cpp" line="874"/>
|
||||
<location filename="../src/gui.cpp" line="402"/>
|
||||
<location filename="../src/gui.cpp" line="524"/>
|
||||
<location filename="../src/gui.cpp" line="944"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
@ -880,17 +920,17 @@
|
||||
<context>
|
||||
<name>RouteItem</name>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="14"/>
|
||||
<location filename="../src/routeitem.cpp" line="15"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="16"/>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<location filename="../src/routeitem.cpp" line="18"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
@ -921,28 +961,28 @@
|
||||
<context>
|
||||
<name>SpeedGraph</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||
<location filename="../src/speedgraph.h" line="14"/>
|
||||
<source>Speed</source>
|
||||
<translation>Rychlost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="78"/>
|
||||
<location filename="../src/speedgraph.cpp" line="79"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="20"/>
|
||||
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||
<source>Average</source>
|
||||
<translation>Průměr</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="22"/>
|
||||
<location filename="../src/speedgraph.cpp" line="23"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Maximum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="81"/>
|
||||
<location filename="../src/speedgraph.cpp" line="82"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
@ -984,32 +1024,32 @@
|
||||
<context>
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="12"/>
|
||||
<location filename="../src/trackitem.cpp" line="13"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="14"/>
|
||||
<location filename="../src/trackitem.cpp" line="15"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="15"/>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<location filename="../src/trackitem.cpp" line="18"/>
|
||||
<source>Total time</source>
|
||||
<translation>Celkový čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<location filename="../src/trackitem.cpp" line="20"/>
|
||||
<source>Moving time</source>
|
||||
<translation>Čistý čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="21"/>
|
||||
<location filename="../src/trackitem.cpp" line="22"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
@ -1017,27 +1057,27 @@
|
||||
<context>
|
||||
<name>WaypointItem</name>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="17"/>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<location filename="../src/waypointitem.cpp" line="19"/>
|
||||
<source>Coordinates</source>
|
||||
<translation>Souřadnice</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="21"/>
|
||||
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Výška</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="24"/>
|
||||
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="27"/>
|
||||
<location filename="../src/waypointitem.cpp" line="28"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
|
1084
lang/gpxsee_de.ts
Normal file
1084
lang/gpxsee_de.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -190,265 +190,320 @@
|
||||
<context>
|
||||
<name>GUI</name>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="569"/>
|
||||
<location filename="../src/gui.cpp" line="625"/>
|
||||
<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>GPXSee distribueras under vilkoren för GNU General Public License version 3. För mer info om GPXSee, besök hemsidan på </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="633"/>
|
||||
<location filename="../src/gui.cpp" line="703"/>
|
||||
<source>Open file</source>
|
||||
<translation>Öppna fil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="723"/>
|
||||
<location filename="../src/gui.cpp" line="793"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Öppna POI-fil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="227"/>
|
||||
<location filename="../src/gui.cpp" line="284"/>
|
||||
<source>Open</source>
|
||||
<translation>Öppna</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="211"/>
|
||||
<location filename="../src/gui.cpp" line="268"/>
|
||||
<source>Quit</source>
|
||||
<translation>Avsluta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="219"/>
|
||||
<location filename="../src/gui.cpp" line="585"/>
|
||||
<location filename="../src/gui.cpp" line="586"/>
|
||||
<location filename="../src/gui.cpp" line="276"/>
|
||||
<location filename="../src/gui.cpp" line="641"/>
|
||||
<location filename="../src/gui.cpp" line="642"/>
|
||||
<source>Keyboard controls</source>
|
||||
<translation>Snabbtangenter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="243"/>
|
||||
<location filename="../src/gui.cpp" line="300"/>
|
||||
<source>Close</source>
|
||||
<translation>Stäng</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="249"/>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<source>Reload</source>
|
||||
<translation>Uppdatera</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="497"/>
|
||||
<location filename="../src/gui.cpp" line="555"/>
|
||||
<source>Show</source>
|
||||
<translation>Visa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="415"/>
|
||||
<location filename="../src/gui.cpp" line="491"/>
|
||||
<location filename="../src/gui.cpp" line="473"/>
|
||||
<location filename="../src/gui.cpp" line="549"/>
|
||||
<source>File</source>
|
||||
<translation>Arkiv</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="104"/>
|
||||
<location filename="../src/gui.cpp" line="108"/>
|
||||
<source>FIT files (*.fit)</source>
|
||||
<translation>FIT-filer (*.fit)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="105"/>
|
||||
<location filename="../src/gui.cpp" line="109"/>
|
||||
<source>IGC files (*.igc)</source>
|
||||
<translation>IGC-filer (*.igc)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="106"/>
|
||||
<location filename="../src/gui.cpp" line="110"/>
|
||||
<source>NMEA files (*.nmea)</source>
|
||||
<translation>NMEA-filer (*.nmea)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="217"/>
|
||||
<location filename="../src/gui.cpp" line="608"/>
|
||||
<location filename="../src/gui.cpp" line="609"/>
|
||||
<location filename="../src/gui.cpp" line="274"/>
|
||||
<location filename="../src/gui.cpp" line="670"/>
|
||||
<location filename="../src/gui.cpp" line="671"/>
|
||||
<source>Data sources</source>
|
||||
<translation>Datakällor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="257"/>
|
||||
<location filename="../src/gui.cpp" line="314"/>
|
||||
<source>Load POI file</source>
|
||||
<translation>Läs in POI-fil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="260"/>
|
||||
<location filename="../src/gui.cpp" line="317"/>
|
||||
<source>Close POI files</source>
|
||||
<translation>Stäng POI-filer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="262"/>
|
||||
<location filename="../src/gui.cpp" line="319"/>
|
||||
<source>Overlap POIs</source>
|
||||
<translation>Överlappa POI:er</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="266"/>
|
||||
<location filename="../src/gui.cpp" line="323"/>
|
||||
<source>Show POI labels</source>
|
||||
<translation>Visa POI-namn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="271"/>
|
||||
<location filename="../src/gui.cpp" line="328"/>
|
||||
<source>Show POIs</source>
|
||||
<translation>Visa POI:er</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="280"/>
|
||||
<location filename="../src/gui.cpp" line="337"/>
|
||||
<source>Show map</source>
|
||||
<translation>Visa karta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="286"/>
|
||||
<location filename="../src/gui.cpp" line="344"/>
|
||||
<source>Clear tile cache</source>
|
||||
<translation>Rensa kart-cache</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="295"/>
|
||||
<location filename="../src/gui.cpp" line="299"/>
|
||||
<location filename="../src/gui.cpp" line="597"/>
|
||||
<location filename="../src/gui.cpp" line="353"/>
|
||||
<location filename="../src/gui.cpp" line="357"/>
|
||||
<location filename="../src/gui.cpp" line="653"/>
|
||||
<source>Next map</source>
|
||||
<translation>Nästa karta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="306"/>
|
||||
<location filename="../src/gui.cpp" line="364"/>
|
||||
<source>Show tracks</source>
|
||||
<translation>Visa spår</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="310"/>
|
||||
<location filename="../src/gui.cpp" line="368"/>
|
||||
<source>Show routes</source>
|
||||
<translation>Visa rutter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="314"/>
|
||||
<location filename="../src/gui.cpp" line="372"/>
|
||||
<source>Show waypoints</source>
|
||||
<translation>Visa vägpunkter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="318"/>
|
||||
<location filename="../src/gui.cpp" line="376"/>
|
||||
<source>Waypoint labels</source>
|
||||
<translation>Vägpunktsnamn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="329"/>
|
||||
<location filename="../src/gui.cpp" line="387"/>
|
||||
<source>Show graphs</source>
|
||||
<translation>Visa diagram</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="351"/>
|
||||
<location filename="../src/gui.cpp" line="409"/>
|
||||
<source>Show grid</source>
|
||||
<translation>Visa stödlinjer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="357"/>
|
||||
<location filename="../src/gui.cpp" line="415"/>
|
||||
<source>Show toolbars</source>
|
||||
<translation>Visa verktygsfält</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="363"/>
|
||||
<location filename="../src/gui.cpp" line="421"/>
|
||||
<source>Total time</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Total tid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="368"/>
|
||||
<location filename="../src/gui.cpp" line="876"/>
|
||||
<location filename="../src/gui.cpp" line="426"/>
|
||||
<location filename="../src/gui.cpp" line="946"/>
|
||||
<source>Moving time</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Förflyttningstid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="375"/>
|
||||
<location filename="../src/gui.cpp" line="433"/>
|
||||
<source>Metric</source>
|
||||
<translation>Meter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="380"/>
|
||||
<location filename="../src/gui.cpp" line="438"/>
|
||||
<source>Imperial</source>
|
||||
<translation>Imperial</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="386"/>
|
||||
<location filename="../src/gui.cpp" line="444"/>
|
||||
<source>Fullscreen mode</source>
|
||||
<translation>Helskärmsläge</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="392"/>
|
||||
<location filename="../src/gui.cpp" line="450"/>
|
||||
<source>Options...</source>
|
||||
<translation>Alternativ...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="397"/>
|
||||
<location filename="../src/gui.cpp" line="455"/>
|
||||
<source>Next</source>
|
||||
<translation>Nästa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="400"/>
|
||||
<location filename="../src/gui.cpp" line="458"/>
|
||||
<source>Previous</source>
|
||||
<translation>Föregående</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="404"/>
|
||||
<location filename="../src/gui.cpp" line="462"/>
|
||||
<source>Last</source>
|
||||
<translation>Sista</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="407"/>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<source>First</source>
|
||||
<translation>Första</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="429"/>
|
||||
<location filename="../src/gui.cpp" line="487"/>
|
||||
<source>Map</source>
|
||||
<translation>Karta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="436"/>
|
||||
<location filename="../src/gui.cpp" line="494"/>
|
||||
<source>Graph</source>
|
||||
<translation>Diagram</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="444"/>
|
||||
<location filename="../src/gui.cpp" line="502"/>
|
||||
<source>POI</source>
|
||||
<translation>POI</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="445"/>
|
||||
<location filename="../src/gui.cpp" line="503"/>
|
||||
<source>POI files</source>
|
||||
<translation>POI-filer</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="456"/>
|
||||
<location filename="../src/gui.cpp" line="514"/>
|
||||
<source>Data</source>
|
||||
<translation>Data</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="457"/>
|
||||
<location filename="../src/gui.cpp" line="515"/>
|
||||
<source>Display</source>
|
||||
<translation>Visa</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="465"/>
|
||||
<location filename="../src/gui.cpp" line="523"/>
|
||||
<source>Settings</source>
|
||||
<translation>Inställningar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="469"/>
|
||||
<location filename="../src/gui.cpp" line="527"/>
|
||||
<source>Units</source>
|
||||
<translation>Enhet</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="478"/>
|
||||
<location filename="../src/gui.cpp" line="536"/>
|
||||
<source>Help</source>
|
||||
<translation>Hjälp</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="598"/>
|
||||
<location filename="../src/gui.cpp" line="651"/>
|
||||
<source>Append file</source>
|
||||
<translation>Lägg till fil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="652"/>
|
||||
<source>Next/Previous</source>
|
||||
<translation>Nästa/Föregående</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="655"/>
|
||||
<source>Previous map</source>
|
||||
<translation>Föregående karta</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="1082"/>
|
||||
<location filename="../src/gui.cpp" line="656"/>
|
||||
<source>Zoom in</source>
|
||||
<translation>Zooma in</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="658"/>
|
||||
<source>Zoom out</source>
|
||||
<translation>Zooma ut</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="660"/>
|
||||
<source>Digital zoom</source>
|
||||
<translation>Digital zoom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="661"/>
|
||||
<source>Zoom</source>
|
||||
<translation>Zoom</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="673"/>
|
||||
<source>Online maps</source>
|
||||
<translation>Online-kartor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="674"/>
|
||||
<source>Online map URLs are read on program startup from the following file:</source>
|
||||
<translation>Online-kartors URL:er, läses från följande fil vid programstart:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="684"/>
|
||||
<source>Offline maps</source>
|
||||
<translation>Offline-kartor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="685"/>
|
||||
<source>Offline maps are loaded on program startup from the following directory:</source>
|
||||
<translation>Offline-kartor läses in från följande mapp vid programstart:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="688"/>
|
||||
<source>The expected structure is one map/atlas in a separate subdirectory. Supported map formats are OziExplorer image-based maps and tiled TrekBuddy maps/atlases (tared and non-tared).</source>
|
||||
<translation>Den förväntade strukturen är en karta/atlas i en separat undermapp. Kartformat som stöds är OziExplorer bildbaserade kartor och rutindelade TrekBuddy-kartor/-kartsamlingar (tarerade och icke tarerade).</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="1144"/>
|
||||
<source>No files loaded</source>
|
||||
<translation>Inga filer inlästa</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../src/gui.cpp" line="1086"/>
|
||||
<location filename="../src/gui.cpp" line="1148"/>
|
||||
<source>%n files</source>
|
||||
<translation>
|
||||
<numerusform>%n filer</numerusform>
|
||||
@ -456,168 +511,153 @@
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="105"/>
|
||||
<location filename="../src/gui.cpp" line="109"/>
|
||||
<source>GPX files (*.gpx)</source>
|
||||
<translation>GPX-filer (*.gpx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="107"/>
|
||||
<location filename="../src/gui.cpp" line="111"/>
|
||||
<source>TCX files (*.tcx)</source>
|
||||
<translation>TCX-filer (*.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="106"/>
|
||||
<location filename="../src/gui.cpp" line="110"/>
|
||||
<source>KML files (*.kml)</source>
|
||||
<translation>KML-filer (*.kml)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="104"/>
|
||||
<location filename="../src/gui.cpp" line="108"/>
|
||||
<source>CSV files (*.csv)</source>
|
||||
<translation>CSV-filer (*.csv)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="107"/>
|
||||
<location filename="../src/gui.cpp" line="111"/>
|
||||
<source>All files (*)</source>
|
||||
<translation>Alla filer (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="862"/>
|
||||
<location filename="../src/gui.cpp" line="865"/>
|
||||
<location filename="../src/gui.cpp" line="932"/>
|
||||
<location filename="../src/gui.cpp" line="935"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="854"/>
|
||||
<location filename="../src/gui.cpp" line="924"/>
|
||||
<source>Routes</source>
|
||||
<translation>Rutter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="588"/>
|
||||
<location filename="../src/gui.cpp" line="645"/>
|
||||
<source>Next file</source>
|
||||
<translation>Nästa fil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="566"/>
|
||||
<location filename="../src/gui.cpp" line="622"/>
|
||||
<source>Version </source>
|
||||
<translation>Version </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="232"/>
|
||||
<location filename="../src/gui.cpp" line="289"/>
|
||||
<source>Print...</source>
|
||||
<translation>Skriv ut...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="237"/>
|
||||
<location filename="../src/gui.cpp" line="294"/>
|
||||
<source>Export to PDF...</source>
|
||||
<translation>Exportera till PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="856"/>
|
||||
<location filename="../src/gui.cpp" line="926"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Vägpunkter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="590"/>
|
||||
<location filename="../src/gui.cpp" line="646"/>
|
||||
<source>Previous file</source>
|
||||
<translation>Föregående fil</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="103"/>
|
||||
<location filename="../src/gui.cpp" line="107"/>
|
||||
<source>Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</source>
|
||||
<translation>Filer som stöds (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="322"/>
|
||||
<location filename="../src/gui.cpp" line="380"/>
|
||||
<source>Route waypoints</source>
|
||||
<translation>Ruttvägpunkter</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="592"/>
|
||||
<location filename="../src/gui.cpp" line="648"/>
|
||||
<source>First file</source>
|
||||
<translation>Första filen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="594"/>
|
||||
<location filename="../src/gui.cpp" line="650"/>
|
||||
<source>Last file</source>
|
||||
<translation>Sista filen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="595"/>
|
||||
<source>Append modifier</source>
|
||||
<translation>Tillämpa modifierare</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="612"/>
|
||||
<source>Map (tiles) source URLs are read on program startup from the following file:</source>
|
||||
<translation>Kartadresser (URL:er) läses in vid programstart, från följande fil:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="615"/>
|
||||
<location filename="../src/gui.cpp" line="677"/>
|
||||
<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>Filformatet är en kartpost per rad, bestående av kartnamn och kartrutans URL, avgränsade med ett TAB-tecken. Kartrutans X- och Y-koordinater ersätts med $x och $y i URL:en och zoomnivån ersätts med $z. Exempel på en kartfil kan se ut så här:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="623"/>
|
||||
<location filename="../src/gui.cpp" line="693"/>
|
||||
<source>To make GPXSee load a POI file automatically on startup, add the file to the following directory:</source>
|
||||
<translation>För att GPXSee skall läsa in en POI-fil automatiskt vid programstart, läggs filen i följande mapp:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="712"/>
|
||||
<location filename="../src/gui.cpp" line="782"/>
|
||||
<source>Error loading data file:</source>
|
||||
<translation>Fel vid inläsning av datafil:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="715"/>
|
||||
<location filename="../src/gui.cpp" line="740"/>
|
||||
<location filename="../src/gui.cpp" line="785"/>
|
||||
<location filename="../src/gui.cpp" line="810"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Rad: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="737"/>
|
||||
<location filename="../src/gui.cpp" line="807"/>
|
||||
<source>Error loading POI file:</source>
|
||||
<translation>Fel vid inläsning av POI-fil:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="848"/>
|
||||
<location filename="../src/gui.cpp" line="918"/>
|
||||
<source>Name</source>
|
||||
<translation>Namn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="852"/>
|
||||
<location filename="../src/gui.cpp" line="922"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Spår</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="222"/>
|
||||
<location filename="../src/gui.cpp" line="565"/>
|
||||
<location filename="../src/gui.cpp" line="279"/>
|
||||
<location filename="../src/gui.cpp" line="621"/>
|
||||
<source>About GPXSee</source>
|
||||
<translation>Om GPXSee</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="502"/>
|
||||
<location filename="../src/gui.cpp" line="560"/>
|
||||
<source>Navigation</source>
|
||||
<translation>Navigation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="611"/>
|
||||
<source>Map sources</source>
|
||||
<translation>Kartkällor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="622"/>
|
||||
<location filename="../src/gui.cpp" line="692"/>
|
||||
<source>POIs</source>
|
||||
<translation>POI:er</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="337"/>
|
||||
<location filename="../src/gui.cpp" line="872"/>
|
||||
<location filename="../src/gui.cpp" line="395"/>
|
||||
<location filename="../src/gui.cpp" line="942"/>
|
||||
<source>Distance</source>
|
||||
<translation>Avstånd</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="344"/>
|
||||
<location filename="../src/gui.cpp" line="466"/>
|
||||
<location filename="../src/gui.cpp" line="874"/>
|
||||
<location filename="../src/gui.cpp" line="402"/>
|
||||
<location filename="../src/gui.cpp" line="524"/>
|
||||
<location filename="../src/gui.cpp" line="944"/>
|
||||
<source>Time</source>
|
||||
<translation>Tid</translation>
|
||||
</message>
|
||||
@ -808,7 +848,7 @@
|
||||
<message>
|
||||
<location filename="../src/optionsdialog.cpp" line="155"/>
|
||||
<source>Moving time</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Förflyttningstid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/optionsdialog.cpp" line="157"/>
|
||||
@ -879,17 +919,17 @@
|
||||
<context>
|
||||
<name>RouteItem</name>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="14"/>
|
||||
<location filename="../src/routeitem.cpp" line="15"/>
|
||||
<source>Name</source>
|
||||
<translation>Namn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="16"/>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<source>Description</source>
|
||||
<translation>Beskrivning</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<location filename="../src/routeitem.cpp" line="18"/>
|
||||
<source>Distance</source>
|
||||
<translation>Avstånd</translation>
|
||||
</message>
|
||||
@ -920,28 +960,28 @@
|
||||
<context>
|
||||
<name>SpeedGraph</name>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="12"/>
|
||||
<location filename="../src/speedgraph.cpp" line="13"/>
|
||||
<location filename="../src/speedgraph.h" line="14"/>
|
||||
<source>Speed</source>
|
||||
<translation>Hastighet</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="78"/>
|
||||
<location filename="../src/speedgraph.cpp" line="79"/>
|
||||
<source>km/h</source>
|
||||
<translation>km/h</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="20"/>
|
||||
<location filename="../src/speedgraph.cpp" line="21"/>
|
||||
<source>Average</source>
|
||||
<translation>Medel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="22"/>
|
||||
<location filename="../src/speedgraph.cpp" line="23"/>
|
||||
<source>Maximum</source>
|
||||
<translation>Max</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/speedgraph.cpp" line="81"/>
|
||||
<location filename="../src/speedgraph.cpp" line="82"/>
|
||||
<source>mi/h</source>
|
||||
<translation>mi/h</translation>
|
||||
</message>
|
||||
@ -983,32 +1023,32 @@
|
||||
<context>
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="12"/>
|
||||
<location filename="../src/trackitem.cpp" line="13"/>
|
||||
<source>Name</source>
|
||||
<translation>Namn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="14"/>
|
||||
<location filename="../src/trackitem.cpp" line="15"/>
|
||||
<source>Description</source>
|
||||
<translation>Beskrivning</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="15"/>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<source>Distance</source>
|
||||
<translation>Avstånd</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<location filename="../src/trackitem.cpp" line="18"/>
|
||||
<source>Total time</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Total tid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="19"/>
|
||||
<location filename="../src/trackitem.cpp" line="20"/>
|
||||
<source>Moving time</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Förflyttningstid</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="21"/>
|
||||
<location filename="../src/trackitem.cpp" line="22"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
@ -1016,27 +1056,27 @@
|
||||
<context>
|
||||
<name>WaypointItem</name>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="17"/>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<source>Name</source>
|
||||
<translation>Namn</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="18"/>
|
||||
<location filename="../src/waypointitem.cpp" line="19"/>
|
||||
<source>Coordinates</source>
|
||||
<translation>Koordinater</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="21"/>
|
||||
<location filename="../src/waypointitem.cpp" line="22"/>
|
||||
<source>Elevation</source>
|
||||
<translation>Höjd</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="24"/>
|
||||
<location filename="../src/waypointitem.cpp" line="25"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/waypointitem.cpp" line="27"/>
|
||||
<location filename="../src/waypointitem.cpp" line="28"/>
|
||||
<source>Description</source>
|
||||
<translation>Beskrivning</translation>
|
||||
</message>
|
||||
|
123
pkg/datums.csv
Normal file
123
pkg/datums.csv
Normal file
@ -0,0 +1,123 @@
|
||||
Adindan,4201,5,-162,-12,206
|
||||
Afgooye,4205,15,-43,-163,45
|
||||
Ain el Abd 1970,4204,14,-150,-251,-2
|
||||
Anna 1 Astro 1965,4708,2,-491,-22,435
|
||||
Arc 1950,4209,5,-143,-90,-294
|
||||
Arc 1960,4210,5,-160,-8,-300
|
||||
Ascension Island 1958,4712,14,-207,107,52
|
||||
Astro B4 Sorol Atoll,4707,14,114,-116,-333
|
||||
Astro Beacon 1945,4709,14,145,75,-272
|
||||
Astro DOS 71/4,4710,14,-320,550,-494
|
||||
Astronomic Stn 1952,4711,14,124,-234,-25
|
||||
Australian Geodetic 1966,4202,2,-133,-48,148
|
||||
Australian Geodetic 1984,4203,2,-134,-48,149
|
||||
Australian Geocentric 1994 (GDA94),4283,11,0,0,0
|
||||
Austrian,4312,3,594,84,471
|
||||
Bellevue (IGN),4714,14,-127,-769,472
|
||||
Bermuda 1957,4216,4,-73,213,296
|
||||
Bogota Observatory,4218,14,307,304,-318
|
||||
Campo Inchauspe,4221,14,-148,136,90
|
||||
Canton Astro 1966,4716,14,298,-304,-375
|
||||
Cape,4222,5,-136,-108,-292
|
||||
Cape Canaveral,4717,4,-2,150,181
|
||||
Carthage,4223,5,-263,6,431
|
||||
CH-1903,4149,3,674,15,405
|
||||
Chatham 1971,4672,14,175,-38,113
|
||||
Chua Astro,4224,14,-134,229,-29
|
||||
Corrego Alegre,4225,14,-206,172,-6
|
||||
Djakarta (Batavia),4211,3,-377,681,-50
|
||||
DOS 1968,,14,230,-199,-752
|
||||
Easter Island 1967,4719,14,211,147,111
|
||||
Egypt,,14,-130,-117,-151
|
||||
European 1950,4230,14,-87,-98,-121
|
||||
European 1950 (Mean France),,14,-87,-96,-120
|
||||
European 1950 (Spain and Portugal),,14,-84,-107,-120
|
||||
European 1979,4668,14,-86,-98,-119
|
||||
Finland Hayford,4123,14,-78,-231,-97
|
||||
Gandajika Base,4233,14,-133,-321,50
|
||||
Geodetic Datum 1949,4272,14,84,-22,209
|
||||
GGRS 87,4121,11,-199.87,74.79,246.62
|
||||
Guam 1963,4675,4,-100,-248,259
|
||||
GUX 1 Astro,4718,14,252,-209,-751
|
||||
Hartebeeshoek94,4148,20,0,0,0
|
||||
Hermannskogel,3906,3,653,-212,449
|
||||
Hjorsey 1955,4658,14,-73,46,-86
|
||||
Hong Kong 1963,4739,14,-156,-271,-189
|
||||
Hu-Tzu-Shan,4236,14,-634,-549,-201
|
||||
Indian Bangladesh,4682,6,289,734,257
|
||||
Indian Thailand,4240,6,214,836,303
|
||||
Israeli,4281,23,-235,-85,264
|
||||
Ireland 1965,4299,1,506,-122,611
|
||||
ISTS 073 Astro 1969,4724,14,208,-435,-229
|
||||
Johnston Island,4725,14,191,-77,-204
|
||||
Kandawala,4244,6,-97,787,86
|
||||
Kerguelen Island,4698,14,145,-187,103
|
||||
Kertau 1948,4245,7,-11,851,5
|
||||
L.C. 5 Astro,4726,4,42,124,147
|
||||
Liberia 1964,4251,5,-90,40,88
|
||||
Luzon Mindanao,,4,-133,-79,-72
|
||||
Luzon Philippines,4253,4,-133,-77,-51
|
||||
Mahe 1971,4256,5,41,-220,-134
|
||||
Marco Astro,4616,14,-289,-124,60
|
||||
Massawa,4262,3,639,405,60
|
||||
Merchich,4261,5,31,146,47
|
||||
Midway Astro 1961,4727,14,912,-58,1227
|
||||
Minna,4263,5,-92,-93,122
|
||||
NAD27 Alaska,,4,-5,135,172
|
||||
NAD27 Bahamas,,4,-4,154,178
|
||||
NAD27 Canada,,4,-10,158,187
|
||||
NAD27 Canal Zone,,4,0,125,201
|
||||
NAD27 Caribbean,,4,-7,152,178
|
||||
NAD27 Central,,4,0,125,194
|
||||
NAD27 CONUS,,4,-8,160,176
|
||||
NAD27 Cuba,,4,-9,152,178
|
||||
NAD27 Greenland,,4,11,114,195
|
||||
NAD27 Mexico,,4,-12,130,190
|
||||
NAD27 San Salvador,,4,1,140,165
|
||||
NAD83,4269,11,0,0,0
|
||||
Nahrwn Masirah Ilnd,,5,-247,-148,369
|
||||
Nahrwn Saudi Arbia,,5,-231,-196,482
|
||||
Nahrwn United Arab,,5,-249,-156,381
|
||||
Naparima BWI,4271,14,-2,374,172
|
||||
NGO1948,4273,27,315,-217,528
|
||||
NTF France,4275,24,-168,-60,320
|
||||
Norsk,4817,27,278,93,474
|
||||
NZGD1949,4272,14,84,-22,209
|
||||
NZGD2000,4167,20,0,0,0
|
||||
Observatorio 1966,4182,14,-425,-169,81
|
||||
Old Egyptian,4229,12,-130,110,-13
|
||||
Old Hawaiian,4135,4,61,-285,-181
|
||||
Oman,4232,5,-346,-1,224
|
||||
Ord Srvy Grt Britn,4277,0,375,-111,431
|
||||
Pico De Las Nieves,4728,14,-307,-92,127
|
||||
Pitcairn Astro 1967,4729,14,185,165,42
|
||||
Potsdam Rauenberg DHDN,4314,3,606,23,413
|
||||
Prov So Amrican 1956,4248,14,-288,175,-376
|
||||
Prov So Chilean 1963,4254,14,16,196,93
|
||||
Puerto Rico,4139,4,11,72,-101
|
||||
Pulkovo 1942 (1),4284,15,28,-130,-95
|
||||
Pulkovo 1942 (2),4284,15,28,-130,-95
|
||||
Qatar National,4285,14,-128,-283,22
|
||||
Qornoq,4287,14,164,138,-189
|
||||
Reunion,4626,14,94,-948,-1262
|
||||
Rijksdriehoeksmeting,4289,3,593,26,478
|
||||
Rome 1940,4806,14,-225,-65,9
|
||||
RT 90,4124,3,498,-36,568
|
||||
S42,4179,15,28,-121,-77
|
||||
Santo (DOS),4730,14,170,42,84
|
||||
Sao Braz,4184,14,-203,141,53
|
||||
Sapper Hill 1943,4292,14,-355,16,74
|
||||
Schwarzeck,4293,21,616,97,-251
|
||||
South American 1969,4291,16,-57,1,-41
|
||||
South Asia,,8,7,-10,-26
|
||||
Southeast Base,4615,14,-499,-249,314
|
||||
Southwest Base,4183,14,-104,167,-38
|
||||
Timbalai 1948,4298,6,-689,691,-46
|
||||
Tokyo,4301,3,-128,481,664
|
||||
Tristan Astro 1968,4734,14,-632,438,-609
|
||||
Viti Levu 1916,4731,5,51,391,-36
|
||||
Wake-Eniwetok 1960,4732,13,101,52,-39
|
||||
WGS 72,4322,19,0,0,5
|
||||
WGS 84,4326,20,0,0,0
|
||||
Yacare,4309,14,-155,171,37
|
||||
Zanderij,4311,14,-265,120,-358
|
|
30
pkg/ellipsoids.csv
Normal file
30
pkg/ellipsoids.csv
Normal file
@ -0,0 +1,30 @@
|
||||
0,Airy 1830,6377563.396,299.3249646
|
||||
1,Modified Airy,6377340.189,299.3249646
|
||||
2,Australian National,6378160.0,298.25
|
||||
3,Bessel 1841,6377397.155,299.1528128
|
||||
4,Clarke 1866,6378206.4,294.9786982
|
||||
5,Clarke 1880,6378249.145,293.465
|
||||
6,Everest (India 1830),6377276.345,300.8017
|
||||
7,Everest (1948),6377304.063,300.8017
|
||||
8,Modified Fischer 1960,6378155.0,298.3
|
||||
9,Everest (Pakistan),6377309.613,300.8017
|
||||
10,Indonesian 1974,6378160.0,298.247
|
||||
11,GRS 80,6378137.0,298.257222101
|
||||
12,Helmert 1906,6378200.0,298.3
|
||||
13,Hough 1960,6378270.0,297.0
|
||||
14,International 1924,6378388.0,297.0
|
||||
15,Krassovsky 1940,6378245.0,298.3
|
||||
16,South American 1969,6378160.0,298.25
|
||||
17,Everest (Malaysia 1969),6377295.664,300.8017
|
||||
18,Everest (Sabah Sarawak),6377298.556,300.8017
|
||||
19,WGS 72,6378135.0,298.26
|
||||
20,WGS 84,6378137.0,298.257223563
|
||||
21,Bessel 1841 (Namibia),6377483.865,299.1528128
|
||||
22,Everest (India 1956),6377301.243,300.8017
|
||||
23,Clarke 1880 Palestine,6378300.789,293.466
|
||||
24,Clarke 1880 IGN,6378249.2,293.466021
|
||||
25,Hayford 1909,6378388.0,296.959263
|
||||
26,Clarke 1858,6378350.87,294.26
|
||||
27,Bessel 1841 (Norway),6377492.0176,299.1528
|
||||
28,Plessis 1817 (France),6376523.0,308.6409971
|
||||
29,Hayford 1924,6378388.0,297.0
|
|
BIN
pkg/gpxsee.cer
Normal file
BIN
pkg/gpxsee.cer
Normal file
Binary file not shown.
@ -5,7 +5,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "3.9"
|
||||
!define VERSION "4.4"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}.exe"
|
||||
@ -16,6 +16,14 @@ RequestExecutionLevel admin
|
||||
; The default installation directory
|
||||
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
|
||||
; overwrite the old one automatically)
|
||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||
@ -74,6 +82,8 @@ Section "GPXSee" SEC_APP
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
File "ellipsoids.csv"
|
||||
File "datums.csv"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
@ -163,6 +173,7 @@ Section "MSVC runtime" SEC_MSVC
|
||||
SetOutPath $TEMP
|
||||
File "VC_redist.x86.exe"
|
||||
ExecWait '"$TEMP/VC_redist.x86.exe" /install /quiet /norestart'
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
done:
|
||||
SectionEnd
|
||||
@ -241,4 +252,4 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
@ -5,7 +5,7 @@
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "3.9"
|
||||
!define VERSION "4.4"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
@ -16,6 +16,14 @@ RequestExecutionLevel admin
|
||||
; The default installation directory
|
||||
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
|
||||
; overwrite the old one automatically)
|
||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||
@ -81,6 +89,8 @@ Section "GPXSee" SEC_APP
|
||||
; Put the files there
|
||||
File "gpxsee.exe"
|
||||
File "maps.txt"
|
||||
File "ellipsoids.csv"
|
||||
File "datums.csv"
|
||||
|
||||
; Create start menu entry and add links
|
||||
SetShellVarContext all
|
||||
@ -98,7 +108,7 @@ Section "GPXSee" SEC_APP
|
||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||
|
||||
; 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}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
@ -165,6 +175,7 @@ Section "MSVC runtime" SEC_MSVC
|
||||
SetOutPath $TEMP
|
||||
File "VC_redist.x64.exe"
|
||||
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
|
||||
SetOutPath $INSTDIR
|
||||
|
||||
done:
|
||||
SectionEnd
|
||||
@ -244,4 +255,4 @@ LangString DESC_APP ${LANG_ENGLISH} \
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
10
src/app.cpp
10
src/app.cpp
@ -6,23 +6,26 @@
|
||||
#include <QPixmapCache>
|
||||
#include "opengl.h"
|
||||
#include "gui.h"
|
||||
#include "onlinemap.h"
|
||||
#include "downloader.h"
|
||||
#include "app.h"
|
||||
|
||||
|
||||
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
_argc(argc), _argv(argv)
|
||||
{
|
||||
_translator = new QTranslator();
|
||||
QTranslator *translator = new QTranslator(this);
|
||||
|
||||
QString locale = QLocale::system().name();
|
||||
_translator->load(QString(":/lang/gpxsee_") + locale);
|
||||
installTranslator(_translator);
|
||||
translator->load(QString(":/lang/gpxsee_") + locale);
|
||||
installTranslator(translator);
|
||||
#ifdef Q_OS_MAC
|
||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||
QPixmapCache::setCacheLimit(65536);
|
||||
OnlineMap::setDownloader(new Downloader(this));
|
||||
OPENGL_SET_SAMPLES(4);
|
||||
|
||||
_gui = new GUI();
|
||||
@ -31,7 +34,6 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
App::~App()
|
||||
{
|
||||
delete _gui;
|
||||
delete _translator;
|
||||
}
|
||||
|
||||
void App::run()
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QApplication>
|
||||
|
||||
class GUI;
|
||||
class QTranslator;
|
||||
|
||||
class App : QApplication
|
||||
{
|
||||
@ -22,7 +21,6 @@ private:
|
||||
int &_argc;
|
||||
char **_argv;
|
||||
GUI *_gui;
|
||||
QTranslator *_translator;
|
||||
};
|
||||
|
||||
#endif // APP_H
|
||||
|
280
src/atlas.cpp
Normal file
280
src/atlas.cpp
Normal file
@ -0,0 +1,280 @@
|
||||
#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(Tar &tar, 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++) {
|
||||
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++) {
|
||||
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)
|
||||
{
|
||||
Tar tar;
|
||||
|
||||
_valid = false;
|
||||
_zoom = 0;
|
||||
|
||||
QFileInfo fi(path);
|
||||
_name = fi.fileName();
|
||||
|
||||
QDir dir(path);
|
||||
QFileInfoList files = dir.entryInfoList(QDir::Files);
|
||||
if (!isAtlas(tar, 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();
|
||||
|
||||
_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);
|
||||
}
|
49
src/atlas.h
Normal file
49
src/atlas.h
Normal file
@ -0,0 +1,49 @@
|
||||
#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(Tar &tar, const QFileInfoList &files);
|
||||
void computeZooms();
|
||||
void computeBounds();
|
||||
|
||||
QString _name;
|
||||
bool _valid;
|
||||
|
||||
QList<OfflineMap*> _maps;
|
||||
QVector<QPair<int, int> > _zooms;
|
||||
QVector<QPair<QRectF, QRectF> > _bounds;
|
||||
int _zoom;
|
||||
};
|
||||
|
||||
#endif // ATLAS_H
|
19
src/config.h
19
src/config.h
@ -13,7 +13,10 @@
|
||||
#define FONT_SIZE 12
|
||||
#define SCREEN_DPI 96.0
|
||||
|
||||
#define ELLIPSOID_FILE QString("ellipsoids.csv")
|
||||
#define DATUM_FILE QString("datums.csv")
|
||||
#define MAP_FILE QString("maps.txt")
|
||||
#define MAP_DIR QString("maps")
|
||||
#define POI_DIR QString("POI")
|
||||
|
||||
#if defined(Q_OS_WIN32)
|
||||
@ -28,10 +31,16 @@
|
||||
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
||||
#endif
|
||||
|
||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
||||
#define USER_ELLIPSOID_FILE USER_DIR + QString("/") + ELLIPSOID_FILE
|
||||
#define USER_DATUM_FILE USER_DIR + QString("/") + DATUM_FILE
|
||||
#define USER_MAP_DIR USER_DIR + QString("/") + MAP_DIR
|
||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
||||
#define GLOBAL_ELLIPSOID_FILE GLOBAL_DIR + QString("/") + ELLIPSOID_FILE
|
||||
#define GLOBAL_DATUM_FILE GLOBAL_DIR + QString("/") + DATUM_FILE
|
||||
#define GLOBAL_MAP_DIR GLOBAL_DIR + QString("/") + MAP_DIR
|
||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
||||
|
||||
#endif /* CONFIG_H */
|
||||
|
@ -17,27 +17,12 @@ qreal Coordinates::distanceTo(const Coordinates &c) const
|
||||
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)
|
||||
{
|
||||
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
||||
<< coordinates.lat() << ")";
|
||||
|
||||
return dbg.maybeSpace();
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
||||
|
@ -12,6 +12,9 @@ public:
|
||||
Coordinates(const Coordinates &c) {_lon = c._lon; _lat = c._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 &rlat() {return _lat;}
|
||||
void setLon(qreal lon) {_lon = lon;}
|
||||
@ -28,14 +31,14 @@ public:
|
||||
qreal distanceTo(const Coordinates &c) const;
|
||||
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
||||
|
||||
QPointF toMercator() const;
|
||||
static Coordinates fromMercator(const QPointF &m);
|
||||
|
||||
private:
|
||||
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);
|
||||
|
||||
#endif // COORDINATES_H
|
||||
|
@ -82,9 +82,9 @@ bool Data::loadFile(const QString &fileName)
|
||||
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++)
|
||||
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()));
|
||||
|
||||
_errorLine = 0;
|
||||
|
83
src/datum.cpp
Normal file
83
src/datum.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
#include <QFile>
|
||||
#include "wgs84.h"
|
||||
#include "datum.h"
|
||||
|
||||
|
||||
static QMap<QString, Datum> WGS84()
|
||||
{
|
||||
QMap<QString, Datum> map;
|
||||
map.insert("WGS 84", Datum(Ellipsoid(WGS84_RADIUS, WGS84_FLATTENING),
|
||||
0, 0, 0));
|
||||
return map;
|
||||
}
|
||||
|
||||
QMap<QString, Datum> Datum::_datums = WGS84();
|
||||
QString Datum::_errorString;
|
||||
int Datum::_errorLine = 0;
|
||||
|
||||
Datum Datum::datum(const QString &name)
|
||||
{
|
||||
QMap<QString, Datum>::const_iterator it = _datums.find(name);
|
||||
|
||||
if (it == _datums.end())
|
||||
return Datum();
|
||||
|
||||
return it.value();
|
||||
}
|
||||
|
||||
bool Datum::loadList(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
bool res;
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
_errorString = qPrintable(file.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
_errorLine = 1;
|
||||
_errorString.clear();
|
||||
|
||||
while (!file.atEnd()) {
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() != 6) {
|
||||
_errorString = "Format error";
|
||||
return false;
|
||||
}
|
||||
|
||||
int eid = list[2].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid id";
|
||||
return false;
|
||||
}
|
||||
double dx = list[3].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid dx";
|
||||
return false;
|
||||
}
|
||||
double dy = list[4].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid dy";
|
||||
return false;
|
||||
}
|
||||
double dz = list[5].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid dz";
|
||||
return false;
|
||||
}
|
||||
|
||||
Ellipsoid e = Ellipsoid::ellipsoid(eid);
|
||||
if (e.isNull()) {
|
||||
_errorString = "Unknown ellipsoid ID";
|
||||
return false;
|
||||
}
|
||||
|
||||
Datum d(e, dx, dy, dz);
|
||||
_datums.insert(list[0].trimmed(), d);
|
||||
|
||||
_errorLine++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
38
src/datum.h
Normal file
38
src/datum.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef DATUM_H
|
||||
#define DATUM_H
|
||||
|
||||
#include <QMap>
|
||||
#include "ellipsoid.h"
|
||||
|
||||
class Datum
|
||||
{
|
||||
public:
|
||||
Datum() : _ellipsoid(Ellipsoid()), _dx(0), _dy(0), _dz(0) {}
|
||||
Datum(const Ellipsoid &ellipsoid, double dx, double dy, double dz)
|
||||
: _ellipsoid(ellipsoid), _dx(dx), _dy(dy), _dz(dz) {}
|
||||
|
||||
const Ellipsoid &ellipsoid() const {return _ellipsoid;}
|
||||
double dx() const {return _dx;}
|
||||
double dy() const {return _dy;}
|
||||
double dz() const {return _dz;}
|
||||
|
||||
bool isNull() const {return _ellipsoid.isNull();}
|
||||
bool isWGS84() const
|
||||
{return _ellipsoid.isWGS84() && _dx == 0 && _dy == 0 && _dz == 0;}
|
||||
|
||||
static bool loadList(const QString &path);
|
||||
static const QString &errorString() {return _errorString;}
|
||||
static int errorLine() {return _errorLine;}
|
||||
|
||||
static Datum datum(const QString &name);
|
||||
|
||||
private:
|
||||
Ellipsoid _ellipsoid;
|
||||
double _dx, _dy, _dz;
|
||||
|
||||
static QMap<QString, Datum> _datums;
|
||||
static QString _errorString;
|
||||
static int _errorLine;
|
||||
};
|
||||
|
||||
#endif // DATUM_H
|
@ -61,7 +61,7 @@ bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
||||
QFile file(filename);
|
||||
|
||||
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()));
|
||||
return false;
|
||||
}
|
||||
@ -80,11 +80,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||
if (origin.isEmpty()) {
|
||||
_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()));
|
||||
} else {
|
||||
_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(),
|
||||
qPrintable(reply->errorString()));
|
||||
}
|
||||
@ -99,11 +99,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
|
||||
if (location == url) {
|
||||
_errorDownloads.insert(url);
|
||||
fprintf(stderr, "Error downloading map tile: %s: "
|
||||
qWarning("Error downloading map tile: %s: "
|
||||
"redirect loop\n", url.toEncoded().constData());
|
||||
} else if (level >= MAX_REDIRECT_LEVEL) {
|
||||
_errorDownloads.insert(origin);
|
||||
fprintf(stderr, "Error downloading map tile: %s: "
|
||||
qWarning("Error downloading map tile: %s: "
|
||||
"redirect level limit reached\n",
|
||||
origin.toEncoded().constData());
|
||||
} else {
|
||||
|
62
src/ellipsoid.cpp
Normal file
62
src/ellipsoid.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include <QFile>
|
||||
#include "ellipsoid.h"
|
||||
|
||||
QMap<int, Ellipsoid> Ellipsoid::_ellipsoids;
|
||||
QString Ellipsoid::_errorString;
|
||||
int Ellipsoid::_errorLine = 0;
|
||||
|
||||
Ellipsoid Ellipsoid::ellipsoid(int id)
|
||||
{
|
||||
QMap<int, Ellipsoid>::const_iterator it = _ellipsoids.find(id);
|
||||
|
||||
if (it == _ellipsoids.end())
|
||||
return Ellipsoid();
|
||||
|
||||
return it.value();
|
||||
}
|
||||
|
||||
bool Ellipsoid::loadList(const QString &path)
|
||||
{
|
||||
QFile file(path);
|
||||
bool res;
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
_errorString = qPrintable(file.errorString());
|
||||
return false;
|
||||
}
|
||||
|
||||
_errorLine = 1;
|
||||
_errorString.clear();
|
||||
|
||||
while (!file.atEnd()) {
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() != 4) {
|
||||
_errorString = "Format error";
|
||||
return false;
|
||||
}
|
||||
|
||||
int id = list[0].trimmed().toInt(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid id";
|
||||
return false;
|
||||
}
|
||||
double radius = list[2].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid radius";
|
||||
return false;
|
||||
}
|
||||
double flattening = list[3].trimmed().toDouble(&res);
|
||||
if (!res) {
|
||||
_errorString = "Invalid ellipsoid flattening";
|
||||
return false;
|
||||
}
|
||||
|
||||
Ellipsoid e(radius, 1.0/flattening);
|
||||
_ellipsoids.insert(id, e);
|
||||
|
||||
_errorLine++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
37
src/ellipsoid.h
Normal file
37
src/ellipsoid.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef ELLIPSOID_H
|
||||
#define ELLIPSOID_H
|
||||
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include "wgs84.h"
|
||||
|
||||
class Ellipsoid
|
||||
{
|
||||
public:
|
||||
Ellipsoid() : _radius(-1.0), _flattening(-1.0) {}
|
||||
Ellipsoid(double radius, double flattening)
|
||||
: _radius(radius), _flattening(flattening) {}
|
||||
|
||||
double radius() const {return _radius;}
|
||||
double flattening() const {return _flattening;}
|
||||
|
||||
bool isNull() const {return _radius < 0 || _flattening < 0;}
|
||||
bool isWGS84() const
|
||||
{return _radius == WGS84_RADIUS && _flattening == WGS84_FLATTENING;}
|
||||
|
||||
static bool loadList(const QString &path);
|
||||
static const QString &errorString() {return _errorString;}
|
||||
static int errorLine() {return _errorLine;}
|
||||
|
||||
static Ellipsoid ellipsoid(int id);
|
||||
|
||||
private:
|
||||
double _radius;
|
||||
double _flattening;
|
||||
|
||||
static QMap<int, Ellipsoid> _ellipsoids;
|
||||
static QString _errorString;
|
||||
static int _errorLine;
|
||||
};
|
||||
|
||||
#endif // ELLIPSOID_H
|
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
|
||||
{
|
||||
const QFile *file = static_cast<QFile *>(_device);
|
||||
fprintf(stderr, "%s:%d: %s\n", qPrintable(file->fileName()),
|
||||
_len, text);
|
||||
qWarning("%s:%d: %s\n", qPrintable(file->fileName()), _len, text);
|
||||
}
|
||||
|
||||
bool FITParser::readData(char *data, size_t size)
|
||||
|
164
src/gui.cpp
164
src/gui.cpp
@ -26,8 +26,12 @@
|
||||
#include "keys.h"
|
||||
#include "settings.h"
|
||||
#include "data.h"
|
||||
#include "ellipsoid.h"
|
||||
#include "datum.h"
|
||||
#include "map.h"
|
||||
#include "maplist.h"
|
||||
#include "mapdir.h"
|
||||
#include "emptymap.h"
|
||||
#include "elevationgraph.h"
|
||||
#include "speedgraph.h"
|
||||
#include "heartrategraph.h"
|
||||
@ -36,7 +40,6 @@
|
||||
#include "powergraph.h"
|
||||
#include "pathview.h"
|
||||
#include "trackinfo.h"
|
||||
#include "downloader.h"
|
||||
#include "filebrowser.h"
|
||||
#include "cpuarch.h"
|
||||
#include "graphtab.h"
|
||||
@ -44,8 +47,9 @@
|
||||
#include "gui.h"
|
||||
|
||||
|
||||
GUI::GUI(QWidget *parent) : QMainWindow(parent)
|
||||
GUI::GUI()
|
||||
{
|
||||
loadDatums();
|
||||
loadMaps();
|
||||
loadPOIs();
|
||||
|
||||
@ -116,14 +120,67 @@ void GUI::createBrowser()
|
||||
_browser->setFilter(filter);
|
||||
}
|
||||
|
||||
void GUI::loadDatums()
|
||||
{
|
||||
QString ef, df;
|
||||
bool ok = false;
|
||||
|
||||
if (QFile::exists(USER_ELLIPSOID_FILE))
|
||||
ef = USER_ELLIPSOID_FILE;
|
||||
else if (QFile::exists(GLOBAL_ELLIPSOID_FILE))
|
||||
ef = GLOBAL_ELLIPSOID_FILE;
|
||||
else
|
||||
qWarning("No ellipsoids file found.");
|
||||
|
||||
if (QFile::exists(USER_DATUM_FILE))
|
||||
df = USER_DATUM_FILE;
|
||||
else if (QFile::exists(GLOBAL_DATUM_FILE))
|
||||
df = GLOBAL_DATUM_FILE;
|
||||
else
|
||||
qWarning("No datums file found.");
|
||||
|
||||
if (!ef.isNull() && !df.isNull()) {
|
||||
if (!Ellipsoid::loadList(ef)) {
|
||||
if (Ellipsoid::errorLine())
|
||||
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
|
||||
Ellipsoid::errorLine(), qPrintable(Ellipsoid::errorString()));
|
||||
else
|
||||
qWarning("%s: %s", qPrintable(ef), qPrintable(
|
||||
Ellipsoid::errorString()));
|
||||
} else {
|
||||
if (!Datum::loadList(df)) {
|
||||
if (Datum::errorLine())
|
||||
qWarning("%s: parse error on line %d: %s", qPrintable(ef),
|
||||
Datum::errorLine(), qPrintable(Datum::errorString()));
|
||||
else
|
||||
qWarning("%s: %s", qPrintable(ef), qPrintable(
|
||||
Datum::errorString()));
|
||||
} else
|
||||
ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
qWarning("Maps based on a datum different from WGS84 won't work.");
|
||||
}
|
||||
|
||||
void GUI::loadMaps()
|
||||
{
|
||||
MapList ml(new Downloader(this));
|
||||
QList<Map*> online, offline;
|
||||
|
||||
if (QFile::exists(USER_MAP_FILE))
|
||||
_maps = ml.load(USER_MAP_FILE, this);
|
||||
online = MapList::load(USER_MAP_FILE, this);
|
||||
else
|
||||
_maps = ml.load(GLOBAL_MAP_FILE, this);
|
||||
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()
|
||||
@ -141,11 +198,11 @@ void GUI::loadPOIs()
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
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(_poi->errorString()));
|
||||
if (_poi->errorLine())
|
||||
fprintf(stderr, "Line: %d\n", _poi->errorLine());
|
||||
qWarning("Line: %d\n", _poi->errorLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,7 +338,8 @@ void GUI::createActions()
|
||||
this);
|
||||
_showMapAction->setCheckable(true);
|
||||
_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);
|
||||
_clearMapCacheAction = new QAction(tr("Clear tile cache"), this);
|
||||
connect(_clearMapCacheAction, SIGNAL(triggered()), this,
|
||||
@ -508,15 +566,13 @@ void GUI::createToolBars()
|
||||
|
||||
void GUI::createPathView()
|
||||
{
|
||||
_pathView = new PathView(this);
|
||||
_pathView = new PathView(_map, _poi, this);
|
||||
_pathView->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Expanding));
|
||||
_pathView->setMinimumHeight(200);
|
||||
#ifdef Q_OS_WIN32
|
||||
_pathView->setFrameShape(QFrame::NoFrame);
|
||||
#endif // Q_OS_WIN32
|
||||
|
||||
_pathView->setPOI(_poi);
|
||||
}
|
||||
|
||||
void GUI::createGraphTabs()
|
||||
@ -585,18 +641,24 @@ void GUI::keys()
|
||||
msgBox.setWindowTitle(tr("Keyboard controls"));
|
||||
msgBox.setText("<h3>" + tr("Keyboard controls") + "</h3>");
|
||||
msgBox.setInformativeText(
|
||||
"<div><table width=\"300\"><tr><td>" + tr("Next file")
|
||||
+ "</td><td><i>" + QKeySequence(NEXT_KEY).toString()
|
||||
"<style>td {padding-right: 1.5em;}</style><div><table><tr><td>"
|
||||
+ tr("Next file") + "</td><td><i>" + QKeySequence(NEXT_KEY).toString()
|
||||
+ "</i></td></tr><tr><td>" + tr("Previous file")
|
||||
+ "</td><td><i>" + QKeySequence(PREV_KEY).toString()
|
||||
+ "</i></td></tr><tr><td>" + tr("First file") + "</td><td><i>"
|
||||
+ QKeySequence(FIRST_KEY).toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Last file") + "</td><td><i>" + QKeySequence(LAST_KEY).toString()
|
||||
+ "</i></td></tr><tr><td>" + tr("Append modifier")
|
||||
+ "</td><td><i>SHIFT</i></td></tr><tr><td></td><td></td></tr><tr><td>"
|
||||
+ tr("Next map") + "</td><td><i>" + NEXT_MAP_SHORTCUT.toString()
|
||||
+ "</i></td></tr><tr><td>" + tr("Previous map") + "</td><td><i>"
|
||||
+ PREV_MAP_SHORTCUT.toString() + "</i></td></tr></table></div>");
|
||||
+ "</i></td></tr><tr><td>" + tr("Append file")
|
||||
+ "</td><td><i>" + QKeySequence(MODIFIER).toString() + tr("Next/Previous")
|
||||
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>" + tr("Next map")
|
||||
+ "</td><td><i>" + NEXT_MAP_SHORTCUT.toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Previous map") + "</td><td><i>" + PREV_MAP_SHORTCUT.toString()
|
||||
+ "</i></td></tr><tr><td></td><td></td></tr><tr><td>" + tr("Zoom in")
|
||||
+ "</td><td><i>" + QKeySequence(ZOOM_IN).toString()
|
||||
+ "</i></td></tr><tr><td>" + tr("Zoom out") + "</td><td><i>"
|
||||
+ QKeySequence(ZOOM_OUT).toString() + "</i></td></tr><tr><td>"
|
||||
+ tr("Digital zoom") + "</td><td><i>" + QKeySequence(MODIFIER).toString()
|
||||
+ tr("Zoom") + "</i></td></tr></table></div>");
|
||||
|
||||
msgBox.exec();
|
||||
}
|
||||
@ -608,17 +670,25 @@ void GUI::dataSources()
|
||||
msgBox.setWindowTitle(tr("Data sources"));
|
||||
msgBox.setText("<h3>" + tr("Data sources") + "</h3>");
|
||||
msgBox.setInformativeText(
|
||||
"<h4>" + tr("Map sources") + "</h4><p>"
|
||||
+ tr("Map (tiles) source URLs are read on program startup from the "
|
||||
"<h4>" + tr("Online maps") + "</h4><p>"
|
||||
+ tr("Online map URLs are read on program startup from the "
|
||||
"following file:")
|
||||
+ "</p><p><code>" + USER_MAP_FILE + "</code></p><p>"
|
||||
+ 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 "
|
||||
"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:")
|
||||
+ "</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
||||
+ "</p><p><code>" + USER_MAP_FILE + "</code></p><p>"
|
||||
+ 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 "
|
||||
"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:")
|
||||
+ "</p><p><code>Map1 http://tile.server.com/map/$z/$x/$y.png"
|
||||
"<br/>Map2 http://mapserver.org/map/$z-$x-$y</code></p>"
|
||||
|
||||
+ "<h4>" + tr("Offline 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 OziExplorer 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 "
|
||||
"the file to the following directory:")
|
||||
@ -697,7 +767,7 @@ bool GUI::loadFile(const QString &fileName)
|
||||
if (data.tracks().count() == 1 && !data.routes().count())
|
||||
_pathName = data.tracks().first()->name();
|
||||
else if (data.routes().count() == 1 && !data.tracks().count())
|
||||
_pathName = data.routes().first()->routeData().name();
|
||||
_pathName = data.routes().first()->name();
|
||||
} else
|
||||
_pathName = QString();
|
||||
|
||||
@ -987,14 +1057,6 @@ void GUI::closeAll()
|
||||
updatePathView();
|
||||
}
|
||||
|
||||
void GUI::showMap(bool show)
|
||||
{
|
||||
if (show)
|
||||
_pathView->setMap(_currentMap);
|
||||
else
|
||||
_pathView->setMap(0);
|
||||
}
|
||||
|
||||
void GUI::showGraphs(bool show)
|
||||
{
|
||||
_graphTabWidget->setHidden(!show);
|
||||
@ -1072,7 +1134,7 @@ void GUI::showGraphGrids(bool show)
|
||||
|
||||
void GUI::clearMapCache()
|
||||
{
|
||||
_currentMap->clearCache();
|
||||
_map->clearCache();
|
||||
_pathView->redraw();
|
||||
}
|
||||
|
||||
@ -1097,7 +1159,8 @@ void GUI::updateStatusBarInfo()
|
||||
_timeLabel->setToolTip(Format::timeSpan(time()));
|
||||
} else {
|
||||
_timeLabel->setText(Format::timeSpan(time()));
|
||||
_timeLabel->setToolTip(Format::timeSpan(movingTime()));
|
||||
_timeLabel->setToolTip(Format::timeSpan(movingTime())
|
||||
+ "<sub>M</sub>");
|
||||
}
|
||||
} else {
|
||||
_timeLabel->clear();
|
||||
@ -1115,17 +1178,16 @@ void GUI::updateWindowTitle()
|
||||
|
||||
void GUI::mapChanged(int index)
|
||||
{
|
||||
_currentMap = _maps.at(index);
|
||||
|
||||
if (_showMapAction->isChecked())
|
||||
_pathView->setMap(_currentMap);
|
||||
_map = _maps.at(index);
|
||||
_pathView->setMap(_map);
|
||||
}
|
||||
|
||||
void GUI::nextMap()
|
||||
{
|
||||
if (_maps.count() < 2)
|
||||
return;
|
||||
int next = (_maps.indexOf(_currentMap) + 1) % _maps.count();
|
||||
|
||||
int next = (_maps.indexOf(_map) + 1) % _maps.count();
|
||||
_mapActions.at(next)->setChecked(true);
|
||||
mapChanged(next);
|
||||
}
|
||||
@ -1134,7 +1196,8 @@ void GUI::prevMap()
|
||||
{
|
||||
if (_maps.count() < 2)
|
||||
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);
|
||||
mapChanged(prev);
|
||||
}
|
||||
@ -1302,6 +1365,7 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
if (_fullscreenAction->isChecked()) {
|
||||
_fullscreenAction->setChecked(false);
|
||||
showFullscreen(false);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1310,7 +1374,10 @@ void GUI::keyPressEvent(QKeyEvent *event)
|
||||
if (!(event->modifiers() & MODIFIER))
|
||||
closeFiles();
|
||||
openFile(file);
|
||||
return;
|
||||
}
|
||||
|
||||
QMainWindow::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void GUI::closeEvent(QCloseEvent *event)
|
||||
@ -1368,8 +1435,7 @@ void GUI::writeSettings()
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(MAP_SETTINGS_GROUP);
|
||||
if (_currentMap)
|
||||
settings.setValue(CURRENT_MAP_SETTING, _currentMap->name());
|
||||
settings.setValue(CURRENT_MAP_SETTING, _map->name());
|
||||
if (_showMapAction->isChecked() != SHOW_MAP_DEFAULT)
|
||||
settings.setValue(SHOW_MAP_SETTING, _showMapAction->isChecked());
|
||||
settings.endGroup();
|
||||
@ -1515,11 +1581,9 @@ void GUI::readSettings()
|
||||
if (_maps.count()) {
|
||||
int index = mapIndex(settings.value(CURRENT_MAP_SETTING).toString());
|
||||
_mapActions.at(index)->setChecked(true);
|
||||
_currentMap = _maps.at(index);
|
||||
if (_showMapAction->isChecked())
|
||||
_pathView->setMap(_currentMap);
|
||||
} else
|
||||
_currentMap = 0;
|
||||
_map = _maps.at(index);
|
||||
_pathView->setMap(_map);
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(GRAPH_SETTINGS_GROUP);
|
||||
|
@ -31,7 +31,7 @@ class GUI : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GUI(QWidget *parent = 0);
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
bool openFile(const QString &fileName);
|
||||
@ -47,7 +47,6 @@ private slots:
|
||||
void reloadFile();
|
||||
void openPOIFile();
|
||||
void closePOIFiles();
|
||||
void showMap(bool show);
|
||||
void showGraphs(bool show);
|
||||
void showGraphGrids(bool show);
|
||||
void showToolbars(bool show);
|
||||
@ -80,6 +79,7 @@ private slots:
|
||||
private:
|
||||
typedef QPair<QDate, QDate> DateRange;
|
||||
|
||||
void loadDatums();
|
||||
void loadMaps();
|
||||
void loadPOIs();
|
||||
void closeFiles();
|
||||
@ -189,8 +189,8 @@ private:
|
||||
|
||||
FileBrowser *_browser;
|
||||
QList<QString> _files;
|
||||
Map *_currentMap;
|
||||
|
||||
Map *_map;
|
||||
int _trackCount;
|
||||
int _routeCount;
|
||||
int _waypointCount;
|
||||
|
@ -10,6 +10,9 @@
|
||||
#define LAST_KEY Qt::Key_End
|
||||
#define MODIFIER Qt::ShiftModifier
|
||||
|
||||
#define ZOOM_IN QKeySequence::ZoomIn
|
||||
#define ZOOM_OUT QKeySequence::ZoomOut
|
||||
|
||||
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
||||
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
||||
#define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close)
|
||||
@ -22,6 +25,7 @@
|
||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
|
||||
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
||||
#else // Q_OS_MAC
|
||||
|
81
src/lambertconic.cpp
Normal file
81
src/lambertconic.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
#include <cmath>
|
||||
#include "rd.h"
|
||||
#include "lambertconic.h"
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923
|
||||
#endif // M_PI_2
|
||||
#ifndef M_PI_4
|
||||
#define M_PI_4 0.78539816339744830962
|
||||
#endif // M_PI_4
|
||||
|
||||
static double q(const Ellipsoid &el, double b)
|
||||
{
|
||||
double e = sqrt(el.flattening() * (2. - el.flattening()));
|
||||
double esb = e * sin(b);
|
||||
return log(tan(M_PI_4 + b / 2.) * pow((1. - esb) / (1. + esb), e / 2.));
|
||||
}
|
||||
|
||||
static double iq(const Ellipsoid &el, double q)
|
||||
{
|
||||
double e = sqrt(el.flattening() * (2. - el.flattening()));
|
||||
double b0 = 0.;
|
||||
double b = 2. * atan(exp(q)) - M_PI_2;
|
||||
|
||||
do {
|
||||
b0 = b;
|
||||
double esb = e * sin(b);
|
||||
b = 2. * atan(exp(q) * pow((1. - esb) / (1. + esb), -e / 2.)) - M_PI_2;
|
||||
} while (fabs(b - b0) > 1e-10);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
static double nradius(const Ellipsoid &el, double phi)
|
||||
{
|
||||
double sin_phi = sin(phi);
|
||||
return (el.radius() / sqrt(1. - (el.flattening() * (2. - el.flattening()))
|
||||
* sin_phi * sin_phi));
|
||||
}
|
||||
|
||||
LambertConic::LambertConic(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double scale, double falseEasting, double falseNorthing) : _e(ellipsoid)
|
||||
{
|
||||
_cm = longitudeOrigin;
|
||||
_fe = falseEasting;
|
||||
_fn = falseNorthing;
|
||||
|
||||
double sp1 = deg2rad(standardParallel1);
|
||||
double sp2 = deg2rad(standardParallel2);
|
||||
|
||||
double N1 = nradius(_e, sp1);
|
||||
double N2 = nradius(_e, sp2);
|
||||
|
||||
_q0 = q(_e, deg2rad(latitudeOrigin));
|
||||
double q1 = q(_e, sp1);
|
||||
double q2 = q(_e, sp2);
|
||||
|
||||
_n = log((N1 * cos(sp1)) / (N2 * cos(sp2))) / (q2 - q1);
|
||||
double R1 = N1 * cos(sp1) / _n;
|
||||
_R0 = scale * R1 * exp(_n * (q1 - _q0));
|
||||
}
|
||||
|
||||
QPointF LambertConic::ll2xy(const Coordinates &c) const
|
||||
{
|
||||
double dl = _n * (deg2rad(c.lon()) - deg2rad(_cm));
|
||||
double R = _R0 * exp(_n * (_q0 - q(_e, deg2rad(c.lat()))));
|
||||
|
||||
return QPointF(_fe + R * sin(dl), _fn + _R0 - R * cos(dl));
|
||||
}
|
||||
|
||||
Coordinates LambertConic::xy2ll(const QPointF &p) const
|
||||
{
|
||||
double dl = atan((p.x() - _fe) / (_fn + _R0 - p.y()));
|
||||
double dx = p.x() - _fe;
|
||||
double dy = p.y() - _fn - _R0;
|
||||
double R = sqrt(dx * dx + dy * dy);
|
||||
double q = _q0 - log(R / _R0) / _n;
|
||||
|
||||
return Coordinates(rad2deg(deg2rad(_cm) + dl / _n), rad2deg(iq(_e, q)));
|
||||
}
|
29
src/lambertconic.h
Normal file
29
src/lambertconic.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef LAMBERTCONIC_H
|
||||
#define LAMBERTCONIC_H
|
||||
|
||||
#include "ellipsoid.h"
|
||||
#include "projection.h"
|
||||
|
||||
class LambertConic : public Projection
|
||||
{
|
||||
public:
|
||||
LambertConic(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||
double scale, double falseEasting, double falseNorthing);
|
||||
|
||||
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||
|
||||
private:
|
||||
Ellipsoid _e;
|
||||
|
||||
double _cm;
|
||||
double _fe;
|
||||
double _fn;
|
||||
|
||||
double _q0;
|
||||
double _R0;
|
||||
double _n;
|
||||
};
|
||||
|
||||
#endif // LAMBERTCONIC_H
|
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
|
136
src/map.cpp
136
src/map.cpp
@ -1,136 +0,0 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include "downloader.h"
|
||||
#include "config.h"
|
||||
#include "map.h"
|
||||
|
||||
|
||||
Map::Map(const QString &name, const QString &url, Downloader *downloader,
|
||||
QObject *parent) : QObject(parent)
|
||||
{
|
||||
_name = name;
|
||||
_url = url;
|
||||
|
||||
_downloader = downloader;
|
||||
|
||||
|
||||
connect(_downloader, 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->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, 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 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));
|
||||
}
|
49
src/map.h
49
src/map.h
@ -1,41 +1,42 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include "tile.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QRectF>
|
||||
|
||||
class Downloader;
|
||||
class QPainter;
|
||||
class Coordinates;
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Map(const QString &name, const QString &url, Downloader *downloader,
|
||||
QObject *parent = 0);
|
||||
Map(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
const QString &name() const {return _name;}
|
||||
void loadTiles(QList<Tile> &list, bool block);
|
||||
void clearCache();
|
||||
virtual const QString &name() const = 0;
|
||||
|
||||
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:
|
||||
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);
|
||||
|
||||
Downloader *_downloader;
|
||||
|
||||
QString _name;
|
||||
QString _url;
|
||||
};
|
||||
|
||||
#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 <QFileInfo>
|
||||
#include "map.h"
|
||||
#include "onlinemap.h"
|
||||
#include "maplist.h"
|
||||
|
||||
|
||||
QList<Map*> MapList::load(const QString &fileName, QObject *parent)
|
||||
{
|
||||
QList<Map*> mapList;
|
||||
QList<Map*> maps;
|
||||
QFileInfo fi(fileName);
|
||||
|
||||
if (!fi.exists())
|
||||
return mapList;
|
||||
return maps;
|
||||
|
||||
QFile file(fileName);
|
||||
|
||||
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()));
|
||||
return mapList;
|
||||
return maps;
|
||||
}
|
||||
|
||||
int ln = 0;
|
||||
@ -26,16 +26,16 @@ QList<Map*> MapList::load(const QString &fileName, QObject *parent)
|
||||
QByteArray line = file.readLine();
|
||||
QList<QByteArray> list = line.split('\t');
|
||||
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;
|
||||
}
|
||||
|
||||
QByteArray ba1 = list[0].trimmed();
|
||||
QByteArray ba2 = list[1].trimmed();
|
||||
|
||||
mapList.append(new Map(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||
QString::fromLatin1(ba2.data(), ba2.size()), _downloader, parent));
|
||||
maps.append(new OnlineMap(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||
QString::fromLatin1(ba2.data(), ba2.size()), parent));
|
||||
}
|
||||
|
||||
return mapList;
|
||||
return maps;
|
||||
}
|
||||
|
@ -3,19 +3,14 @@
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QObject>
|
||||
|
||||
class QObject;
|
||||
class Map;
|
||||
class Downloader;
|
||||
|
||||
class MapList
|
||||
{
|
||||
public:
|
||||
MapList(Downloader *downloader) : _downloader(downloader) {}
|
||||
QList<Map*> load(const QString &fileName, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
Downloader *_downloader;
|
||||
static QList<Map*> load(const QString &fileName, QObject *parent = 0);
|
||||
};
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
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,13 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <QRectF>
|
||||
|
||||
#define ARRAY_SIZE(array) \
|
||||
(sizeof(array) / sizeof((array)[0]))
|
||||
|
||||
double niceNum(double x, int round);
|
||||
int str2int(const char *str, int len);
|
||||
QRectF scaled(const QRectF &rect, qreal factor);
|
||||
|
||||
#endif // MISC_H
|
||||
|
672
src/offlinemap.cpp
Normal file
672
src/offlinemap.cpp
Normal file
@ -0,0 +1,672 @@
|
||||
#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 "datum.h"
|
||||
#include "latlon.h"
|
||||
#include "mercator.h"
|
||||
#include "transversemercator.h"
|
||||
#include "utm.h"
|
||||
#include "lambertconic.h"
|
||||
#include "ozf.h"
|
||||
#include "offlinemap.h"
|
||||
|
||||
|
||||
// Abridged Molodensky transformation
|
||||
static Coordinates toWGS84(Coordinates c, const Datum &datum)
|
||||
{
|
||||
Ellipsoid WGS84(WGS84_RADIUS, WGS84_FLATTENING);
|
||||
|
||||
double dX = datum.dx();
|
||||
double dY = datum.dy();
|
||||
double dZ = datum.dz();
|
||||
|
||||
double slat = sin(deg2rad(c.lat()));
|
||||
double clat = cos(deg2rad(c.lat()));
|
||||
double slon = sin(deg2rad(c.lon()));
|
||||
double clon = cos(deg2rad(c.lon()));
|
||||
double ssqlat = slat * slat;
|
||||
|
||||
double from_f = datum.ellipsoid().flattening();
|
||||
double df = WGS84.flattening() - from_f;
|
||||
double from_a = datum.ellipsoid().radius();
|
||||
double da = WGS84.radius() - from_a;
|
||||
double from_esq = datum.ellipsoid().flattening()
|
||||
* (2.0 - datum.ellipsoid().flattening());
|
||||
double adb = 1.0 / (1.0 - from_f);
|
||||
double rn = from_a / sqrt(1 - from_esq * ssqlat);
|
||||
double rm = from_a * (1 - from_esq) / pow((1 - from_esq * ssqlat), 1.5);
|
||||
double from_h = 0.0; // we're flat!
|
||||
|
||||
double dlat = (-dX * slat * clon - dY * slat * slon + dZ * clat + da * rn
|
||||
* from_esq * slat * clat / from_a + +df * (rm * adb + rn / adb) * slat
|
||||
* clat) / (rm + from_h);
|
||||
double dlon = (-dX * slon + dY * clon) / ((rn + from_h) * clat);
|
||||
|
||||
return Coordinates(c.lon() + rad2deg(dlon), c.lat() + rad2deg(dlat));
|
||||
}
|
||||
|
||||
int OfflineMap::parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||
QString &projection, ProjectionSetup &setup, QString &datum)
|
||||
{
|
||||
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 if (ln == 5)
|
||||
datum = line.split(',').at(0).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.latitudeOrigin = list.at(1).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.latitudeOrigin = 0;
|
||||
setup.longitudeOrigin = list.at(2).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.longitudeOrigin = 0;
|
||||
setup.scale = list.at(3).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.scale = 1.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;
|
||||
setup.standardParallel1 = list.at(6).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.standardParallel1 = 0;
|
||||
setup.standardParallel2 = list.at(7).trimmed().toFloat(&res);
|
||||
if (!res)
|
||||
setup.standardParallel2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ln++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OfflineMap::createProjection(const QString &datum,
|
||||
const QString &projection, const ProjectionSetup &setup,
|
||||
QList<ReferencePoint> &points)
|
||||
{
|
||||
if (points.count() < 2) {
|
||||
qWarning("%s: insufficient number of reference points",
|
||||
qPrintable(_name));
|
||||
return false;
|
||||
}
|
||||
|
||||
Datum d = Datum::datum(datum);
|
||||
if (d.isNull()) {
|
||||
qWarning("%s: %s: unknown datum", qPrintable(_name), qPrintable(datum));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (projection == "Mercator")
|
||||
_projection = new Mercator();
|
||||
else if (projection == "Transverse Mercator")
|
||||
_projection = new TransverseMercator(d.ellipsoid(),
|
||||
setup.longitudeOrigin, setup.scale, setup.falseEasting,
|
||||
setup.falseNorthing);
|
||||
else if (projection == "Latitude/Longitude")
|
||||
_projection = new LatLon();
|
||||
else if (projection == "Lambert Conformal Conic")
|
||||
_projection = new LambertConic(d.ellipsoid(),
|
||||
setup.standardParallel1, setup.standardParallel2,
|
||||
setup.latitudeOrigin, setup.longitudeOrigin, setup.scale,
|
||||
setup.falseEasting, setup.falseNorthing);
|
||||
else if (projection == "(UTM) Universal Transverse Mercator") {
|
||||
if (setup.zone)
|
||||
_projection = new UTM(d.ellipsoid(), setup.zone);
|
||||
else if (!points.first().ll.isNull())
|
||||
_projection = new UTM(d.ellipsoid(), 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()) {
|
||||
if (d.isWGS84())
|
||||
points[i].ll = _projection->xy2ll(points.at(i).pp);
|
||||
else
|
||||
points[i].ll = toWGS84(_projection->xy2ll(points.at(i).pp), d);
|
||||
} else {
|
||||
if (!d.isWGS84())
|
||||
points[i].ll = toWGS84(points[i].ll, d);
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
_inverted = _transform.inverted();
|
||||
|
||||
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())
|
||||
ii.setFile(path + "/" + _imgPath);
|
||||
|
||||
if (!ii.exists()) {
|
||||
int last = _imgPath.lastIndexOf('\\');
|
||||
if (last >= 0 && last < _imgPath.length() - 1) {
|
||||
QStringRef fn(&_imgPath, last + 1, _imgPath.length() - last - 1);
|
||||
ii.setFile(path + "/" + fn.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (ii.exists())
|
||||
_imgPath = ii.absoluteFilePath();
|
||||
else {
|
||||
qWarning("%s: %s: No such image file", qPrintable(_name),
|
||||
qPrintable(_imgPath));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_imgPath.endsWith("ozf3", Qt::CaseInsensitive)
|
||||
|| _imgPath.endsWith("ozf4", Qt::CaseInsensitive)) {
|
||||
qWarning("%s: %s: obfuscated image files are not supported",
|
||||
qPrintable(_name), qPrintable(_imgPath));
|
||||
return false;
|
||||
} else if (_imgPath.endsWith("ozf2", Qt::CaseInsensitive)) {
|
||||
_ozf.load(_imgPath);
|
||||
_size = _ozf.size();
|
||||
} else {
|
||||
QImageReader img(_imgPath);
|
||||
_size = img.size();
|
||||
}
|
||||
if (!_size.isValid()) {
|
||||
qWarning("%s: %s: error reading map image", qPrintable(_name),
|
||||
qPrintable(_imgPath));
|
||||
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, datum;
|
||||
ProjectionSetup setup;
|
||||
|
||||
|
||||
_valid = false;
|
||||
_img = 0;
|
||||
_projection = 0;
|
||||
_resolution = 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, datum);
|
||||
_imgPath = QString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (fileName.endsWith(".map")) {
|
||||
QFile mapFile(mapFiles.at(i).absoluteFilePath());
|
||||
errorLine = parseMapFile(mapFile, points, proj, setup, datum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!mapLoaded(errorLine))
|
||||
return;
|
||||
|
||||
if (!createProjection(datum, 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, datum;
|
||||
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, datum);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!mapLoaded(errorLine))
|
||||
return;
|
||||
|
||||
if (!createProjection(datum, 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() && !_ozf.isOpen()) {
|
||||
_img = new QImage(_imgPath);
|
||||
if (_img->isNull())
|
||||
qWarning("%s: error loading map image", qPrintable(_imgPath));
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::unload()
|
||||
{
|
||||
if (_img) {
|
||||
delete _img;
|
||||
_img = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::drawTiled(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
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();
|
||||
|
||||
if (!QRectF(QPointF(x, y), _ozf.tileSize()).intersects(bounds())) {
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white);
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::drawOZF(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
QPoint tl = QPoint((int)floor(rect.left() / _ozf.tileSize().width())
|
||||
* _ozf.tileSize().width(), (int)floor(rect.top()
|
||||
/ _ozf.tileSize().height()) * _ozf.tileSize().height());
|
||||
|
||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
||||
for (int i = 0; i < ceil(s.width() / _ozf.tileSize().width()); i++) {
|
||||
for (int j = 0; j < ceil(s.height() / _ozf.tileSize().height()); j++) {
|
||||
int x = tl.x() + i * _ozf.tileSize().width();
|
||||
int y = tl.y() + j * _ozf.tileSize().height();
|
||||
|
||||
if (!QRectF(QPointF(x, y), _ozf.tileSize()).intersects(bounds())) {
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white);
|
||||
continue;
|
||||
}
|
||||
|
||||
QPixmap pixmap;
|
||||
QString key = _ozf.fileName() + "/" + QString::number(x)
|
||||
+ "_" + QString::number(y);
|
||||
if (!QPixmapCache::find(key, &pixmap)) {
|
||||
pixmap = _ozf.tile(x, y);
|
||||
if (!pixmap.isNull())
|
||||
QPixmapCache::insert(key, pixmap);
|
||||
}
|
||||
|
||||
if (pixmap.isNull()) {
|
||||
qWarning("%s: error loading tile image", qPrintable(key));
|
||||
painter->fillRect(QRectF(QPoint(x, y), _tileSize), Qt::white);
|
||||
} else
|
||||
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::drawImage(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if (_ozf.isOpen())
|
||||
drawOZF(painter, rect);
|
||||
else if (_tileSize.isValid())
|
||||
drawTiled(painter, rect);
|
||||
else
|
||||
drawImage(painter, rect);
|
||||
}
|
103
src/offlinemap.h
Normal file
103
src/offlinemap.h
Normal file
@ -0,0 +1,103 @@
|
||||
#ifndef OFFLINEMAP_H
|
||||
#define OFFLINEMAP_H
|
||||
|
||||
#include <QTransform>
|
||||
#include "map.h"
|
||||
#include "tar.h"
|
||||
#include "ozf.h"
|
||||
#include "coordinates.h"
|
||||
#include "projection.h"
|
||||
|
||||
|
||||
class QIODevice;
|
||||
class QImage;
|
||||
|
||||
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 {return QRectF(QPointF(0, 0), _size);}
|
||||
qreal resolution(const QPointF &) const {return _resolution;}
|
||||
|
||||
qreal zoom() const {return 1.0;}
|
||||
qreal zoomFit(const QSize &, const QRectF &) {return 1.0;}
|
||||
qreal zoomIn() {return 1.0;}
|
||||
qreal zoomOut() {return 1.0;}
|
||||
|
||||
QPointF ll2xy(const Coordinates &c) const
|
||||
{return _transform.map(_projection->ll2xy(c));}
|
||||
Coordinates xy2ll(const QPointF &p) const
|
||||
{return _projection->xy2ll(_inverted.map(p));}
|
||||
|
||||
void draw(QPainter *painter, const QRectF &rect);
|
||||
|
||||
void load();
|
||||
void unload();
|
||||
|
||||
bool isValid() {return _valid;}
|
||||
|
||||
QPointF ll2pp(const Coordinates &c) const
|
||||
{return _projection->ll2xy(c);}
|
||||
QPointF xy2pp(const QPointF &p) const
|
||||
{return _inverted.map(p);}
|
||||
QPointF pp2xy(const QPointF &p) const
|
||||
{return _transform.map(p);}
|
||||
|
||||
private:
|
||||
typedef struct {
|
||||
QPoint xy;
|
||||
Coordinates ll;
|
||||
QPointF pp;
|
||||
} ReferencePoint;
|
||||
|
||||
typedef struct {
|
||||
double latitudeOrigin;
|
||||
double longitudeOrigin;
|
||||
double scale;
|
||||
double falseEasting;
|
||||
double falseNorthing;
|
||||
double standardParallel1;
|
||||
double standardParallel2;
|
||||
int zone;
|
||||
} ProjectionSetup;
|
||||
|
||||
int parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||
QString &projection, ProjectionSetup &setup, QString &datum);
|
||||
bool mapLoaded(int res);
|
||||
bool totalSizeSet();
|
||||
bool createProjection(const QString &datum, 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);
|
||||
|
||||
void drawTiled(QPainter *painter, const QRectF &rect);
|
||||
void drawOZF(QPainter *painter, const QRectF &rect);
|
||||
void drawImage(QPainter *painter, const QRectF &rect);
|
||||
|
||||
QString _name;
|
||||
QSize _size;
|
||||
Projection *_projection;
|
||||
QTransform _transform, _inverted;
|
||||
qreal _resolution;
|
||||
|
||||
OZF _ozf;
|
||||
Tar _tar;
|
||||
QString _tarPath;
|
||||
QImage *_img;
|
||||
QString _imgPath;
|
||||
QSize _tileSize;
|
||||
QString _tileName;
|
||||
|
||||
bool _valid;
|
||||
};
|
||||
|
||||
#endif // OFFLINEMAP_H
|
245
src/onlinemap.cpp
Normal file
245
src/onlinemap.cpp
Normal file
@ -0,0 +1,245 @@
|
||||
#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;
|
||||
_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
|
142
src/ozf.cpp
Normal file
142
src/ozf.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
#include <QtEndian>
|
||||
#include <QFile>
|
||||
#include "ozf.h"
|
||||
|
||||
|
||||
#define OZF2_MAGIC 0x7778
|
||||
#define OZF2_SEPARATOR 0x77777777
|
||||
|
||||
template<class T> bool OZF::readValue(T &val)
|
||||
{
|
||||
T data;
|
||||
|
||||
if (_file.read((char*)&data, sizeof(T)) < (qint64)sizeof(T))
|
||||
return false;
|
||||
|
||||
if (sizeof(T) > 1)
|
||||
val = qFromLittleEndian(data);
|
||||
else
|
||||
val = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OZF::readHeaders()
|
||||
{
|
||||
quint16 magic;
|
||||
quint32 separator;
|
||||
|
||||
if (!readValue(magic) || magic != OZF2_MAGIC)
|
||||
return false;
|
||||
|
||||
if (!_file.seek(_file.pos() + 52))
|
||||
return false;
|
||||
if (!readValue(separator) || separator != OZF2_SEPARATOR)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OZF::readTileTable()
|
||||
{
|
||||
quint32 offset, bgr0, w, h;
|
||||
quint16 x, y;
|
||||
|
||||
|
||||
if (!_file.seek(_file.size() - 4))
|
||||
return false;
|
||||
// table offset
|
||||
if (!readValue(offset))
|
||||
return false;
|
||||
if (!_file.seek(offset))
|
||||
return false;
|
||||
// tiles offset (zoom level 0)
|
||||
if (!readValue(offset))
|
||||
return false;
|
||||
if (!_file.seek(offset))
|
||||
return false;
|
||||
|
||||
if (!readValue(w))
|
||||
return false;
|
||||
if (!readValue(h))
|
||||
return false;
|
||||
if (!readValue(x))
|
||||
return false;
|
||||
if (!readValue(y))
|
||||
return false;
|
||||
|
||||
_size = QSize(w, h);
|
||||
_dim = QSize(x, y);
|
||||
|
||||
_palette = QVector<quint32>(256);
|
||||
for (int i = 0; i < _palette.size(); i++) {
|
||||
if (!readValue(bgr0))
|
||||
return false;
|
||||
|
||||
quint32 b = (bgr0 & 0x000000FF);
|
||||
quint32 g = (bgr0 & 0x0000FF00) >> 8;
|
||||
quint32 r = (bgr0 & 0x00FF0000) >> 16;
|
||||
|
||||
_palette[i] = 0xFF000000 | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
_tiles = QVector<quint32>(_dim.width() * _dim.height() + 1);
|
||||
for (int i = 0; i < _tiles.size(); i++)
|
||||
if (!readValue(_tiles[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OZF::load(const QString &path)
|
||||
{
|
||||
if (_file.isOpen())
|
||||
_file.close();
|
||||
|
||||
_file.setFileName(path);
|
||||
if (!_file.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
if (!readHeaders()) {
|
||||
qWarning("%s: not a OZF2 file", qPrintable(_file.fileName()));
|
||||
_file.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!readTileTable()) {
|
||||
qWarning("%s: file format error", qPrintable(_file.fileName()));
|
||||
_file.close();
|
||||
_size = QSize();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QPixmap OZF::tile(int x, int y)
|
||||
{
|
||||
Q_ASSERT(_file.isOpen());
|
||||
|
||||
int i = (y/tileSize().height()) * _dim.width() + (x/tileSize().width());
|
||||
if (i >= _tiles.size() - 1 || i < 0)
|
||||
return QPixmap();
|
||||
|
||||
int size = _tiles.at(i+1) - _tiles.at(i);
|
||||
if (!_file.seek(_tiles.at(i)))
|
||||
return QPixmap();
|
||||
|
||||
QByteArray ba = _file.read(size);
|
||||
if (ba.size() != size)
|
||||
return QPixmap();
|
||||
quint32 bes = qToBigEndian(tileSize().width() * tileSize().height());
|
||||
ba.prepend(QByteArray((char*)&bes, sizeof(bes)));
|
||||
QByteArray uba = qUncompress(ba);
|
||||
if (uba.size() != tileSize().width() * tileSize().height())
|
||||
return QPixmap();
|
||||
|
||||
QImage img((const uchar*)uba.constData(), tileSize().width(),
|
||||
tileSize().height(), QImage::Format_Indexed8);
|
||||
img.setColorTable(_palette);
|
||||
|
||||
return QPixmap::fromImage(img.mirrored());
|
||||
}
|
36
src/ozf.h
Normal file
36
src/ozf.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef OZF_H
|
||||
#define OZF_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSize>
|
||||
#include <QColor>
|
||||
#include <QVector>
|
||||
#include <QFile>
|
||||
#include <QPixmap>
|
||||
|
||||
class OZF
|
||||
{
|
||||
public:
|
||||
bool load(const QString &path);
|
||||
|
||||
QString fileName() const {return _file.fileName();}
|
||||
bool isOpen() const {return _file.isOpen();}
|
||||
|
||||
QSize size() const {return _size;}
|
||||
QSize tileSize() const {return QSize(64, 64);}
|
||||
QPixmap tile(int x, int y);
|
||||
|
||||
private:
|
||||
template<class T> bool readValue(T &val);
|
||||
bool readHeaders();
|
||||
bool readTileTable();
|
||||
|
||||
QSize _size;
|
||||
QSize _dim;
|
||||
QVector<QRgb> _palette;
|
||||
QVector<quint32> _tiles;
|
||||
|
||||
QFile _file;
|
||||
};
|
||||
|
||||
#endif // OZF_H
|
24
src/path.cpp
24
src/path.cpp
@ -1,5 +1,29 @@
|
||||
#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)
|
||||
{
|
||||
dbg.nospace() << "PathPoint(" << point.distance() << ", "
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define PATH_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QRectF>
|
||||
#include "coordinates.h"
|
||||
|
||||
class PathPoint
|
||||
@ -23,6 +24,11 @@ private:
|
||||
Q_DECLARE_TYPEINFO(PathPoint, Q_PRIMITIVE_TYPE);
|
||||
QDebug operator<<(QDebug dbg, const PathPoint &point);
|
||||
|
||||
typedef QVector<PathPoint> Path;
|
||||
|
||||
class Path : public QVector<PathPoint>
|
||||
{
|
||||
public:
|
||||
QRectF boundingRect() const;
|
||||
};
|
||||
|
||||
#endif // PATH_H
|
||||
|
@ -3,29 +3,48 @@
|
||||
#include <QCursor>
|
||||
#include <QPainter>
|
||||
#include "tooltip.h"
|
||||
#include "map.h"
|
||||
#include "misc.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()));
|
||||
_marker->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
_md = _path.at(0).distance();
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void PathItem::updateShape()
|
||||
{
|
||||
QPainterPathStroker s;
|
||||
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);
|
||||
_pen = QPen(brush, _width);
|
||||
|
||||
_units = Metric;
|
||||
|
||||
_marker = new MarkerItem(this);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
_painterPath.moveTo(map->ll2xy(_path.first().coordinates()));
|
||||
for (int i = 1; i < _path.size(); i++)
|
||||
_painterPath.lineTo(map->ll2xy(_path.at(i).coordinates()));
|
||||
}
|
||||
|
||||
void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
@ -35,7 +54,7 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
Q_UNUSED(widget);
|
||||
|
||||
painter->setPen(_pen);
|
||||
painter->drawPath(_path);
|
||||
painter->drawPath(_painterPath);
|
||||
|
||||
/*
|
||||
QPen p = QPen(QBrush(Qt::red), 0);
|
||||
@ -44,15 +63,15 @@ void PathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
*/
|
||||
}
|
||||
|
||||
void PathItem::setScale(qreal scale)
|
||||
void PathItem::setMap(Map *map)
|
||||
{
|
||||
_map = map;
|
||||
prepareGeometryChange();
|
||||
|
||||
_pen.setWidthF(_width * 1.0/scale);
|
||||
QGraphicsItem::setScale(scale);
|
||||
_marker->setScale(1.0/scale);
|
||||
|
||||
updatePainterPath(map);
|
||||
updateShape();
|
||||
|
||||
_marker->setPos(position(_md));
|
||||
}
|
||||
|
||||
void PathItem::setColor(const QColor &color)
|
||||
@ -61,7 +80,7 @@ void PathItem::setColor(const QColor &color)
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setWidth(int width)
|
||||
void PathItem::setWidth(qreal width)
|
||||
{
|
||||
prepareGeometryChange();
|
||||
|
||||
@ -77,41 +96,36 @@ void PathItem::setStyle(Qt::PenStyle style)
|
||||
update();
|
||||
}
|
||||
|
||||
void PathItem::setUnits(enum Units units)
|
||||
{
|
||||
_units = units;
|
||||
}
|
||||
|
||||
QPointF PathItem::position(qreal x) const
|
||||
{
|
||||
int low = 0;
|
||||
int high = _distance.count() - 1;
|
||||
int high = _path.count() - 1;
|
||||
int mid = 0;
|
||||
|
||||
|
||||
Q_ASSERT(_distance.count() == _path.elementCount());
|
||||
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) {
|
||||
mid = low + ((high - low) / 2);
|
||||
qreal val = _distance.at(mid);
|
||||
qreal val = _path.at(mid).distance();
|
||||
if (val > x)
|
||||
high = mid - 1;
|
||||
else if (val < x)
|
||||
low = mid + 1;
|
||||
else
|
||||
return _path.elementAt(mid);
|
||||
return _map->ll2xy(_path.at(mid).coordinates());
|
||||
}
|
||||
|
||||
QLineF l;
|
||||
qreal p1, p2;
|
||||
if (_distance.at(mid) < x) {
|
||||
l = QLineF(_path.elementAt(mid), _path.elementAt(mid+1));
|
||||
p1 = _distance.at(mid); p2 = _distance.at(mid+1);
|
||||
if (_path.at(mid).distance() < x) {
|
||||
l = QLineF(_map->ll2xy(_path.at(mid).coordinates()),
|
||||
_map->ll2xy(_path.at(mid+1).coordinates()));
|
||||
p1 = _path.at(mid).distance(); p2 = _path.at(mid+1).distance();
|
||||
} else {
|
||||
l = QLineF(_path.elementAt(mid-1), _path.elementAt(mid));
|
||||
p1 = _distance.at(mid-1); p2 = _distance.at(mid);
|
||||
l = QLineF(_map->ll2xy(_path.at(mid-1).coordinates()),
|
||||
_map->ll2xy(_path.at(mid).coordinates()));
|
||||
p1 = _path.at(mid-1).distance(); p2 = _path.at(mid).distance();
|
||||
}
|
||||
|
||||
return l.pointAt((x - p1) / (p2 - p1));
|
||||
@ -119,9 +133,11 @@ QPointF PathItem::position(qreal x) const
|
||||
|
||||
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->setPos(position(distance));
|
||||
_md = distance;
|
||||
} else
|
||||
_marker->setVisible(false);
|
||||
}
|
||||
|
@ -4,29 +4,33 @@
|
||||
#include <QGraphicsObject>
|
||||
#include <QPen>
|
||||
#include "markeritem.h"
|
||||
#include "units.h"
|
||||
#include "path.h"
|
||||
|
||||
|
||||
class Map;
|
||||
|
||||
class PathItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathItem(QGraphicsItem *parent = 0);
|
||||
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
const QPainterPath &path() const {return _path;}
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
void setScale(qreal scale);
|
||||
void setUnits(enum Units units);
|
||||
const Path &path() const {return _path;}
|
||||
|
||||
void setMap(Map *map);
|
||||
|
||||
void setColor(const QColor &color);
|
||||
void setWidth(int width);
|
||||
void setWidth(qreal width);
|
||||
void setStyle(Qt::PenStyle style);
|
||||
|
||||
void showMarker(bool show) {_marker->setVisible(show);}
|
||||
|
||||
public slots:
|
||||
void moveMarker(qreal distance);
|
||||
|
||||
@ -34,22 +38,24 @@ signals:
|
||||
void selected(bool);
|
||||
|
||||
protected:
|
||||
void updateShape();
|
||||
|
||||
QVector<qreal> _distance;
|
||||
QPainterPath _path;
|
||||
Path _path;
|
||||
MarkerItem *_marker;
|
||||
Units _units;
|
||||
|
||||
private:
|
||||
QPointF position(qreal distance) const;
|
||||
void updatePainterPath(Map *map);
|
||||
void updateShape();
|
||||
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
int _width;
|
||||
Map *_map;
|
||||
qreal _md;
|
||||
|
||||
qreal _width;
|
||||
QPen _pen;
|
||||
QPainterPath _shape;
|
||||
QPainterPath _painterPath;
|
||||
};
|
||||
|
||||
#endif // PATHITEM_H
|
||||
|
404
src/pathview.cpp
404
src/pathview.cpp
@ -1,72 +1,25 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include "opengl.h"
|
||||
#include "rd.h"
|
||||
#include "wgs84.h"
|
||||
#include "misc.h"
|
||||
#include "poi.h"
|
||||
#include "data.h"
|
||||
#include "map.h"
|
||||
#include "emptymap.h"
|
||||
#include "trackitem.h"
|
||||
#include "routeitem.h"
|
||||
#include "waypointitem.h"
|
||||
#include "scaleitem.h"
|
||||
#include "keys.h"
|
||||
#include "pathview.h"
|
||||
|
||||
|
||||
#define ZOOM_MAX 18
|
||||
#define ZOOM_MIN 3
|
||||
#define MAX_ZOOM 1
|
||||
#define MIN_ZOOM -3
|
||||
#define MARGIN 10.0
|
||||
#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)
|
||||
{
|
||||
if (p.x() < rect.left())
|
||||
@ -79,16 +32,12 @@ static void unite(QRectF &rect, const QPointF &p)
|
||||
rect.setTop(p.y());
|
||||
}
|
||||
|
||||
static QRectF scaled(const QRectF &rect, qreal factor)
|
||||
{
|
||||
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
||||
QSizeF(rect.width() * factor, rect.height() * factor));
|
||||
}
|
||||
|
||||
|
||||
PathView::PathView(QWidget *parent)
|
||||
PathView::PathView(Map *map, POI *poi, QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
{
|
||||
Q_ASSERT(map != 0);
|
||||
Q_ASSERT(poi != 0);
|
||||
|
||||
_scene = new QGraphicsScene(this);
|
||||
setScene(_scene);
|
||||
setCacheMode(QGraphicsView::CacheBackground);
|
||||
@ -101,14 +50,16 @@ PathView::PathView(QWidget *parent)
|
||||
|
||||
_mapScale = new ScaleItem();
|
||||
_mapScale->setZValue(2.0);
|
||||
_mapScale->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
|
||||
_zoom = ZOOM_MAX;
|
||||
_res = 1.0;
|
||||
_map = 0;
|
||||
_poi = 0;
|
||||
_map = map;
|
||||
_poi = poi;
|
||||
connect(_map, SIGNAL(loaded()), this, SLOT(redraw()));
|
||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||
|
||||
_units = Metric;
|
||||
|
||||
_showMap = true;
|
||||
_showTracks = true;
|
||||
_showRoutes = true;
|
||||
_showWaypoints = true;
|
||||
@ -123,8 +74,10 @@ PathView::PathView(QWidget *parent)
|
||||
_routeStyle = Qt::DashLine;
|
||||
|
||||
_plot = false;
|
||||
_digitalZoom = 0;
|
||||
|
||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / mapScale(_zoom)));
|
||||
_scene->setSceneRect(_map->bounds());
|
||||
_res = _map->resolution(_scene->sceneRect().center());
|
||||
}
|
||||
|
||||
PathView::~PathView()
|
||||
@ -140,19 +93,16 @@ PathItem *PathView::addTrack(const Track &track)
|
||||
return 0;
|
||||
}
|
||||
|
||||
TrackItem *ti = new TrackItem(track);
|
||||
TrackItem *ti = new TrackItem(track, _map);
|
||||
_tracks.append(ti);
|
||||
_tr |= ti->path().boundingRect();
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
ti->setScale(1.0/mapScale(_zoom));
|
||||
ti->setColor(_palette.nextColor());
|
||||
ti->setWidth(_trackWidth);
|
||||
ti->setWidth(_trackWidth * pow(2, -_digitalZoom));
|
||||
ti->setStyle(_trackStyle);
|
||||
ti->setVisible(_showTracks);
|
||||
_scene->addItem(ti);
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(ti));
|
||||
addPOI(_poi->points(ti->path()));
|
||||
|
||||
return ti;
|
||||
}
|
||||
@ -164,74 +114,64 @@ PathItem *PathView::addRoute(const Route &route)
|
||||
return 0;
|
||||
}
|
||||
|
||||
RouteItem *ri = new RouteItem(route);
|
||||
RouteItem *ri = new RouteItem(route, _map);
|
||||
_routes.append(ri);
|
||||
_rr |= ri->path().boundingRect();
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
ri->setScale(1.0/mapScale(_zoom));
|
||||
ri->setColor(_palette.nextColor());
|
||||
ri->setWidth(_routeWidth);
|
||||
ri->setWidth(_routeWidth * pow(2, -_digitalZoom));
|
||||
ri->setStyle(_routeStyle);
|
||||
ri->setVisible(_showRoutes);
|
||||
ri->showWaypoints(_showRouteWaypoints);
|
||||
ri->showWaypointLabels(_showWaypointLabels);
|
||||
_scene->addItem(ri);
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(ri));
|
||||
addPOI(_poi->points(ri->path()));
|
||||
|
||||
return ri;
|
||||
}
|
||||
|
||||
void PathView::addWaypoints(const QList<Waypoint> &waypoints)
|
||||
{
|
||||
qreal scale = mapScale(_zoom);
|
||||
|
||||
for (int i = 0; i < waypoints.count(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
|
||||
WaypointItem *wi = new WaypointItem(w);
|
||||
WaypointItem *wi = new WaypointItem(w, _map);
|
||||
_waypoints.append(wi);
|
||||
updateWaypointsBoundingRect(wi->coordinates());
|
||||
wi->setScale(1.0/scale);
|
||||
Coordinates c = wi->waypoint().coordinates();
|
||||
updateWaypointsBoundingRect(QPointF(c.lon(), c.lat()));
|
||||
wi->setZValue(1);
|
||||
wi->showLabel(_showWaypointLabels);
|
||||
wi->setVisible(_showWaypoints);
|
||||
wi->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
_scene->addItem(wi);
|
||||
}
|
||||
|
||||
if (_poi)
|
||||
addPOI(_poi->points(waypoints));
|
||||
|
||||
_zoom = scale2zoom(contentsScale());
|
||||
addPOI(_poi->points(waypoints));
|
||||
}
|
||||
|
||||
QList<PathItem *> PathView::loadData(const Data &data)
|
||||
{
|
||||
QList<PathItem *> paths;
|
||||
int zoom = _zoom;
|
||||
|
||||
qreal scale = _map->zoom();
|
||||
|
||||
for (int i = 0; i < data.tracks().count(); i++)
|
||||
paths.append(addTrack(*(data.tracks().at(i))));
|
||||
|
||||
for (int i = 0; i < data.routes().count(); i++)
|
||||
paths.append(addRoute(*(data.routes().at(i))));
|
||||
|
||||
addWaypoints(data.waypoints());
|
||||
|
||||
if (_tracks.empty() && _routes.empty() && _waypoints.empty())
|
||||
return paths;
|
||||
|
||||
if (_zoom < zoom)
|
||||
rescale(_zoom);
|
||||
if (mapScale() != scale)
|
||||
rescale();
|
||||
else
|
||||
updatePOIVisibility();
|
||||
|
||||
QPointF center = contentsCenter();
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
|
||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
if (_mapScale->scene() != _scene)
|
||||
_scene->addItem(_mapScale);
|
||||
@ -252,33 +192,25 @@ void PathView::updateWaypointsBoundingRect(const QPointF &wp)
|
||||
unite(_wr, wp);
|
||||
}
|
||||
|
||||
qreal PathView::contentsScale() const
|
||||
qreal PathView::mapScale() const
|
||||
{
|
||||
QRectF br = _tr | _rr | _wr;
|
||||
if (!br.isNull() && !_wp.isNull())
|
||||
unite(br, _wp);
|
||||
|
||||
if (br.isNull())
|
||||
return mapScale(ZOOM_MAX);
|
||||
|
||||
QPointF sc(br.width() / (viewport()->width() - MARGIN/2),
|
||||
br.height() / (viewport()->height() - MARGIN/2));
|
||||
|
||||
return qMax(sc.x(), sc.y());
|
||||
return _map->zoomFit(viewport()->size() - QSize(MARGIN/2, MARGIN/2), br);
|
||||
}
|
||||
|
||||
QPointF PathView::contentsCenter() const
|
||||
QPointF PathView::contentCenter() const
|
||||
{
|
||||
QRectF br = _tr | _rr | _wr;
|
||||
if (!br.isNull() && !_wp.isNull())
|
||||
unite(br, _wp);
|
||||
|
||||
qreal scale = mapScale(_zoom);
|
||||
|
||||
if (br.isNull())
|
||||
return _wp / scale;
|
||||
return _map->ll2xy(_wp);
|
||||
else
|
||||
return scaled(br, 1.0/scale).center();
|
||||
return _map->ll2xy(br.center());
|
||||
}
|
||||
|
||||
void PathView::updatePOIVisibility()
|
||||
@ -302,25 +234,21 @@ void PathView::updatePOIVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
void PathView::rescale(int zoom)
|
||||
void PathView::rescale()
|
||||
{
|
||||
_zoom = zoom;
|
||||
qreal scale = mapScale(zoom);
|
||||
|
||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / scale));
|
||||
_scene->setSceneRect(_map->bounds());
|
||||
resetCachedContent();
|
||||
|
||||
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++)
|
||||
_routes.at(i)->setScale(1.0/scale);
|
||||
|
||||
_routes.at(i)->setMap(_map);
|
||||
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;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setScale(1.0/scale);
|
||||
it.value()->setMap(_map);
|
||||
|
||||
updatePOIVisibility();
|
||||
}
|
||||
@ -336,16 +264,48 @@ void PathView::setPalette(const Palette &palette)
|
||||
_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()));
|
||||
|
||||
resetDigitalZoom();
|
||||
|
||||
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);
|
||||
|
||||
QHash<Waypoint, WaypointItem*>::const_iterator it;
|
||||
for (it = _pois.constBegin(); it != _pois.constEnd(); it++)
|
||||
it.value()->setMap(_map);
|
||||
updatePOIVisibility();
|
||||
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (_poi)
|
||||
connect(_poi, SIGNAL(pointsChanged()), this, SLOT(updatePOI()));
|
||||
|
||||
updatePOI();
|
||||
}
|
||||
|
||||
@ -359,13 +319,10 @@ void PathView::updatePOI()
|
||||
}
|
||||
_pois.clear();
|
||||
|
||||
if (!_poi)
|
||||
return;
|
||||
|
||||
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++)
|
||||
addPOI(_poi->points(_routes.at(i)));
|
||||
addPOI(_poi->points(_routes.at(i)->path()));
|
||||
addPOI(_poi->points(_waypoints));
|
||||
|
||||
updatePOIVisibility();
|
||||
@ -373,38 +330,23 @@ void PathView::updatePOI()
|
||||
|
||||
void PathView::addPOI(const QVector<Waypoint> &waypoints)
|
||||
{
|
||||
qreal scale = mapScale(_zoom);
|
||||
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
const Waypoint &w = waypoints.at(i);
|
||||
|
||||
if (_pois.contains(w))
|
||||
continue;
|
||||
|
||||
WaypointItem *pi = new WaypointItem(w);
|
||||
pi->setScale(1.0/scale);
|
||||
WaypointItem *pi = new WaypointItem(w, _map);
|
||||
pi->setZValue(1);
|
||||
pi->showLabel(_showPOILabels);
|
||||
pi->setVisible(_showPOI);
|
||||
pi->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
||||
_scene->addItem(pi);
|
||||
|
||||
_pois.insert(w, pi);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
_units = units;
|
||||
@ -428,34 +370,71 @@ void PathView::redraw()
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::zoom(int z, const QPoint &pos)
|
||||
void PathView::resetDigitalZoom()
|
||||
{
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
_digitalZoom = 0;
|
||||
|
||||
QPoint offset = pos - viewport()->rect().center();
|
||||
QPointF spos = mapToScene(pos);
|
||||
resetTransform();
|
||||
|
||||
qreal os = mapScale(_zoom);
|
||||
_zoom = z;
|
||||
setTrackWidth(_trackWidth);
|
||||
setRouteWidth(_routeWidth);
|
||||
}
|
||||
|
||||
rescale(_zoom);
|
||||
void PathView::digitalZoom(int zoom)
|
||||
{
|
||||
_digitalZoom += zoom;
|
||||
scale(pow(2, zoom), pow(2, zoom));
|
||||
|
||||
QPointF center = (spos * (os/mapScale(_zoom))) - offset;
|
||||
centerOn(center);
|
||||
setTrackWidth(_trackWidth);
|
||||
setRouteWidth(_routeWidth);
|
||||
|
||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||
_mapScale->setResolution(_res);
|
||||
_mapScale->setResolution(_res * pow(2, -_digitalZoom));
|
||||
}
|
||||
|
||||
resetCachedContent();
|
||||
void PathView::zoom(int zoom, const QPoint &pos, const Coordinates &c)
|
||||
{
|
||||
bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier;
|
||||
|
||||
if (_digitalZoom) {
|
||||
if (((_digitalZoom > 0 && zoom > 0) && (!shift || _digitalZoom
|
||||
>= MAX_ZOOM)) || ((_digitalZoom < 0 && zoom < 0) && (!shift
|
||||
|| _digitalZoom <= MIN_ZOOM)))
|
||||
return;
|
||||
|
||||
digitalZoom(zoom);
|
||||
} else {
|
||||
qreal os, ns;
|
||||
os = _map->zoom();
|
||||
ns = (zoom > 0) ? _map->zoomIn() : _map->zoomOut();
|
||||
|
||||
if (ns != os) {
|
||||
QPoint offset = pos - viewport()->rect().center();
|
||||
|
||||
rescale();
|
||||
|
||||
QPointF center = _map->ll2xy(c) - offset;
|
||||
centerOn(center);
|
||||
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
} else {
|
||||
if (shift)
|
||||
digitalZoom(zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PathView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
int z = (event->delta() > 0) ?
|
||||
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;
|
||||
|
||||
Coordinates c = _map->xy2ll(mapToScene(event->pos()));
|
||||
zoom((event->delta() > 0) ? 1 : -1, event->pos(), c);
|
||||
}
|
||||
|
||||
void PathView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
@ -463,25 +442,30 @@ void PathView::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
if (event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
|
||||
return;
|
||||
|
||||
int z = (event->button() == Qt::LeftButton) ?
|
||||
qMin(_zoom + 1, ZOOM_MAX) : qMax(_zoom - 1, ZOOM_MIN);
|
||||
|
||||
zoom(z, event->pos());
|
||||
Coordinates c = _map->xy2ll(mapToScene(event->pos()));
|
||||
zoom((event->button() == Qt::LeftButton) ? 1 : -1, event->pos(), c);
|
||||
}
|
||||
|
||||
void PathView::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
int z = -1;
|
||||
int z;
|
||||
|
||||
if (event->matches(QKeySequence::ZoomIn))
|
||||
z = qMin(_zoom + 1, ZOOM_MAX);
|
||||
if (event->matches(QKeySequence::ZoomOut))
|
||||
z = qMax(_zoom - 1, ZOOM_MIN);
|
||||
QPoint pos = QRect(QPoint(), viewport()->size()).center();
|
||||
Coordinates c = _map->xy2ll(mapToScene(pos));
|
||||
|
||||
if (z >= 0)
|
||||
zoom(z, QRect(QPoint(), size()).center());
|
||||
else
|
||||
QWidget::keyPressEvent(event);
|
||||
if (event->matches(ZOOM_IN))
|
||||
z = 1;
|
||||
else if (event->matches(ZOOM_OUT))
|
||||
z = -1;
|
||||
else if (_digitalZoom && event->key() == Qt::Key_Escape) {
|
||||
resetDigitalZoom();
|
||||
return;
|
||||
} else {
|
||||
QGraphicsView::keyPressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
zoom(z, pos, c);
|
||||
}
|
||||
|
||||
void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
@ -493,7 +477,7 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
orig = viewport()->rect();
|
||||
|
||||
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();
|
||||
adj = orig.adjusted(0, -diff/2, 0, diff/2);
|
||||
} else {
|
||||
@ -504,6 +488,7 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
|
||||
setUpdatesEnabled(false);
|
||||
_plot = true;
|
||||
_map->setBlockingMode(true);
|
||||
|
||||
QPointF pos = _mapScale->pos();
|
||||
_mapScale->setPos(mapToScene(QPoint(adj.bottomRight() + QPoint(
|
||||
@ -514,6 +499,7 @@ void PathView::plot(QPainter *painter, const QRectF &target)
|
||||
|
||||
_mapScale->setPos(pos);
|
||||
|
||||
_map->setBlockingMode(false);
|
||||
_plot = false;
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
@ -530,12 +516,13 @@ void PathView::clear()
|
||||
_scene->clear();
|
||||
_palette.reset();
|
||||
|
||||
_zoom = ZOOM_MAX;
|
||||
_res = 1.0;
|
||||
_tr = QRectF(); _rr = QRectF(); _wr = QRectF();
|
||||
_wp = QPointF();
|
||||
|
||||
_scene->setSceneRect(scaled(mapBounds(), 1.0 / mapScale(_zoom)));
|
||||
_digitalZoom = 0;
|
||||
resetTransform();
|
||||
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::showTracks(bool show)
|
||||
@ -581,6 +568,12 @@ void PathView::showRouteWaypoints(bool show)
|
||||
_routes.at(i)->showWaypoints(show);
|
||||
}
|
||||
|
||||
void PathView::showMap(bool show)
|
||||
{
|
||||
_showMap = show;
|
||||
resetCachedContent();
|
||||
}
|
||||
|
||||
void PathView::showPOI(bool show)
|
||||
{
|
||||
_showPOI = show;
|
||||
@ -615,7 +608,7 @@ void PathView::setTrackWidth(int width)
|
||||
_trackWidth = width;
|
||||
|
||||
for (int i = 0; i < _tracks.count(); i++)
|
||||
_tracks.at(i)->setWidth(width);
|
||||
_tracks.at(i)->setWidth(width * pow(2, -_digitalZoom));
|
||||
}
|
||||
|
||||
void PathView::setRouteWidth(int width)
|
||||
@ -623,7 +616,7 @@ void PathView::setRouteWidth(int width)
|
||||
_routeWidth = width;
|
||||
|
||||
for (int i = 0; i < _routes.count(); i++)
|
||||
_routes.at(i)->setWidth(width);
|
||||
_routes.at(i)->setWidth(width * pow(2, -_digitalZoom));
|
||||
}
|
||||
|
||||
void PathView::setTrackStyle(Qt::PenStyle style)
|
||||
@ -644,54 +637,25 @@ void PathView::setRouteStyle(Qt::PenStyle style)
|
||||
|
||||
void PathView::drawBackground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
if ((_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
|| !_map) {
|
||||
if (_showMap)
|
||||
_map->draw(painter, rect);
|
||||
else
|
||||
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)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
qreal scale = _map->zoom();
|
||||
if (mapScale() != scale)
|
||||
rescale();
|
||||
|
||||
if (_tracks.isEmpty() && _routes.isEmpty() && _waypoints.isEmpty())
|
||||
return;
|
||||
|
||||
int zoom = scale2zoom(contentsScale());
|
||||
if (zoom != _zoom)
|
||||
rescale(zoom);
|
||||
|
||||
QPointF center = contentsCenter();
|
||||
QPointF center = contentCenter();
|
||||
centerOn(center);
|
||||
|
||||
_res = zoom2resolution(_zoom, -(center.y() * mapScale(_zoom)));
|
||||
_res = _map->resolution(center);
|
||||
_mapScale->setResolution(_res);
|
||||
|
||||
resetCachedContent();
|
||||
QGraphicsView::resizeEvent(event);
|
||||
}
|
||||
|
||||
void PathView::paintEvent(QPaintEvent *event)
|
||||
@ -710,7 +674,7 @@ void PathView::scrollContentsBy(int dx, int dy)
|
||||
QGraphicsView::scrollContentsBy(dx, dy);
|
||||
|
||||
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) {
|
||||
_mapScale->setResolution(res);
|
||||
|
@ -25,7 +25,7 @@ class PathView : public QGraphicsView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PathView(QWidget *parent = 0);
|
||||
PathView(Map *map, POI *poi, QWidget *parent = 0);
|
||||
~PathView();
|
||||
|
||||
QList<PathItem*> loadData(const Data &data);
|
||||
@ -48,6 +48,7 @@ public:
|
||||
public slots:
|
||||
void redraw();
|
||||
|
||||
void showMap(bool show);
|
||||
void showPOI(bool show);
|
||||
void setPOIOverlap(bool overlap);
|
||||
void showWaypointLabels(bool show);
|
||||
@ -72,10 +73,12 @@ private:
|
||||
void loadPOI();
|
||||
void clearPOI();
|
||||
|
||||
qreal contentsScale() const;
|
||||
QPointF contentsCenter() const;
|
||||
void rescale(int zoom);
|
||||
void zoom(int z, const QPoint &pos);
|
||||
qreal mapScale() const;
|
||||
QPointF contentCenter() const;
|
||||
void rescale();
|
||||
void zoom(int zoom, const QPoint &pos, const Coordinates &c);
|
||||
void digitalZoom(int zoom);
|
||||
void resetDigitalZoom();
|
||||
void updatePOIVisibility();
|
||||
void updateWaypointsBoundingRect(const QPointF &wp);
|
||||
|
||||
@ -94,7 +97,6 @@ private:
|
||||
QList<WaypointItem*> _waypoints;
|
||||
QHash<Waypoint, WaypointItem*> _pois;
|
||||
|
||||
int _zoom;
|
||||
QRectF _tr, _rr, _wr;
|
||||
QPointF _wp;
|
||||
qreal _res;
|
||||
@ -104,6 +106,7 @@ private:
|
||||
Palette _palette;
|
||||
Units _units;
|
||||
|
||||
bool _showMap;
|
||||
bool _showTracks;
|
||||
bool _showRoutes;
|
||||
bool _showWaypoints;
|
||||
@ -117,6 +120,7 @@ private:
|
||||
Qt::PenStyle _trackStyle;
|
||||
Qt::PenStyle _routeStyle;
|
||||
|
||||
int _digitalZoom;
|
||||
bool _plot;
|
||||
};
|
||||
|
||||
|
11
src/poi.cpp
11
src/poi.cpp
@ -58,18 +58,15 @@ static bool cb(size_t data, void* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<Waypoint> POI::points(const PathItem *path) const
|
||||
QVector<Waypoint> POI::points(const Path &path) const
|
||||
{
|
||||
QVector<Waypoint> ret;
|
||||
QSet<int> set;
|
||||
qreal min[2], max[2];
|
||||
const QPainterPath &pp = path->path();
|
||||
|
||||
for (int i = 0; i < pp.elementCount(); i++) {
|
||||
const QPainterPath::Element &pe = pp.elementAt(i);
|
||||
Coordinates p = Coordinates::fromMercator(QPointF(pe.x, -pe.y));
|
||||
|
||||
QPair<Coordinates, Coordinates> br = p.boundingRect(_radius);
|
||||
for (int i = 0; i < path.count(); i++) {
|
||||
const Coordinates &c = path.at(i).coordinates();
|
||||
QPair<Coordinates, Coordinates> br = c.boundingRect(_radius);
|
||||
min[0] = br.first.lon();
|
||||
min[1] = br.first.lat();
|
||||
max[0] = br.second.lon();
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include <QStringList>
|
||||
#include "waypoint.h"
|
||||
#include "rtree.h"
|
||||
#include "path.h"
|
||||
|
||||
class PathItem;
|
||||
class WaypointItem;
|
||||
|
||||
class POI : public QObject
|
||||
@ -25,7 +25,7 @@ public:
|
||||
unsigned radius() const {return _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<Waypoint> &list) 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 graph;
|
||||
|
@ -11,13 +11,17 @@ class Route
|
||||
public:
|
||||
Route(const RouteData &data);
|
||||
|
||||
const RouteData &routeData() const {return _data;}
|
||||
const QVector<qreal> &distanceData() const {return _distance;}
|
||||
Path path() const;
|
||||
|
||||
const QVector<Waypoint> &waypoints() const {return _data;}
|
||||
|
||||
Graph elevation() 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);}
|
||||
|
||||
private:
|
||||
|
@ -3,10 +3,11 @@
|
||||
#include "waypoint.h"
|
||||
#include "waypointitem.h"
|
||||
#include "tooltip.h"
|
||||
#include "map.h"
|
||||
#include "routeitem.h"
|
||||
|
||||
|
||||
QString RouteItem::toolTip()
|
||||
QString RouteItem::toolTip(Units units)
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
@ -14,58 +15,41 @@ QString RouteItem::toolTip()
|
||||
tt.insert(tr("Name"), _name);
|
||||
if (!_desc.isEmpty())
|
||||
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();
|
||||
}
|
||||
|
||||
RouteItem::RouteItem(const Route &route, QGraphicsItem *parent)
|
||||
: PathItem(parent)
|
||||
RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
|
||||
: PathItem(route.path(), map, parent)
|
||||
{
|
||||
const RouteData &r = route.routeData();
|
||||
const QVector<qreal> &d = route.distanceData();
|
||||
QPointF p;
|
||||
const QVector<Waypoint> &waypoints = route.waypoints();
|
||||
|
||||
for (int i = 0; i < waypoints.size(); i++)
|
||||
new WaypointItem(waypoints.at(i), map, this);
|
||||
|
||||
Q_ASSERT(r.count() >= 2);
|
||||
Q_ASSERT(r.size() == d.size());
|
||||
_name = route.name();
|
||||
_desc = route.description();
|
||||
|
||||
_name = r.name();
|
||||
_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());
|
||||
setToolTip(toolTip(Metric));
|
||||
}
|
||||
|
||||
void RouteItem::setScale(qreal scale)
|
||||
void RouteItem::setMap(Map *map)
|
||||
{
|
||||
QList<QGraphicsItem *> childs = childItems();
|
||||
for (int i = 0; i < childs.count(); i++)
|
||||
childs.at(i)->setScale(1.0/scale);
|
||||
for (int i = 0; i < childs.count(); i++) {
|
||||
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)
|
||||
{
|
||||
PathItem::setUnits(units);
|
||||
setToolTip(toolTip());
|
||||
setToolTip(toolTip(units));
|
||||
}
|
||||
|
||||
void RouteItem::showWaypoints(bool show)
|
||||
|
@ -3,23 +3,26 @@
|
||||
|
||||
#include "pathitem.h"
|
||||
#include "route.h"
|
||||
#include "units.h"
|
||||
|
||||
class Map;
|
||||
|
||||
class RouteItem : public PathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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 showWaypointLabels(bool show);
|
||||
|
||||
private:
|
||||
QString toolTip();
|
||||
QString toolTip(Units units);
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
|
@ -6,6 +6,7 @@
|
||||
SpeedGraph::SpeedGraph(QWidget *parent) : GraphTab(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_timeType = Total;
|
||||
_showTracks = true;
|
||||
|
||||
setYUnits();
|
||||
|
89
src/tar.cpp
Normal file
89
src/tar.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
#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;
|
||||
|
||||
if (_file.isOpen())
|
||||
_file.close();
|
||||
_index.clear();
|
||||
|
||||
_file.setFileName(path);
|
||||
if (!_file.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
while ((ret = _file.read(buffer, BLOCKSIZE)) > 0) {
|
||||
if (ret < BLOCKSIZE) {
|
||||
_file.close();
|
||||
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)) {
|
||||
_file.close();
|
||||
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();
|
||||
|
||||
Q_ASSERT(_file.isOpen());
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,6 @@ public:
|
||||
const QPoint& xy() const {return _xy;}
|
||||
QPixmap& pixmap() {return _pixmap;}
|
||||
|
||||
static int size() {return 256;}
|
||||
|
||||
private:
|
||||
int _zoom;
|
||||
QPoint _xy;
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
Track(const TrackData &data);
|
||||
|
||||
Path path() const;
|
||||
|
||||
Graph elevation() const;
|
||||
Graph speed() const;
|
||||
Graph heartRate() const;
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include <QPainter>
|
||||
#include "format.h"
|
||||
#include "tooltip.h"
|
||||
#include "map.h"
|
||||
#include "trackitem.h"
|
||||
|
||||
|
||||
QString TrackItem::toolTip()
|
||||
QString TrackItem::toolTip(Units units)
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
@ -12,7 +13,7 @@ QString TrackItem::toolTip()
|
||||
tt.insert(tr("Name"), _name);
|
||||
if (!_desc.isEmpty())
|
||||
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)
|
||||
tt.insert(tr("Total time"), Format::timeSpan(_time));
|
||||
if (_movingTime > 0)
|
||||
@ -23,39 +24,19 @@ QString TrackItem::toolTip()
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
TrackItem::TrackItem(const Track &track, QGraphicsItem *parent)
|
||||
: PathItem(parent)
|
||||
TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *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();
|
||||
_desc = track.description();
|
||||
_date = track.date();
|
||||
_time = track.time();
|
||||
_movingTime = track.movingTime();
|
||||
|
||||
_marker->setPos(_path.elementAt(0));
|
||||
|
||||
setToolTip(toolTip());
|
||||
setToolTip(toolTip(Metric));
|
||||
}
|
||||
|
||||
void TrackItem::setUnits(enum Units units)
|
||||
void TrackItem::setUnits(Units units)
|
||||
{
|
||||
PathItem::setUnits(units);
|
||||
setToolTip(toolTip());
|
||||
setToolTip(toolTip(units));
|
||||
}
|
||||
|
@ -5,19 +5,21 @@
|
||||
#include <QPen>
|
||||
#include "track.h"
|
||||
#include "pathitem.h"
|
||||
#include "units.h"
|
||||
|
||||
class Map;
|
||||
|
||||
class TrackItem : public PathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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:
|
||||
QString toolTip();
|
||||
QString toolTip(Units units);
|
||||
|
||||
QString _name;
|
||||
QString _desc;
|
||||
|
93
src/transversemercator.cpp
Normal file
93
src/transversemercator.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
#include <cmath>
|
||||
#include "rd.h"
|
||||
#include "ellipsoid.h"
|
||||
#include "transversemercator.h"
|
||||
|
||||
|
||||
TransverseMercator::TransverseMercator(const Ellipsoid &ellipsoid,
|
||||
double centralMeridian, double scale, double falseEasting,
|
||||
double falseNorthing)
|
||||
{
|
||||
_centralMeridian = centralMeridian;
|
||||
_scale = scale;
|
||||
_falseEasting = falseEasting;
|
||||
_falseNorthing = falseNorthing;
|
||||
|
||||
|
||||
const double e2 = ellipsoid.flattening() * (2 - ellipsoid.flattening());
|
||||
const double n = ellipsoid.flattening() / (2 - ellipsoid.flattening());
|
||||
_rectifyingRadius = ellipsoid.radius() / (1 + n)
|
||||
* (1 + 0.25*pow(n, 2) + 0.015625*pow(n, 4));
|
||||
|
||||
_A = e2;
|
||||
_B = (5 * pow(e2, 2) - pow(e2, 3)) / 6.0;
|
||||
_C = (104 * pow(e2, 3) - 45 * pow(e2, 4)) / 120.0;
|
||||
_D = (1237 * pow(e2, 4)) / 1260.0;
|
||||
|
||||
_beta1 = 1/2.0 * n - 2/3.0 * pow(n, 2) + 5/16.0 * pow(n, 3) + 41/180.0
|
||||
* pow(n, 4);
|
||||
_beta2 = 13/48.0 * pow(n, 2) - 3/5.0 * pow(n, 3) + 557/1440.0 * pow(n, 4);
|
||||
_beta3 = 61/240.0 * pow(n, 3) - 103/140.0 * pow(n, 4);
|
||||
_beta4 = 49561/161280.0 * pow(n, 4);
|
||||
|
||||
_delta1 = 1/2.0 * n - 2/3.0 * pow(n, 2) + 37/96.0 * pow(n, 3) - 1/360.0
|
||||
* pow(n, 4);
|
||||
_delta2 = 1/48.0 * pow(n, 2) + 1/15.0 * pow(n, 3) - 437/1440.0 * pow(n, 4);
|
||||
_delta3 = 17/480.0 * pow(n, 3) - 37/840.0 * pow(n, 4);
|
||||
_delta4 = 4397/161280.0 * pow(n, 4);
|
||||
|
||||
_AStar = e2 + pow(e2, 2) + pow(e2, 3) + pow(e2, 4);
|
||||
_BStar = (7 * pow(e2, 2) + 17 * pow(e2, 3) + 30 * pow(e2, 4)) / -6;
|
||||
_CStar = (224 * pow(e2, 3) + 889 * pow(e2, 4)) / 120;
|
||||
_DStar = (4279 * pow(e2, 4)) / -1260;
|
||||
}
|
||||
|
||||
QPointF TransverseMercator::ll2xy(const Coordinates &c) const
|
||||
{
|
||||
QPointF p;
|
||||
|
||||
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));
|
||||
|
||||
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
|
||||
{
|
||||
double xi = (p.y() - _falseNorthing) / (_scale * _rectifyingRadius);
|
||||
double eta = (p.x() - _falseEasting) / (_scale * _rectifyingRadius);
|
||||
|
||||
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 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));
|
||||
}
|
30
src/transversemercator.h
Normal file
30
src/transversemercator.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef TRANSVERSEMERCATOR_H
|
||||
#define TRANSVERSEMERCATOR_H
|
||||
|
||||
#include "projection.h"
|
||||
|
||||
class Ellipsoid;
|
||||
|
||||
class TransverseMercator : public Projection
|
||||
{
|
||||
public:
|
||||
TransverseMercator(const Ellipsoid &ellipsoid, 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;
|
||||
|
||||
double _rectifyingRadius;
|
||||
double _A, _B, _C, _D;
|
||||
double _beta1, _beta2, _beta3, _beta4;
|
||||
double _delta1, _delta2, _delta3, _delta4;
|
||||
double _AStar, _BStar, _CStar, _DStar;
|
||||
};
|
||||
|
||||
#endif // TRANSVERSEMERCATOR_H
|
31
src/utm.cpp
Normal file
31
src/utm.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
#include "ellipsoid.h"
|
||||
#include "utm.h"
|
||||
|
||||
UTM::UTM(const Ellipsoid &ellipsoid, int zone)
|
||||
: _tm(ellipsoid, (qAbs(zone) - 1)*6 - 180 + 3, 0.9996, 500000,
|
||||
zone < 0 ? 10000000 : 0)
|
||||
{
|
||||
}
|
||||
|
||||
UTM::UTM(const Ellipsoid &ellipsoid, const Coordinates &c)
|
||||
: _tm(ellipsoid, 0, 0, 0, 0)
|
||||
{
|
||||
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(ellipsoid, cm, 0.9996, 500000,
|
||||
(c.lat() < 0) ? 10000000 : 0);
|
||||
}
|
22
src/utm.h
Normal file
22
src/utm.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef UTM_H
|
||||
#define UTM_H
|
||||
|
||||
#include "projection.h"
|
||||
#include "transversemercator.h"
|
||||
|
||||
class UTM : public Projection
|
||||
{
|
||||
public:
|
||||
UTM(const Ellipsoid &ellipsoid, int zone);
|
||||
UTM(const Ellipsoid &ellipsoid, 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 "format.h"
|
||||
#include "tooltip.h"
|
||||
#include "map.h"
|
||||
#include "waypointitem.h"
|
||||
|
||||
|
||||
#define POINT_SIZE 8
|
||||
#define HOVER_SIZE 10
|
||||
|
||||
QString WaypointItem::toolTip()
|
||||
QString WaypointItem::toolTip(Units units)
|
||||
{
|
||||
ToolTip tt;
|
||||
|
||||
if (!_waypoint.name().isEmpty() && !_showLabel)
|
||||
if (!_waypoint.name().isEmpty())
|
||||
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
|
||||
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
|
||||
Format::coordinates(_waypoint.coordinates()));
|
||||
if (!std::isnan(_waypoint.elevation()))
|
||||
tt.insert(qApp->translate("WaypointItem", "Elevation"),
|
||||
Format::elevation(_waypoint.elevation(), _units));
|
||||
Format::elevation(_waypoint.elevation(), units));
|
||||
if (!_waypoint.timestamp().isNull())
|
||||
tt.insert(qApp->translate("WaypointItem", "Date"),
|
||||
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
|
||||
@ -30,25 +31,26 @@ QString WaypointItem::toolTip()
|
||||
return tt.toString();
|
||||
}
|
||||
|
||||
WaypointItem::WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
|
||||
QGraphicsItem *parent) : QGraphicsItem(parent)
|
||||
{
|
||||
_units = Metric;
|
||||
_waypoint = waypoint;
|
||||
_showLabel = true;
|
||||
_hover = false;
|
||||
|
||||
_waypoint = waypoint;
|
||||
QPointF p = waypoint.coordinates().toMercator();
|
||||
_coordinates = QPointF(p.x(), -p.y());
|
||||
|
||||
updateShape();
|
||||
|
||||
setPos(_coordinates);
|
||||
setToolTip(toolTip());
|
||||
setPos(map->ll2xy(waypoint.coordinates()));
|
||||
setToolTip(toolTip(Metric));
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void WaypointItem::setMap(Map *map)
|
||||
{
|
||||
setPos(map->ll2xy(_waypoint.coordinates()));
|
||||
}
|
||||
|
||||
void WaypointItem::updateShape()
|
||||
{
|
||||
QPainterPath p;
|
||||
@ -104,15 +106,17 @@ void WaypointItem::paint(QPainter *painter,
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
_units = units;
|
||||
setToolTip(toolTip());
|
||||
setToolTip(toolTip(units));
|
||||
}
|
||||
|
||||
void WaypointItem::showLabel(bool show)
|
||||
@ -120,7 +124,6 @@ void WaypointItem::showLabel(bool show)
|
||||
prepareGeometryChange();
|
||||
_showLabel = show;
|
||||
updateShape();
|
||||
setToolTip(toolTip());
|
||||
}
|
||||
|
||||
void WaypointItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
@ -5,16 +5,17 @@
|
||||
#include "waypoint.h"
|
||||
#include "units.h"
|
||||
|
||||
class Map;
|
||||
|
||||
class WaypointItem : public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
WaypointItem(const Waypoint &waypoint, QGraphicsItem *parent = 0);
|
||||
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
|
||||
|
||||
const Waypoint &waypoint() const {return _waypoint;}
|
||||
const QPointF &coordinates() const {return _coordinates;}
|
||||
|
||||
void setUnits(enum Units units);
|
||||
void setScale(qreal scale);
|
||||
void setMap(Map *map);
|
||||
void setUnits(Units units);
|
||||
void showLabel(bool show);
|
||||
|
||||
QPainterPath shape() const {return _shape;}
|
||||
@ -27,12 +28,10 @@ private:
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||
|
||||
void updateShape();
|
||||
QString toolTip();
|
||||
QString toolTip(Units units);
|
||||
|
||||
QPainterPath _shape;
|
||||
QPointF _coordinates;
|
||||
Waypoint _waypoint;
|
||||
Units _units;
|
||||
|
||||
bool _hover;
|
||||
bool _showLabel;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef 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
|
||||
|
Reference in New Issue
Block a user