mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-01 21:39:15 +02:00
Compare commits
268 Commits
Author | SHA1 | Date | |
---|---|---|---|
e76439bb6e | |||
b54aeff369 | |||
72968efeef | |||
ec3f529b0f | |||
57a171ee8c | |||
d3193abd0b | |||
6809853a8a | |||
3155e8436b | |||
69f9d05ccb | |||
e24a3cd99a | |||
a94fa9f0ea | |||
c4f2a44410 | |||
da4a51e7fa | |||
bb47a34823 | |||
11196c0e35 | |||
00ef815738 | |||
64f685cf60 | |||
7ab13ec8e5 | |||
d3fbbecb2d | |||
7bc83603ca | |||
2cd35b139e | |||
a74afa54fd | |||
753c4e8db0 | |||
d0b3f48caf | |||
e47cd1be7e | |||
d1ba35f012 | |||
b9489afbfe | |||
a7506cfd82 | |||
c060abe6a7 | |||
b457fc430c | |||
89947851fd | |||
7d40dfddb2 | |||
151ae03b53 | |||
9fd8b84c3b | |||
47683e5447 | |||
84bcf07bd4 | |||
cc694971be | |||
ba856d7eb6 | |||
b14eeb58ab | |||
8e932b966c | |||
35818ce16e | |||
6ef7537dff | |||
abbb823890 | |||
0a4f8a46d4 | |||
fd2823c703 | |||
d16b61051f | |||
e69f17aad5 | |||
33b1e179d3 | |||
5efb9f8a4e | |||
ebf39f11bd | |||
8b7422b70a | |||
ef3da2e156 | |||
6e13c2b704 | |||
f3e4719439 | |||
7b6789e78d | |||
95442461fc | |||
729cbd641c | |||
2e2dad8d04 | |||
4e3b6c2eb2 | |||
6430933a96 | |||
3e14d4afda | |||
ebb30a3fca | |||
bd20d40ba7 | |||
77823fba14 | |||
dcc5cbe9bc | |||
cd3c99b065 | |||
83189a4e65 | |||
797fd7f02b | |||
a45125be9a | |||
a7154988ab | |||
afe9a14d5b | |||
b3f1596918 | |||
cd90407f56 | |||
73f06e61f0 | |||
c708fa35fd | |||
dcedfe1e9f | |||
daa9d296bd | |||
b8a9a4481c | |||
e792bf3b23 | |||
359a9f0a5a | |||
4b0b6513d1 | |||
c7762e26fb | |||
5b8d41afb7 | |||
81e1664a9b | |||
fad3f116f5 | |||
a6e522d758 | |||
ab65deadb6 | |||
7f80e8f7b7 | |||
9a5c5eaf61 | |||
9bc5016141 | |||
a4a46232e4 | |||
d85fbe5b48 | |||
141e0cb404 | |||
2b7d0cd631 | |||
d106f47771 | |||
e48729fc84 | |||
dca53bc622 | |||
65045dfee4 | |||
002b9c35e1 | |||
945528d6b1 | |||
4697ba4ef0 | |||
9bf1447a7e | |||
1a8114af8e | |||
ad154dfd7d | |||
c2004ded31 | |||
3ced367fab | |||
506d1998f8 | |||
afc5e9ca4b | |||
425d0e3013 | |||
3a8b1107fe | |||
ad7a413d50 | |||
8d5f72de64 | |||
9e798e626c | |||
cb70f0dded | |||
400003f684 | |||
69db510b10 | |||
cd9ea0f8a9 | |||
0f6c8eb896 | |||
6b3c0d05ca | |||
b0cc028c4c | |||
1513130435 | |||
ec798451e8 | |||
ffc61552d2 | |||
aff7b1c13f | |||
d54f22d3f0 | |||
dba6291f3e | |||
e96cee2ea8 | |||
1eaaea98a3 | |||
a90073c422 | |||
223a13583c | |||
4386e1f2e1 | |||
5bfe9c2527 | |||
efa2b1c366 | |||
e0ad64a902 | |||
f0a1acb96a | |||
5f3bdb87f8 | |||
90d062e097 | |||
58b4c87d46 | |||
02654ec862 | |||
ff015c8714 | |||
c339116cd1 | |||
d8d70bfd8b | |||
7d8149ace3 | |||
4460b454c4 | |||
211310f377 | |||
1e4bcd0ac1 | |||
1a66ed0a36 | |||
273a127069 | |||
1c0a0fd0b3 | |||
713e331b2a | |||
96f406aad7 | |||
0aedec66c4 | |||
b500031713 | |||
699e4f32d5 | |||
992c8aaaf9 | |||
68a72c5809 | |||
eace308774 | |||
e4e3f7d143 | |||
acc49d015e | |||
b48652cb78 | |||
0808f6679e | |||
610ac3d73f | |||
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 | |||
1ec732c78d | |||
ff733b2705 | |||
99e32b1a15 | |||
f4a992a66f | |||
f52fa9a9ef | |||
61f3a1c932 | |||
93313da01d | |||
a253ac1796 | |||
e6a0eeefcc | |||
214d7c40dc | |||
cd89706d74 | |||
961eac9324 | |||
ddacac8d2e | |||
bd9b5dbc6a | |||
8b813b5879 | |||
b79de29464 | |||
ae2765528d | |||
0356917790 | |||
7352b24473 | |||
3a9ec6247c | |||
e74ac78138 | |||
5fa91be4ac | |||
536b4fd121 | |||
0556ae0f58 | |||
211a4e4cef |
52
.appveyor.yml
Normal file
52
.appveyor.yml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
version: 4.16.{build}
|
||||||
|
configuration: Release
|
||||||
|
platform: Any CPU
|
||||||
|
environment:
|
||||||
|
NSISDIR: C:\Program Files (x86)\NSIS
|
||||||
|
matrix:
|
||||||
|
- QTDIR: C:\Qt\5.9\msvc2015
|
||||||
|
PLATFORM: x86
|
||||||
|
NSI: gpxsee.nsi
|
||||||
|
OPENSSLDIR: C:\OpenSSL-Win32\bin
|
||||||
|
- QTDIR: C:\Qt\5.9\msvc2015_64
|
||||||
|
PLATFORM: x86_amd64
|
||||||
|
NSI: gpxsee64.nsi
|
||||||
|
OPENSSLDIR: C:\OpenSSL-Win64\bin
|
||||||
|
install:
|
||||||
|
- cmd: >-
|
||||||
|
set PATH=%QTDIR%\bin;%NSISDIR%;%PATH%
|
||||||
|
|
||||||
|
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %PLATFORM%
|
||||||
|
build_script:
|
||||||
|
- cmd: >-
|
||||||
|
lrelease gpxsee.pro
|
||||||
|
|
||||||
|
qmake gpxsee.pro
|
||||||
|
|
||||||
|
nmake release
|
||||||
|
|
||||||
|
|
||||||
|
md installer
|
||||||
|
|
||||||
|
copy release\GPXSee.exe installer
|
||||||
|
|
||||||
|
windeployqt --no-svg --release installer\GPXSee.exe
|
||||||
|
|
||||||
|
copy pkg\%NSI% installer
|
||||||
|
|
||||||
|
copy pkg\datums.csv installer
|
||||||
|
|
||||||
|
copy pkg\ellipsoids.csv installer
|
||||||
|
|
||||||
|
copy pkg\maps.txt installer
|
||||||
|
|
||||||
|
copy licence.txt installer
|
||||||
|
|
||||||
|
copy %OPENSSLDIR%\libeay32.dll installer
|
||||||
|
|
||||||
|
copy %OPENSSLDIR%\ssleay32.dll installer
|
||||||
|
|
||||||
|
|
||||||
|
makensis.exe installer\%NSI%
|
||||||
|
artifacts:
|
||||||
|
- path: installer\GPXSee-*.exe
|
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
language: c++
|
||||||
|
|
||||||
|
install:
|
||||||
|
- sudo apt-get install libqt4-dev
|
||||||
|
|
||||||
|
script:
|
||||||
|
- lrelease gpxsee.pro
|
||||||
|
- qmake gpxsee.pro
|
||||||
|
- make
|
@ -15,7 +15,7 @@
|
|||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>@EXECUTABLE@</string>
|
<string>@EXECUTABLE@</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>cz.wz.tumic.GPXSee</string>
|
<string>org.gpxsee.GPXSee</string>
|
||||||
|
|
||||||
<key>CFBundleDocumentTypes</key>
|
<key>CFBundleDocumentTypes</key>
|
||||||
<array>
|
<array>
|
||||||
|
23
README.md
23
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.
|
KML, FIT, IGC and NMEA files.
|
||||||
|
|
||||||
## Features
|
## 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.
|
* Elevation, speed, heart rate, cadence, power and temperature graphs.
|
||||||
* Support for multiple tracks in one view.
|
* Support for multiple tracks in one view.
|
||||||
* Support for POI files.
|
* Support for POI files.
|
||||||
@ -12,25 +13,21 @@ KML, FIT, IGC and NMEA files.
|
|||||||
* Native GUI for Windows, Mac OS X and Linux.
|
* Native GUI for Windows, Mac OS X and Linux.
|
||||||
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
* Opens GPX, TCX, FIT, KML, IGC, NMEA and Garmin CSV files.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Build
|
## Build
|
||||||
### Linux/OS X
|
|
||||||
```shell
|
```shell
|
||||||
lrelease gpxsee.pro
|
lrelease gpxsee.pro
|
||||||
qmake gpxsee.pro
|
qmake gpxsee.pro
|
||||||
make
|
make
|
||||||
```
|
```
|
||||||
### Windows
|
|
||||||
```shell
|
|
||||||
lrelease gpxsee.pro
|
|
||||||
qmake gpxsee.pro
|
|
||||||
nmake release
|
|
||||||
```
|
|
||||||
|
|
||||||
## Binaries
|
## Download
|
||||||
* Windows & OS X builds: http://sourceforge.net/projects/gpxsee
|
* [Windows & OS X builds](http://sourceforge.net/projects/gpxsee)
|
||||||
* Linux packages: https://build.opensuse.org/project/repositories/home:tumic:GPXSee
|
* [Linux packages](http://software.opensuse.org/download.html?project=home%3Atumic%3AGPXSee&package=gpxsee)
|
||||||
|
|
||||||
|
## Changelog
|
||||||
|
[Changelog](https://build.opensuse.org/package/view_file/home:tumic:GPXSee/gpxsee/gpxsee.changes)
|
||||||
|
|
||||||
## Homepage
|
## Homepage
|
||||||
GPXSee homepage: http://tumic.wz.cz/gpxsee
|
http://www.gpxsee.org
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
|
|
||||||
set PATH=C:\qt\qtbase\bin;%PATH%
|
|
||||||
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
|
|
||||||
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
|
|
||||||
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib;%LIB%
|
|
||||||
set CL=/D_USING_V110_SDK71_
|
|
@ -1,6 +0,0 @@
|
|||||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
|
|
||||||
set PATH=C:\qt64\qtbase\bin;%PATH%
|
|
||||||
set PATH=C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin;%PATH%
|
|
||||||
set INCLUDE=C:\Program Files\Microsoft SDKs\Windows\v7.1\Include;%INCLUDE%
|
|
||||||
set LIB=C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;%LIB%
|
|
||||||
set CL=/D_USING_V110_SDK71_
|
|
BIN
cert/mac/gpxsee.cer
Normal file
BIN
cert/mac/gpxsee.cer
Normal file
Binary file not shown.
BIN
cert/win/gpxsee.cer
Normal file
BIN
cert/win/gpxsee.cer
Normal file
Binary file not shown.
69
gpxsee.pro
69
gpxsee.pro
@ -1,5 +1,5 @@
|
|||||||
TARGET = GPXSee
|
TARGET = GPXSee
|
||||||
VERSION = 3.7
|
VERSION = 4.16
|
||||||
QT += core \
|
QT += core \
|
||||||
gui \
|
gui \
|
||||||
network
|
network
|
||||||
@ -22,7 +22,7 @@ HEADERS += src/config.h \
|
|||||||
src/sliderinfoitem.h \
|
src/sliderinfoitem.h \
|
||||||
src/filebrowser.h \
|
src/filebrowser.h \
|
||||||
src/map.h \
|
src/map.h \
|
||||||
src/maplist.h \
|
src/onlinemap.h \
|
||||||
src/downloader.h \
|
src/downloader.h \
|
||||||
src/units.h \
|
src/units.h \
|
||||||
src/scaleitem.h \
|
src/scaleitem.h \
|
||||||
@ -76,7 +76,34 @@ HEADERS += src/config.h \
|
|||||||
src/optionsdialog.h \
|
src/optionsdialog.h \
|
||||||
src/colorbox.h \
|
src/colorbox.h \
|
||||||
src/stylecombobox.h \
|
src/stylecombobox.h \
|
||||||
src/opengl.h
|
src/opengl.h \
|
||||||
|
src/timetype.h \
|
||||||
|
src/emptymap.h \
|
||||||
|
src/offlinemap.h \
|
||||||
|
src/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 \
|
||||||
|
src/maplist.h \
|
||||||
|
src/albersequal.h \
|
||||||
|
src/oddspinbox.h \
|
||||||
|
src/rectc.h \
|
||||||
|
src/searchpointer.h \
|
||||||
|
src/percentslider.h \
|
||||||
|
src/elevationgraphitem.h \
|
||||||
|
src/speedgraphitem.h \
|
||||||
|
src/heartrategraphitem.h \
|
||||||
|
src/temperaturegraphitem.h \
|
||||||
|
src/cadencegraphitem.h \
|
||||||
|
src/powergraphitem.h
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/gui.cpp \
|
src/gui.cpp \
|
||||||
src/poi.cpp \
|
src/poi.cpp \
|
||||||
@ -88,8 +115,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/speedgraph.cpp \
|
src/speedgraph.cpp \
|
||||||
src/sliderinfoitem.cpp \
|
src/sliderinfoitem.cpp \
|
||||||
src/filebrowser.cpp \
|
src/filebrowser.cpp \
|
||||||
src/map.cpp \
|
src/onlinemap.cpp \
|
||||||
src/maplist.cpp \
|
|
||||||
src/downloader.cpp \
|
src/downloader.cpp \
|
||||||
src/scaleitem.cpp \
|
src/scaleitem.cpp \
|
||||||
src/track.cpp \
|
src/track.cpp \
|
||||||
@ -130,9 +156,34 @@ SOURCES += src/main.cpp \
|
|||||||
src/nmeaparser.cpp \
|
src/nmeaparser.cpp \
|
||||||
src/optionsdialog.cpp \
|
src/optionsdialog.cpp \
|
||||||
src/colorbox.cpp \
|
src/colorbox.cpp \
|
||||||
src/stylecombobox.cpp
|
src/stylecombobox.cpp \
|
||||||
|
src/emptymap.cpp \
|
||||||
|
src/offlinemap.cpp \
|
||||||
|
src/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 \
|
||||||
|
src/maplist.cpp \
|
||||||
|
src/albersequal.cpp \
|
||||||
|
src/oddspinbox.cpp \
|
||||||
|
src/rectc.cpp \
|
||||||
|
src/percentslider.cpp \
|
||||||
|
src/elevationgraphitem.cpp \
|
||||||
|
src/speedgraphitem.cpp \
|
||||||
|
src/heartrategraphitem.cpp \
|
||||||
|
src/temperaturegraphitem.cpp \
|
||||||
|
src/cadencegraphitem.cpp \
|
||||||
|
src/powergraphitem.cpp
|
||||||
RESOURCES += gpxsee.qrc
|
RESOURCES += gpxsee.qrc
|
||||||
TRANSLATIONS = lang/gpxsee_cs.ts
|
TRANSLATIONS = lang/gpxsee_cs.ts \
|
||||||
|
lang/gpxsee_sv.ts \
|
||||||
|
lang/gpxsee_de.ts
|
||||||
macx {
|
macx {
|
||||||
ICON = icons/gpxsee.icns
|
ICON = icons/gpxsee.icns
|
||||||
QMAKE_INFO_PLIST = Info.plist
|
QMAKE_INFO_PLIST = Info.plist
|
||||||
@ -142,7 +193,9 @@ macx {
|
|||||||
icons/fit.icns \
|
icons/fit.icns \
|
||||||
icons/igc.icns \
|
icons/igc.icns \
|
||||||
icons/nmea.icns \
|
icons/nmea.icns \
|
||||||
pkg/maps.txt
|
pkg/maps.txt \
|
||||||
|
pkg/ellipsoids.csv \
|
||||||
|
pkg/datums.csv
|
||||||
APP_RESOURCES.path = Contents/Resources
|
APP_RESOURCES.path = Contents/Resources
|
||||||
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
QMAKE_BUNDLE_DATA += APP_RESOURCES
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,14 @@
|
|||||||
<file>icons/arrow-left-double.png</file>
|
<file>icons/arrow-left-double.png</file>
|
||||||
<file>icons/arrow-right-double.png</file>
|
<file>icons/arrow-right-double.png</file>
|
||||||
<file>icons/view-fullscreen.png</file>
|
<file>icons/view-fullscreen.png</file>
|
||||||
<file>icons/office-chart-line-stacked.png</file>
|
<file>icons/office-chart-line.png</file>
|
||||||
<file>icons/preferences-desktop-display.png</file>
|
<file>icons/preferences-desktop-display.png</file>
|
||||||
<file>icons/flag_48.png</file>
|
<file>icons/flag_48.png</file>
|
||||||
<file>icons/system-run.png</file>
|
<file>icons/system-run.png</file>
|
||||||
<file>icons/document-print-preview.png</file>
|
<file>icons/document-print-preview.png</file>
|
||||||
|
<file>icons/view-filter.png</file>
|
||||||
<file>lang/gpxsee_cs.qm</file>
|
<file>lang/gpxsee_cs.qm</file>
|
||||||
|
<file>lang/gpxsee_sv.qm</file>
|
||||||
|
<file>lang/gpxsee_de.qm</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 727 B |
BIN
icons/office-chart-line.png
Normal file
BIN
icons/office-chart-line.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 728 B |
BIN
icons/view-filter.png
Normal file
BIN
icons/view-filter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
File diff suppressed because it is too large
Load Diff
1475
lang/gpxsee_de.ts
Normal file
1475
lang/gpxsee_de.ts
Normal file
File diff suppressed because it is too large
Load Diff
1475
lang/gpxsee_sv.ts
Normal file
1475
lang/gpxsee_sv.ts
Normal file
File diff suppressed because it is too large
Load Diff
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
|
|
@ -1,13 +1,16 @@
|
|||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "x64.nsh"
|
!include "x64.nsh"
|
||||||
|
!include "WinVer.nsh"
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "3.7"
|
!define VERSION "4.16"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}.exe"
|
OutFile "GPXSee-${VERSION}.exe"
|
||||||
|
; Compression method
|
||||||
|
SetCompressor /SOLID lzma
|
||||||
|
|
||||||
; Required execution level
|
; Required execution level
|
||||||
RequestExecutionLevel admin
|
RequestExecutionLevel admin
|
||||||
@ -15,6 +18,14 @@ RequestExecutionLevel admin
|
|||||||
; The default installation directory
|
; The default installation directory
|
||||||
InstallDir "$PROGRAMFILES\GPXSee"
|
InstallDir "$PROGRAMFILES\GPXSee"
|
||||||
|
|
||||||
|
; Installer executable info
|
||||||
|
VIProductVersion "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductVersion" ${VERSION}
|
||||||
|
VIAddVersionKey "FileVersion" "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductName" "GPXSee"
|
||||||
|
VIAddVersionKey "LegalCopyright" "GPXSee project"
|
||||||
|
VIAddVersionKey "FileDescription" "GPXSee installer"
|
||||||
|
|
||||||
; Registry key to check for directory (so if you install again, it will
|
; Registry key to check for directory (so if you install again, it will
|
||||||
; overwrite the old one automatically)
|
; overwrite the old one automatically)
|
||||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||||
@ -55,9 +66,15 @@ Var StartMenuFolder
|
|||||||
; Languages
|
; Languages
|
||||||
!insertmacro MUI_LANGUAGE "English"
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
|
Function .onInit
|
||||||
|
${IfNot} ${AtLeastWin7}
|
||||||
|
MessageBox MB_OK "GPXSee can only be installed on Windows 7 or later."
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
; The stuff to install
|
; The stuff to install
|
||||||
Section "GPXSee (required)" SEC_APP
|
Section "GPXSee" SEC_APP
|
||||||
|
|
||||||
SectionIn RO
|
SectionIn RO
|
||||||
|
|
||||||
@ -67,6 +84,8 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
; Put the files there
|
; Put the files there
|
||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
File "maps.txt"
|
File "maps.txt"
|
||||||
|
File "ellipsoids.csv"
|
||||||
|
File "datums.csv"
|
||||||
|
|
||||||
; Create start menu entry and add links
|
; Create start menu entry and add links
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
@ -122,16 +141,15 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "QT libs" SEC_QT
|
Section "QT framework" SEC_QT
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
File "Qt5Core.dll"
|
File "Qt5Core.dll"
|
||||||
File "Qt5Gui.dll"
|
File "Qt5Gui.dll"
|
||||||
File "Qt5Widgets.dll"
|
File "Qt5Widgets.dll"
|
||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "libGLESv2.dll"
|
|
||||||
File "libEGL.dll"
|
|
||||||
File "D3DCompiler_47.dll"
|
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -140,6 +158,8 @@ SectionEnd
|
|||||||
|
|
||||||
Section "MSVC runtime" SEC_MSVC
|
Section "MSVC runtime" SEC_MSVC
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
||||||
${If} ${RunningX64}
|
${If} ${RunningX64}
|
||||||
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
|
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x86" "Installed"
|
||||||
@ -153,12 +173,28 @@ Section "MSVC runtime" SEC_MSVC
|
|||||||
|
|
||||||
DetailPrint "Installing Visual C++ 2015 Redistributable..."
|
DetailPrint "Installing Visual C++ 2015 Redistributable..."
|
||||||
SetOutPath $TEMP
|
SetOutPath $TEMP
|
||||||
File "VC_redist.x86.exe"
|
File "vcredist_x86.exe"
|
||||||
ExecWait '"$TEMP/VC_redist.x86.exe" /install /quiet /norestart'
|
ExecWait '"$TEMP\vcredist_x86.exe" /install /quiet /norestart'
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
Section "OpenSSL" SEC_OPENSSL
|
||||||
|
|
||||||
|
File "libeay32.dll"
|
||||||
|
File "ssleay32.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "ANGLE" SEC_ANGLE
|
||||||
|
|
||||||
|
File "libGLESv2.dll"
|
||||||
|
File "libEGL.dll"
|
||||||
|
File "D3DCompiler_47.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
; Uninstaller
|
; Uninstaller
|
||||||
@ -201,15 +237,21 @@ SectionEnd
|
|||||||
|
|
||||||
;Language strings
|
;Language strings
|
||||||
LangString DESC_QT ${LANG_ENGLISH} \
|
LangString DESC_QT ${LANG_ENGLISH} \
|
||||||
"QT Library. Unselct only if you have QT already installed!"
|
"QT cross-platform application framework."
|
||||||
LangString DESC_MSVC ${LANG_ENGLISH} \
|
LangString DESC_MSVC ${LANG_ENGLISH} \
|
||||||
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
|
"Visual C++ 2015 runtime components. If already installed, will be skipped."
|
||||||
|
LangString DESC_OPENSSL ${LANG_ENGLISH} \
|
||||||
|
"OpenSSL library. Required for HTTPS to work."
|
||||||
|
LangString DESC_ANGLE ${LANG_ENGLISH} \
|
||||||
|
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
|
||||||
LangString DESC_APP ${LANG_ENGLISH} \
|
LangString DESC_APP ${LANG_ENGLISH} \
|
||||||
"GPXSee application"
|
"GPXSee application"
|
||||||
|
|
||||||
;Assign language strings to sections
|
;Assign language strings to sections
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_OPENSSL} $(DESC_OPENSSL)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
@ -1,13 +1,16 @@
|
|||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "x64.nsh"
|
!include "x64.nsh"
|
||||||
|
!include "WinVer.nsh"
|
||||||
|
|
||||||
; The name of the installer
|
; The name of the installer
|
||||||
Name "GPXSee"
|
Name "GPXSee"
|
||||||
; Program version
|
; Program version
|
||||||
!define VERSION "3.7"
|
!define VERSION "4.16"
|
||||||
|
|
||||||
; The file to write
|
; The file to write
|
||||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||||
|
; Compression method
|
||||||
|
SetCompressor /SOLID lzma
|
||||||
|
|
||||||
; Required execution level
|
; Required execution level
|
||||||
RequestExecutionLevel admin
|
RequestExecutionLevel admin
|
||||||
@ -15,6 +18,14 @@ RequestExecutionLevel admin
|
|||||||
; The default installation directory
|
; The default installation directory
|
||||||
InstallDir "$PROGRAMFILES64\GPXSee"
|
InstallDir "$PROGRAMFILES64\GPXSee"
|
||||||
|
|
||||||
|
; Installer executable info
|
||||||
|
VIProductVersion "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductVersion" ${VERSION}
|
||||||
|
VIAddVersionKey "FileVersion" "${VERSION}.0.0"
|
||||||
|
VIAddVersionKey "ProductName" "GPXSee"
|
||||||
|
VIAddVersionKey "LegalCopyright" "GPXSee project"
|
||||||
|
VIAddVersionKey "FileDescription" "GPXSee installer (x64)"
|
||||||
|
|
||||||
; Registry key to check for directory (so if you install again, it will
|
; Registry key to check for directory (so if you install again, it will
|
||||||
; overwrite the old one automatically)
|
; overwrite the old one automatically)
|
||||||
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
InstallDirRegKey HKLM "Software\GPXSee" "Install_Dir"
|
||||||
@ -55,7 +66,12 @@ Var StartMenuFolder
|
|||||||
; Languages
|
; Languages
|
||||||
!insertmacro MUI_LANGUAGE "English"
|
!insertmacro MUI_LANGUAGE "English"
|
||||||
|
|
||||||
Function .onInit
|
Function .onInit
|
||||||
|
${IfNot} ${AtLeastWin7}
|
||||||
|
MessageBox MB_OK "GPXSee can only be installed on Windows 7 or later."
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
${If} ${RunningX64}
|
${If} ${RunningX64}
|
||||||
SetRegView 64
|
SetRegView 64
|
||||||
${Else}
|
${Else}
|
||||||
@ -65,7 +81,7 @@ Function .onInit
|
|||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
; The stuff to install
|
; The stuff to install
|
||||||
Section "GPXSee (required)" SEC_APP
|
Section "GPXSee" SEC_APP
|
||||||
|
|
||||||
SectionIn RO
|
SectionIn RO
|
||||||
|
|
||||||
@ -75,6 +91,8 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
; Put the files there
|
; Put the files there
|
||||||
File "gpxsee.exe"
|
File "gpxsee.exe"
|
||||||
File "maps.txt"
|
File "maps.txt"
|
||||||
|
File "ellipsoids.csv"
|
||||||
|
File "datums.csv"
|
||||||
|
|
||||||
; Create start menu entry and add links
|
; Create start menu entry and add links
|
||||||
SetShellVarContext all
|
SetShellVarContext all
|
||||||
@ -92,7 +110,7 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
WriteRegStr HKLM SOFTWARE\GPXSee "Install_Dir" "$INSTDIR"
|
||||||
|
|
||||||
; Write the uninstall keys for Windows
|
; Write the uninstall keys for Windows
|
||||||
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee"
|
WriteRegStr HKLM "${REGENTRY}" "DisplayName" "GPXSee (x64)"
|
||||||
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
WriteRegStr HKLM "${REGENTRY}" "Publisher" "Martin Tuma"
|
||||||
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
WriteRegStr HKLM "${REGENTRY}" "DisplayVersion" "${VERSION}"
|
||||||
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
WriteRegStr HKLM "${REGENTRY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||||
@ -130,16 +148,15 @@ Section "GPXSee (required)" SEC_APP
|
|||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "QT libs" SEC_QT
|
Section "QT framework" SEC_QT
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
File "Qt5Core.dll"
|
File "Qt5Core.dll"
|
||||||
File "Qt5Gui.dll"
|
File "Qt5Gui.dll"
|
||||||
File "Qt5Widgets.dll"
|
File "Qt5Widgets.dll"
|
||||||
File "Qt5PrintSupport.dll"
|
File "Qt5PrintSupport.dll"
|
||||||
File "Qt5Network.dll"
|
File "Qt5Network.dll"
|
||||||
File "libGLESv2.dll"
|
|
||||||
File "libEGL.dll"
|
|
||||||
File "D3DCompiler_47.dll"
|
|
||||||
File /r "platforms"
|
File /r "platforms"
|
||||||
File /r "imageformats"
|
File /r "imageformats"
|
||||||
File /r "printsupport"
|
File /r "printsupport"
|
||||||
@ -148,6 +165,8 @@ SectionEnd
|
|||||||
|
|
||||||
Section "MSVC runtime" SEC_MSVC
|
Section "MSVC runtime" SEC_MSVC
|
||||||
|
|
||||||
|
SectionIn RO
|
||||||
|
|
||||||
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
DetailPrint "Checking whether Visual C++ 2015 Redistributable is already installed..."
|
||||||
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
ReadRegDword $R0 HKLM "SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Installed"
|
||||||
StrCmp $R0 "1" 0 +3
|
StrCmp $R0 "1" 0 +3
|
||||||
@ -156,12 +175,28 @@ Section "MSVC runtime" SEC_MSVC
|
|||||||
|
|
||||||
DetailPrint "Installing Visual C++ 2015 Redistributable..."
|
DetailPrint "Installing Visual C++ 2015 Redistributable..."
|
||||||
SetOutPath $TEMP
|
SetOutPath $TEMP
|
||||||
File "VC_redist.x64.exe"
|
File "vcredist_x64.exe"
|
||||||
ExecWait '"$TEMP/VC_redist.x64.exe" /install /quiet /norestart'
|
ExecWait '"$TEMP\vcredist_x64.exe" /install /quiet /norestart'
|
||||||
|
SetOutPath $INSTDIR
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
|
Section "OpenSSL" SEC_OPENSSL
|
||||||
|
|
||||||
|
File "libeay32.dll"
|
||||||
|
File "ssleay32.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "ANGLE" SEC_ANGLE
|
||||||
|
|
||||||
|
File "libGLESv2.dll"
|
||||||
|
File "libEGL.dll"
|
||||||
|
File "D3DCompiler_47.dll"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
; Uninstaller
|
; Uninstaller
|
||||||
@ -205,15 +240,21 @@ SectionEnd
|
|||||||
|
|
||||||
;Language strings
|
;Language strings
|
||||||
LangString DESC_QT ${LANG_ENGLISH} \
|
LangString DESC_QT ${LANG_ENGLISH} \
|
||||||
"QT Library. Unselct only if you have QT already installed!"
|
"QT cross-platform application framework."
|
||||||
LangString DESC_MSVC ${LANG_ENGLISH} \
|
LangString DESC_MSVC ${LANG_ENGLISH} \
|
||||||
"Visual C++ 2015 runtime components. Unselct only if you have the runtime already installed!"
|
"Visual C++ 2015 runtime components. If already installed, will be skipped."
|
||||||
|
LangString DESC_OPENSSL ${LANG_ENGLISH} \
|
||||||
|
"OpenSSL library. Required for HTTPS to work."
|
||||||
|
LangString DESC_ANGLE ${LANG_ENGLISH} \
|
||||||
|
"ANGLE (OpenGL via Direct3D). Enables OpenGL on systems without native OpenGL drivers."
|
||||||
LangString DESC_APP ${LANG_ENGLISH} \
|
LangString DESC_APP ${LANG_ENGLISH} \
|
||||||
"GPXSee application"
|
"GPXSee application"
|
||||||
|
|
||||||
;Assign language strings to sections
|
;Assign language strings to sections
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_QT} $(DESC_QT)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_OPENSSL} $(DESC_OPENSSL)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_ANGLE} $(DESC_ANGLE)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
Thunderforest http://tile.thunderforest.com/outdoors/$z/$x/$y.png
|
Open Topo Map https://a.tile.opentopomap.org/$z/$x/$y.png 17
|
||||||
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png
|
4UMaps http://4umaps.eu/$z/$x/$y.png 15
|
||||||
|
Open Street Map http://tile.openstreetmap.org/$z/$x/$y.png 19
|
||||||
|
USGS Topo https://navigator.er.usgs.gov/tiles/tcr.cgi/$z/$x/$y.png 15
|
||||||
|
USGS Imagery https://navigator.er.usgs.gov/tiles/aerial_Imagery.cgi/$z/$x/$y 15
|
||||||
|
229
src/albersequal.cpp
Normal file
229
src/albersequal.cpp
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
/*
|
||||||
|
* Based on libgeotrans with the following Source Code Disclaimer:
|
||||||
|
|
||||||
|
1. The GEOTRANS source code ("the software") is provided free of charge by
|
||||||
|
the National Imagery and Mapping Agency (NIMA) of the United States
|
||||||
|
Department of Defense. Although NIMA makes no copyright claim under Title 17
|
||||||
|
U.S.C., NIMA claims copyrights in the source code under other legal regimes.
|
||||||
|
NIMA hereby grants to each user of the software a license to use and
|
||||||
|
distribute the software, and develop derivative works.
|
||||||
|
|
||||||
|
2. Warranty Disclaimer: The software was developed to meet only the internal
|
||||||
|
requirements of the U.S. National Imagery and Mapping Agency. The software
|
||||||
|
is provided "as is," and no warranty, express or implied, including but not
|
||||||
|
limited to the implied warranties of merchantability and fitness for
|
||||||
|
particular purpose or arising by statute or otherwise in law or from a
|
||||||
|
course of dealing or usage in trade, is made by NIMA as to the accuracy and
|
||||||
|
functioning of the software.
|
||||||
|
|
||||||
|
3. NIMA and its personnel are not required to provide technical support or
|
||||||
|
general assistance with respect to the software.
|
||||||
|
|
||||||
|
4. Neither NIMA nor its personnel will be liable for any claims, losses, or
|
||||||
|
damages arising from or connected with the use of the software. The user
|
||||||
|
agrees to hold harmless the United States National Imagery and Mapping
|
||||||
|
Agency. The user's sole and exclusive remedy is to stop using the software.
|
||||||
|
|
||||||
|
5. NIMA requests that products developed using the software credit the
|
||||||
|
source of the software with the following statement, "The product was
|
||||||
|
developed using GEOTRANS, a product of the National Imagery and Mapping
|
||||||
|
Agency and U.S. Army Engineering Research and Development Center."
|
||||||
|
|
||||||
|
6. For any products developed using the software, NIMA requires a disclaimer
|
||||||
|
that use of the software does not indicate endorsement or approval of the
|
||||||
|
product by the Secretary of Defense or the National Imagery and Mapping
|
||||||
|
Agency. Pursuant to the United States Code, 10 U.S.C. Sec. 2797, the name of
|
||||||
|
the National Imagery and Mapping Agency, the initials "NIMA", the seal of
|
||||||
|
the National Imagery and Mapping Agency, or any colorable imitation thereof
|
||||||
|
shall not be used to imply approval, endorsement, or authorization of a
|
||||||
|
product without prior written permission from United States Secretary of
|
||||||
|
Defense.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ellipsoid.h"
|
||||||
|
#include "rd.h"
|
||||||
|
#include "albersequal.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef M_PI_2
|
||||||
|
#define M_PI_2 1.57079632679489661923
|
||||||
|
#endif // M_PI_2
|
||||||
|
|
||||||
|
#define ONE_MINUS_SQR(x) (1.0 - (x) * (x))
|
||||||
|
#define ALBERS_Q(slat, one_minus_sqr_es_sin, es_sin) \
|
||||||
|
(_one_minus_es2 * ((slat) / (one_minus_sqr_es_sin) - \
|
||||||
|
(1 / (_two_es)) * log((1 - (es_sin)) / (1 + (es_sin)))))
|
||||||
|
#define ALBERS_M(clat, one_minus_sqr_es_sin) \
|
||||||
|
((clat) / sqrt(one_minus_sqr_es_sin))
|
||||||
|
|
||||||
|
|
||||||
|
AlbersEqual::AlbersEqual(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||||
|
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||||
|
double falseEasting, double falseNorthing)
|
||||||
|
{
|
||||||
|
double sin_lat, sin_lat1, sin_lat2, cos_lat1, cos_lat2;
|
||||||
|
double m1, m2, sqr_m1, sqr_m2;
|
||||||
|
double q0, q1, q2;
|
||||||
|
double es_sin, es_sin1, es_sin2;
|
||||||
|
double one_minus_sqr_es_sin1, one_minus_sqr_es_sin2;
|
||||||
|
double nq0;
|
||||||
|
double sp1, sp2;
|
||||||
|
|
||||||
|
|
||||||
|
_e = ellipsoid;
|
||||||
|
_latitudeOrigin = deg2rad(latitudeOrigin);
|
||||||
|
_longitudeOrigin = deg2rad(longitudeOrigin);
|
||||||
|
_falseEasting = falseEasting;
|
||||||
|
_falseNorthing = falseNorthing;
|
||||||
|
|
||||||
|
sp1 = deg2rad(standardParallel1);
|
||||||
|
sp2 = deg2rad(standardParallel2);
|
||||||
|
|
||||||
|
_es2 = 2 * _e.flattening() - _e.flattening() * _e.flattening();
|
||||||
|
_es = sqrt(_es2);
|
||||||
|
_one_minus_es2 = 1 - _es2;
|
||||||
|
_two_es = 2 * _es;
|
||||||
|
|
||||||
|
sin_lat = sin(_latitudeOrigin);
|
||||||
|
es_sin = _es * sin_lat;
|
||||||
|
q0 = ALBERS_Q(sin_lat, ONE_MINUS_SQR(es_sin), es_sin);
|
||||||
|
|
||||||
|
sin_lat1 = sin(sp1);
|
||||||
|
cos_lat1 = cos(sp1);
|
||||||
|
es_sin1 = _es * sin_lat1;
|
||||||
|
one_minus_sqr_es_sin1 = ONE_MINUS_SQR(es_sin1);
|
||||||
|
m1 = ALBERS_M(cos_lat1, one_minus_sqr_es_sin1);
|
||||||
|
q1 = ALBERS_Q(sin_lat1, one_minus_sqr_es_sin1, es_sin1);
|
||||||
|
|
||||||
|
sqr_m1 = m1 * m1;
|
||||||
|
if (fabs(sp1 - sp2) > 1.0e-10) {
|
||||||
|
sin_lat2 = sin(sp2);
|
||||||
|
cos_lat2 = cos(sp2);
|
||||||
|
es_sin2 = _es * sin_lat2;
|
||||||
|
one_minus_sqr_es_sin2 = ONE_MINUS_SQR(es_sin2);
|
||||||
|
m2 = ALBERS_M(cos_lat2, one_minus_sqr_es_sin2);
|
||||||
|
q2 = ALBERS_Q(sin_lat2, one_minus_sqr_es_sin2, es_sin2);
|
||||||
|
sqr_m2 = m2 * m2;
|
||||||
|
_n = (sqr_m1 - sqr_m2) / (q2 - q1);
|
||||||
|
} else
|
||||||
|
_n = sin_lat1;
|
||||||
|
|
||||||
|
_C = sqr_m1 + _n * q1;
|
||||||
|
_a_over_n = _e.radius() / _n;
|
||||||
|
nq0 = _n * q0;
|
||||||
|
_rho0 = (_C < nq0) ? 0 : _a_over_n * sqrt(_C - nq0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF AlbersEqual::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
double dlam;
|
||||||
|
double sin_lat;
|
||||||
|
double es_sin;
|
||||||
|
double q;
|
||||||
|
double rho;
|
||||||
|
double theta;
|
||||||
|
double nq;
|
||||||
|
|
||||||
|
|
||||||
|
dlam = deg2rad(c.lon()) - _longitudeOrigin;
|
||||||
|
if (dlam > M_PI)
|
||||||
|
dlam -= 2.0 * M_PI;
|
||||||
|
if (dlam < -M_PI)
|
||||||
|
dlam += 2.0 * M_PI;
|
||||||
|
|
||||||
|
sin_lat = sin(deg2rad(c.lat()));
|
||||||
|
es_sin = _es * sin_lat;
|
||||||
|
q = ALBERS_Q(sin_lat, ONE_MINUS_SQR(es_sin), es_sin);
|
||||||
|
nq = _n * q;
|
||||||
|
rho = (_C < nq) ? 0 : _a_over_n * sqrt(_C - nq);
|
||||||
|
theta = _n * dlam;
|
||||||
|
|
||||||
|
return QPointF(rho * sin(theta) + _falseEasting,
|
||||||
|
_rho0 - rho * cos(theta) + _falseNorthing);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates AlbersEqual::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
double dy, dx;
|
||||||
|
double rho0_minus_dy;
|
||||||
|
double q, qc, q_over_2;
|
||||||
|
double rho, rho_n;
|
||||||
|
double phi, delta_phi = 1.0;
|
||||||
|
double sin_phi;
|
||||||
|
double es_sin, one_minus_sqr_es_sin;
|
||||||
|
double theta = 0.0;
|
||||||
|
int count = 30;
|
||||||
|
double tolerance = 4.85e-10;
|
||||||
|
double lat, lon;
|
||||||
|
|
||||||
|
|
||||||
|
dy = p.y() - _falseNorthing;
|
||||||
|
dx = p.x() - _falseEasting;
|
||||||
|
|
||||||
|
rho0_minus_dy = _rho0 - dy;
|
||||||
|
rho = sqrt(dx * dx + rho0_minus_dy * rho0_minus_dy);
|
||||||
|
|
||||||
|
if (_n < 0) {
|
||||||
|
rho *= -1.0;
|
||||||
|
dx *= -1.0;
|
||||||
|
rho0_minus_dy *= -1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rho != 0.0)
|
||||||
|
theta = atan2(dx, rho0_minus_dy);
|
||||||
|
rho_n = rho * _n;
|
||||||
|
q = (_C - (rho_n * rho_n) / (_e.radius() * _e.radius())) / _n;
|
||||||
|
qc = 1 - ((_one_minus_es2) / (_two_es)) * log((1.0 - _es) / (1.0 + _es));
|
||||||
|
if (fabs(fabs(qc) - fabs(q)) > 1.0e-6) {
|
||||||
|
q_over_2 = q / 2.0;
|
||||||
|
if (q_over_2 > 1.0)
|
||||||
|
lat = M_PI_2;
|
||||||
|
else if (q_over_2 < -1.0)
|
||||||
|
lat = -M_PI_2;
|
||||||
|
else {
|
||||||
|
phi = asin(q_over_2);
|
||||||
|
if (_es < 1.0e-10)
|
||||||
|
lat = phi;
|
||||||
|
else {
|
||||||
|
while ((fabs(delta_phi) > tolerance) && count) {
|
||||||
|
sin_phi = sin(phi);
|
||||||
|
es_sin = _es * sin_phi;
|
||||||
|
one_minus_sqr_es_sin = ONE_MINUS_SQR(es_sin);
|
||||||
|
delta_phi = (one_minus_sqr_es_sin * one_minus_sqr_es_sin)
|
||||||
|
/ (2.0 * cos(phi)) * (q / (_one_minus_es2) - sin_phi
|
||||||
|
/ one_minus_sqr_es_sin + (log((1.0 - es_sin)
|
||||||
|
/ (1.0 + es_sin)) / (_two_es)));
|
||||||
|
phi += delta_phi;
|
||||||
|
count --;
|
||||||
|
}
|
||||||
|
|
||||||
|
lat = phi;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lat > M_PI_2)
|
||||||
|
lat = M_PI_2;
|
||||||
|
else if (lat < -M_PI_2)
|
||||||
|
lat = -M_PI_2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (q >= 0.0)
|
||||||
|
lat = M_PI_2;
|
||||||
|
else
|
||||||
|
lat = -M_PI_2;
|
||||||
|
}
|
||||||
|
|
||||||
|
lon = _longitudeOrigin + theta / _n;
|
||||||
|
|
||||||
|
if (lon > M_PI)
|
||||||
|
lon -= M_PI * 2;
|
||||||
|
if (lon < -M_PI)
|
||||||
|
lon += M_PI * 2;
|
||||||
|
|
||||||
|
if (lon > M_PI)
|
||||||
|
lon = M_PI;
|
||||||
|
else if (lon < -M_PI)
|
||||||
|
lon = -M_PI;
|
||||||
|
|
||||||
|
return Coordinates(rad2deg(lon), rad2deg(lat));
|
||||||
|
}
|
36
src/albersequal.h
Normal file
36
src/albersequal.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef ALBERSEQUAL_H
|
||||||
|
#define ALBERSEQUAL_H
|
||||||
|
|
||||||
|
#include "projection.h"
|
||||||
|
|
||||||
|
class Ellipsoid;
|
||||||
|
|
||||||
|
class AlbersEqual : public Projection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AlbersEqual(const Ellipsoid &ellipsoid, double standardParallel1,
|
||||||
|
double standardParallel2, double latitudeOrigin, double longitudeOrigin,
|
||||||
|
double falseEasting, double falseNorthing);
|
||||||
|
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ellipsoid _e;
|
||||||
|
|
||||||
|
double _latitudeOrigin;
|
||||||
|
double _longitudeOrigin;
|
||||||
|
double _falseEasting;
|
||||||
|
double _falseNorthing;
|
||||||
|
|
||||||
|
double _rho0;
|
||||||
|
double _C;
|
||||||
|
double _n;
|
||||||
|
double _es;
|
||||||
|
double _es2;
|
||||||
|
double _a_over_n;
|
||||||
|
double _one_minus_es2;
|
||||||
|
double _two_es;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ALBERSEQUAL_H
|
20
src/app.cpp
20
src/app.cpp
@ -3,26 +3,33 @@
|
|||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QFileOpenEvent>
|
#include <QFileOpenEvent>
|
||||||
#include <QNetworkProxyFactory>
|
#include <QNetworkProxyFactory>
|
||||||
#include <QPixmapCache>
|
#include <QLibraryInfo>
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
#include "onlinemap.h"
|
||||||
|
#include "downloader.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
|
|
||||||
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||||
_argc(argc), _argv(argv)
|
_argc(argc), _argv(argv)
|
||||||
{
|
{
|
||||||
_translator = new QTranslator();
|
QTranslator *gpxsee = new QTranslator(this);
|
||||||
|
|
||||||
QString locale = QLocale::system().name();
|
QString locale = QLocale::system().name();
|
||||||
_translator->load(QString(":/lang/gpxsee_") + locale);
|
gpxsee->load(QString(":/lang/gpxsee_") + locale);
|
||||||
installTranslator(_translator);
|
installTranslator(gpxsee);
|
||||||
|
|
||||||
|
QTranslator *qt = new QTranslator(this);
|
||||||
|
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
|
||||||
|
QLibraryInfo::TranslationsPath));
|
||||||
|
installTranslator(qt);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
|
|
||||||
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
||||||
QPixmapCache::setCacheLimit(65536);
|
OnlineMap::setDownloader(new Downloader(this));
|
||||||
OPENGL_SET_SAMPLES(4);
|
OPENGL_SET_SAMPLES(4);
|
||||||
|
|
||||||
_gui = new GUI();
|
_gui = new GUI();
|
||||||
@ -31,7 +38,6 @@ App::App(int &argc, char **argv) : QApplication(argc, argv),
|
|||||||
App::~App()
|
App::~App()
|
||||||
{
|
{
|
||||||
delete _gui;
|
delete _gui;
|
||||||
delete _translator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::run()
|
void App::run()
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
class GUI;
|
class GUI;
|
||||||
class QTranslator;
|
|
||||||
|
|
||||||
class App : QApplication
|
class App : QApplication
|
||||||
{
|
{
|
||||||
@ -22,7 +21,6 @@ private:
|
|||||||
int &_argc;
|
int &_argc;
|
||||||
char **_argv;
|
char **_argv;
|
||||||
GUI *_gui;
|
GUI *_gui;
|
||||||
QTranslator *_translator;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APP_H
|
#endif // APP_H
|
||||||
|
338
src/atlas.cpp
Normal file
338
src/atlas.cpp
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
#include <QDir>
|
||||||
|
#include <QtAlgorithms>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "rectc.h"
|
||||||
|
#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 QString &path)
|
||||||
|
{
|
||||||
|
QFileInfo fi(path);
|
||||||
|
QByteArray ba;
|
||||||
|
QString suffix = fi.suffix().toLower();
|
||||||
|
|
||||||
|
if (suffix == "tar") {
|
||||||
|
if (!tar.load(path)) {
|
||||||
|
_errorString = "Error reading tar file";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QString tbaFileName = fi.completeBaseName() + ".tba";
|
||||||
|
ba = tar.file(tbaFileName);
|
||||||
|
} else if (suffix == "tba") {
|
||||||
|
QFile tbaFile(path);
|
||||||
|
if (!tbaFile.open(QIODevice::ReadOnly)) {
|
||||||
|
_errorString = QString("Error opening tba file: %1")
|
||||||
|
.arg(tbaFile.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ba = tbaFile.readAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ba.startsWith("Atlas 1.0"))
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
_errorString = "Missing or invalid tba file";
|
||||||
|
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++) {
|
||||||
|
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(0);
|
||||||
|
for (int i = 1; i < m.size(); i++) {
|
||||||
|
qreal w = round(m.first()->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(0);
|
||||||
|
for (int i = 1; i < m.size(); i++) {
|
||||||
|
qreal h = round(m.first()->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 &fileName, QObject *parent) : Map(parent)
|
||||||
|
{
|
||||||
|
Tar tar;
|
||||||
|
QFileInfo fi(fileName);
|
||||||
|
|
||||||
|
_valid = false;
|
||||||
|
_zoom = 0;
|
||||||
|
_name = fi.dir().dirName();
|
||||||
|
_ci = -1; _cz = -1;
|
||||||
|
|
||||||
|
if (!isAtlas(tar, fileName))
|
||||||
|
return;
|
||||||
|
|
||||||
|
QDir dir(fi.absolutePath());
|
||||||
|
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++) {
|
||||||
|
QString mapFile = maps.at(i).absoluteFilePath() + "/"
|
||||||
|
+ maps.at(i).fileName() + ".map";
|
||||||
|
|
||||||
|
OfflineMap *map;
|
||||||
|
if (tar.isOpen())
|
||||||
|
map = new OfflineMap(mapFile, tar, this);
|
||||||
|
else
|
||||||
|
map = new OfflineMap(mapFile, this);
|
||||||
|
|
||||||
|
if (map->isValid())
|
||||||
|
_maps.append(map);
|
||||||
|
else {
|
||||||
|
_errorString = QString("Error loading map: %1: %2")
|
||||||
|
.arg(mapFile, map->errorString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_maps.isEmpty()) {
|
||||||
|
_errorString = "No maps found in atlas";
|
||||||
|
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 RectC &br)
|
||||||
|
{
|
||||||
|
_zoom = 0;
|
||||||
|
|
||||||
|
if (!br.isValid()) {
|
||||||
|
_zoom = _zooms.size() - 1;
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
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::zoomFit(qreal resolution, const Coordinates &c)
|
||||||
|
{
|
||||||
|
_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(c)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (_maps.at(i)->resolution(_maps.at(i)->ll2xy(c)) < resolution)
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
QPointF pp;
|
||||||
|
|
||||||
|
if (_cz != _zoom) {
|
||||||
|
_ci = -1;
|
||||||
|
_cz = _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_ci >= 0)
|
||||||
|
pp = _maps.at(_ci)->ll2pp(c);
|
||||||
|
if (_ci < 0 || !_bounds.at(_ci).first.contains(pp)) {
|
||||||
|
_ci = _zooms.at(_zoom).first;
|
||||||
|
for (int i = _zooms.at(_zoom).first; i <= _zooms.at(_zoom).second; i++) {
|
||||||
|
pp = _maps.at(i)->ll2pp(c);
|
||||||
|
if (_bounds.at(i).first.contains(pp)) {
|
||||||
|
_ci = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF p = _maps.at(_ci)->pp2xy(pp);
|
||||||
|
return p + _bounds.at(_ci).second.topLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Atlas::xy2ll(const QPointF &p)
|
||||||
|
{
|
||||||
|
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++) {
|
||||||
|
if (_bounds.at(i).second.contains(rect)) {
|
||||||
|
draw(painter, rect, i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiple maps
|
||||||
|
painter->fillRect(rect, _backgroundColor);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Atlas::unload()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _maps.count(); i++)
|
||||||
|
_maps.at(i)->unload();
|
||||||
|
}
|
56
src/atlas.h
Normal file
56
src/atlas.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#ifndef ATLAS_H
|
||||||
|
#define ATLAS_H
|
||||||
|
|
||||||
|
#include <QFileInfoList>
|
||||||
|
#include "map.h"
|
||||||
|
#include "offlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
|
class Atlas : public Map
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
Atlas(const QString &fileName, 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 RectC &br);
|
||||||
|
qreal zoomFit(qreal resolution, const Coordinates &c);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c);
|
||||||
|
Coordinates xy2ll(const QPointF &p);
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
void unload();
|
||||||
|
|
||||||
|
bool isValid() const {return _valid;}
|
||||||
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void draw(QPainter *painter, const QRectF &rect, int mapIndex);
|
||||||
|
bool isAtlas(Tar &tar, const QString &path);
|
||||||
|
void computeZooms();
|
||||||
|
void computeBounds();
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
bool _valid;
|
||||||
|
QString _errorString;
|
||||||
|
|
||||||
|
QList<OfflineMap*> _maps;
|
||||||
|
QVector<QPair<int, int> > _zooms;
|
||||||
|
QVector<QPair<QRectF, QRectF> > _bounds;
|
||||||
|
int _zoom;
|
||||||
|
|
||||||
|
int _ci, _cz;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ATLAS_H
|
@ -1,10 +1,10 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "cadencegraphitem.h"
|
||||||
#include "cadencegraph.h"
|
#include "cadencegraph.h"
|
||||||
|
|
||||||
|
|
||||||
CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent)
|
CadenceGraph::CadenceGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
GraphView::setYUnits(tr("1/min"));
|
GraphView::setYUnits(tr("1/min"));
|
||||||
@ -28,21 +28,16 @@ void CadenceGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->cadence();
|
const Graph &graph = data.tracks().at(i)->cadence();
|
||||||
qreal sum = 0, w = 0;
|
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (graph.size() < 2) {
|
||||||
skipColor();
|
skipColor();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++) {
|
CadenceGraphItem *gi = new CadenceGraphItem(graph, _graphType);
|
||||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
sum += graph.at(j).y() * ds;
|
|
||||||
w += ds;
|
|
||||||
}
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
|
||||||
|
|
||||||
GraphView::loadGraph(graph, paths.at(i));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < data.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
|
@ -13,7 +13,6 @@ public:
|
|||||||
QString label() const {return tr("Cadence");}
|
QString label() const {return tr("Cadence");}
|
||||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units) {}
|
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
void showRoutes(bool show) {Q_UNUSED(show);}
|
||||||
|
|
||||||
@ -24,7 +23,6 @@ private:
|
|||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
|
||||||
enum Units _units;
|
|
||||||
bool _showTracks;
|
bool _showTracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
26
src/cadencegraphitem.cpp
Normal file
26
src/cadencegraphitem.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "tooltip.h"
|
||||||
|
#include "cadencegraphitem.h"
|
||||||
|
|
||||||
|
CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
|
{
|
||||||
|
qreal sum = 0;
|
||||||
|
|
||||||
|
for (int j = 1; j < graph.size(); j++)
|
||||||
|
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||||
|
_avg = sum/graph.last().s();
|
||||||
|
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CadenceGraphItem::toolTip() const
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
|
||||||
|
tt.insert(tr("Maximum"), QString::number(max(), 'f', 1)
|
||||||
|
+ UNIT_SPACE + tr("1/min"));
|
||||||
|
tt.insert(tr("Average"), QString::number(avg(), 'f', 1)
|
||||||
|
+ UNIT_SPACE + tr("1/min"));
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
23
src/cadencegraphitem.h
Normal file
23
src/cadencegraphitem.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef CADENCEGRAPHITEM_H
|
||||||
|
#define CADENCEGRAPHITEM_H
|
||||||
|
|
||||||
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
class CadenceGraphItem : public GraphItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CadenceGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
qreal max() const {return -bounds().top();}
|
||||||
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString toolTip() const;
|
||||||
|
|
||||||
|
qreal _avg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CADENCEGRAPHITEM_H
|
@ -9,6 +9,8 @@
|
|||||||
ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
|
ColorBox::ColorBox(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
_color = Qt::red;
|
_color = Qt::red;
|
||||||
|
_alpha = true;
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,9 +53,9 @@ void ColorBox::mousePressEvent(QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if (event->button() != Qt::LeftButton)
|
if (event->button() != Qt::LeftButton)
|
||||||
return;
|
return;
|
||||||
|
QColorDialog::ColorDialogOptions options = _alpha
|
||||||
QColor color = QColorDialog::getColor(_color, this, QString(),
|
? QColorDialog::ShowAlphaChannel : (QColorDialog::ColorDialogOptions)0;
|
||||||
QColorDialog::ShowAlphaChannel);
|
QColor color = QColorDialog::getColor(_color, this, QString(), options);
|
||||||
if (color.isValid()) {
|
if (color.isValid()) {
|
||||||
_color = color;
|
_color = color;
|
||||||
update();
|
update();
|
||||||
|
@ -12,6 +12,7 @@ public:
|
|||||||
|
|
||||||
const QColor &color() const {return _color;}
|
const QColor &color() const {return _color;}
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
|
void enableAlphaChannel(bool enable) {_alpha = enable;}
|
||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QColor _color;
|
QColor _color;
|
||||||
|
bool _alpha;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLORBOX_H
|
#endif // COLORBOX_H
|
||||||
|
24
src/config.h
24
src/config.h
@ -7,13 +7,15 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#define APP_NAME "GPXSee"
|
#define APP_NAME "GPXSee"
|
||||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
#define APP_HOMEPAGE "http://www.gpxsee.org"
|
||||||
|
|
||||||
#define FONT_FAMILY "Arial"
|
#define FONT_FAMILY "Arial"
|
||||||
#define FONT_SIZE 12
|
#define FONT_SIZE 12 // px
|
||||||
#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_FILE QString("maps.txt")
|
||||||
|
#define MAP_DIR QString("maps")
|
||||||
#define POI_DIR QString("POI")
|
#define POI_DIR QString("POI")
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
@ -28,10 +30,16 @@
|
|||||||
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
#define GLOBAL_DIR QString("/usr/share/gpxsee")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
#define USER_ELLIPSOID_FILE USER_DIR + QString("/") + ELLIPSOID_FILE
|
||||||
#define USER_POI_DIR USER_DIR + QString("/") + POI_DIR
|
#define USER_DATUM_FILE USER_DIR + QString("/") + DATUM_FILE
|
||||||
#define GLOBAL_MAP_FILE GLOBAL_DIR + QString("/") + MAP_FILE
|
#define USER_MAP_DIR USER_DIR + QString("/") + MAP_DIR
|
||||||
#define GLOBAL_POI_DIR GLOBAL_DIR + QString("/") + POI_DIR
|
#define USER_MAP_FILE USER_DIR + QString("/") + MAP_FILE
|
||||||
#define TILES_DIR USER_DIR + QString("/tiles")
|
#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 */
|
#endif /* CONFIG_H */
|
||||||
|
@ -17,27 +17,11 @@ qreal Coordinates::distanceTo(const Coordinates &c) const
|
|||||||
return (WGS84_RADIUS * (2.0 * atan2(sqrt(a), sqrt(1.0 - a))));
|
return (WGS84_RADIUS * (2.0 * atan2(sqrt(a), sqrt(1.0 - a))));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF Coordinates::toMercator() const
|
|
||||||
{
|
|
||||||
return QPointF(_lon, rad2deg(log(tan(M_PI/4.0 + deg2rad(_lat)/2.0))));
|
|
||||||
}
|
|
||||||
|
|
||||||
Coordinates Coordinates::fromMercator(const QPointF &m)
|
|
||||||
{
|
|
||||||
return Coordinates(m.x(), rad2deg(2 * atan(exp(deg2rad(m.y()))) - M_PI/2));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Coordinates &c1, const Coordinates &c2)
|
|
||||||
{
|
|
||||||
return (c1.lat() == c2.lat() && c1.lon() == c2.lon());
|
|
||||||
}
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
|
||||||
{
|
{
|
||||||
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
|
||||||
<< coordinates.lat() << ")";
|
<< coordinates.lat() << ")";
|
||||||
|
return dbg.space();
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
||||||
@ -64,6 +48,7 @@ QPair<Coordinates, Coordinates> Coordinates::boundingRect(qreal distance) const
|
|||||||
maxLon = MAX_LON;
|
maxLon = MAX_LON;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPair<Coordinates, Coordinates>(Coordinates(rad2deg(minLon),
|
return QPair<Coordinates, Coordinates>(Coordinates(rad2deg(qMin(minLon,
|
||||||
rad2deg(minLat)), Coordinates(rad2deg(maxLon), rad2deg(maxLat)));
|
maxLon)), rad2deg(qMin(minLat, maxLat))), Coordinates(rad2deg(qMax(minLon,
|
||||||
|
maxLon)), rad2deg(qMax(minLat, maxLat))));
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define COORDINATES_H
|
#define COORDINATES_H
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QPointF>
|
#include <QPair>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
class Coordinates
|
class Coordinates
|
||||||
@ -20,22 +20,23 @@ public:
|
|||||||
qreal lat() const {return _lat;}
|
qreal lat() const {return _lat;}
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{return (std::isnan(_lon) || std::isnan(_lat)) ? true : false;}
|
{return std::isnan(_lon) && std::isnan(_lat);}
|
||||||
bool isValid() const
|
bool isValid() const
|
||||||
{return (_lon >= -180.0 && _lon <= 180.0 && _lat >= -90.0
|
{return (_lon >= -180.0 && _lon <= 180.0
|
||||||
&& _lat <= 90.0) ? true : false;}
|
&& _lat >= -90.0 && _lat <= 90.0);}
|
||||||
|
|
||||||
qreal distanceTo(const Coordinates &c) const;
|
qreal distanceTo(const Coordinates &c) const;
|
||||||
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
QPair<Coordinates, Coordinates> boundingRect(qreal distance) const;
|
||||||
|
|
||||||
QPointF toMercator() const;
|
|
||||||
static Coordinates fromMercator(const QPointF &m);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal _lat, _lon;
|
qreal _lat, _lon;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool operator==(const Coordinates &c1, const Coordinates &c2);
|
inline bool operator==(const Coordinates &c1, const Coordinates &c2)
|
||||||
|
{return (c1.lat() == c2.lat() && c1.lon() == c2.lon());}
|
||||||
|
inline bool operator!=(const Coordinates &c1, const Coordinates &c2)
|
||||||
|
{return !(c1 == c2);}
|
||||||
|
|
||||||
QDebug operator<<(QDebug dbg, const Coordinates &trackpoint);
|
QDebug operator<<(QDebug dbg, const Coordinates &trackpoint);
|
||||||
|
|
||||||
#endif // COORDINATES_H
|
#endif // COORDINATES_H
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
#include "csvparser.h"
|
#include "csvparser.h"
|
||||||
|
|
||||||
bool CSVParser::loadFile(QFile *file)
|
bool CSVParser::parse(QFile *file, QList<TrackData> &track,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(track);
|
||||||
|
Q_UNUSED(routes);
|
||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
_errorLine = 1;
|
_errorLine = 1;
|
||||||
@ -36,7 +39,7 @@ bool CSVParser::loadFile(QFile *file)
|
|||||||
wp.setDescription(QString::fromUtf8(ba.data(), ba.size()));
|
wp.setDescription(QString::fromUtf8(ba.data(), ba.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
_waypoints.append(wp);
|
waypoints.append(wp);
|
||||||
_errorLine++;
|
_errorLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,12 +6,11 @@
|
|||||||
class CSVParser : public Parser
|
class CSVParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CSVParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
CSVParser() : _errorLine(0) {}
|
||||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
|
||||||
{_errorLine = 0;}
|
|
||||||
~CSVParser() {}
|
~CSVParser() {}
|
||||||
|
|
||||||
bool loadFile(QFile *file);
|
bool parse(QFile *file, QList<TrackData> &track, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
|
77
src/data.cpp
77
src/data.cpp
@ -11,38 +11,41 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
|
|
||||||
Data::Data() : _errorLine(0)
|
static GPXParser gpx;
|
||||||
|
static TCXParser tcx;
|
||||||
|
static KMLParser kml;
|
||||||
|
static FITParser fit;
|
||||||
|
static CSVParser csv;
|
||||||
|
static IGCParser igc;
|
||||||
|
static NMEAParser nmea;
|
||||||
|
|
||||||
|
static QHash<QString, Parser*> parsers()
|
||||||
{
|
{
|
||||||
_parsers.insert("gpx", new GPXParser(_trackData, _routeData,
|
QHash<QString, Parser*> hash;
|
||||||
_waypointData));
|
|
||||||
_parsers.insert("tcx", new TCXParser(_trackData, _routeData,
|
hash.insert("gpx", &gpx);
|
||||||
_waypointData));
|
hash.insert("tcx", &tcx);
|
||||||
_parsers.insert("kml", new KMLParser(_trackData, _routeData,
|
hash.insert("kml", &kml);
|
||||||
_waypointData));
|
hash.insert("fit", &fit);
|
||||||
_parsers.insert("fit", new FITParser(_trackData, _routeData,
|
hash.insert("csv", &csv);
|
||||||
_waypointData));
|
hash.insert("igc", &igc);
|
||||||
_parsers.insert("csv", new CSVParser(_trackData, _routeData,
|
hash.insert("nmea", &nmea);
|
||||||
_waypointData));
|
|
||||||
_parsers.insert("igc", new IGCParser(_trackData, _routeData,
|
return hash;
|
||||||
_waypointData));
|
|
||||||
_parsers.insert("nmea", new NMEAParser(_trackData, _routeData,
|
|
||||||
_waypointData));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QHash<QString, Parser*> Data::_parsers = parsers();
|
||||||
|
|
||||||
Data::~Data()
|
Data::~Data()
|
||||||
{
|
{
|
||||||
QHash<QString, Parser*>::iterator it;
|
|
||||||
|
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
|
||||||
delete it.value();
|
|
||||||
|
|
||||||
for (int i = 0; i < _tracks.count(); i++)
|
for (int i = 0; i < _tracks.count(); i++)
|
||||||
delete _tracks.at(i);
|
delete _tracks.at(i);
|
||||||
for (int i = 0; i < _routes.count(); i++)
|
for (int i = 0; i < _routes.count(); i++)
|
||||||
delete _routes.at(i);
|
delete _routes.at(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Data::createData()
|
void Data::processData()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _trackData.count(); i++)
|
for (int i = 0; i < _trackData.count(); i++)
|
||||||
_tracks.append(new Track(_trackData.at(i)));
|
_tracks.append(new Track(_trackData.at(i)));
|
||||||
@ -66,8 +69,8 @@ bool Data::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
QHash<QString, Parser*>::iterator it;
|
QHash<QString, Parser*>::iterator it;
|
||||||
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
||||||
if (it.value()->loadFile(&file)) {
|
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
|
||||||
createData();
|
processData();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,16 +78,16 @@ bool Data::loadFile(const QString &fileName)
|
|||||||
_errorString = it.value()->errorString();
|
_errorString = it.value()->errorString();
|
||||||
} else {
|
} else {
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||||
if (it.value()->loadFile(&file)) {
|
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
|
||||||
createData();
|
processData();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
file.reset();
|
file.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Error loading data file: %s:\n", qPrintable(fileName));
|
qWarning("Error loading data file: %s:\n", qPrintable(fileName));
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
fprintf(stderr, "%s: line %d: %s\n", qPrintable(it.key()),
|
qWarning("%s: line %d: %s\n", qPrintable(it.key()),
|
||||||
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||||
|
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
@ -93,3 +96,23 @@ bool Data::loadFile(const QString &fileName)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Data::formats()
|
||||||
|
{
|
||||||
|
return tr("Supported files (*.csv *.fit *.gpx *.igc *.kml *.nmea *.tcx)")
|
||||||
|
+ ";;" + tr("CSV files (*.csv)") + ";;" + tr("FIT files (*.fit)") + ";;"
|
||||||
|
+ tr("GPX files (*.gpx)") + ";;" + tr("IGC files (*.igc)") + ";;"
|
||||||
|
+ tr("KML files (*.kml)") + ";;" + tr("NMEA files (*.nmea)") + ";;"
|
||||||
|
+ tr("TCX files (*.tcx)") + ";;" + tr("All files (*)");
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList Data::filter()
|
||||||
|
{
|
||||||
|
QStringList filter;
|
||||||
|
QHash<QString, Parser*>::iterator it;
|
||||||
|
|
||||||
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
|
filter << QString("*.%1").arg(it.key());
|
||||||
|
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
19
src/data.h
19
src/data.h
@ -6,16 +6,19 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QStringList>
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
#include "track.h"
|
#include "track.h"
|
||||||
#include "route.h"
|
#include "route.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
|
|
||||||
|
|
||||||
class Data
|
class Data : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Data();
|
Data(QObject *parent = 0) : QObject(parent), _errorLine(0) {}
|
||||||
~Data();
|
~Data();
|
||||||
|
|
||||||
bool loadFile(const QString &fileName);
|
bool loadFile(const QString &fileName);
|
||||||
@ -24,21 +27,25 @@ public:
|
|||||||
|
|
||||||
const QList<Track*> &tracks() const {return _tracks;}
|
const QList<Track*> &tracks() const {return _tracks;}
|
||||||
const QList<Route*> &routes() const {return _routes;}
|
const QList<Route*> &routes() const {return _routes;}
|
||||||
const QList<Waypoint> &waypoints() const {return _waypointData;}
|
const QList<Waypoint> &waypoints() const {return _waypoints;}
|
||||||
|
|
||||||
|
static QString formats();
|
||||||
|
static QStringList filter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createData();
|
void processData();
|
||||||
|
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
QHash<QString, Parser*> _parsers;
|
|
||||||
|
|
||||||
QList<Track*> _tracks;
|
QList<Track*> _tracks;
|
||||||
QList<Route*> _routes;
|
QList<Route*> _routes;
|
||||||
|
QList<Waypoint> _waypoints;
|
||||||
|
|
||||||
QList<TrackData> _trackData;
|
QList<TrackData> _trackData;
|
||||||
QList<RouteData> _routeData;
|
QList<RouteData> _routeData;
|
||||||
QList<Waypoint> _waypointData;
|
|
||||||
|
static QHash<QString, Parser*> _parsers;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DATA_H
|
#endif // DATA_H
|
||||||
|
121
src/datum.cpp
Normal file
121
src/datum.cpp
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include <QFile>
|
||||||
|
#include "wgs84.h"
|
||||||
|
#include "rd.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.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Abridged Molodensky transformation
|
||||||
|
Coordinates Datum::toWGS84(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
if (_ellipsoid.radius() == WGS84_RADIUS
|
||||||
|
&& _ellipsoid.flattening() == WGS84_FLATTENING
|
||||||
|
&& _dx == 0.0 && _dy == 0.0 && _dz == 0.0)
|
||||||
|
return c;
|
||||||
|
|
||||||
|
double rlat = deg2rad(c.lat());
|
||||||
|
double rlon = deg2rad(c.lon());
|
||||||
|
|
||||||
|
double slat = sin(rlat);
|
||||||
|
double clat = cos(rlat);
|
||||||
|
double slon = sin(rlon);
|
||||||
|
double clon = cos(rlon);
|
||||||
|
double ssqlat = slat * slat;
|
||||||
|
|
||||||
|
double from_f = ellipsoid().flattening();
|
||||||
|
double df = WGS84_FLATTENING - from_f;
|
||||||
|
double from_a = ellipsoid().radius();
|
||||||
|
double da = WGS84_RADIUS - from_a;
|
||||||
|
double from_esq = ellipsoid().flattening()
|
||||||
|
* (2.0 - 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;
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
40
src/datum.h
Normal file
40
src/datum.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#ifndef DATUM_H
|
||||||
|
#define DATUM_H
|
||||||
|
|
||||||
|
#include <QMap>
|
||||||
|
#include "ellipsoid.h"
|
||||||
|
#include "coordinates.h"
|
||||||
|
|
||||||
|
class Datum
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Datum() : _ellipsoid(Ellipsoid()), _dx(0.0), _dy(0.0), _dz(0.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() && _dx == 0.0 && _dy == 0.0 && _dz == 0.0);}
|
||||||
|
|
||||||
|
Coordinates toWGS84(const Coordinates &c) const;
|
||||||
|
|
||||||
|
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
|
@ -1,5 +1,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "downloader.h"
|
#include "downloader.h"
|
||||||
|
|
||||||
@ -25,7 +27,7 @@
|
|||||||
#define MAX_REDIRECT_LEVEL 5
|
#define MAX_REDIRECT_LEVEL 5
|
||||||
|
|
||||||
|
|
||||||
Downloader::Downloader()
|
Downloader::Downloader(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
connect(&_manager, SIGNAL(finished(QNetworkReply*)),
|
||||||
SLOT(downloadFinished(QNetworkReply*)));
|
SLOT(downloadFinished(QNetworkReply*)));
|
||||||
@ -59,7 +61,7 @@ bool Downloader::saveToDisk(const QString &filename, QIODevice *data)
|
|||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
fprintf(stderr, "Error writing map tile: %s: %s\n",
|
qWarning("Error writing map tile: %s: %s\n",
|
||||||
qPrintable(filename), qPrintable(file.errorString()));
|
qPrintable(filename), qPrintable(file.errorString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -78,11 +80,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
|||||||
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
QUrl origin = reply->request().attribute(ATTR_ORIGIN).toUrl();
|
||||||
if (origin.isEmpty()) {
|
if (origin.isEmpty()) {
|
||||||
_errorDownloads.insert(url);
|
_errorDownloads.insert(url);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
qWarning("Error downloading map tile: %s: %s\n",
|
||||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||||
} else {
|
} else {
|
||||||
_errorDownloads.insert(origin);
|
_errorDownloads.insert(origin);
|
||||||
fprintf(stderr, "Error downloading map tile: %s -> %s: %s\n",
|
qWarning("Error downloading map tile: %s -> %s: %s\n",
|
||||||
origin.toEncoded().constData(), url.toEncoded().constData(),
|
origin.toEncoded().constData(), url.toEncoded().constData(),
|
||||||
qPrintable(reply->errorString()));
|
qPrintable(reply->errorString()));
|
||||||
}
|
}
|
||||||
@ -97,11 +99,11 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
|||||||
|
|
||||||
if (location == url) {
|
if (location == url) {
|
||||||
_errorDownloads.insert(url);
|
_errorDownloads.insert(url);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: "
|
qWarning("Error downloading map tile: %s: "
|
||||||
"redirect loop\n", url.toEncoded().constData());
|
"redirect loop\n", url.toEncoded().constData());
|
||||||
} else if (level >= MAX_REDIRECT_LEVEL) {
|
} else if (level >= MAX_REDIRECT_LEVEL) {
|
||||||
_errorDownloads.insert(origin);
|
_errorDownloads.insert(origin);
|
||||||
fprintf(stderr, "Error downloading map tile: %s: "
|
qWarning("Error downloading map tile: %s: "
|
||||||
"redirect level limit reached\n",
|
"redirect level limit reached\n",
|
||||||
origin.toEncoded().constData());
|
origin.toEncoded().constData());
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,13 +2,14 @@
|
|||||||
#define DOWNLOADER_H
|
#define DOWNLOADER_H
|
||||||
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QNetworkRequest>
|
|
||||||
#include <QNetworkReply>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
|
|
||||||
|
class QNetworkReply;
|
||||||
|
|
||||||
class Download
|
class Download
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -28,8 +29,8 @@ class Downloader : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Downloader& instance()
|
Downloader(QObject *parent = 0);
|
||||||
{static Downloader i; return i;}
|
|
||||||
bool get(const QList<Download> &list);
|
bool get(const QList<Download> &list);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -56,10 +57,6 @@ private:
|
|||||||
int _level;
|
int _level;
|
||||||
};
|
};
|
||||||
|
|
||||||
Downloader();
|
|
||||||
Downloader(Downloader const&);
|
|
||||||
void operator=(Downloader const&);
|
|
||||||
|
|
||||||
bool doDownload(const Download &dl, const Redirect &redirect = Redirect());
|
bool doDownload(const Download &dl, const Redirect &redirect = Redirect());
|
||||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "tooltip.h"
|
||||||
|
#include "elevationgraphitem.h"
|
||||||
#include "elevationgraph.h"
|
#include "elevationgraph.h"
|
||||||
|
|
||||||
|
|
||||||
@ -42,11 +44,8 @@ ElevationGraph::ElevationGraph(QWidget *parent) : GraphTab(parent)
|
|||||||
_showRoutes = true;
|
_showRoutes = true;
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
_units = Metric;
|
setYUnits(Metric);
|
||||||
|
|
||||||
setYUnits();
|
|
||||||
setYLabel(tr("Elevation"));
|
setYLabel(tr("Elevation"));
|
||||||
|
|
||||||
setMinYRange(50.0);
|
setMinYRange(50.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,43 +67,25 @@ void ElevationGraph::setInfo()
|
|||||||
|
|
||||||
void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
void ElevationGraph::loadGraph(const Graph &graph, Type type, PathItem *path)
|
||||||
{
|
{
|
||||||
qreal ascent = 0, descent = 0;
|
|
||||||
qreal min, max;
|
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (graph.size() < 2) {
|
||||||
skipColor();
|
skipColor();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
max = min = graph.at(0).y();
|
ElevationGraphItem *gi = new ElevationGraphItem(graph, _graphType);
|
||||||
for (int j = 1; j < graph.size(); j++) {
|
GraphView::addGraph(gi, path, type);
|
||||||
qreal cur = graph.at(j).y();
|
|
||||||
qreal prev = graph.at(j-1).y();
|
|
||||||
|
|
||||||
if (cur > prev)
|
|
||||||
ascent += cur - prev;
|
|
||||||
if (cur < prev)
|
|
||||||
descent += prev - cur;
|
|
||||||
|
|
||||||
if (cur < min)
|
|
||||||
min = cur;
|
|
||||||
if (cur > max)
|
|
||||||
max = cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == Track) {
|
if (type == Track) {
|
||||||
_trackAscent += ascent;
|
_trackAscent += gi->ascent();
|
||||||
_trackDescent += descent;
|
_trackDescent += gi->descent();
|
||||||
_trackMax = nMax(_trackMax, max);
|
_trackMax = nMax(_trackMax, gi->max());
|
||||||
_trackMin = nMin(_trackMin, min);
|
_trackMin = nMin(_trackMin, gi->min());
|
||||||
} else {
|
} else {
|
||||||
_routeAscent += ascent;
|
_routeAscent += gi->ascent();
|
||||||
_routeDescent += descent;
|
_routeDescent += gi->descent();
|
||||||
_routeMax = nMax(_routeMax, max);
|
_routeMax = nMax(_routeMax, gi->max());
|
||||||
_routeMin = nMin(_routeMin, min);
|
_routeMin = nMin(_routeMin, gi->min());
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphView::loadGraph(graph, path, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
void ElevationGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
||||||
@ -135,9 +116,9 @@ void ElevationGraph::clear()
|
|||||||
GraphView::clear();
|
GraphView::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::setYUnits()
|
void ElevationGraph::setYUnits(Units units)
|
||||||
{
|
{
|
||||||
if (_units == Metric) {
|
if (units == Metric) {
|
||||||
GraphView::setYUnits(tr("m"));
|
GraphView::setYUnits(tr("m"));
|
||||||
setYScale(1);
|
setYScale(1);
|
||||||
} else {
|
} else {
|
||||||
@ -146,15 +127,12 @@ void ElevationGraph::setYUnits()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::setUnits(enum Units units)
|
void ElevationGraph::setUnits(Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
setYUnits(units);
|
||||||
|
|
||||||
setYUnits();
|
|
||||||
setInfo();
|
setInfo();
|
||||||
GraphView::setUnits(units);
|
|
||||||
|
|
||||||
redraw();
|
GraphView::setUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElevationGraph::showTracks(bool show)
|
void ElevationGraph::showTracks(bool show)
|
||||||
|
@ -25,7 +25,7 @@ private:
|
|||||||
qreal ascent() const;
|
qreal ascent() const;
|
||||||
qreal descent() const;
|
qreal descent() const;
|
||||||
|
|
||||||
void setYUnits();
|
void setYUnits(Units units);
|
||||||
void setInfo();
|
void setInfo();
|
||||||
|
|
||||||
void loadGraph(const Graph &graph, Type type, PathItem *path);
|
void loadGraph(const Graph &graph, Type type, PathItem *path);
|
||||||
@ -35,7 +35,6 @@ private:
|
|||||||
qreal _trackMax, _routeMax;
|
qreal _trackMax, _routeMax;
|
||||||
qreal _trackMin, _routeMin;
|
qreal _trackMin, _routeMin;
|
||||||
|
|
||||||
enum Units _units;
|
|
||||||
bool _showTracks, _showRoutes;
|
bool _showTracks, _showRoutes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
43
src/elevationgraphitem.cpp
Normal file
43
src/elevationgraphitem.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#include "tooltip.h"
|
||||||
|
#include "elevationgraphitem.h"
|
||||||
|
|
||||||
|
ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
|
{
|
||||||
|
_ascent = _descent = 0;
|
||||||
|
|
||||||
|
for (int j = 1; j < graph.size(); j++) {
|
||||||
|
qreal cur = graph.at(j).y();
|
||||||
|
qreal prev = graph.at(j-1).y();
|
||||||
|
|
||||||
|
if (cur > prev)
|
||||||
|
_ascent += cur - prev;
|
||||||
|
if (cur < prev)
|
||||||
|
_descent += prev - cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
setToolTip(toolTip(Metric));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ElevationGraphItem::toolTip(Units units) const
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
qreal scale = (units == Metric) ? 1.0 : M2FT;
|
||||||
|
QString su = (units == Metric) ? tr("m") : tr("ft");
|
||||||
|
|
||||||
|
tt.insert(tr("Ascent"), QString::number(ascent() * scale, 'f', 0)
|
||||||
|
+ UNIT_SPACE + su);
|
||||||
|
tt.insert(tr("Descent"), QString::number(descent() * scale, 'f', 0)
|
||||||
|
+ UNIT_SPACE + su);
|
||||||
|
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 0)
|
||||||
|
+ UNIT_SPACE + su);
|
||||||
|
tt.insert(tr("Minimum"), QString::number(min() * scale, 'f', 0)
|
||||||
|
+ UNIT_SPACE + su);
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElevationGraphItem::setUnits(Units units)
|
||||||
|
{
|
||||||
|
setToolTip(toolTip(units));
|
||||||
|
}
|
27
src/elevationgraphitem.h
Normal file
27
src/elevationgraphitem.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef ELEVATIONGRAPHITEM_H
|
||||||
|
#define ELEVATIONGRAPHITEM_H
|
||||||
|
|
||||||
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
class ElevationGraphItem : public GraphItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ElevationGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
qreal ascent() const {return _ascent;}
|
||||||
|
qreal descent() const {return _descent;}
|
||||||
|
qreal min() const {return -bounds().bottom();}
|
||||||
|
qreal max() const {return -bounds().top();}
|
||||||
|
|
||||||
|
void setUnits(Units units);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString toolTip(Units units) const;
|
||||||
|
|
||||||
|
qreal _ascent, _descent;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ELEVATIONGRAPHITEM_H
|
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;
|
||||||
|
}
|
34
src/ellipsoid.h
Normal file
34
src/ellipsoid.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef ELLIPSOID_H
|
||||||
|
#define ELLIPSOID_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
class Ellipsoid
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Ellipsoid() : _radius(0.0), _flattening(0.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.0 && _flattening == 0.0);}
|
||||||
|
|
||||||
|
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
|
86
src/emptymap.cpp
Normal file
86
src/emptymap.cpp
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
#include <QtGlobal>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "rectc.h"
|
||||||
|
#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 RectC &br)
|
||||||
|
{
|
||||||
|
if (!br.isValid())
|
||||||
|
_scale = SCALE_MAX;
|
||||||
|
else {
|
||||||
|
QRectF tbr(Mercator().ll2xy(br.topLeft()),
|
||||||
|
Mercator().ll2xy(br.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::zoomFit(qreal resolution, const Coordinates &c)
|
||||||
|
{
|
||||||
|
_scale = (360.0 * resolution) / (WGS84_RADIUS * 2 * M_PI
|
||||||
|
* cos(deg2rad(c.lat())));
|
||||||
|
|
||||||
|
_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, _backgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF EmptyMap::ll2xy(const Coordinates &c)
|
||||||
|
{
|
||||||
|
QPointF m = Mercator().ll2xy(c);
|
||||||
|
return QPointF(m.x() / _scale, m.y() / -_scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates EmptyMap::xy2ll(const QPointF &p)
|
||||||
|
{
|
||||||
|
QPointF m(p.x() * _scale, -p.y() * _scale);
|
||||||
|
return Mercator().xy2ll(m);
|
||||||
|
}
|
34
src/emptymap.h
Normal file
34
src/emptymap.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#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 RectC &br);
|
||||||
|
qreal zoomFit(qreal resolution, const Coordinates &c);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c);
|
||||||
|
Coordinates xy2ll(const QPointF &p);
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString _name;
|
||||||
|
qreal _scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EMPTYMAP_H
|
@ -26,15 +26,28 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
|||||||
_fileSelect->setFile(_export->fileName);
|
_fileSelect->setFile(_export->fileName);
|
||||||
|
|
||||||
_paperSize = new QComboBox();
|
_paperSize = new QComboBox();
|
||||||
|
_paperSize->addItem("A2", QPrinter::A2);
|
||||||
_paperSize->addItem("A3", QPrinter::A3);
|
_paperSize->addItem("A3", QPrinter::A3);
|
||||||
_paperSize->addItem("A4", QPrinter::A4);
|
_paperSize->addItem("A4", QPrinter::A4);
|
||||||
_paperSize->addItem("A5", QPrinter::A5);
|
_paperSize->addItem("A5", QPrinter::A5);
|
||||||
|
_paperSize->addItem("A6", QPrinter::A6);
|
||||||
|
_paperSize->addItem("B3", QPrinter::B3);
|
||||||
|
_paperSize->addItem("B4", QPrinter::B4);
|
||||||
|
_paperSize->addItem("B5", QPrinter::B5);
|
||||||
|
_paperSize->addItem("B6", QPrinter::B6);
|
||||||
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
_paperSize->addItem("Tabloid", QPrinter::Tabloid);
|
||||||
_paperSize->addItem("Legal", QPrinter::Legal);
|
_paperSize->addItem("Legal", QPrinter::Legal);
|
||||||
_paperSize->addItem("Letter", QPrinter::Letter);
|
_paperSize->addItem("Letter", QPrinter::Letter);
|
||||||
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
|
if ((index = _paperSize->findData(_export->paperSize)) >= 0)
|
||||||
_paperSize->setCurrentIndex(index);
|
_paperSize->setCurrentIndex(index);
|
||||||
|
|
||||||
|
_resolution = new QComboBox();
|
||||||
|
_resolution->addItem("300 DPI", 300);
|
||||||
|
_resolution->addItem("600 DPI", 600);
|
||||||
|
_resolution->addItem("1200 DPI", 1200);
|
||||||
|
if ((index = _resolution->findData(_export->resolution)) >= 0)
|
||||||
|
_resolution->setCurrentIndex(index);
|
||||||
|
|
||||||
_portrait = new QRadioButton(tr("Portrait"));
|
_portrait = new QRadioButton(tr("Portrait"));
|
||||||
_landscape = new QRadioButton(tr("Landscape"));
|
_landscape = new QRadioButton(tr("Landscape"));
|
||||||
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
QHBoxLayout *orientationLayout = new QHBoxLayout();
|
||||||
@ -81,6 +94,7 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
|||||||
#endif // Q_OS_MAC
|
#endif // Q_OS_MAC
|
||||||
QFormLayout *pageSetupLayout = new QFormLayout;
|
QFormLayout *pageSetupLayout = new QFormLayout;
|
||||||
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
|
pageSetupLayout->addRow(tr("Page size:"), _paperSize);
|
||||||
|
pageSetupLayout->addRow(tr("Resolution:"), _resolution);
|
||||||
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
|
pageSetupLayout->addRow(tr("Orientation:"), orientationLayout);
|
||||||
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
|
pageSetupLayout->addRow(tr("Margins:"), marginsLayout);
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@ -161,9 +175,11 @@ void ExportDialog::accept()
|
|||||||
? QPrinter::Portrait : QPrinter::Landscape;
|
? QPrinter::Portrait : QPrinter::Landscape;
|
||||||
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
QPrinter::PaperSize paperSize = static_cast<QPrinter::PaperSize>
|
||||||
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
(_paperSize->itemData(_paperSize->currentIndex()).toInt());
|
||||||
|
int resolution = _resolution->itemData(_resolution->currentIndex()).toInt();
|
||||||
|
|
||||||
_export->fileName = _fileSelect->file();
|
_export->fileName = _fileSelect->file();
|
||||||
_export->paperSize = paperSize;
|
_export->paperSize = paperSize;
|
||||||
|
_export->resolution = resolution;
|
||||||
_export->orientation = orientation;
|
_export->orientation = orientation;
|
||||||
if (_export->units == Imperial)
|
if (_export->units == Imperial)
|
||||||
_export->margins = MarginsF(_leftMargin->value() / MM2IN,
|
_export->margins = MarginsF(_leftMargin->value() / MM2IN,
|
||||||
|
@ -16,6 +16,7 @@ struct Export {
|
|||||||
QPrinter::PaperSize paperSize;
|
QPrinter::PaperSize paperSize;
|
||||||
QPrinter::Orientation orientation;
|
QPrinter::Orientation orientation;
|
||||||
MarginsF margins;
|
MarginsF margins;
|
||||||
|
int resolution;
|
||||||
|
|
||||||
Units units;
|
Units units;
|
||||||
};
|
};
|
||||||
@ -37,6 +38,7 @@ private:
|
|||||||
|
|
||||||
FileSelectWidget *_fileSelect;
|
FileSelectWidget *_fileSelect;
|
||||||
QComboBox *_paperSize;
|
QComboBox *_paperSize;
|
||||||
|
QComboBox *_resolution;
|
||||||
QRadioButton *_portrait;
|
QRadioButton *_portrait;
|
||||||
QRadioButton *_landscape;
|
QRadioButton *_landscape;
|
||||||
QDoubleSpinBox *_topMargin;
|
QDoubleSpinBox *_topMargin;
|
||||||
|
@ -10,8 +10,7 @@ const quint32 FIT_MAGIC = 0x5449462E; // .FIT
|
|||||||
#define TIMESTAMP_FIELD 253
|
#define TIMESTAMP_FIELD 253
|
||||||
|
|
||||||
|
|
||||||
FITParser::FITParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
FITParser::FITParser()
|
||||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
|
||||||
{
|
{
|
||||||
memset(_defs, 0, sizeof(_defs));
|
memset(_defs, 0, sizeof(_defs));
|
||||||
|
|
||||||
@ -36,8 +35,7 @@ void FITParser::clearDefinitions()
|
|||||||
void FITParser::warning(const char *text) const
|
void FITParser::warning(const char *text) const
|
||||||
{
|
{
|
||||||
const QFile *file = static_cast<QFile *>(_device);
|
const QFile *file = static_cast<QFile *>(_device);
|
||||||
fprintf(stderr, "%s:%d: %s\n", qPrintable(file->fileName()),
|
qWarning("%s:%d: %s\n", qPrintable(file->fileName()), _len, text);
|
||||||
_len, text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::readData(char *data, size_t size)
|
bool FITParser::readData(char *data, size_t size)
|
||||||
@ -192,7 +190,8 @@ bool FITParser::readField(Field *f, quint32 &val)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseData(MessageDefinition *def, quint8 offset)
|
bool FITParser::parseData(TrackData &track, MessageDefinition *def,
|
||||||
|
quint8 offset)
|
||||||
{
|
{
|
||||||
Field *field;
|
Field *field;
|
||||||
quint32 timestamp = _timestamp + offset;
|
quint32 timestamp = _timestamp + offset;
|
||||||
@ -269,7 +268,7 @@ bool FITParser::parseData(MessageDefinition *def, quint8 offset)
|
|||||||
if (trackpoint.coordinates().isValid()) {
|
if (trackpoint.coordinates().isValid()) {
|
||||||
trackpoint.setTimestamp(QDateTime::fromTime_t(timestamp
|
trackpoint.setTimestamp(QDateTime::fromTime_t(timestamp
|
||||||
+ 631065600));
|
+ 631065600));
|
||||||
_tracks.last().append(trackpoint);
|
track.append(trackpoint);
|
||||||
} else {
|
} else {
|
||||||
if (trackpoint.coordinates().isNull())
|
if (trackpoint.coordinates().isNull())
|
||||||
warning("Missing coordinates");
|
warning("Missing coordinates");
|
||||||
@ -283,21 +282,21 @@ bool FITParser::parseData(MessageDefinition *def, quint8 offset)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseDataMessage(quint8 header)
|
bool FITParser::parseDataMessage(TrackData &track, quint8 header)
|
||||||
{
|
{
|
||||||
int local_id = header & 0xf;
|
int local_id = header & 0xf;
|
||||||
MessageDefinition* def = &_defs[local_id];
|
MessageDefinition* def = &_defs[local_id];
|
||||||
return parseData(def, 0);
|
return parseData(track, def, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseCompressedMessage(quint8 header)
|
bool FITParser::parseCompressedMessage(TrackData &track, quint8 header)
|
||||||
{
|
{
|
||||||
int local_id = (header >> 5) & 3;
|
int local_id = (header >> 5) & 3;
|
||||||
MessageDefinition* def = &_defs[local_id];
|
MessageDefinition* def = &_defs[local_id];
|
||||||
return parseData(def, header & 0x1f);
|
return parseData(track, def, header & 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseRecord()
|
bool FITParser::parseRecord(TrackData &track)
|
||||||
{
|
{
|
||||||
quint8 header;
|
quint8 header;
|
||||||
|
|
||||||
@ -305,11 +304,11 @@ bool FITParser::parseRecord()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (header & 0x80)
|
if (header & 0x80)
|
||||||
return parseCompressedMessage(header);
|
return parseCompressedMessage(track, header);
|
||||||
else if (header & 0x40)
|
else if (header & 0x40)
|
||||||
return parseDefinitionMessage(header);
|
return parseDefinitionMessage(header);
|
||||||
else
|
else
|
||||||
return parseDataMessage(header);
|
return parseDataMessage(track, header);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::parseHeader()
|
bool FITParser::parseHeader()
|
||||||
@ -338,8 +337,11 @@ bool FITParser::parseHeader()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FITParser::loadFile(QFile *file)
|
bool FITParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(routes);
|
||||||
|
Q_UNUSED(waypoints);
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
_device = file;
|
_device = file;
|
||||||
@ -349,10 +351,11 @@ bool FITParser::loadFile(QFile *file)
|
|||||||
if (!parseHeader())
|
if (!parseHeader())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
_tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
|
TrackData &track = tracks.last();
|
||||||
|
|
||||||
while (_len)
|
while (_len)
|
||||||
if ((ret = parseRecord()) == false)
|
if ((ret = parseRecord(track)) == false)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
clearDefinitions();
|
clearDefinitions();
|
||||||
|
@ -6,37 +6,37 @@
|
|||||||
class FITParser : public Parser
|
class FITParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FITParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
FITParser();
|
||||||
QList<Waypoint> &waypoints);
|
|
||||||
~FITParser() {}
|
~FITParser() {}
|
||||||
|
|
||||||
bool loadFile(QFile *file);
|
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return 0;}
|
int errorLine() const {return 0;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef struct {
|
struct FileHeader {
|
||||||
quint8 headerSize;
|
quint8 headerSize;
|
||||||
quint8 protocolVersion;
|
quint8 protocolVersion;
|
||||||
quint16 profileVersion;
|
quint16 profileVersion;
|
||||||
quint32 dataSize;
|
quint32 dataSize;
|
||||||
quint32 magic;
|
quint32 magic;
|
||||||
} FileHeader;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct Field {
|
||||||
quint8 id;
|
quint8 id;
|
||||||
quint8 size;
|
quint8 size;
|
||||||
quint8 type;
|
quint8 type;
|
||||||
} Field;
|
};
|
||||||
|
|
||||||
typedef struct {
|
struct MessageDefinition {
|
||||||
quint8 endian;
|
quint8 endian;
|
||||||
quint16 globalId;
|
quint16 globalId;
|
||||||
quint8 numFields;
|
quint8 numFields;
|
||||||
Field *fields;
|
Field *fields;
|
||||||
quint8 numDevFields;
|
quint8 numDevFields;
|
||||||
Field *devFields;
|
Field *devFields;
|
||||||
} MessageDefinition;
|
};
|
||||||
|
|
||||||
|
|
||||||
void warning(const char *text) const;
|
void warning(const char *text) const;
|
||||||
@ -47,11 +47,11 @@ private:
|
|||||||
bool skipValue(size_t size);
|
bool skipValue(size_t size);
|
||||||
|
|
||||||
bool parseHeader();
|
bool parseHeader();
|
||||||
bool parseRecord();
|
bool parseRecord(TrackData &track);
|
||||||
bool parseDefinitionMessage(quint8 header);
|
bool parseDefinitionMessage(quint8 header);
|
||||||
bool parseCompressedMessage(quint8 header);
|
bool parseCompressedMessage(TrackData &track, quint8 header);
|
||||||
bool parseDataMessage(quint8 header);
|
bool parseDataMessage(TrackData &track, quint8 header);
|
||||||
bool parseData(MessageDefinition *def, quint8 offset);
|
bool parseData(TrackData &track, MessageDefinition *def, quint8 offset);
|
||||||
bool readField(Field *f, quint32 &val);
|
bool readField(Field *f, quint32 &val);
|
||||||
|
|
||||||
QIODevice *_device;
|
QIODevice *_device;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "coordinates.h"
|
#include "coordinates.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
|
||||||
QString Format::timeSpan(qreal time)
|
QString Format::timeSpan(qreal time, bool full)
|
||||||
{
|
{
|
||||||
unsigned h, m, s;
|
unsigned h, m, s;
|
||||||
|
|
||||||
@ -10,8 +10,12 @@ QString Format::timeSpan(qreal time)
|
|||||||
m = (time - (h * 3600)) / 60;
|
m = (time - (h * 3600)) / 60;
|
||||||
s = time - (h * 3600) - (m * 60);
|
s = time - (h * 3600) - (m * 60);
|
||||||
|
|
||||||
return QString("%1:%2:%3").arg(h).arg(m, 2, 10, QChar('0'))
|
if (full || h)
|
||||||
.arg(s, 2, 10, QChar('0'));
|
return QString("%1:%2:%3").arg(h, 2, 10, QChar('0'))
|
||||||
|
.arg(m, 2, 10, QChar('0')).arg(s, 2, 10, QChar('0'));
|
||||||
|
else
|
||||||
|
return QString("%1:%2").arg(m, 2, 10, QChar('0'))
|
||||||
|
.arg(s, 2, 10, QChar('0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Format::distance(qreal value, Units units)
|
QString Format::distance(qreal value, Units units)
|
||||||
|
@ -8,7 +8,7 @@ class Coordinates;
|
|||||||
|
|
||||||
namespace Format
|
namespace Format
|
||||||
{
|
{
|
||||||
QString timeSpan(qreal time);
|
QString timeSpan(qreal time, bool full = true);
|
||||||
QString distance(qreal value, Units units);
|
QString distance(qreal value, Units units);
|
||||||
QString elevation(qreal value, Units units);
|
QString elevation(qreal value, Units units);
|
||||||
QString coordinates(const Coordinates &value);
|
QString coordinates(const Coordinates &value);
|
||||||
|
@ -167,39 +167,36 @@ void GPXParser::track(TrackData &track)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::gpx()
|
void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
|
QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "trk") {
|
if (_reader.name() == "trk") {
|
||||||
_tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
track(_tracks.back());
|
track(tracks.back());
|
||||||
} else if (_reader.name() == "rte") {
|
} else if (_reader.name() == "rte") {
|
||||||
_routes.append(RouteData());
|
routes.append(RouteData());
|
||||||
routepoints(_routes.back());
|
routepoints(routes.back());
|
||||||
} else if (_reader.name() == "wpt") {
|
} else if (_reader.name() == "wpt") {
|
||||||
_waypoints.append(Waypoint(coordinates()));
|
waypoints.append(Waypoint(coordinates()));
|
||||||
waypointData(_waypoints.last());
|
waypointData(waypoints.last());
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPXParser::parse()
|
bool GPXParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
_reader.clear();
|
||||||
|
_reader.setDevice(file);
|
||||||
|
|
||||||
if (_reader.readNextStartElement()) {
|
if (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "gpx")
|
if (_reader.name() == "gpx")
|
||||||
gpx();
|
gpx(tracks, routes, waypoints);
|
||||||
else
|
else
|
||||||
_reader.raiseError("Not a GPX file");
|
_reader.raiseError("Not a GPX file");
|
||||||
}
|
}
|
||||||
|
|
||||||
return !_reader.error();
|
return !_reader.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GPXParser::loadFile(QFile *file)
|
|
||||||
{
|
|
||||||
_reader.clear();
|
|
||||||
_reader.setDevice(file);
|
|
||||||
|
|
||||||
return parse();
|
|
||||||
}
|
|
||||||
|
@ -8,17 +8,16 @@
|
|||||||
class GPXParser : public Parser
|
class GPXParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GPXParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
|
||||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
|
||||||
~GPXParser() {}
|
~GPXParser() {}
|
||||||
|
|
||||||
bool loadFile(QFile *file);
|
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parse();
|
void gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||||
void gpx();
|
QList<Waypoint> &waypoints);
|
||||||
void track(TrackData &track);
|
void track(TrackData &track);
|
||||||
void trackpoints(TrackData &track);
|
void trackpoints(TrackData &track);
|
||||||
void routepoints(RouteData &route);
|
void routepoints(RouteData &route);
|
||||||
|
@ -4,6 +4,5 @@ QDebug operator<<(QDebug dbg, const GraphPoint &point)
|
|||||||
{
|
{
|
||||||
dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", "
|
dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", "
|
||||||
<< point.y() << ")";
|
<< point.y() << ")";
|
||||||
|
return dbg.space();
|
||||||
return dbg.maybeSpace();
|
|
||||||
}
|
}
|
||||||
|
18
src/graph.h
18
src/graph.h
@ -31,22 +31,6 @@ private:
|
|||||||
Q_DECLARE_TYPEINFO(GraphPoint, Q_PRIMITIVE_TYPE);
|
Q_DECLARE_TYPEINFO(GraphPoint, Q_PRIMITIVE_TYPE);
|
||||||
QDebug operator<<(QDebug dbg, const GraphPoint &point);
|
QDebug operator<<(QDebug dbg, const GraphPoint &point);
|
||||||
|
|
||||||
|
typedef QVector<GraphPoint> Graph;
|
||||||
class Graph : public QVector<GraphPoint>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Graph() : QVector<GraphPoint>() {_time = true;}
|
|
||||||
void append(const GraphPoint &p)
|
|
||||||
{
|
|
||||||
if (std::isnan(p.t()))
|
|
||||||
_time = false;
|
|
||||||
QVector<GraphPoint>::append(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasTime() const {return _time;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool _time;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // GRAPH_H
|
#endif // GRAPH_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
|
||||||
GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
GraphItem::GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent)
|
||||||
: QGraphicsObject(parent)
|
: QGraphicsObject(parent)
|
||||||
{
|
{
|
||||||
_id = 0;
|
_id = 0;
|
||||||
@ -10,14 +10,32 @@ GraphItem::GraphItem(const Graph &graph, QGraphicsItem *parent)
|
|||||||
|
|
||||||
_pen = QPen(Qt::black, _width);
|
_pen = QPen(Qt::black, _width);
|
||||||
|
|
||||||
_type = Distance;
|
_type = type;
|
||||||
_graph = graph;
|
_graph = graph;
|
||||||
_sx = 1.0; _sy = 1.0;
|
_sx = 1.0; _sy = 1.0;
|
||||||
|
|
||||||
|
_time = true;
|
||||||
|
for (int i = 0; i < _graph.size(); i++) {
|
||||||
|
if (std::isnan(_graph.at(i).t())) {
|
||||||
|
_time = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setZValue(1.0);
|
setZValue(1.0);
|
||||||
|
|
||||||
updatePath();
|
updatePath();
|
||||||
|
updateShape();
|
||||||
updateBounds();
|
updateBounds();
|
||||||
|
|
||||||
|
setAcceptHoverEvents(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::updateShape()
|
||||||
|
{
|
||||||
|
QPainterPathStroker s;
|
||||||
|
s.setWidth(_width + 1);
|
||||||
|
_shape = s.createStroke(_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
@ -38,25 +56,37 @@ void GraphItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
void GraphItem::setGraphType(GraphType type)
|
void GraphItem::setGraphType(GraphType type)
|
||||||
{
|
{
|
||||||
|
if (type == _type)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_type = type;
|
_type = type;
|
||||||
updatePath();
|
updatePath();
|
||||||
|
updateShape();
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::setColor(const QColor &color)
|
void GraphItem::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
|
if (_pen.color() == color)
|
||||||
|
return;
|
||||||
|
|
||||||
_pen.setColor(color);
|
_pen.setColor(color);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::setWidth(int width)
|
void GraphItem::setWidth(int width)
|
||||||
{
|
{
|
||||||
|
if (width == _width)
|
||||||
|
return;
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
_width = width;
|
_width = width;
|
||||||
_pen.setWidth(width);
|
_pen.setWidth(width);
|
||||||
|
|
||||||
|
updateShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal GraphItem::yAtX(qreal x)
|
qreal GraphItem::yAtX(qreal x)
|
||||||
@ -124,7 +154,7 @@ qreal GraphItem::distanceAtTime(qreal time)
|
|||||||
void GraphItem::emitSliderPositionChanged(qreal pos)
|
void GraphItem::emitSliderPositionChanged(qreal pos)
|
||||||
{
|
{
|
||||||
if (_type == Time) {
|
if (_type == Time) {
|
||||||
if (_graph.hasTime()) {
|
if (_time) {
|
||||||
if (pos >= _graph.first().t() && pos <= _graph.last().t())
|
if (pos >= _graph.first().t() && pos <= _graph.last().t())
|
||||||
emit sliderPositionChanged(distanceAtTime(pos));
|
emit sliderPositionChanged(distanceAtTime(pos));
|
||||||
else
|
else
|
||||||
@ -135,9 +165,9 @@ void GraphItem::emitSliderPositionChanged(qreal pos)
|
|||||||
emit sliderPositionChanged(pos);
|
emit sliderPositionChanged(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::selected(bool selected)
|
void GraphItem::hover(bool hover)
|
||||||
{
|
{
|
||||||
if (selected) {
|
if (hover) {
|
||||||
_pen.setWidth(_width + 1);
|
_pen.setWidth(_width + 1);
|
||||||
setZValue(zValue() + 1.0);
|
setZValue(zValue() + 1.0);
|
||||||
} else {
|
} else {
|
||||||
@ -157,13 +187,14 @@ void GraphItem::setScale(qreal sx, qreal sy)
|
|||||||
|
|
||||||
_sx = sx; _sy = sy;
|
_sx = sx; _sy = sy;
|
||||||
updatePath();
|
updatePath();
|
||||||
|
updateShape();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphItem::updatePath()
|
void GraphItem::updatePath()
|
||||||
{
|
{
|
||||||
_path = QPainterPath();
|
_path = QPainterPath();
|
||||||
|
|
||||||
if (_type == Time && !_graph.hasTime())
|
if (_type == Time && !_time)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
|
_path.moveTo(_graph.first().x(_type) * _sx, -_graph.first().y() * _sy);
|
||||||
@ -173,7 +204,7 @@ void GraphItem::updatePath()
|
|||||||
|
|
||||||
void GraphItem::updateBounds()
|
void GraphItem::updateBounds()
|
||||||
{
|
{
|
||||||
if (_type == Time && !_graph.hasTime()) {
|
if (_type == Time && !_time) {
|
||||||
_bounds = QRectF();
|
_bounds = QRectF();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -191,3 +222,25 @@ void GraphItem::updateBounds()
|
|||||||
|
|
||||||
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
|
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
_pen.setWidthF(_width + 1);
|
||||||
|
setZValue(zValue() + 1.0);
|
||||||
|
update();
|
||||||
|
|
||||||
|
emit selected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
_pen.setWidthF(_width);
|
||||||
|
setZValue(zValue() - 1.0);
|
||||||
|
update();
|
||||||
|
|
||||||
|
emit selected(false);
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsObject>
|
#include <QGraphicsObject>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
#include "units.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
|
|
||||||
class GraphItem : public QGraphicsObject
|
class GraphItem : public QGraphicsObject
|
||||||
@ -10,34 +11,42 @@ class GraphItem : public QGraphicsObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphItem(const Graph &graph, QGraphicsItem *parent = 0);
|
GraphItem(const Graph &graph, GraphType type, QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
QRectF boundingRect() const
|
QPainterPath shape() const {return _shape;}
|
||||||
{return _path.boundingRect();}
|
QRectF boundingRect() const {return _shape.boundingRect();}
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
const QRectF &bounds() const {return _bounds;}
|
const QRectF &bounds() const {return _bounds;}
|
||||||
void setScale(qreal sx, qreal sy);
|
|
||||||
|
|
||||||
|
void setScale(qreal sx, qreal sy);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
int id() const {return _id;}
|
int id() const {return _id;}
|
||||||
void setId(int id) {_id = id;}
|
void setId(int id) {_id = id;}
|
||||||
void setColor(const QColor &color);
|
void setColor(const QColor &color);
|
||||||
void setWidth(int width);
|
void setWidth(int width);
|
||||||
|
virtual void setUnits(Units units) {Q_UNUSED(units);}
|
||||||
|
|
||||||
qreal yAtX(qreal x);
|
qreal yAtX(qreal x);
|
||||||
qreal distanceAtTime(qreal time);
|
qreal distanceAtTime(qreal time);
|
||||||
|
|
||||||
|
void redraw();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sliderPositionChanged(qreal);
|
void sliderPositionChanged(qreal);
|
||||||
|
void selected(bool);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void emitSliderPositionChanged(qreal);
|
void emitSliderPositionChanged(qreal);
|
||||||
void selected(bool selected);
|
void hover(bool hover);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
|
|
||||||
void updatePath();
|
void updatePath();
|
||||||
|
void updateShape();
|
||||||
void updateBounds();
|
void updateBounds();
|
||||||
|
|
||||||
int _id;
|
int _id;
|
||||||
@ -48,8 +57,11 @@ private:
|
|||||||
GraphType _type;
|
GraphType _type;
|
||||||
|
|
||||||
QPainterPath _path;
|
QPainterPath _path;
|
||||||
|
QPainterPath _shape;
|
||||||
QRectF _bounds;
|
QRectF _bounds;
|
||||||
qreal _sx, _sy;
|
qreal _sx, _sy;
|
||||||
|
|
||||||
|
bool _time;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHITEM_H
|
#endif // GRAPHITEM_H
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "timetype.h"
|
||||||
|
|
||||||
class Data;
|
class Data;
|
||||||
class PathItem;
|
class PathItem;
|
||||||
@ -18,10 +19,12 @@ public:
|
|||||||
|
|
||||||
virtual QString label() const = 0;
|
virtual QString label() const = 0;
|
||||||
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
virtual void loadData(const Data &data, const QList<PathItem *> &paths) = 0;
|
||||||
virtual void clear() = 0;
|
virtual void clear() {GraphView::clear();}
|
||||||
virtual void setUnits(enum Units units) = 0;
|
virtual void setUnits(enum Units units) {GraphView::setUnits(units);}
|
||||||
virtual void showTracks(bool show) = 0;
|
virtual void setGraphType(GraphType type) {GraphView::setGraphType(type);}
|
||||||
virtual void showRoutes(bool show) = 0;
|
virtual void setTimeType(enum TimeType type) {Q_UNUSED(type)}
|
||||||
|
virtual void showTracks(bool show) {Q_UNUSED(show)}
|
||||||
|
virtual void showRoutes(bool show) {Q_UNUSED(show)}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHTAB_H
|
#endif // GRAPHTAB_H
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QPaintDevice>
|
#include <QPaintDevice>
|
||||||
#include <QSysInfo>
|
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "axisitem.h"
|
#include "axisitem.h"
|
||||||
@ -14,6 +13,7 @@
|
|||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "graphitem.h"
|
#include "graphitem.h"
|
||||||
#include "pathitem.h"
|
#include "pathitem.h"
|
||||||
|
#include "format.h"
|
||||||
#include "graphview.h"
|
#include "graphview.h"
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ GraphView::GraphView(QWidget *parent)
|
|||||||
_scene = new QGraphicsScene(this);
|
_scene = new QGraphicsScene(this);
|
||||||
setScene(_scene);
|
setScene(_scene);
|
||||||
|
|
||||||
|
setBackgroundBrush(QBrush(Qt::white));
|
||||||
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
||||||
setRenderHint(QPainter::Antialiasing, true);
|
setRenderHint(QPainter::Antialiasing, true);
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
@ -139,7 +140,13 @@ void GraphView::setXUnits()
|
|||||||
void GraphView::setUnits(Units units)
|
void GraphView::setUnits(Units units)
|
||||||
{
|
{
|
||||||
_units = units;
|
_units = units;
|
||||||
|
|
||||||
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
|
_graphs.at(i)->setUnits(units);
|
||||||
|
|
||||||
setXUnits();
|
setXUnits();
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::setGraphType(GraphType type)
|
void GraphView::setGraphType(GraphType type)
|
||||||
@ -167,29 +174,31 @@ void GraphView::showGrid(bool show)
|
|||||||
_grid->setVisible(show);
|
_grid->setVisible(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::loadGraph(const Graph &graph, PathItem *path, int id)
|
void GraphView::showSliderInfo(bool show)
|
||||||
{
|
{
|
||||||
if (graph.size() < 2)
|
_sliderInfo->setVisible(show);
|
||||||
return;
|
}
|
||||||
|
|
||||||
GraphItem *gi = new GraphItem(graph);
|
void GraphView::addGraph(GraphItem *graph, PathItem *path, int id)
|
||||||
gi->setGraphType(_graphType);
|
{
|
||||||
gi->setId(id);
|
graph->setUnits(_units);
|
||||||
gi->setColor(_palette.nextColor());
|
graph->setId(id);
|
||||||
gi->setWidth(_width);
|
graph->setColor(_palette.nextColor());
|
||||||
|
graph->setWidth(_width);
|
||||||
|
|
||||||
connect(this, SIGNAL(sliderPositionChanged(qreal)), gi,
|
connect(this, SIGNAL(sliderPositionChanged(qreal)), graph,
|
||||||
SLOT(emitSliderPositionChanged(qreal)));
|
SLOT(emitSliderPositionChanged(qreal)));
|
||||||
connect(gi, SIGNAL(sliderPositionChanged(qreal)), path,
|
connect(graph, SIGNAL(sliderPositionChanged(qreal)), path,
|
||||||
SLOT(moveMarker(qreal)));
|
SLOT(moveMarker(qreal)));
|
||||||
connect(path, SIGNAL(selected(bool)), gi, SLOT(selected(bool)));
|
connect(path, SIGNAL(selected(bool)), graph, SLOT(hover(bool)));
|
||||||
|
connect(graph, SIGNAL(selected(bool)), path, SLOT(hover(bool)));
|
||||||
|
|
||||||
_graphs.append(gi);
|
_graphs.append(graph);
|
||||||
|
|
||||||
if (!_hide.contains(id)) {
|
if (!_hide.contains(id)) {
|
||||||
_visible.append(gi);
|
_visible.append(graph);
|
||||||
_scene->addItem(gi);
|
_scene->addItem(graph);
|
||||||
_bounds |= gi->bounds();
|
_bounds |= graph->bounds();
|
||||||
setXUnits();
|
setXUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,11 +236,6 @@ void GraphView::showGraph(bool show, int id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::redraw()
|
|
||||||
{
|
|
||||||
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF GraphView::bounds() const
|
QRectF GraphView::bounds() const
|
||||||
{
|
{
|
||||||
QRectF br(_bounds);
|
QRectF br(_bounds);
|
||||||
@ -239,6 +243,11 @@ QRectF GraphView::bounds() const
|
|||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::redraw()
|
||||||
|
{
|
||||||
|
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::redraw(const QSizeF &size)
|
void GraphView::redraw(const QSizeF &size)
|
||||||
{
|
{
|
||||||
QRectF r;
|
QRectF r;
|
||||||
@ -326,11 +335,9 @@ void GraphView::mousePressEvent(QMouseEvent *e)
|
|||||||
QGraphicsView::mousePressEvent(e);
|
QGraphicsView::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::plot(QPainter *painter, const QRectF &target)
|
void GraphView::plot(QPainter *painter, const QRectF &target, qreal scale)
|
||||||
{
|
{
|
||||||
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
QSizeF canvas = QSizeF(target.width() / scale, target.height() / scale);
|
||||||
/ SCREEN_DPI;
|
|
||||||
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
|
||||||
|
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
redraw(canvas);
|
redraw(canvas);
|
||||||
@ -374,22 +381,26 @@ void GraphView::updateSliderPosition()
|
|||||||
_slider->setVisible(false);
|
_slider->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSliderInfo();
|
if (_slider->isVisible())
|
||||||
|
updateSliderInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::updateSliderInfo()
|
void GraphView::updateSliderInfo()
|
||||||
{
|
{
|
||||||
_sliderInfo->setVisible(_visible.count() == 1);
|
qreal r, y;
|
||||||
if (!_sliderInfo->isVisible())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QRectF br(_visible.first()->bounds());
|
if (_visible.count() > 1) {
|
||||||
if (br.height() < _minYRange)
|
r = 0;
|
||||||
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
y = 0;
|
||||||
_minYRange/2 - br.height()/2);
|
} else {
|
||||||
|
QRectF br(_visible.first()->bounds());
|
||||||
|
if (br.height() < _minYRange)
|
||||||
|
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
||||||
|
_minYRange/2 - br.height()/2);
|
||||||
|
|
||||||
qreal y = _visible.first()->yAtX(_sliderPos);
|
y = _visible.first()->yAtX(_sliderPos);
|
||||||
qreal r = (y - br.bottom()) / br.height();
|
r = (y - br.bottom()) / br.height();
|
||||||
|
}
|
||||||
|
|
||||||
qreal pos = (_sliderPos / bounds().width()) * _slider->area().width();
|
qreal pos = (_sliderPos / bounds().width()) * _slider->area().width();
|
||||||
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
||||||
@ -397,8 +408,11 @@ void GraphView::updateSliderInfo()
|
|||||||
|
|
||||||
_sliderInfo->setSide(s);
|
_sliderInfo->setSide(s);
|
||||||
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
||||||
_sliderInfo->setText(QString::number(-y * _yScale + _yOffset, 'f',
|
_sliderInfo->setText(_graphType == Time ? Format::timeSpan(_sliderPos,
|
||||||
_precision));
|
bounds().width() > 3600) : QString::number(_sliderPos * _xScale, 'f', 1)
|
||||||
|
+ UNIT_SPACE + _xUnits, (_visible.count() > 1) ? QString()
|
||||||
|
: QString::number(-y * _yScale + _yOffset, 'f', _precision) + UNIT_SPACE
|
||||||
|
+ _yUnits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
||||||
@ -454,15 +468,19 @@ void GraphView::setGraphWidth(int width)
|
|||||||
|
|
||||||
for (int i = 0; i < _graphs.count(); i++)
|
for (int i = 0; i < _graphs.count(); i++)
|
||||||
_graphs.at(i)->setWidth(width);
|
_graphs.at(i)->setWidth(width);
|
||||||
|
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphView::useOpenGL(bool use)
|
void GraphView::useOpenGL(bool use)
|
||||||
{
|
{
|
||||||
if (use) {
|
if (use)
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
|
|
||||||
#endif // Q_OS_WIN32
|
|
||||||
setViewport(new OPENGL_WIDGET);
|
setViewport(new OPENGL_WIDGET);
|
||||||
} else
|
else
|
||||||
setViewport(new QWidget);
|
setViewport(new QWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::useAntiAliasing(bool use)
|
||||||
|
{
|
||||||
|
setRenderHint(QPainter::Antialiasing, use);
|
||||||
|
}
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
#include "graph.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
#include "graph.h"
|
|
||||||
|
|
||||||
|
|
||||||
class AxisItem;
|
class AxisItem;
|
||||||
@ -25,18 +25,29 @@ public:
|
|||||||
GraphView(QWidget *parent = 0);
|
GraphView(QWidget *parent = 0);
|
||||||
~GraphView();
|
~GraphView();
|
||||||
|
|
||||||
void loadGraph(const Graph &graph, PathItem *path, int id = 0);
|
bool isEmpty() const {return _graphs.isEmpty();}
|
||||||
int count() const {return _graphs.count();}
|
|
||||||
void redraw();
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
void plot(QPainter *painter, const QRectF &target, qreal scale);
|
||||||
|
|
||||||
|
void setPalette(const Palette &palette);
|
||||||
|
void setGraphWidth(int width);
|
||||||
|
void showGrid(bool show);
|
||||||
|
void showSliderInfo(bool show);
|
||||||
|
void useOpenGL(bool use);
|
||||||
|
void useAntiAliasing(bool use);
|
||||||
|
|
||||||
|
void setSliderPosition(qreal pos);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sliderPositionChanged(qreal);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void addGraph(GraphItem *graph, PathItem *path, int id = 0);
|
||||||
|
|
||||||
void showGraph(bool show, int id = 0);
|
void showGraph(bool show, int id = 0);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
void showGrid(bool show);
|
|
||||||
|
|
||||||
void setPalette(const Palette &palette);
|
|
||||||
void setGraphWidth(int width);
|
|
||||||
|
|
||||||
const QString &yLabel() const {return _yLabel;}
|
const QString &yLabel() const {return _yLabel;}
|
||||||
const QString &yUnits() const {return _yUnits;}
|
const QString &yUnits() const {return _yUnits;}
|
||||||
@ -50,23 +61,16 @@ public:
|
|||||||
void setSliderPrecision(int precision) {_precision = precision;}
|
void setSliderPrecision(int precision) {_precision = precision;}
|
||||||
void setMinYRange(qreal range) {_minYRange = range;}
|
void setMinYRange(qreal range) {_minYRange = range;}
|
||||||
|
|
||||||
qreal sliderPosition() const {return _sliderPos;}
|
|
||||||
void setSliderPosition(qreal pos);
|
|
||||||
|
|
||||||
void plot(QPainter *painter, const QRectF &target);
|
|
||||||
|
|
||||||
void useOpenGL(bool use);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void sliderPositionChanged(qreal);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QRectF bounds() const;
|
QRectF bounds() const;
|
||||||
|
void redraw();
|
||||||
void redraw(const QSizeF &size);
|
void redraw(const QSizeF &size);
|
||||||
void addInfo(const QString &key, const QString &value);
|
void addInfo(const QString &key, const QString &value);
|
||||||
void clearInfo();
|
void clearInfo();
|
||||||
void skipColor() {_palette.nextColor();}
|
void skipColor() {_palette.nextColor();}
|
||||||
|
|
||||||
|
QList<GraphItem*> _graphs;
|
||||||
|
GraphType _graphType;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void emitSliderPositionChanged(const QPointF &pos);
|
void emitSliderPositionChanged(const QPointF &pos);
|
||||||
void newSliderPosition(const QPointF &pos);
|
void newSliderPosition(const QPointF &pos);
|
||||||
@ -83,6 +87,7 @@ private:
|
|||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
Units _units;
|
||||||
qreal _xScale, _yScale;
|
qreal _xScale, _yScale;
|
||||||
qreal _yOffset;
|
qreal _yOffset;
|
||||||
QString _xUnits, _yUnits;
|
QString _xUnits, _yUnits;
|
||||||
@ -99,15 +104,11 @@ private:
|
|||||||
InfoItem *_info;
|
InfoItem *_info;
|
||||||
GridItem *_grid;
|
GridItem *_grid;
|
||||||
|
|
||||||
QList<GraphItem*> _graphs;
|
|
||||||
QList<GraphItem*> _visible;
|
QList<GraphItem*> _visible;
|
||||||
QSet<int> _hide;
|
QSet<int> _hide;
|
||||||
QRectF _bounds;
|
QRectF _bounds;
|
||||||
Palette _palette;
|
Palette _palette;
|
||||||
int _width;
|
int _width;
|
||||||
|
|
||||||
Units _units;
|
|
||||||
GraphType _graphType;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHVIEW_H
|
#endif // GRAPHVIEW_H
|
||||||
|
698
src/gui.cpp
698
src/gui.cpp
File diff suppressed because it is too large
Load Diff
33
src/gui.h
33
src/gui.h
@ -7,11 +7,13 @@
|
|||||||
#include <QDate>
|
#include <QDate>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "timetype.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "poi.h"
|
#include "poi.h"
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
#include "optionsdialog.h"
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
|
|
||||||
class QMenu;
|
class QMenu;
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
@ -24,13 +26,14 @@ class FileBrowser;
|
|||||||
class GraphTab;
|
class GraphTab;
|
||||||
class PathView;
|
class PathView;
|
||||||
class Map;
|
class Map;
|
||||||
|
class MapList;
|
||||||
|
|
||||||
class GUI : public QMainWindow
|
class GUI : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GUI(QWidget *parent = 0);
|
GUI();
|
||||||
~GUI();
|
~GUI();
|
||||||
|
|
||||||
bool openFile(const QString &fileName);
|
bool openFile(const QString &fileName);
|
||||||
@ -46,14 +49,14 @@ private slots:
|
|||||||
void reloadFile();
|
void reloadFile();
|
||||||
void openPOIFile();
|
void openPOIFile();
|
||||||
void closePOIFiles();
|
void closePOIFiles();
|
||||||
void showMap(bool show);
|
|
||||||
void showGraphs(bool show);
|
void showGraphs(bool show);
|
||||||
void showGraphGrids(bool show);
|
void showGraphGrids(bool show);
|
||||||
|
void showGraphSliderInfo(bool show);
|
||||||
void showToolbars(bool show);
|
void showToolbars(bool show);
|
||||||
void showFullscreen(bool show);
|
void showFullscreen(bool show);
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show);
|
void showRoutes(bool show);
|
||||||
void clearMapCache();
|
void loadMap();
|
||||||
void nextMap();
|
void nextMap();
|
||||||
void prevMap();
|
void prevMap();
|
||||||
void openOptions();
|
void openOptions();
|
||||||
@ -67,6 +70,8 @@ private slots:
|
|||||||
void last();
|
void last();
|
||||||
void first();
|
void first();
|
||||||
|
|
||||||
|
void setTotalTime() {setTimeType(Total);}
|
||||||
|
void setMovingTime() {setTimeType(Moving);}
|
||||||
void setMetricUnits() {setUnits(Metric);}
|
void setMetricUnits() {setUnits(Metric);}
|
||||||
void setImperialUnits() {setUnits(Imperial);}
|
void setImperialUnits() {setUnits(Imperial);}
|
||||||
void setDistanceGraph() {setGraphType(Distance);}
|
void setDistanceGraph() {setGraphType(Distance);}
|
||||||
@ -77,6 +82,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
typedef QPair<QDate, QDate> DateRange;
|
typedef QPair<QDate, QDate> DateRange;
|
||||||
|
|
||||||
|
void loadDatums();
|
||||||
void loadMaps();
|
void loadMaps();
|
||||||
void loadPOIs();
|
void loadPOIs();
|
||||||
void closeFiles();
|
void closeFiles();
|
||||||
@ -102,17 +108,19 @@ private:
|
|||||||
void updateGraphTabs();
|
void updateGraphTabs();
|
||||||
void updatePathView();
|
void updatePathView();
|
||||||
|
|
||||||
|
TimeType timeType() const;
|
||||||
|
Units units() const;
|
||||||
|
void setTimeType(TimeType type);
|
||||||
void setUnits(Units units);
|
void setUnits(Units units);
|
||||||
void setGraphType(GraphType type);
|
void setGraphType(GraphType type);
|
||||||
|
|
||||||
qreal distance() const;
|
qreal distance() const;
|
||||||
qreal time() const;
|
qreal time() const;
|
||||||
|
qreal movingTime() const;
|
||||||
int mapIndex(const QString &name);
|
int mapIndex(const QString &name);
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
const QString fileFormats() const;
|
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
@ -122,9 +130,11 @@ private:
|
|||||||
QToolBar *_showToolBar;
|
QToolBar *_showToolBar;
|
||||||
QToolBar *_navigationToolBar;
|
QToolBar *_navigationToolBar;
|
||||||
QMenu *_poiFilesMenu;
|
QMenu *_poiFilesMenu;
|
||||||
|
QMenu *_mapMenu;
|
||||||
|
|
||||||
QActionGroup *_fileActionGroup;
|
QActionGroup *_fileActionGroup;
|
||||||
QActionGroup *_navigationActionGroup;
|
QActionGroup *_navigationActionGroup;
|
||||||
|
QActionGroup *_mapsActionGroup;
|
||||||
QAction *_exitAction;
|
QAction *_exitAction;
|
||||||
QAction *_keysAction;
|
QAction *_keysAction;
|
||||||
QAction *_dataSourcesAction;
|
QAction *_dataSourcesAction;
|
||||||
@ -142,9 +152,11 @@ private:
|
|||||||
QAction *_showPOILabelsAction;
|
QAction *_showPOILabelsAction;
|
||||||
QAction *_showMapAction;
|
QAction *_showMapAction;
|
||||||
QAction *_fullscreenAction;
|
QAction *_fullscreenAction;
|
||||||
|
QAction *_loadMapAction;
|
||||||
QAction *_clearMapCacheAction;
|
QAction *_clearMapCacheAction;
|
||||||
QAction *_showGraphsAction;
|
QAction *_showGraphsAction;
|
||||||
QAction *_showGraphGridAction;
|
QAction *_showGraphGridAction;
|
||||||
|
QAction *_showGraphSliderInfoAction;
|
||||||
QAction *_distanceGraphAction;
|
QAction *_distanceGraphAction;
|
||||||
QAction *_timeGraphAction;
|
QAction *_timeGraphAction;
|
||||||
QAction *_showToolbarsAction;
|
QAction *_showToolbarsAction;
|
||||||
@ -154,6 +166,8 @@ private:
|
|||||||
QAction *_firstAction;
|
QAction *_firstAction;
|
||||||
QAction *_metricUnitsAction;
|
QAction *_metricUnitsAction;
|
||||||
QAction *_imperialUnitsAction;
|
QAction *_imperialUnitsAction;
|
||||||
|
QAction *_totalTimeAction;
|
||||||
|
QAction *_movingTimeAction;
|
||||||
QAction *_nextMapAction;
|
QAction *_nextMapAction;
|
||||||
QAction *_prevMapAction;
|
QAction *_prevMapAction;
|
||||||
QAction *_showTracksAction;
|
QAction *_showTracksAction;
|
||||||
@ -162,10 +176,12 @@ private:
|
|||||||
QAction *_showWaypointLabelsAction;
|
QAction *_showWaypointLabelsAction;
|
||||||
QAction *_showRouteWaypointsAction;
|
QAction *_showRouteWaypointsAction;
|
||||||
QAction *_openOptionsAction;
|
QAction *_openOptionsAction;
|
||||||
|
QAction *_mapsEnd;
|
||||||
QList<QAction*> _mapActions;
|
QList<QAction*> _mapActions;
|
||||||
QList<QAction*> _poiFilesActions;
|
QList<QAction*> _poiFilesActions;
|
||||||
|
|
||||||
QSignalMapper *_poiFilesSM;
|
QSignalMapper *_poiFilesSignalMapper;
|
||||||
|
QSignalMapper *_mapsSignalMapper;
|
||||||
|
|
||||||
QLabel *_fileNameLabel;
|
QLabel *_fileNameLabel;
|
||||||
QLabel *_distanceLabel;
|
QLabel *_distanceLabel;
|
||||||
@ -176,18 +192,19 @@ private:
|
|||||||
QList<GraphTab*> _tabs;
|
QList<GraphTab*> _tabs;
|
||||||
|
|
||||||
POI *_poi;
|
POI *_poi;
|
||||||
QList<Map*> _maps;
|
MapList *_ml;
|
||||||
|
|
||||||
FileBrowser *_browser;
|
FileBrowser *_browser;
|
||||||
QList<QString> _files;
|
QList<QString> _files;
|
||||||
Map *_currentMap;
|
|
||||||
|
|
||||||
|
Map *_map;
|
||||||
int _trackCount;
|
int _trackCount;
|
||||||
int _routeCount;
|
int _routeCount;
|
||||||
int _waypointCount;
|
int _waypointCount;
|
||||||
qreal _trackDistance;
|
qreal _trackDistance;
|
||||||
qreal _routeDistance;
|
qreal _routeDistance;
|
||||||
qreal _time;
|
qreal _time;
|
||||||
|
qreal _movingTime;
|
||||||
DateRange _dateRange;
|
DateRange _dateRange;
|
||||||
QString _pathName;
|
QString _pathName;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
#include "heartrategraphitem.h"
|
||||||
#include "heartrategraph.h"
|
#include "heartrategraph.h"
|
||||||
|
|
||||||
|
|
||||||
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
HeartRateGraph::HeartRateGraph(QWidget *parent) : GraphTab(parent)
|
||||||
{
|
{
|
||||||
_units = Metric;
|
|
||||||
_showTracks = true;
|
_showTracks = true;
|
||||||
|
|
||||||
GraphView::setYUnits(tr("1/min"));
|
GraphView::setYUnits(tr("1/min"));
|
||||||
@ -28,21 +28,16 @@ void HeartRateGraph::loadData(const Data &data, const QList<PathItem *> &paths)
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < data.tracks().count(); i++) {
|
for (int i = 0; i < data.tracks().count(); i++) {
|
||||||
const Graph &graph = data.tracks().at(i)->heartRate();
|
const Graph &graph = data.tracks().at(i)->heartRate();
|
||||||
qreal sum = 0, w = 0;
|
|
||||||
|
|
||||||
if (graph.size() < 2) {
|
if (graph.size() < 2) {
|
||||||
skipColor();
|
skipColor();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 1; j < graph.size(); j++) {
|
HeartRateGraphItem *gi = new HeartRateGraphItem(graph, _graphType);
|
||||||
qreal ds = graph.at(j).s() - graph.at(j-1).s();
|
GraphView::addGraph(gi, paths.at(i));
|
||||||
sum += graph.at(j).y() * ds;
|
|
||||||
w += ds;
|
|
||||||
}
|
|
||||||
_avg.append(QPointF(data.tracks().at(i)->distance(), sum/w));
|
|
||||||
|
|
||||||
GraphView::loadGraph(graph, paths.at(i));
|
_avg.append(QPointF(data.tracks().at(i)->distance(), gi->avg()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < data.routes().count(); i++)
|
for (int i = 0; i < data.routes().count(); i++)
|
||||||
|
@ -13,9 +13,7 @@ public:
|
|||||||
QString label() const {return tr("Heart rate");}
|
QString label() const {return tr("Heart rate");}
|
||||||
void loadData(const Data &data, const QList<PathItem *> &paths);
|
void loadData(const Data &data, const QList<PathItem *> &paths);
|
||||||
void clear();
|
void clear();
|
||||||
void setUnits(enum Units) {}
|
|
||||||
void showTracks(bool show);
|
void showTracks(bool show);
|
||||||
void showRoutes(bool show) {Q_UNUSED(show);}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal avg() const;
|
qreal avg() const;
|
||||||
@ -24,7 +22,6 @@ private:
|
|||||||
|
|
||||||
QList<QPointF> _avg;
|
QList<QPointF> _avg;
|
||||||
|
|
||||||
enum Units _units;
|
|
||||||
bool _showTracks;
|
bool _showTracks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
26
src/heartrategraphitem.cpp
Normal file
26
src/heartrategraphitem.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#include "tooltip.h"
|
||||||
|
#include "heartrategraphitem.h"
|
||||||
|
|
||||||
|
HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent) : GraphItem(graph, type, parent)
|
||||||
|
{
|
||||||
|
qreal sum = 0;
|
||||||
|
|
||||||
|
for (int j = 1; j < graph.size(); j++)
|
||||||
|
sum += graph.at(j).y() * (graph.at(j).s() - graph.at(j-1).s());
|
||||||
|
_avg = sum/graph.last().s();
|
||||||
|
|
||||||
|
setToolTip(toolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString HeartRateGraphItem::toolTip() const
|
||||||
|
{
|
||||||
|
ToolTip tt;
|
||||||
|
|
||||||
|
tt.insert(tr("Maximum"), QString::number(max(), 'f', 0)
|
||||||
|
+ UNIT_SPACE + tr("1/min"));
|
||||||
|
tt.insert(tr("Average"), QString::number(avg(), 'f', 0)
|
||||||
|
+ UNIT_SPACE + tr("1/min"));
|
||||||
|
|
||||||
|
return tt.toString();
|
||||||
|
}
|
23
src/heartrategraphitem.h
Normal file
23
src/heartrategraphitem.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef HEARTRATEGRAPHITEM_H
|
||||||
|
#define HEARTRATEGRAPHITEM_H
|
||||||
|
|
||||||
|
#include "graphitem.h"
|
||||||
|
|
||||||
|
class HeartRateGraphItem : public GraphItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
HeartRateGraphItem(const Graph &graph, GraphType type,
|
||||||
|
QGraphicsItem *parent = 0);
|
||||||
|
|
||||||
|
qreal max() const {return -bounds().top();}
|
||||||
|
qreal avg() const {return _avg;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString toolTip() const;
|
||||||
|
|
||||||
|
qreal _avg;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HEARTRATEGRAPHITEM_H
|
@ -10,7 +10,7 @@
|
|||||||
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
#define CLOSE_FILE_ICON ":/icons/dialog-close.png"
|
||||||
#define SHOW_POI_ICON ":/icons/flag.png"
|
#define SHOW_POI_ICON ":/icons/flag.png"
|
||||||
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
#define SHOW_MAP_ICON ":/icons/applications-internet.png"
|
||||||
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line-stacked.png"
|
#define SHOW_GRAPHS_ICON ":/icons/office-chart-line.png"
|
||||||
#define QUIT_ICON ":/icons/application-exit.png"
|
#define QUIT_ICON ":/icons/application-exit.png"
|
||||||
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
#define RELOAD_FILE_ICON ":/icons/view-refresh.png"
|
||||||
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
#define NEXT_FILE_ICON ":/icons/arrow-right.png"
|
||||||
@ -24,5 +24,6 @@
|
|||||||
#define POI_ICON ":/icons/flag_48.png"
|
#define POI_ICON ":/icons/flag_48.png"
|
||||||
#define SYSTEM_ICON ":/icons/system-run.png"
|
#define SYSTEM_ICON ":/icons/system-run.png"
|
||||||
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
|
#define PRINT_EXPORT_ICON ":/icons/document-print-preview.png"
|
||||||
|
#define DATA_ICON ":/icons/view-filter.png"
|
||||||
|
|
||||||
#endif /* ICONS_H */
|
#endif /* ICONS_H */
|
||||||
|
@ -120,7 +120,7 @@ bool IGCParser::readHRecord(const char *line, int len)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IGCParser::readBRecord(const char *line, int len)
|
bool IGCParser::readBRecord(TrackData &track, const char *line, int len)
|
||||||
{
|
{
|
||||||
qreal lat, lon, ele;
|
qreal lat, lon, ele;
|
||||||
QTime time;
|
QTime time;
|
||||||
@ -156,12 +156,12 @@ bool IGCParser::readBRecord(const char *line, int len)
|
|||||||
Trackpoint t(Coordinates(lon, lat));
|
Trackpoint t(Coordinates(lon, lat));
|
||||||
t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
|
t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
|
||||||
t.setElevation(ele);
|
t.setElevation(ele);
|
||||||
_tracks.last().append(t);
|
track.append(t);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IGCParser::readCRecord(const char *line, int len)
|
bool IGCParser::readCRecord(RouteData &route, const char *line, int len)
|
||||||
{
|
{
|
||||||
qreal lat, lon;
|
qreal lat, lon;
|
||||||
|
|
||||||
@ -183,14 +183,16 @@ bool IGCParser::readCRecord(const char *line, int len)
|
|||||||
|
|
||||||
Waypoint w(Coordinates(lon, lat));
|
Waypoint w(Coordinates(lon, lat));
|
||||||
w.setName(QString(ba.trimmed()));
|
w.setName(QString(ba.trimmed()));
|
||||||
_routes.last().append(w);
|
route.append(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IGCParser::loadFile(QFile *file)
|
bool IGCParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(waypoints);
|
||||||
qint64 len;
|
qint64 len;
|
||||||
char line[76 + 2 + 1 + 1];
|
char line[76 + 2 + 1 + 1];
|
||||||
bool route = false, track = false;
|
bool route = false, track = false;
|
||||||
@ -221,11 +223,11 @@ bool IGCParser::loadFile(QFile *file)
|
|||||||
return false;
|
return false;
|
||||||
} else if (line[0] == 'C') {
|
} else if (line[0] == 'C') {
|
||||||
if (route) {
|
if (route) {
|
||||||
if (!readCRecord(line, len))
|
if (!readCRecord(routes.last() ,line, len))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
route = true;
|
route = true;
|
||||||
_routes.append(RouteData());
|
routes.append(RouteData());
|
||||||
}
|
}
|
||||||
} else if (line[0] == 'B') {
|
} else if (line[0] == 'B') {
|
||||||
if (_date.isNull()) {
|
if (_date.isNull()) {
|
||||||
@ -233,11 +235,11 @@ bool IGCParser::loadFile(QFile *file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!track) {
|
if (!track) {
|
||||||
_tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
_time = QTime(0, 0);
|
_time = QTime(0, 0);
|
||||||
track = true;
|
track = true;
|
||||||
}
|
}
|
||||||
if (!readBRecord(line, len))
|
if (!readBRecord(tracks.last(), line, len))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,18 @@
|
|||||||
class IGCParser : public Parser
|
class IGCParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IGCParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
IGCParser() : _errorLine(0) {}
|
||||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
|
||||||
{_errorLine = 0;}
|
|
||||||
~IGCParser() {}
|
~IGCParser() {}
|
||||||
|
|
||||||
bool loadFile(QFile *file);
|
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool readHRecord(const char *line, int len);
|
bool readHRecord(const char *line, int len);
|
||||||
bool readBRecord(const char *line, int len);
|
bool readBRecord(TrackData &track, const char *line, int len);
|
||||||
bool readCRecord(const char *line, int len);
|
bool readCRecord(RouteData &route, const char *line, int len);
|
||||||
|
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
|
@ -78,6 +78,7 @@ void InfoItem::insert(const QString &key, const QString &value)
|
|||||||
_list[i] = kv;
|
_list[i] = kv;
|
||||||
|
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoItem::clear()
|
void InfoItem::clear()
|
||||||
|
21
src/keys.h
21
src/keys.h
@ -10,18 +10,23 @@
|
|||||||
#define LAST_KEY Qt::Key_End
|
#define LAST_KEY Qt::Key_End
|
||||||
#define MODIFIER Qt::ShiftModifier
|
#define MODIFIER Qt::ShiftModifier
|
||||||
|
|
||||||
#define QUIT_SHORTCUT QKeySequence::Quit
|
#define ZOOM_IN QKeySequence::ZoomIn
|
||||||
#define OPEN_SHORTCUT QKeySequence::Open
|
#define ZOOM_OUT QKeySequence::ZoomOut
|
||||||
#define CLOSE_SHORTCUT QKeySequence::Close
|
|
||||||
#define RELOAD_SHORTCUT QKeySequence::Refresh
|
#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X
|
||||||
|
#define TOGGLE_TIME_TYPE_KEY Qt::Key_T
|
||||||
|
|
||||||
|
#define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit)
|
||||||
|
#define OPEN_SHORTCUT QKeySequence(QKeySequence::Open)
|
||||||
|
#define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close)
|
||||||
|
#define RELOAD_SHORTCUT QKeySequence(QKeySequence::Refresh)
|
||||||
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
#define EXPORT_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_E)
|
||||||
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
#define SHOW_POI_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_P)
|
||||||
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
#define SHOW_MAP_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_M)
|
||||||
#define NEXT_MAP_SHORTCUT QKeySequence::Forward
|
#define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward)
|
||||||
#define PREV_MAP_SHORTCUT QKeySequence::Back
|
#define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back)
|
||||||
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
#define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G)
|
||||||
#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D)
|
|
||||||
#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T)
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
#define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)
|
||||||
#else // Q_OS_MAC
|
#else // Q_OS_MAC
|
||||||
|
@ -225,10 +225,127 @@ void KMLParser::point(Waypoint &waypoint)
|
|||||||
_reader.raiseError("Missing Point coordinates");
|
_reader.raiseError("Missing Point coordinates");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KMLParser::heartRate(TrackData &track, int start)
|
||||||
|
{
|
||||||
|
int i = start;
|
||||||
|
const char error[] = "Heartrate data count mismatch";
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "value") {
|
||||||
|
if (i < track.size())
|
||||||
|
track[i++].setHeartRate(number());
|
||||||
|
else {
|
||||||
|
_reader.raiseError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != track.size())
|
||||||
|
_reader.raiseError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::cadence(TrackData &track, int start)
|
||||||
|
{
|
||||||
|
int i = start;
|
||||||
|
const char error[] = "Cadence data count mismatch";
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "value") {
|
||||||
|
if (i < track.size())
|
||||||
|
track[i++].setCadence(number());
|
||||||
|
else {
|
||||||
|
_reader.raiseError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != track.size())
|
||||||
|
_reader.raiseError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::speed(TrackData &track, int start)
|
||||||
|
{
|
||||||
|
int i = start;
|
||||||
|
const char error[] = "Speed data count mismatch";
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "value") {
|
||||||
|
if (i < track.size())
|
||||||
|
track[i++].setSpeed(number());
|
||||||
|
else {
|
||||||
|
_reader.raiseError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != track.size())
|
||||||
|
_reader.raiseError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::temperature(TrackData &track, int start)
|
||||||
|
{
|
||||||
|
int i = start;
|
||||||
|
const char error[] = "Temperature data count mismatch";
|
||||||
|
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "value") {
|
||||||
|
if (i < track.size())
|
||||||
|
track[i++].setTemperature(number());
|
||||||
|
else {
|
||||||
|
_reader.raiseError(error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != track.size())
|
||||||
|
_reader.raiseError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::schemaData(TrackData &track, int start)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "SimpleArrayData") {
|
||||||
|
QXmlStreamAttributes attr = _reader.attributes();
|
||||||
|
QStringRef name = attr.value("name");
|
||||||
|
|
||||||
|
if (name == "Heartrate")
|
||||||
|
heartRate(track, start);
|
||||||
|
else if (name == "Cadence")
|
||||||
|
cadence(track, start);
|
||||||
|
else if (name == "Speed")
|
||||||
|
speed(track, start);
|
||||||
|
else if (name == "Temperature")
|
||||||
|
temperature(track, start);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
} else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::extendedData(TrackData &track, int start)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "SchemaData")
|
||||||
|
schemaData(track, start);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KMLParser::track(TrackData &track)
|
void KMLParser::track(TrackData &track)
|
||||||
{
|
{
|
||||||
const char mismatchError[] = "gx:coord/when element count mismatch";
|
const char error[] = "gx:coord/when element count mismatch";
|
||||||
int i = track.size();
|
int first = track.size();
|
||||||
|
int i = first;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "when") {
|
if (_reader.name() == "when") {
|
||||||
@ -236,35 +353,48 @@ void KMLParser::track(TrackData &track)
|
|||||||
track.last().setTimestamp(time());
|
track.last().setTimestamp(time());
|
||||||
} else if (_reader.name() == "coord") {
|
} else if (_reader.name() == "coord") {
|
||||||
if (i == track.size()) {
|
if (i == track.size()) {
|
||||||
_reader.raiseError(mismatchError);
|
_reader.raiseError(error);
|
||||||
return;
|
return;
|
||||||
} else if (!coord(track[i])) {
|
} else if (!coord(track[i])) {
|
||||||
_reader.raiseError("Invalid coordinates");
|
_reader.raiseError("Invalid coordinates");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} else
|
} else if (_reader.name() == "ExtendedData")
|
||||||
|
extendedData(track, first);
|
||||||
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != track.size())
|
if (i != track.size())
|
||||||
_reader.raiseError(mismatchError);
|
_reader.raiseError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::multiGeometry(const QString &name, const QString &desc,
|
void KMLParser::multiTrack(TrackData &t)
|
||||||
|
{
|
||||||
|
while (_reader.readNextStartElement()) {
|
||||||
|
if (_reader.name() == "Track")
|
||||||
|
track(t);
|
||||||
|
else
|
||||||
|
_reader.skipCurrentElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KMLParser::multiGeometry(QList<TrackData> &tracks,
|
||||||
|
QList<Waypoint> &waypoints, const QString &name, const QString &desc,
|
||||||
const QDateTime timestamp)
|
const QDateTime timestamp)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Point") {
|
if (_reader.name() == "Point") {
|
||||||
_waypoints.append(Waypoint());
|
waypoints.append(Waypoint());
|
||||||
Waypoint &w = _waypoints.last();
|
Waypoint &w = waypoints.last();
|
||||||
w.setName(name);
|
w.setName(name);
|
||||||
w.setDescription(desc);
|
w.setDescription(desc);
|
||||||
w.setTimestamp(timestamp);
|
w.setTimestamp(timestamp);
|
||||||
point(w);
|
point(w);
|
||||||
} else if (_reader.name() == "LineString") {
|
} else if (_reader.name() == "LineString") {
|
||||||
_tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
TrackData &t = _tracks.last();
|
TrackData &t = tracks.last();
|
||||||
t.setName(name);
|
t.setName(name);
|
||||||
t.setDescription(desc);
|
t.setDescription(desc);
|
||||||
lineString(t);
|
lineString(t);
|
||||||
@ -273,7 +403,7 @@ void KMLParser::multiGeometry(const QString &name, const QString &desc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::placemark()
|
void KMLParser::placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
QString name, desc;
|
QString name, desc;
|
||||||
QDateTime timestamp;
|
QDateTime timestamp;
|
||||||
@ -286,83 +416,90 @@ void KMLParser::placemark()
|
|||||||
else if (_reader.name() == "TimeStamp")
|
else if (_reader.name() == "TimeStamp")
|
||||||
timestamp = timeStamp();
|
timestamp = timeStamp();
|
||||||
else if (_reader.name() == "MultiGeometry")
|
else if (_reader.name() == "MultiGeometry")
|
||||||
multiGeometry(name, desc, timestamp);
|
multiGeometry(tracks, waypoints, name, desc, timestamp);
|
||||||
else if (_reader.name() == "Point") {
|
else if (_reader.name() == "Point") {
|
||||||
_waypoints.append(Waypoint());
|
waypoints.append(Waypoint());
|
||||||
Waypoint &w = _waypoints.last();
|
Waypoint &w = waypoints.last();
|
||||||
w.setName(name);
|
w.setName(name);
|
||||||
w.setDescription(desc);
|
w.setDescription(desc);
|
||||||
w.setTimestamp(timestamp);
|
w.setTimestamp(timestamp);
|
||||||
point(w);
|
point(w);
|
||||||
} else if (_reader.name() == "LineString") {
|
} else if (_reader.name() == "LineString"
|
||||||
_tracks.append(TrackData());
|
|| _reader.name() == "LinearRing") {
|
||||||
TrackData &t = _tracks.last();
|
tracks.append(TrackData());
|
||||||
|
TrackData &t = tracks.last();
|
||||||
t.setName(name);
|
t.setName(name);
|
||||||
t.setDescription(desc);
|
t.setDescription(desc);
|
||||||
lineString(t);
|
lineString(t);
|
||||||
} else if (_reader.name() == "Track") {
|
} else if (_reader.name() == "Track") {
|
||||||
_tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
TrackData &t = _tracks.last();
|
TrackData &t = tracks.last();
|
||||||
t.setName(name);
|
t.setName(name);
|
||||||
t.setDescription(desc);
|
t.setDescription(desc);
|
||||||
track(t);
|
track(t);
|
||||||
|
} else if (_reader.name() == "MultiTrack") {
|
||||||
|
tracks.append(TrackData());
|
||||||
|
TrackData &t = tracks.last();
|
||||||
|
t.setName(name);
|
||||||
|
t.setDescription(desc);
|
||||||
|
multiTrack(t);
|
||||||
} else
|
} else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::folder()
|
void KMLParser::folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Placemark")
|
if (_reader.name() == "Placemark")
|
||||||
placemark();
|
placemark(tracks, waypoints);
|
||||||
else if (_reader.name() == "Folder")
|
else if (_reader.name() == "Folder")
|
||||||
folder();
|
folder(tracks, waypoints);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::document()
|
void KMLParser::document(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Placemark")
|
if (_reader.name() == "Placemark")
|
||||||
placemark();
|
placemark(tracks, waypoints);
|
||||||
else if (_reader.name() == "Folder")
|
else if (_reader.name() == "Folder")
|
||||||
folder();
|
folder(tracks, waypoints);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMLParser::kml()
|
void KMLParser::kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "Document")
|
if (_reader.name() == "Document")
|
||||||
document();
|
document(tracks, waypoints);
|
||||||
else if (_reader.name() == "Placemark")
|
else if (_reader.name() == "Placemark")
|
||||||
placemark();
|
placemark(tracks, waypoints);
|
||||||
|
else if (_reader.name() == "Folder")
|
||||||
|
folder(tracks, waypoints);
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KMLParser::parse()
|
bool KMLParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(routes);
|
||||||
|
|
||||||
|
_reader.clear();
|
||||||
|
_reader.setDevice(file);
|
||||||
|
|
||||||
if (_reader.readNextStartElement()) {
|
if (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == "kml")
|
if (_reader.name() == "kml")
|
||||||
kml();
|
kml(tracks, waypoints);
|
||||||
else
|
else
|
||||||
_reader.raiseError("Not a KML file");
|
_reader.raiseError("Not a KML file");
|
||||||
}
|
}
|
||||||
|
|
||||||
return !_reader.error();
|
return !_reader.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KMLParser::loadFile(QFile *file)
|
|
||||||
{
|
|
||||||
_reader.clear();
|
|
||||||
_reader.setDevice(file);
|
|
||||||
|
|
||||||
return parse();
|
|
||||||
}
|
|
||||||
|
@ -8,28 +8,33 @@
|
|||||||
class KMLParser : public Parser
|
class KMLParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KMLParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
|
||||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints) {}
|
|
||||||
~KMLParser() {}
|
~KMLParser() {}
|
||||||
|
|
||||||
bool loadFile(QFile *file);
|
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _reader.errorString();}
|
QString errorString() const {return _reader.errorString();}
|
||||||
int errorLine() const {return _reader.lineNumber();}
|
int errorLine() const {return _reader.lineNumber();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parse();
|
void kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints);
|
||||||
void kml();
|
void document(QList<TrackData> &tracks, QList<Waypoint> &waypoints);
|
||||||
void document();
|
void folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints);
|
||||||
void folder();
|
void placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints);
|
||||||
void placemark();
|
void multiGeometry(QList<TrackData> &tracks, QList<Waypoint> &waypoints,
|
||||||
void multiGeometry(const QString &name, const QString &desc,
|
const QString &name, const QString &desc, const QDateTime timestamp);
|
||||||
const QDateTime timestamp);
|
|
||||||
void track(TrackData &track);
|
void track(TrackData &track);
|
||||||
|
void multiTrack(TrackData &t);
|
||||||
void lineString(TrackData &track);
|
void lineString(TrackData &track);
|
||||||
void point(Waypoint &waypoint);
|
void point(Waypoint &waypoint);
|
||||||
bool pointCoordinates(Waypoint &waypoint);
|
bool pointCoordinates(Waypoint &waypoint);
|
||||||
bool lineCoordinates(TrackData &track);
|
bool lineCoordinates(TrackData &track);
|
||||||
bool coord(Trackpoint &trackpoint);
|
bool coord(Trackpoint &trackpoint);
|
||||||
|
void extendedData(TrackData &track, int start);
|
||||||
|
void schemaData(TrackData &track, int start);
|
||||||
|
void heartRate(TrackData &track, int start);
|
||||||
|
void cadence(TrackData &track, int start);
|
||||||
|
void speed(TrackData &track, int start);
|
||||||
|
void temperature(TrackData &track, int start);
|
||||||
QDateTime timeStamp();
|
QDateTime timeStamp();
|
||||||
qreal number();
|
qreal number();
|
||||||
QDateTime time();
|
QDateTime time();
|
||||||
|
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(fabs(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 QPointF(c.lon(), c.lat());}
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const
|
||||||
|
{return Coordinates(p.x(), p.y());}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LATLON_H
|
134
src/map.cpp
134
src/map.cpp
@ -1,134 +0,0 @@
|
|||||||
#include <QFileInfo>
|
|
||||||
#include <QDir>
|
|
||||||
#include "downloader.h"
|
|
||||||
#include "config.h"
|
|
||||||
#include "map.h"
|
|
||||||
|
|
||||||
|
|
||||||
Map::Map(QObject *parent, const QString &name, const QString &url)
|
|
||||||
: QObject(parent)
|
|
||||||
{
|
|
||||||
_name = name;
|
|
||||||
_url = url;
|
|
||||||
|
|
||||||
connect(&Downloader::instance(), SIGNAL(finished()), this,
|
|
||||||
SLOT(emitLoaded()));
|
|
||||||
|
|
||||||
QString path = TILES_DIR + QString("/") + _name;
|
|
||||||
if (!QDir().mkpath(path))
|
|
||||||
fprintf(stderr, "Error creating tiles dir: %s\n", qPrintable(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::emitLoaded()
|
|
||||||
{
|
|
||||||
emit loaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::loadTiles(QList<Tile> &list, bool block)
|
|
||||||
{
|
|
||||||
if (block)
|
|
||||||
loadTilesSync(list);
|
|
||||||
else
|
|
||||||
loadTilesAsync(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::loadTilesAsync(QList<Tile> &list)
|
|
||||||
{
|
|
||||||
QList<Download> dl;
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
QString file = tileFile(t);
|
|
||||||
QFileInfo fi(file);
|
|
||||||
|
|
||||||
if (!fi.exists()) {
|
|
||||||
fillTile(t);
|
|
||||||
dl.append(Download(tileUrl(t), file));
|
|
||||||
} else
|
|
||||||
loadTileFile(t, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dl.empty())
|
|
||||||
Downloader::instance().get(dl);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::loadTilesSync(QList<Tile> &list)
|
|
||||||
{
|
|
||||||
QList<Download> dl;
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
QString file = tileFile(t);
|
|
||||||
QFileInfo fi(file);
|
|
||||||
|
|
||||||
if (!fi.exists())
|
|
||||||
dl.append(Download(tileUrl(t), file));
|
|
||||||
else
|
|
||||||
loadTileFile(t, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dl.empty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QEventLoop wait;
|
|
||||||
connect(&Downloader::instance(), SIGNAL(finished()), &wait, SLOT(quit()));
|
|
||||||
if (Downloader::instance().get(dl))
|
|
||||||
wait.exec();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); i++) {
|
|
||||||
Tile &t = list[i];
|
|
||||||
|
|
||||||
if (t.pixmap().isNull()) {
|
|
||||||
QString file = tileFile(t);
|
|
||||||
QFileInfo fi(file);
|
|
||||||
|
|
||||||
if (!(fi.exists() && loadTileFile(t, file)))
|
|
||||||
fillTile(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::fillTile(Tile &tile)
|
|
||||||
{
|
|
||||||
tile.pixmap() = QPixmap(Tile::size(), Tile::size());
|
|
||||||
tile.pixmap().fill();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Map::loadTileFile(Tile &tile, const QString &file)
|
|
||||||
{
|
|
||||||
if (!tile.pixmap().load(file)) {
|
|
||||||
fprintf(stderr, "%s: error loading tile file\n", qPrintable(file));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Map::tileUrl(const Tile &tile)
|
|
||||||
{
|
|
||||||
QString url(_url);
|
|
||||||
|
|
||||||
url.replace("$z", QString::number(tile.zoom()));
|
|
||||||
url.replace("$x", QString::number(tile.xy().x()));
|
|
||||||
url.replace("$y", QString::number(tile.xy().y()));
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Map::tileFile(const Tile &tile)
|
|
||||||
{
|
|
||||||
QString file = TILES_DIR + QString("/%1/%2-%3-%4").arg(_name)
|
|
||||||
.arg(tile.zoom()).arg(tile.xy().x()).arg(tile.xy().y());
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Map::clearCache()
|
|
||||||
{
|
|
||||||
QString path = TILES_DIR + QString("/") + _name;
|
|
||||||
QDir dir = QDir(path);
|
|
||||||
QStringList list = dir.entryList();
|
|
||||||
|
|
||||||
for (int i = 0; i < list.count(); i++)
|
|
||||||
dir.remove(list.at(i));
|
|
||||||
}
|
|
53
src/map.h
53
src/map.h
@ -1,37 +1,50 @@
|
|||||||
#ifndef MAP_H
|
#ifndef MAP_H
|
||||||
#define MAP_H
|
#define MAP_H
|
||||||
|
|
||||||
#include "tile.h"
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include <QRectF>
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
class QPainter;
|
||||||
|
class Coordinates;
|
||||||
|
class RectC;
|
||||||
|
|
||||||
class Map : public QObject
|
class Map : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Map(QObject *parent = 0, const QString &name = QString(),
|
Map(QObject *parent = 0) : QObject(parent) {_backgroundColor = Qt::white;}
|
||||||
const QString &url = QString());
|
|
||||||
|
|
||||||
const QString &name() const {return _name;}
|
virtual const QString &name() const = 0;
|
||||||
void loadTiles(QList<Tile> &list, bool block);
|
|
||||||
void clearCache();
|
virtual QRectF bounds() const = 0;
|
||||||
|
virtual qreal resolution(const QPointF &p) const = 0;
|
||||||
|
|
||||||
|
virtual qreal zoom() const = 0;
|
||||||
|
virtual qreal zoomFit(const QSize &size, const RectC &br) = 0;
|
||||||
|
virtual qreal zoomFit(qreal resolution, const Coordinates &c) = 0;
|
||||||
|
virtual qreal zoomIn() = 0;
|
||||||
|
virtual qreal zoomOut() = 0;
|
||||||
|
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) = 0;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) = 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() {}
|
||||||
|
|
||||||
|
void setBackgroundColor(const QColor &color) {_backgroundColor = color;}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loaded();
|
void loaded();
|
||||||
|
|
||||||
private slots:
|
protected:
|
||||||
void emitLoaded();
|
QColor _backgroundColor;
|
||||||
|
|
||||||
private:
|
|
||||||
QString tileUrl(const Tile &tile);
|
|
||||||
QString tileFile(const Tile &tile);
|
|
||||||
bool loadTileFile(Tile &tile, const QString &file);
|
|
||||||
void fillTile(Tile &tile);
|
|
||||||
|
|
||||||
void loadTilesAsync(QList<Tile> &list);
|
|
||||||
void loadTilesSync(QList<Tile> &list);
|
|
||||||
|
|
||||||
QString _name;
|
|
||||||
QString _url;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAP_H
|
#endif // MAP_H
|
||||||
|
153
src/maplist.cpp
153
src/maplist.cpp
@ -1,41 +1,150 @@
|
|||||||
#include <QFile>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "map.h"
|
#include <QDir>
|
||||||
|
#include "range.h"
|
||||||
|
#include "atlas.h"
|
||||||
|
#include "offlinemap.h"
|
||||||
|
#include "onlinemap.h"
|
||||||
#include "maplist.h"
|
#include "maplist.h"
|
||||||
|
|
||||||
|
|
||||||
QList<Map*> MapList::load(QObject *parent, const QString &fileName)
|
#define ZOOM_MAX 18
|
||||||
|
#define ZOOM_MIN 2
|
||||||
|
|
||||||
|
Map *MapList::loadListEntry(const QByteArray &line)
|
||||||
{
|
{
|
||||||
QList<Map*> mapList;
|
int max;
|
||||||
QFileInfo fi(fileName);
|
|
||||||
|
|
||||||
if (!fi.exists())
|
QList<QByteArray> list = line.split('\t');
|
||||||
return mapList;
|
if (list.size() < 2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
QFile file(fileName);
|
QByteArray ba1 = list.at(0).trimmed();
|
||||||
|
QByteArray ba2 = list.at(1).trimmed();
|
||||||
|
if (ba1.isEmpty() || ba2.isEmpty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (list.size() == 3) {
|
||||||
|
bool ok;
|
||||||
|
max = QString(list.at(2).trimmed()).toInt(&ok);
|
||||||
|
if (!ok)
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
max = ZOOM_MAX;
|
||||||
|
|
||||||
|
return new OnlineMap(QString::fromUtf8(ba1.data(), ba1.size()),
|
||||||
|
QString::fromLatin1(ba2.data(), ba2.size()), Range(ZOOM_MIN, max), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapList::loadList(const QString &path)
|
||||||
|
{
|
||||||
|
QFile file(path);
|
||||||
|
QList<Map*> maps;
|
||||||
|
|
||||||
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
if (!file.open(QFile::ReadOnly | QFile::Text)) {
|
||||||
fprintf(stderr, "Error opening map list file: %s: %s\n",
|
_errorString = file.errorString();
|
||||||
qPrintable(fileName), qPrintable(file.errorString()));
|
return false;
|
||||||
return mapList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ln = 0;
|
int ln = 0;
|
||||||
while (!file.atEnd()) {
|
while (!file.atEnd()) {
|
||||||
ln++;
|
ln++;
|
||||||
QByteArray line = file.readLine();
|
QByteArray line = file.readLine();
|
||||||
QList<QByteArray> list = line.split('\t');
|
Map *map = loadListEntry(line);
|
||||||
if (list.size() != 2) {
|
|
||||||
fprintf(stderr, "Invalid map list entry on line %d\n", ln);
|
if (map)
|
||||||
continue;
|
maps.append(map);
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < maps.count(); i++)
|
||||||
|
delete maps.at(i);
|
||||||
|
_errorString = QString("Invalid map list entry on line %1.")
|
||||||
|
.arg(QString::number(ln));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray ba1 = list[0].trimmed();
|
|
||||||
QByteArray ba2 = list[1].trimmed();
|
|
||||||
|
|
||||||
mapList.append(new Map(parent, QString::fromUtf8(ba1.data(), ba1.size()),
|
|
||||||
QString::fromLatin1(ba2.data(), ba2.size())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mapList;
|
_maps += maps;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapList::loadMap(const QString &path)
|
||||||
|
{
|
||||||
|
OfflineMap *map = new OfflineMap(path, this);
|
||||||
|
if (map->isValid()) {
|
||||||
|
_maps.append(map);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_errorString = map->errorString();
|
||||||
|
delete map;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapList::loadTba(const QString &path)
|
||||||
|
{
|
||||||
|
Atlas *atlas = new Atlas(path, this);
|
||||||
|
if (atlas->isValid()) {
|
||||||
|
_maps.append(atlas);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_errorString = atlas->errorString();
|
||||||
|
delete atlas;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapList::loadTar(const QString &path)
|
||||||
|
{
|
||||||
|
Atlas *atlas = new Atlas(path, this);
|
||||||
|
if (atlas->isValid()) {
|
||||||
|
_maps.append(atlas);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
_errorString = atlas->errorString();
|
||||||
|
delete atlas;
|
||||||
|
OfflineMap *map = new OfflineMap(path, this);
|
||||||
|
if (map->isValid()) {
|
||||||
|
_maps.append(map);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
qWarning("%s: %s", qPrintable(path), qPrintable(_errorString));
|
||||||
|
qWarning("%s: %s", qPrintable(path),
|
||||||
|
qPrintable(map->errorString()));
|
||||||
|
_errorString = "Not a map/atlas file";
|
||||||
|
delete map;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MapList::loadFile(const QString &path)
|
||||||
|
{
|
||||||
|
QFileInfo fi(path);
|
||||||
|
QString suffix = fi.suffix().toLower();
|
||||||
|
|
||||||
|
if (suffix == "txt")
|
||||||
|
return loadList(path);
|
||||||
|
else if (suffix == "map")
|
||||||
|
return loadMap(path);
|
||||||
|
else if (suffix == "tba")
|
||||||
|
return loadTba(path);
|
||||||
|
else if (suffix == "tar")
|
||||||
|
return loadTar(path);
|
||||||
|
else {
|
||||||
|
_errorString = "Not a map/atlas file";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MapList::formats()
|
||||||
|
{
|
||||||
|
return tr("Map files (*.map *.tba *.tar)") + ";;"
|
||||||
|
+ tr("URL list files (*.txt)");
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList MapList::filter()
|
||||||
|
{
|
||||||
|
QStringList filter;
|
||||||
|
filter << "*.map" << "*.tba" << "*.tar" << "*.txt";
|
||||||
|
return filter;
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,35 @@
|
|||||||
#ifndef MAPLIST_H
|
#ifndef MAPLIST_H
|
||||||
#define MAPLIST_H
|
#define MAPLIST_H
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QString>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QString>
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
class Map;
|
class MapList : public QObject
|
||||||
|
|
||||||
class MapList
|
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QList<Map*> load(QObject *parent = 0,
|
MapList(QObject *parent = 0) : QObject(parent) {}
|
||||||
const QString &fileName = QString());
|
|
||||||
|
bool loadFile(const QString &path);
|
||||||
|
|
||||||
|
const QList<Map*> &maps() const {return _maps;}
|
||||||
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
|
static QString formats();
|
||||||
|
static QStringList filter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Map *loadListEntry(const QByteArray &line);
|
||||||
|
|
||||||
|
bool loadList(const QString &path);
|
||||||
|
bool loadMap(const QString &path);
|
||||||
|
bool loadTba(const QString &path);
|
||||||
|
bool loadTar(const QString &path);
|
||||||
|
|
||||||
|
QList<Map*> _maps;
|
||||||
|
QString _errorString;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAPLIST_H
|
#endif // MAPLIST_H
|
||||||
|
130
src/matrix.cpp
Normal file
130
src/matrix.cpp
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const Matrix &matrix)
|
||||||
|
{
|
||||||
|
dbg.nospace() << "Matrix(" << endl;
|
||||||
|
for (size_t i = 0; i < matrix.h(); i++) {
|
||||||
|
for (size_t j = 0; j < matrix.w(); j++)
|
||||||
|
dbg << "\t" << matrix.m(i, j);
|
||||||
|
dbg << endl;
|
||||||
|
}
|
||||||
|
dbg << ")";
|
||||||
|
|
||||||
|
return dbg.space();
|
||||||
|
}
|
36
src/matrix.h
Normal file
36
src/matrix.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef MATRIX_H
|
||||||
|
#define MATRIX_H
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cfloat>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
QDebug operator<<(QDebug dbg, const Matrix &matrix);
|
||||||
|
|
||||||
|
#endif // MATRIX_H
|
13
src/mercator.cpp
Normal file
13
src/mercator.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <cmath>
|
||||||
|
#include "rd.h"
|
||||||
|
#include "mercator.h"
|
||||||
|
|
||||||
|
QPointF Mercator::ll2xy(const Coordinates &c) const
|
||||||
|
{
|
||||||
|
return QPointF(c.lon(), rad2deg(log(tan(M_PI/4.0 + deg2rad(c.lat())/2.0))));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates Mercator::xy2ll(const QPointF &p) const
|
||||||
|
{
|
||||||
|
return Coordinates(p.x(), rad2deg(2 * atan(exp(deg2rad(p.y()))) - M_PI/2));
|
||||||
|
}
|
13
src/mercator.h
Normal file
13
src/mercator.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef MERCATOR_H
|
||||||
|
#define MERCATOR_H
|
||||||
|
|
||||||
|
#include "projection.h"
|
||||||
|
|
||||||
|
class Mercator : public Projection
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual QPointF ll2xy(const Coordinates &c) const;
|
||||||
|
virtual Coordinates xy2ll(const QPointF &p) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MERCATOR_H
|
@ -48,3 +48,9 @@ int str2int(const char *str, int len)
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF scaled(const QRectF &rect, qreal factor)
|
||||||
|
{
|
||||||
|
return QRectF(QPointF(rect.left() * factor, rect.top() * factor),
|
||||||
|
QSizeF(rect.width() * factor, rect.height() * factor));
|
||||||
|
}
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#ifndef MISC_H
|
#ifndef MISC_H
|
||||||
#define MISC_H
|
#define MISC_H
|
||||||
|
|
||||||
|
#include <QRectF>
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(array) \
|
||||||
|
(sizeof(array) / sizeof((array)[0]))
|
||||||
|
|
||||||
double niceNum(double x, int round);
|
double niceNum(double x, int round);
|
||||||
int str2int(const char *str, int len);
|
int str2int(const char *str, int len);
|
||||||
|
QRectF scaled(const QRectF &rect, qreal factor);
|
||||||
|
|
||||||
#endif // MISC_H
|
#endif // MISC_H
|
||||||
|
@ -227,7 +227,7 @@ bool NMEAParser::readEW(const char *data, int len, qreal &lon)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NMEAParser::readRMC(const char *line, int len)
|
bool NMEAParser::readRMC(TrackData &track, const char *line, int len)
|
||||||
{
|
{
|
||||||
int col = 1;
|
int col = 1;
|
||||||
const char *vp = line;
|
const char *vp = line;
|
||||||
@ -280,22 +280,23 @@ bool NMEAParser::readRMC(const char *line, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!date.isNull()) {
|
if (!date.isNull()) {
|
||||||
if (_date.isNull() && !_time.isNull() && !_tracks.last().isEmpty())
|
if (_date.isNull() && !_time.isNull() && !track.isEmpty())
|
||||||
_tracks.last().last().setTimestamp(QDateTime(date, _time, Qt::UTC));
|
track.last().setTimestamp(QDateTime(date, _time, Qt::UTC));
|
||||||
_date = date;
|
_date = date;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid && !_GGA && !std::isnan(lat) && !std::isnan(lon)) {
|
Coordinates c(lon, lat);
|
||||||
Trackpoint t(Coordinates(lon, lat));
|
if (valid && !_GGA && c.isValid()) {
|
||||||
|
Trackpoint t(c);
|
||||||
if (!_date.isNull() && !time.isNull())
|
if (!_date.isNull() && !time.isNull())
|
||||||
t.setTimestamp(QDateTime(_date, time, Qt::UTC));
|
t.setTimestamp(QDateTime(_date, time, Qt::UTC));
|
||||||
_tracks.last().append(t);
|
track.append(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NMEAParser::readGGA(const char *line, int len)
|
bool NMEAParser::readGGA(TrackData &track, const char *line, int len)
|
||||||
{
|
{
|
||||||
int col = 1;
|
int col = 1;
|
||||||
const char *vp = line;
|
const char *vp = line;
|
||||||
@ -356,13 +357,14 @@ bool NMEAParser::readGGA(const char *line, int len)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::isnan(lat) && !std::isnan(lon)) {
|
Coordinates c(lon, lat);
|
||||||
Trackpoint t(Coordinates(lon, lat));
|
if (c.isValid()) {
|
||||||
|
Trackpoint t(c);
|
||||||
if (!(_time.isNull() || _date.isNull()))
|
if (!(_time.isNull() || _date.isNull()))
|
||||||
t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
|
t.setTimestamp(QDateTime(_date, _time, Qt::UTC));
|
||||||
if (!std::isnan(ele))
|
if (!std::isnan(ele))
|
||||||
t.setElevation(ele - gh);
|
t.setElevation(ele - gh);
|
||||||
_tracks.last().append(t);
|
track.append(t);
|
||||||
|
|
||||||
_GGA = true;
|
_GGA = true;
|
||||||
}
|
}
|
||||||
@ -370,7 +372,7 @@ bool NMEAParser::readGGA(const char *line, int len)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NMEAParser::readWPL(const char *line, int len)
|
bool NMEAParser::readWPL(QList<Waypoint> &waypoints, const char *line, int len)
|
||||||
{
|
{
|
||||||
int col = 1;
|
int col = 1;
|
||||||
const char *vp = line;
|
const char *vp = line;
|
||||||
@ -411,10 +413,11 @@ bool NMEAParser::readWPL(const char *line, int len)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::isnan(lat) && !std::isnan(lon)) {
|
Coordinates c(lon, lat);
|
||||||
Waypoint w(Coordinates(lon, lat));
|
if (c.isValid()) {
|
||||||
|
Waypoint w(c);
|
||||||
w.setName(name);
|
w.setName(name);
|
||||||
_waypoints.append(w);
|
waypoints.append(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -474,8 +477,10 @@ bool NMEAParser::readZDA(const char *line, int len)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NMEAParser::loadFile(QFile *file)
|
bool NMEAParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(routes);
|
||||||
qint64 len;
|
qint64 len;
|
||||||
char line[80 + 2 + 1 + 1];
|
char line[80 + 2 + 1 + 1];
|
||||||
|
|
||||||
@ -486,7 +491,8 @@ bool NMEAParser::loadFile(QFile *file)
|
|||||||
_time = QTime();
|
_time = QTime();
|
||||||
_GGA = false;
|
_GGA = false;
|
||||||
|
|
||||||
_tracks.append(TrackData());
|
tracks.append(TrackData());
|
||||||
|
TrackData &track = tracks.last();
|
||||||
|
|
||||||
while (!file->atEnd()) {
|
while (!file->atEnd()) {
|
||||||
len = file->readLine(line, sizeof(line));
|
len = file->readLine(line, sizeof(line));
|
||||||
@ -501,16 +507,16 @@ bool NMEAParser::loadFile(QFile *file)
|
|||||||
|
|
||||||
if (validSentence(line, len)) {
|
if (validSentence(line, len)) {
|
||||||
if (!memcmp(line + 3, "RMC,", 4)) {
|
if (!memcmp(line + 3, "RMC,", 4)) {
|
||||||
if (!readRMC(line + 7, len))
|
if (!readRMC(track, line + 7, len - 7))
|
||||||
return false;
|
return false;
|
||||||
} else if (!memcmp(line + 3, "GGA,", 4)) {
|
} else if (!memcmp(line + 3, "GGA,", 4)) {
|
||||||
if (!readGGA(line + 7, len))
|
if (!readGGA(track, line + 7, len - 7))
|
||||||
return false;
|
return false;
|
||||||
} else if (!memcmp(line + 3, "WPL,", 4)) {
|
} else if (!memcmp(line + 3, "WPL,", 4)) {
|
||||||
if (!readWPL(line + 7, len))
|
if (!readWPL(waypoints, line + 7, len - 7))
|
||||||
return false;
|
return false;
|
||||||
} else if (!memcmp(line + 3, "ZDA,", 4)) {
|
} else if (!memcmp(line + 3, "ZDA,", 4)) {
|
||||||
if (!readZDA(line + 7, len))
|
if (!readZDA(line + 7, len - 7))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,7 +524,7 @@ bool NMEAParser::loadFile(QFile *file)
|
|||||||
_errorLine++;
|
_errorLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_tracks.last().size() && !_waypoints.size()) {
|
if (!tracks.last().size() && !waypoints.size()) {
|
||||||
_errorString = "No usable NMEA sentence found";
|
_errorString = "No usable NMEA sentence found";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,11 @@
|
|||||||
class NMEAParser : public Parser
|
class NMEAParser : public Parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NMEAParser(QList<TrackData> &tracks, QList<RouteData> &routes,
|
NMEAParser() : _errorLine(0), _GGA(false) {}
|
||||||
QList<Waypoint> &waypoints) : Parser(tracks, routes, waypoints)
|
|
||||||
{_errorLine = 0; _GGA = false;}
|
|
||||||
~NMEAParser() {}
|
~NMEAParser() {}
|
||||||
|
|
||||||
bool loadFile(QFile *file);
|
bool parse(QFile *file, QList<TrackData> &tracks,
|
||||||
|
QList<RouteData> &routes, QList<Waypoint> &waypoints);
|
||||||
QString errorString() const {return _errorString;}
|
QString errorString() const {return _errorString;}
|
||||||
int errorLine() const {return _errorLine;}
|
int errorLine() const {return _errorLine;}
|
||||||
|
|
||||||
@ -27,9 +26,9 @@ private:
|
|||||||
bool readAltitude(const char *data, int len, qreal &ele);
|
bool readAltitude(const char *data, int len, qreal &ele);
|
||||||
bool readGeoidHeight(const char *data, int len, qreal &gh);
|
bool readGeoidHeight(const char *data, int len, qreal &gh);
|
||||||
|
|
||||||
bool readRMC(const char *line, int len);
|
bool readRMC(TrackData &track, const char *line, int len);
|
||||||
bool readGGA(const char *line, int len);
|
bool readGGA(TrackData &track, const char *line, int len);
|
||||||
bool readWPL(const char *line, int len);
|
bool readWPL(QList<Waypoint> &waypoints, const char *line, int len);
|
||||||
bool readZDA(const char *line, int len);
|
bool readZDA(const char *line, int len);
|
||||||
|
|
||||||
int _errorLine;
|
int _errorLine;
|
||||||
|
20
src/oddspinbox.cpp
Normal file
20
src/oddspinbox.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#include "oddspinbox.h"
|
||||||
|
|
||||||
|
OddSpinBox::OddSpinBox(QWidget *parent) : QSpinBox(parent)
|
||||||
|
{
|
||||||
|
setSingleStep(2);
|
||||||
|
setMinimum(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QValidator::State OddSpinBox::validate(QString &text, int &pos) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(pos);
|
||||||
|
bool ok;
|
||||||
|
int val;
|
||||||
|
|
||||||
|
val = text.toInt(&ok);
|
||||||
|
if (!ok || val < 0 || val % 2 == 0)
|
||||||
|
return QValidator::Invalid;
|
||||||
|
|
||||||
|
return QValidator::Acceptable;
|
||||||
|
}
|
15
src/oddspinbox.h
Normal file
15
src/oddspinbox.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef ODDSPINBOX_H
|
||||||
|
#define ODDSPINBOX_H
|
||||||
|
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
|
class OddSpinBox : public QSpinBox
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OddSpinBox(QWidget *parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QValidator::State validate(QString &text, int &pos) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ODDSPINBOX_H
|
797
src/offlinemap.cpp
Normal file
797
src/offlinemap.cpp
Normal file
@ -0,0 +1,797 @@
|
|||||||
|
#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 "albersequal.h"
|
||||||
|
#include "ozf.h"
|
||||||
|
#include "rectc.h"
|
||||||
|
#include "offlinemap.h"
|
||||||
|
|
||||||
|
|
||||||
|
int OfflineMap::parse(QIODevice &device, QList<ReferencePoint> &points,
|
||||||
|
QString &projection, ProjectionSetup &setup, QString &datum)
|
||||||
|
{
|
||||||
|
bool res;
|
||||||
|
int ln = 1;
|
||||||
|
|
||||||
|
while (!device.atEnd()) {
|
||||||
|
QByteArray line = device.readLine();
|
||||||
|
|
||||||
|
if (ln == 1) {
|
||||||
|
if (!line.trimmed().startsWith("OziExplorer Map Data File"))
|
||||||
|
return ln;
|
||||||
|
} else if (ln == 2)
|
||||||
|
_name = line.trimmed();
|
||||||
|
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;
|
||||||
|
latm = -latm;
|
||||||
|
}
|
||||||
|
if (ll && list.at(11).trimmed() == "W") {
|
||||||
|
lond = -lond;
|
||||||
|
lonm = -lonm;
|
||||||
|
}
|
||||||
|
|
||||||
|
setup.zone = list.at(13).trimmed().toInt(&res);
|
||||||
|
if (!res)
|
||||||
|
setup.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")
|
||||||
|
setup.zone = -setup.zone;
|
||||||
|
|
||||||
|
ReferencePoint p;
|
||||||
|
p.xy = QPoint(x, y);
|
||||||
|
if (ll) {
|
||||||
|
p.ll = Coordinates(lond + lonm/60.0, latd + latm/60.0);
|
||||||
|
if (p.ll.isValid())
|
||||||
|
points.append(p);
|
||||||
|
else
|
||||||
|
return ln;
|
||||||
|
} else if (pp) {
|
||||||
|
p.pp = QPointF(ppx, ppy);
|
||||||
|
points.append(p);
|
||||||
|
} else
|
||||||
|
return ln;
|
||||||
|
} else if (key == "IWH") {
|
||||||
|
if (list.count() < 4)
|
||||||
|
return ln;
|
||||||
|
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") {
|
||||||
|
if (list.count() < 2)
|
||||||
|
return ln;
|
||||||
|
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::parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||||
|
QString &projection, ProjectionSetup &setup, QString &datum)
|
||||||
|
{
|
||||||
|
int el;
|
||||||
|
|
||||||
|
if (!device.open(QIODevice::ReadOnly)) {
|
||||||
|
_errorString = QString("Error opening map file: %1")
|
||||||
|
.arg(device.errorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((el = parse(device, points, projection, setup, datum))) {
|
||||||
|
_errorString = QString("Map file parse error on line %1").arg(el);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::createProjection(const QString &datum,
|
||||||
|
const QString &projection, const ProjectionSetup &setup,
|
||||||
|
QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
if (points.count() < 2) {
|
||||||
|
_errorString = "Insufficient number of reference points";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Datum d = Datum::datum(datum);
|
||||||
|
if (d.isNull()) {
|
||||||
|
_errorString = QString("%1: Unknown datum").arg(datum);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setup.latitudeOrigin < -90.0 || setup.latitudeOrigin > 90.0
|
||||||
|
|| setup.longitudeOrigin < -180.0 || setup.longitudeOrigin > 180.0
|
||||||
|
|| setup.standardParallel1 < -90.0 || setup.standardParallel1 > 90.0
|
||||||
|
|| setup.standardParallel2 < -90.0 || setup.standardParallel2 > 90.0) {
|
||||||
|
_errorString = "Invalid projection setup";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (projection == "Mercator")
|
||||||
|
_projection = new Mercator();
|
||||||
|
else if (projection == "Transverse Mercator")
|
||||||
|
_projection = new TransverseMercator(d.ellipsoid(),
|
||||||
|
setup.latitudeOrigin, 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 == "Albers Equal Area")
|
||||||
|
_projection = new AlbersEqual(d.ellipsoid(), setup.standardParallel1,
|
||||||
|
setup.standardParallel2, setup.latitudeOrigin, setup.longitudeOrigin,
|
||||||
|
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 {
|
||||||
|
_errorString = "Can not determine UTM zone";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (projection == "(NZTM2) New Zealand TM 2000")
|
||||||
|
_projection = new TransverseMercator(d.ellipsoid(), 0, 173.0, 0.9996,
|
||||||
|
1600000, 10000000);
|
||||||
|
else if (projection == "(BNG) British National Grid")
|
||||||
|
_projection = new TransverseMercator(d.ellipsoid(), 49, -2, 0.999601,
|
||||||
|
400000, -100000);
|
||||||
|
else if (projection == "(IG) Irish Grid")
|
||||||
|
_projection = new TransverseMercator(d.ellipsoid(), 53.5, -8, 1.000035,
|
||||||
|
200000, 250000);
|
||||||
|
else if (projection == "(SG) Swedish Grid")
|
||||||
|
_projection = new TransverseMercator(d.ellipsoid(), 0, 15.808278, 1,
|
||||||
|
1500000, 0);
|
||||||
|
else if (projection == "(I) France Zone I")
|
||||||
|
_projection = new LambertConic(d.ellipsoid(), 48.598523, 50.395912,
|
||||||
|
49.5, 2.337229, 1 /*0.99987734*/, 600000, 1200000);
|
||||||
|
else if (projection == "(II) France Zone II")
|
||||||
|
_projection = new LambertConic(d.ellipsoid(), 45.898919, 47.696014,
|
||||||
|
46.8, 2.337229, 1 /*0.99987742*/, 600000, 2200000);
|
||||||
|
else if (projection == "(III) France Zone III")
|
||||||
|
_projection = new LambertConic(d.ellipsoid(), 43.199291, 44.996094,
|
||||||
|
44.1, 2.337229, 1 /*0.99987750*/, 600000, 3200000);
|
||||||
|
else if (projection == "(IV) France Zone IV")
|
||||||
|
_projection = new LambertConic(d.ellipsoid(), 41.560388, 42.767663,
|
||||||
|
42.165, 2.337229, 1 /*0.99994471*/, 234.358, 4185861.369);
|
||||||
|
else if (projection == "(VICGRID) Victoria Australia")
|
||||||
|
_projection = new LambertConic(d.ellipsoid(), -36, -38, -37, 145, 1,
|
||||||
|
2500000, 4500000);
|
||||||
|
else if (projection == "(VG94) VICGRID94 Victoria Australia")
|
||||||
|
_projection = new LambertConic(d.ellipsoid(), -36, -38, -37, 145, 1,
|
||||||
|
2500000, 2500000);
|
||||||
|
else {
|
||||||
|
_errorString = QString("%1: Unknown map projection").arg(projection);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < points.size(); i++) {
|
||||||
|
if (points.at(i).ll.isNull())
|
||||||
|
points[i].ll = d.toWGS84(_projection->xy2ll(points.at(i).pp));
|
||||||
|
else
|
||||||
|
points[i].ll = d.toWGS84(points[i].ll);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::simpleTransformation(const QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
if (points.at(0).xy.x() == points.at(1).xy.x()
|
||||||
|
|| points.at(0).xy.y() == points.at(1).xy.y()) {
|
||||||
|
_errorString = "Invalid reference points tuple";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF p0(_projection->ll2xy(points.at(0).ll));
|
||||||
|
QPointF p1(_projection->ll2xy(points.at(1).ll));
|
||||||
|
|
||||||
|
qreal dX, dY, lat0, lon0;
|
||||||
|
dX = (p0.x() - p1.x()) / (points.at(0).xy.x() - points.at(1).xy.x());
|
||||||
|
dY = (p1.y() - p0.y()) / (points.at(1).xy.y() - points.at(0).xy.y());
|
||||||
|
lat0 = p0.y() - points.at(0).xy.y() * dY;
|
||||||
|
lon0 = p1.x() - points.at(1).xy.x() * dX;
|
||||||
|
|
||||||
|
_transform = QTransform(1.0/dX, 0, 0, 1.0/dY, -lon0/dX, -lat0/dY);
|
||||||
|
_inverted = _transform.inverted();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::affineTransformation(const QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
Matrix c(3, 2);
|
||||||
|
c.zeroize();
|
||||||
|
for (size_t i = 0; i < c.h(); i++) {
|
||||||
|
for (size_t j = 0; j < c.w(); j++) {
|
||||||
|
for (int k = 0; k < points.size(); k++) {
|
||||||
|
double f[3], t[2];
|
||||||
|
QPointF p = _projection->ll2xy(points.at(k).ll);
|
||||||
|
|
||||||
|
f[0] = p.x();
|
||||||
|
f[1] = p.y();
|
||||||
|
f[2] = 1.0;
|
||||||
|
t[0] = points.at(k).xy.x();
|
||||||
|
t[1] = points.at(k).xy.y();
|
||||||
|
c.m(i,j) += f[i] * 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()) {
|
||||||
|
_errorString = "Singular transformation matrix";
|
||||||
|
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::computeTransformation(const QList<ReferencePoint> &points)
|
||||||
|
{
|
||||||
|
Q_ASSERT(points.size() >= 2);
|
||||||
|
|
||||||
|
if (points.size() == 2)
|
||||||
|
return simpleTransformation(points);
|
||||||
|
else
|
||||||
|
return affineTransformation(points);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
_errorString = QString("%1: No such image file").arg(_imgPath);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OZF::isOZF(_imgPath)) {
|
||||||
|
if (!_ozf.load(_imgPath)) {
|
||||||
|
_errorString = QString("%1: Error loading OZF file")
|
||||||
|
.arg(QFileInfo(_imgPath).fileName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QImageReader img(_imgPath);
|
||||||
|
_size = img.size();
|
||||||
|
if (!_size.isValid()) {
|
||||||
|
_errorString = QString("%1: Error reading map image")
|
||||||
|
.arg(QFileInfo(_imgPath).fileName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::getTileInfo(const QStringList &tiles, const QString &path)
|
||||||
|
{
|
||||||
|
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()) {
|
||||||
|
_errorString = QString("Error retrieving tile size: "
|
||||||
|
"%1: Invalid image").arg(QFileInfo(tiles.at(i)).fileName());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_errorString = "Invalid/missing tile set";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OfflineMap::totalSizeSet()
|
||||||
|
{
|
||||||
|
if (!_size.isValid()) {
|
||||||
|
_errorString = "Missing total image size (IWH)";
|
||||||
|
return false;
|
||||||
|
} else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineMap::OfflineMap(const QString &fileName, QObject *parent)
|
||||||
|
: Map(parent)
|
||||||
|
{
|
||||||
|
QList<ReferencePoint> points;
|
||||||
|
QString proj, datum;
|
||||||
|
ProjectionSetup setup;
|
||||||
|
QFileInfo fi(fileName);
|
||||||
|
QString suffix = fi.suffix().toLower();
|
||||||
|
|
||||||
|
|
||||||
|
_valid = false;
|
||||||
|
_img = 0;
|
||||||
|
_projection = 0;
|
||||||
|
_resolution = 0.0;
|
||||||
|
_zoom = 0;
|
||||||
|
_scale = QPointF(1.0, 1.0);
|
||||||
|
|
||||||
|
if (suffix == "tar") {
|
||||||
|
if (!_tar.load(fileName)) {
|
||||||
|
_errorString = "Error reading tar file";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString mapFileName = fi.completeBaseName() + ".map";
|
||||||
|
QByteArray ba = _tar.file(mapFileName);
|
||||||
|
if (ba.isNull()) {
|
||||||
|
_errorString = "Map file not found";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QBuffer mapFile(&ba);
|
||||||
|
if (!parseMapFile(mapFile, points, proj, setup, datum))
|
||||||
|
return;
|
||||||
|
} else if (suffix =="map") {
|
||||||
|
QFile mapFile(fileName);
|
||||||
|
if (!parseMapFile(mapFile, points, proj, setup, datum))
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
_errorString = "Not a map file";
|
||||||
|
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;
|
||||||
|
_imgPath = QString();
|
||||||
|
} else {
|
||||||
|
QDir set(fi.absolutePath() + "/" + "set");
|
||||||
|
if (set.exists()) {
|
||||||
|
if (!totalSizeSet())
|
||||||
|
return;
|
||||||
|
if (!getTileInfo(set.entryList(), set.absolutePath()))
|
||||||
|
return;
|
||||||
|
_imgPath = QString();
|
||||||
|
} else {
|
||||||
|
if (!getImageInfo(fi.absolutePath()))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflineMap::OfflineMap(const QString &fileName, Tar &tar, QObject *parent)
|
||||||
|
: Map(parent)
|
||||||
|
{
|
||||||
|
QList<ReferencePoint> points;
|
||||||
|
QString proj, datum;
|
||||||
|
ProjectionSetup setup;
|
||||||
|
QFileInfo fi(fileName);
|
||||||
|
|
||||||
|
_valid = false;
|
||||||
|
_img = 0;
|
||||||
|
_projection = 0;
|
||||||
|
_resolution = 0.0;
|
||||||
|
_zoom = 0;
|
||||||
|
_scale = QPointF(1.0, 1.0);
|
||||||
|
|
||||||
|
QFileInfo map(fi.absolutePath());
|
||||||
|
QFileInfo layer(map.absolutePath());
|
||||||
|
QString mapFile = layer.fileName() + "/" + map.fileName() + "/"
|
||||||
|
+ fi.fileName();
|
||||||
|
QByteArray ba = tar.file(mapFile);
|
||||||
|
if (ba.isNull()) {
|
||||||
|
_errorString = "Map file not found";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QBuffer buffer(&ba);
|
||||||
|
|
||||||
|
if (!parseMapFile(buffer, points, proj, setup, datum))
|
||||||
|
return;
|
||||||
|
if (!createProjection(datum, proj, setup, points))
|
||||||
|
return;
|
||||||
|
if (!totalSizeSet())
|
||||||
|
return;
|
||||||
|
if (!computeTransformation(points))
|
||||||
|
return;
|
||||||
|
computeResolution(points);
|
||||||
|
|
||||||
|
|
||||||
|
_tarPath = fi.absolutePath() + "/" + fi.completeBaseName() + ".tar";
|
||||||
|
_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: error loading tar file", qPrintable(_tarPath));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!getTileInfo(_tar.files()))
|
||||||
|
qWarning("%s: %s", qPrintable(_tarPath), qPrintable(_errorString));
|
||||||
|
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), _tileSize).intersects(bounds())) {
|
||||||
|
painter->fillRect(QRectF(QPoint(x, y), _tileSize),
|
||||||
|
_backgroundColor);
|
||||||
|
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),
|
||||||
|
_backgroundColor);
|
||||||
|
} 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), _ozf.tileSize()),
|
||||||
|
_backgroundColor);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPixmap pixmap;
|
||||||
|
QString key = _ozf.fileName() + "/" + QString::number(_zoom) + "_"
|
||||||
|
+ QString::number(x) + "_" + QString::number(y);
|
||||||
|
if (!QPixmapCache::find(key, &pixmap)) {
|
||||||
|
pixmap = _ozf.tile(_zoom, 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), _ozf.tileSize()),
|
||||||
|
_backgroundColor);
|
||||||
|
} else
|
||||||
|
painter->drawPixmap(QPoint(x, y), pixmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OfflineMap::drawImage(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
if (!_img || _img->isNull())
|
||||||
|
painter->fillRect(rect, _backgroundColor);
|
||||||
|
else {
|
||||||
|
QRect r(rect.toRect());
|
||||||
|
painter->drawImage(r.left(), r.top(), *_img, r.left(), r.top(),
|
||||||
|
r.width(), r.height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF OfflineMap::ll2xy(const Coordinates &c)
|
||||||
|
{
|
||||||
|
if (_ozf.isOpen()) {
|
||||||
|
QPointF p(_transform.map(_projection->ll2xy(c)));
|
||||||
|
return QPointF(p.x() * _scale.x(), p.y() * _scale.y());
|
||||||
|
} else
|
||||||
|
return _transform.map(_projection->ll2xy(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates OfflineMap::xy2ll(const QPointF &p)
|
||||||
|
{
|
||||||
|
if (_ozf.isOpen()) {
|
||||||
|
return _projection->xy2ll(_inverted.map(QPointF(p.x() / _scale.x(),
|
||||||
|
p.y() / _scale.y())));
|
||||||
|
} else
|
||||||
|
return _projection->xy2ll(_inverted.map(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF OfflineMap::bounds() const
|
||||||
|
{
|
||||||
|
if (_ozf.isOpen())
|
||||||
|
return QRectF(QPointF(0, 0), _ozf.size(_zoom));
|
||||||
|
else
|
||||||
|
return QRectF(QPointF(0, 0), _size);
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::resolution(const QPointF &p) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(p);
|
||||||
|
|
||||||
|
if (_ozf.isOpen())
|
||||||
|
return _resolution / ((_scale.x() + _scale.y()) / 2.0);
|
||||||
|
else
|
||||||
|
return _resolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomFit(const QSize &size, const RectC &br)
|
||||||
|
{
|
||||||
|
if (_ozf.isOpen()) {
|
||||||
|
if (!br.isValid())
|
||||||
|
rescale(0);
|
||||||
|
else {
|
||||||
|
QRect sbr(QRectF(_transform.map(_projection->ll2xy(br.topLeft())),
|
||||||
|
_transform.map(_projection->ll2xy(br.bottomRight())))
|
||||||
|
.toRect().normalized());
|
||||||
|
|
||||||
|
for (int i = 0; i < _ozf.zooms(); i++) {
|
||||||
|
rescale(i);
|
||||||
|
if (sbr.size().width() * _scale.x() <= size.width()
|
||||||
|
&& sbr.size().height() * _scale.y() <= size.height())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomFit(qreal resolution, const Coordinates &c)
|
||||||
|
{
|
||||||
|
Q_UNUSED(c);
|
||||||
|
|
||||||
|
if (_ozf.isOpen()) {
|
||||||
|
for (int i = 0; i < _ozf.zooms(); i++) {
|
||||||
|
rescale(i);
|
||||||
|
qreal sr = _resolution / ((_scale.x() + _scale.y()) / 2.0);
|
||||||
|
if (sr >= resolution)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomIn()
|
||||||
|
{
|
||||||
|
if (_ozf.isOpen())
|
||||||
|
rescale(qMax(_zoom - 1, 0));
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OfflineMap::zoomOut()
|
||||||
|
{
|
||||||
|
if (_ozf.isOpen())
|
||||||
|
rescale(qMin(_zoom + 1, _ozf.zooms() - 1));
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OfflineMap::rescale(int zoom)
|
||||||
|
{
|
||||||
|
_zoom = zoom;
|
||||||
|
_scale = QPointF(
|
||||||
|
(qreal)_ozf.size(_zoom).width() / (qreal)_ozf.size(0).width(),
|
||||||
|
(qreal)_ozf.size(_zoom).height() / (qreal)_ozf.size(0).height());
|
||||||
|
}
|
112
src/offlinemap.h
Normal file
112
src/offlinemap.h
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#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 &fileName, QObject *parent = 0);
|
||||||
|
OfflineMap(const QString &fileName, Tar &tar, QObject *parent = 0);
|
||||||
|
~OfflineMap();
|
||||||
|
|
||||||
|
const QString &name() const {return _name;}
|
||||||
|
|
||||||
|
QRectF bounds() const;
|
||||||
|
qreal resolution(const QPointF &p) const;
|
||||||
|
|
||||||
|
qreal zoom() const {return _zoom;}
|
||||||
|
qreal zoomFit(const QSize &size, const RectC &br);
|
||||||
|
qreal zoomFit(qreal resolution, const Coordinates &c);
|
||||||
|
qreal zoomIn();
|
||||||
|
qreal zoomOut();
|
||||||
|
|
||||||
|
QPointF ll2xy(const Coordinates &c);
|
||||||
|
Coordinates xy2ll(const QPointF &p);
|
||||||
|
|
||||||
|
void draw(QPainter *painter, const QRectF &rect);
|
||||||
|
|
||||||
|
void load();
|
||||||
|
void unload();
|
||||||
|
|
||||||
|
bool isValid() const {return _valid;}
|
||||||
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
|
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:
|
||||||
|
struct ReferencePoint {
|
||||||
|
QPoint xy;
|
||||||
|
Coordinates ll;
|
||||||
|
QPointF pp;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ProjectionSetup {
|
||||||
|
double latitudeOrigin;
|
||||||
|
double longitudeOrigin;
|
||||||
|
double scale;
|
||||||
|
double falseEasting;
|
||||||
|
double falseNorthing;
|
||||||
|
double standardParallel1;
|
||||||
|
double standardParallel2;
|
||||||
|
int zone;
|
||||||
|
};
|
||||||
|
|
||||||
|
int parse(QIODevice &device, QList<ReferencePoint> &points,
|
||||||
|
QString &projection, ProjectionSetup &setup, QString &datum);
|
||||||
|
bool parseMapFile(QIODevice &device, QList<ReferencePoint> &points,
|
||||||
|
QString &projection, ProjectionSetup &setup, QString &datum);
|
||||||
|
bool totalSizeSet();
|
||||||
|
bool createProjection(const QString &datum, const QString &projection,
|
||||||
|
const ProjectionSetup &setup, QList<ReferencePoint> &points);
|
||||||
|
bool simpleTransformation(const QList<ReferencePoint> &points);
|
||||||
|
bool affineTransformation(const 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);
|
||||||
|
|
||||||
|
void rescale(int zoom);
|
||||||
|
|
||||||
|
QString _name;
|
||||||
|
bool _valid;
|
||||||
|
QString _errorString;
|
||||||
|
|
||||||
|
QSize _size;
|
||||||
|
Projection *_projection;
|
||||||
|
QTransform _transform, _inverted;
|
||||||
|
qreal _resolution;
|
||||||
|
|
||||||
|
OZF _ozf;
|
||||||
|
Tar _tar;
|
||||||
|
QString _tarPath;
|
||||||
|
QImage *_img;
|
||||||
|
QString _imgPath;
|
||||||
|
QSize _tileSize;
|
||||||
|
QString _tileName;
|
||||||
|
|
||||||
|
int _zoom;
|
||||||
|
QPointF _scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OFFLINEMAP_H
|
269
src/onlinemap.cpp
Normal file
269
src/onlinemap.cpp
Normal file
@ -0,0 +1,269 @@
|
|||||||
|
#include <QFileInfo>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QPainter>
|
||||||
|
#include "rectc.h"
|
||||||
|
#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 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 qreal zoom2scale(int zoom)
|
||||||
|
{
|
||||||
|
return (360.0/(qreal)((1<<zoom) * TILE_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int scale2zoom(qreal scale)
|
||||||
|
{
|
||||||
|
return (int)log2(360.0/(scale * (qreal)TILE_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool loadTileFile(Tile &tile, const QString &file)
|
||||||
|
{
|
||||||
|
if (!tile.pixmap().load(file)) {
|
||||||
|
qWarning("%s: error loading tile file\n", qPrintable(file));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Downloader *OnlineMap::downloader;
|
||||||
|
|
||||||
|
OnlineMap::OnlineMap(const QString &name, const QString &url,
|
||||||
|
const Range &zooms, QObject *parent) : Map(parent)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
_url = url;
|
||||||
|
_block = false;
|
||||||
|
_zooms = zooms;
|
||||||
|
_zoom = zooms.max();
|
||||||
|
|
||||||
|
QString path = TILES_DIR + QString("/") + name;
|
||||||
|
if (!QDir().mkpath(path))
|
||||||
|
qWarning("Error creating tiles dir: %s\n", qPrintable(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::load()
|
||||||
|
{
|
||||||
|
connect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::unload()
|
||||||
|
{
|
||||||
|
disconnect(downloader, SIGNAL(finished()), this, SLOT(emitLoaded()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::fillTile(Tile &tile)
|
||||||
|
{
|
||||||
|
tile.pixmap() = QPixmap(TILE_SIZE, TILE_SIZE);
|
||||||
|
tile.pixmap().fill(_backgroundColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString OnlineMap::tileUrl(const Tile &tile) const
|
||||||
|
{
|
||||||
|
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) const
|
||||||
|
{
|
||||||
|
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/zoom2scale(_zoom));
|
||||||
|
}
|
||||||
|
|
||||||
|
int OnlineMap::limitZoom(int zoom) const
|
||||||
|
{
|
||||||
|
if (zoom < _zooms.min())
|
||||||
|
return _zooms.min();
|
||||||
|
if (zoom > _zooms.max())
|
||||||
|
return _zooms.max();
|
||||||
|
|
||||||
|
return zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomFit(const QSize &size, const RectC &br)
|
||||||
|
{
|
||||||
|
if (!br.isValid())
|
||||||
|
_zoom = _zooms.max();
|
||||||
|
else {
|
||||||
|
QRectF tbr(Mercator().ll2xy(br.topLeft()),
|
||||||
|
Mercator().ll2xy(br.bottomRight()));
|
||||||
|
QPointF sc(tbr.width() / size.width(), tbr.height() / size.height());
|
||||||
|
|
||||||
|
_zoom = limitZoom(scale2zoom(qMax(sc.x(), sc.y())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomFit(qreal resolution, const Coordinates &c)
|
||||||
|
{
|
||||||
|
_zoom = limitZoom((int)(log2((WGS84_RADIUS * 2 * M_PI
|
||||||
|
* cos(deg2rad(c.lat()))) / resolution) - log2(TILE_SIZE)));
|
||||||
|
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::resolution(const QPointF &p) const
|
||||||
|
{
|
||||||
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
|
||||||
|
return (WGS84_RADIUS * 2 * M_PI * scale / 360.0
|
||||||
|
* cos(2.0 * atan(exp(deg2rad(-p.y() * scale))) - M_PI/2));
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomIn()
|
||||||
|
{
|
||||||
|
_zoom = qMin(_zoom + 1, _zooms.max());
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal OnlineMap::zoomOut()
|
||||||
|
{
|
||||||
|
_zoom = qMax(_zoom - 1, _zooms.min());
|
||||||
|
return _zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
|
{
|
||||||
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
QPointF m = Mercator().ll2xy(c);
|
||||||
|
return QPointF(m.x() / scale, m.y() / -scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
Coordinates OnlineMap::xy2ll(const QPointF &p)
|
||||||
|
{
|
||||||
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
QPointF m(p.x() * scale, -p.y() * scale);
|
||||||
|
return Mercator().xy2ll(m);
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user