1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-01 13:29:16 +02:00

Compare commits

...

99 Commits
7.13 ... 7.17

Author SHA1 Message Date
26c922d9a2 Merge branch 'origin/master' into Weblate. 2019-11-02 09:54:50 +01:00
2ba78545ef Fixed broken GPI files encoding handling 2019-11-02 09:54:11 +01:00
d2a47d1a51 Merge branch 'origin/master' into Weblate. 2019-11-01 19:11:10 +01:00
b2ca97b836 Version++ 2019-11-01 19:10:47 +01:00
979981ffb8 Merge branch 'origin/master' into Weblate. 2019-11-01 19:07:57 +01:00
9a57ca69a0 Added support for mangled POI files 2019-11-01 19:07:21 +01:00
7b9bdf1f08 Merge branch 'origin/master' into Weblate. 2019-10-31 19:16:04 +01:00
034647b461 Added Garmin GPI info 2019-10-31 19:16:00 +01:00
f1d8497851 Merge branch 'origin/master' into Weblate. 2019-10-31 17:49:39 +01:00
2f2f155707 Fixed broken DEM value reading on southern and western coordinates
Fixes #240
2019-10-31 17:47:58 +01:00
6d87587544 Translated using Weblate (Norwegian Bokmål)
Currently translated at 91.9% (319 of 347 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2019-10-31 06:46:09 +01:00
dad2d79361 Translated using Weblate (Swedish)
Currently translated at 100.0% (347 of 347 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/sv/
2019-10-30 22:56:49 +01:00
9f2d7eb4bb Translated using Weblate (Turkish)
Currently translated at 100.0% (347 of 347 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/tr/
2019-10-30 22:56:48 +01:00
b57809b3b3 Translated using Weblate (German)
Currently translated at 100.0% (347 of 347 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/de/
2019-10-30 22:56:48 +01:00
6cb6c1b4fd Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (347 of 347 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/pt_BR/
2019-10-30 22:56:47 +01:00
14a01b7126 Translated using Weblate (Czech)
Currently translated at 100.0% (347 of 347 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/cs/
2019-10-30 22:56:47 +01:00
315c095af9 Localization files update 2019-10-30 19:48:06 +01:00
10d2fe4431 Fixed crash on empty segment
Fixes #239
2019-10-29 09:10:32 +01:00
29147e1b8b Merge branch 'origin/master' into Weblate. 2019-10-28 15:21:08 +01:00
0a1a1ac6be Fixed path marker Z-value issue 2019-10-28 15:20:38 +01:00
6c102c6d98 Merge branch 'origin/master' into Weblate. 2019-10-28 14:34:50 +01:00
df89952483 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (346 of 346 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/pt_BR/
2019-10-28 14:34:50 +01:00
01d8d917cb Merge branch 'master' of https://github.com/tumic0/GPXSee 2019-10-28 14:34:32 +01:00
d1522210e5 Added Windows GPI integration 2019-10-28 14:34:01 +01:00
d3ac528d57 Merge branch 'origin/master' into Weblate. 2019-10-28 12:02:26 +01:00
82eed4759c Added OS X GPI integration 2019-10-28 12:01:58 +01:00
2a94e1ac59 Merge branch 'origin/master' into Weblate. 2019-10-28 11:06:31 +01:00
8feeeaa918 Added GPI icon 2019-10-28 11:06:06 +01:00
2946fa799e Merge branch 'origin/master' into Weblate. 2019-10-28 09:11:26 +01:00
41ebe8aec7 Be more strict when handling tracks with missing timestamps 2019-10-28 09:10:38 +01:00
e35a8246f9 Merge branch 'origin/master' into Weblate. 2019-10-27 22:52:06 +01:00
725bb8a381 Graphs with zero size height are valid 2019-10-27 22:51:36 +01:00
fc5eea33cf Merge branch 'origin/master' into Weblate. 2019-10-27 19:54:12 +01:00
a1de3c956c Fixed broken graphs with missing time data handling 2019-10-27 19:53:32 +01:00
d2d9b94e78 Merge branch 'origin/master' into Weblate. 2019-10-27 16:35:16 +01:00
e6b205e823 Fixed error handling 2019-10-27 16:34:53 +01:00
0b680928fd Merge branch 'origin/master' into Weblate. 2019-10-25 22:31:04 +02:00
c0c01eef8b Added support for GPI files 2019-10-25 22:30:12 +02:00
7cdee93e9e Translated using Weblate (Turkish)
Currently translated at 100.0% (346 of 346 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/tr/
2019-10-24 05:01:25 +02:00
33071ac8df Translated using Weblate (Finnish)
Currently translated at 100.0% (346 of 346 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/fi/
2019-10-24 05:01:25 +02:00
c7ff6f3aa1 Translated using Weblate (Norwegian Bokmål)
Currently translated at 91.3% (316 of 346 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2019-10-24 05:01:24 +02:00
c61d4c8201 Translated using Weblate (Russian)
Currently translated at 100.0% (346 of 346 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/ru/
2019-10-24 05:01:23 +02:00
05a871c8a0 Translated using Weblate (Swedish)
Currently translated at 100.0% (346 of 346 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/sv/
2019-10-24 05:01:23 +02:00
ae9dd309e9 CZ and DE translations 2019-10-22 22:41:08 +02:00
cea0a51d0e Localization update 2019-10-22 22:35:36 +02:00
5dcc63600c Removed the pt_PT localization stub as noone is evidently going to really translate that language... 2019-10-22 22:28:43 +02:00
c29ed0a2ca Nicer multiple links display 2019-10-22 22:27:12 +02:00
9905de67bd Added support for GPX 1.0 links 2019-10-20 20:30:10 +02:00
25b42fd2f8 Version++ 2019-10-18 08:38:04 +02:00
0a6d575b21 Fixed symbol name collision 2019-10-17 22:37:21 +02:00
21de5e22e4 Fixed QT4 build 2019-10-17 22:14:58 +02:00
4670630e22 A much better windows popup close handling 2019-10-17 22:02:44 +02:00
5f79326601 Made the popup disappear logic work on Windows 2019-10-16 22:58:22 +02:00
0c1a123cd9 Handle the tooltips pixel accurate 2019-10-16 19:22:55 +02:00
9c96e7124a Added tooltip event triggers for info messages 2019-10-15 23:59:15 +02:00
694847a424 Extended links support + popup fixes 2019-10-14 20:07:05 +02:00
e7f5da5af7 Added missing text wrappping 2019-10-14 01:45:16 +02:00
d59a37466b Added support for waypoint links 2019-10-14 01:16:38 +02:00
f2bfd584d0 Fixed flickering & QT4 problems 2019-10-14 00:07:57 +02:00
a9ce6f54c7 Hyperlink + copy&paste enabled tool tips 2019-10-13 20:20:32 +02:00
de9bae9d66 Fixed broken path ticks tool tip units switching
Fixes #233
2019-10-07 22:03:26 +02:00
716662322d Wrong project... 2019-10-05 22:06:13 +02:00
2a893fe4ef Added change log link 2019-10-05 22:04:14 +02:00
a24d55025f Text layout tweaking & optimization 2019-10-05 12:41:42 +02:00
04ddcecb70 Increased tile cache size 2019-10-03 22:47:31 +02:00
dc9a600a6e Version++ 2019-10-03 01:06:53 +02:00
c365de130b Properly align the zoom 0 level with tiles of a different size than 256 2019-10-02 23:58:58 +02:00
d3558198ca Translated using Weblate (German)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/de/
2019-09-29 11:58:18 +02:00
acc69f5c3d Merge branch 'origin/master' into Weblate. 2019-09-29 11:47:55 +02:00
7a900f2252 Version++ 2019-09-29 11:48:08 +02:00
dad76a4e89 Merge branch 'origin/master' into Weblate. 2019-09-29 11:24:33 +02:00
e28e69b248 Added support for enchanced altitude and speed entries 2019-09-29 11:24:20 +02:00
7fffd6a161 Merge branch 'origin/master' into Weblate. 2019-09-29 00:03:21 +02:00
c4fd82e5a0 Properly handle routes without elevation data as well 2019-09-29 00:03:14 +02:00
fa08c0dbea Properly handle files without elevation data 2019-09-28 23:56:59 +02:00
070eff2115 Print a warning message on unsupported IMG compression 2019-09-28 23:55:26 +02:00
20a4870904 Merge branch 'origin/master' into Weblate. 2019-09-21 00:37:02 +02:00
1bb9908936 Some more code cleanup 2019-09-21 00:36:49 +02:00
36555b3140 Code cleanup 2019-09-20 00:23:47 +02:00
6564fb36ab Merge branch 'origin/master' into Weblate. 2019-09-20 00:23:46 +02:00
1a3356b8fe Cosmetics 2019-09-18 09:18:09 +02:00
7ad64922c9 Merge branch 'origin/master' into Weblate. 2019-09-18 09:18:09 +02:00
64a8ec1b84 Merge branch 'origin/master' into Weblate. 2019-09-18 09:12:36 +02:00
0a75298b2b Made the variable record info parsing universal 2019-09-18 09:11:46 +02:00
99be5699af Merge branch 'origin/master' into Weblate. 2019-09-18 08:38:05 +02:00
cdb641b204 Properly read variable length values
Code cleanup
2019-09-18 08:37:33 +02:00
f57bd48840 Merge branch 'origin/master' into Weblate. 2019-09-10 19:45:52 +02:00
c2abf2c146 Prefer loading speed over "NT maps not supported" reporting 2019-09-10 19:45:06 +02:00
a5a2070ccc Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/pt_BR/
2019-09-09 12:35:04 +02:00
ed7cb1beb1 Translated using Weblate (Norwegian Bokmål)
Currently translated at 91.3% (313 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2019-09-09 12:35:04 +02:00
37d832bc7f Translated using Weblate (French)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/fr/
2019-09-09 12:35:04 +02:00
c322bf9f68 Translated using Weblate (Turkish)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/tr/
2019-09-07 21:35:43 +02:00
2705ffbbfe Translated using Weblate (Russian)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/ru/
2019-09-07 00:22:41 +02:00
e8962dd50f Translated using Weblate (Czech)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/cs/
2019-09-07 00:22:40 +02:00
b37e32d622 Translated using Weblate (Finnish)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/fi/
2019-09-07 00:22:40 +02:00
2b1d0d2189 Translated using Weblate (Swedish)
Currently translated at 100.0% (343 of 343 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/sv/
2019-09-07 00:22:39 +02:00
33e3471ca3 Added pt_PT translation file stub 2019-09-06 20:10:40 +02:00
bf55f1e07d ts files update 2019-09-06 20:10:09 +02:00
37a0eec48f Added support for pseudo-NT IMG maps (e.g. TopoHispania) 2019-09-05 22:31:13 +02:00
93 changed files with 4465 additions and 3072 deletions

View File

@ -1,4 +1,4 @@
version: 7.13.{build}
version: 7.17.{build}
configuration: Release
platform: Any CPU
environment:

View File

@ -2,7 +2,7 @@
GPXSee is a Qt-based GPS log file viewer and analyzer that supports all common GPS log file formats.
## Features
* Opens GPX, TCX, FIT, KML, NMEA, IGC, CUP, SLF, LOC, GeoJSON, OziExplorer (PLT, RTE, WPT), Garmin CSV and geotagged JPEG files.
* Opens GPX, TCX, FIT, KML, NMEA, IGC, CUP, SLF, LOC, GeoJSON, OziExplorer (PLT, RTE, WPT), Garmin GPI&CSV and geotagged JPEG files.
* User-definable online maps (OpenStreetMap/Google tiles, WMTS, WMS, TMS, QuadTiles).
* Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases, Garmin IMG & JNX maps, TwoNav RMaps, GeoTIFF images).
* Elevation, speed, heart rate, cadence, power, temperature and gear ratio/shifts graphs.

View File

@ -3,7 +3,7 @@ unix:!macx {
} else {
TARGET = GPXSee
}
VERSION = 7.13
VERSION = 7.17
QT += core \
gui \
@ -19,6 +19,8 @@ equals(QT_MAJOR_VERSION, 5) : lessThan(QT_MINOR_VERSION, 4) {QT += opengl}
INCLUDEPATH += ./src
HEADERS += src/common/config.h \
src/GUI/graphicsscene.h \
src/GUI/popup.h \
src/common/staticassert.h \
src/common/coordinates.h \
src/common/range.h \
@ -84,6 +86,7 @@ HEADERS += src/common/config.h \
src/GUI/mapview.h \
src/GUI/font.h \
src/GUI/areaitem.h \
src/data/link.h \
src/map/IMG/bitmapline.h \
src/map/IMG/textpathitem.h \
src/map/IMG/textpointitem.h \
@ -183,8 +186,10 @@ HEADERS += src/common/config.h \
src/map/IMG/textitem.h \
src/map/IMG/label.h \
src/data/csv.h \
src/data/cupparser.h
src/data/cupparser.h \
src/data/gpiparser.h
SOURCES += src/main.cpp \
src/GUI/popup.cpp \
src/common/coordinates.cpp \
src/common/rectc.cpp \
src/common/range.cpp \
@ -316,7 +321,9 @@ SOURCES += src/main.cpp \
src/GUI/pathtickitem.cpp \
src/map/IMG/textitem.cpp \
src/data/csv.cpp \
src/data/cupparser.cpp
src/data/cupparser.cpp \
src/GUI/graphicsscene.cpp \
src/data/gpiparser.cpp
greaterThan(QT_MAJOR_VERSION, 4) {
HEADERS += src/data/geojsonparser.h
@ -376,7 +383,8 @@ macx {
icons/formats/loc.icns \
icons/formats/slf.icns \
icons/formats/json.icns \
icons/formats/cup.icns
icons/formats/cup.icns \
icons/formats/gpi.icns
QMAKE_BUNDLE_DATA += locale maps icons csv
}
@ -394,7 +402,8 @@ win32 {
icons/formats/loc.ico \
icons/formats/slf.ico \
icons/formats/json.ico \
icons/formats/cup.ico
icons/formats/cup.ico \
icons/formats/gpi.ico
DEFINES += _USE_MATH_DEFINES \
NOGDI
}

BIN
icons/formats/gpi.icns Normal file

Binary file not shown.

BIN
icons/formats/gpi.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

View File

@ -11,3 +11,4 @@ wpt:#66ff00
loc:#556677
slf:#881199
cup:#20a810
gpi:#fca314

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -227,6 +227,22 @@
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gpi</string>
</array>
<key>CFBundleTypeMIMETypes</key>
<array>
<string>application/vnd.garmin.gpi</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>icons/gpi.icns</string>
<key>CFBundleTypeName</key>
<string>Garmin POI File</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
<key>UTImportedTypeDeclarations</key>
@ -504,6 +520,27 @@
<string>application/vnd.naviter.seeyou.cup</string>
</dict>
</dict>
<dict>
<key>UTTypeIdentifier</key>
<string>com.garmin.gpi</string>
<key>UTTypeReferenceURL</key>
<string>http://www.garmin.com</string>
<key>UTTypeDescription</key>
<string>Garmin POI File</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gpi</string>
</array>
<key>public.mime-type</key>
<string>application/vnd.garmin.cup</string>
</dict>
</dict>
</array>
</dict>
</plist>

View File

@ -7,7 +7,7 @@
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "7.13"
!define VERSION "7.17"
; The file to write
OutFile "GPXSee-${VERSION}.exe"
@ -106,19 +106,20 @@ Section "GPXSee" SEC_APP
; Associate file formats
DetailPrint "Associating file types..."
!insertmacro FILE_ASSOCIATION_ADD "gpx" "GPS Exchange Format" 6
!insertmacro FILE_ASSOCIATION_ADD "tcx" "Training Center XML" 7
!insertmacro FILE_ASSOCIATION_ADD "kml" "Keyhole Markup Language" 8
!insertmacro FILE_ASSOCIATION_ADD "fit" "Flexible and Interoperable Data Transfer" 9
!insertmacro FILE_ASSOCIATION_ADD "igc" "Flight Recorder Data Format" 10
!insertmacro FILE_ASSOCIATION_ADD "nmea" "NMEA 0183 data" 11
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track Point File" 12
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 13
!insertmacro FILE_ASSOCIATION_ADD "gpx" "GPS Exchange Format" 7
!insertmacro FILE_ASSOCIATION_ADD "tcx" "Training Center XML" 8
!insertmacro FILE_ASSOCIATION_ADD "kml" "Keyhole Markup Language" 9
!insertmacro FILE_ASSOCIATION_ADD "fit" "Flexible and Interoperable Data Transfer" 10
!insertmacro FILE_ASSOCIATION_ADD "igc" "Flight Recorder Data Format" 11
!insertmacro FILE_ASSOCIATION_ADD "nmea" "NMEA 0183 Data" 12
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track Point File" 13
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 14
!insertmacro FILE_ASSOCIATION_ADD "wpt" "OziExplorer Waypoint File" 1
!insertmacro FILE_ASSOCIATION_ADD "loc" "Geocaching.com Waypoint File" 2
!insertmacro FILE_ASSOCIATION_ADD "slf" "Sigma Log File" 3
!insertmacro FILE_ASSOCIATION_ADD "geojson" "GeoJSON" 4
!insertmacro FILE_ASSOCIATION_ADD "cup" "SeeYou CUP file" 5
!insertmacro FILE_ASSOCIATION_ADD "cup" "SeeYou CUP File" 5
!insertmacro FILE_ASSOCIATION_ADD "gpi" "Garmin POI File" 6
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
@ -228,7 +229,8 @@ Section "Uninstall"
!insertmacro FILE_ASSOCIATION_REMOVE "loc"
!insertmacro FILE_ASSOCIATION_REMOVE "slf"
!insertmacro FILE_ASSOCIATION_REMOVE "geojson"
!insertmacro FILE_ASSOCIATION_REMOVE "cup"
!insertmacro FILE_ASSOCIATION_REMOVE "cup"
!insertmacro FILE_ASSOCIATION_REMOVE "gpi"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
@ -259,4 +261,4 @@ LangString DESC_LOCALIZATION ${LANG_ENGLISH} \
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LOCALIZATION} $(DESC_LOCALIZATION)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
!insertmacro MUI_FUNCTION_DESCRIPTION_END

View File

@ -7,7 +7,7 @@
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "7.13"
!define VERSION "7.17"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"
@ -113,19 +113,20 @@ Section "GPXSee" SEC_APP
; Associate file formats
DetailPrint "Associating file types..."
!insertmacro FILE_ASSOCIATION_ADD "gpx" "GPS Exchange Format" 6
!insertmacro FILE_ASSOCIATION_ADD "tcx" "Training Center XML" 7
!insertmacro FILE_ASSOCIATION_ADD "kml" "Keyhole Markup Language" 8
!insertmacro FILE_ASSOCIATION_ADD "fit" "Flexible and Interoperable Data Transfer" 9
!insertmacro FILE_ASSOCIATION_ADD "igc" "Flight Recorder Data Format" 10
!insertmacro FILE_ASSOCIATION_ADD "nmea" "NMEA 0183 data" 11
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track Point File" 12
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 13
!insertmacro FILE_ASSOCIATION_ADD "gpx" "GPS Exchange Format" 7
!insertmacro FILE_ASSOCIATION_ADD "tcx" "Training Center XML" 8
!insertmacro FILE_ASSOCIATION_ADD "kml" "Keyhole Markup Language" 9
!insertmacro FILE_ASSOCIATION_ADD "fit" "Flexible and Interoperable Data Transfer" 10
!insertmacro FILE_ASSOCIATION_ADD "igc" "Flight Recorder Data Format" 11
!insertmacro FILE_ASSOCIATION_ADD "nmea" "NMEA 0183 Data" 12
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track Point File" 13
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 14
!insertmacro FILE_ASSOCIATION_ADD "wpt" "OziExplorer Waypoint File" 1
!insertmacro FILE_ASSOCIATION_ADD "loc" "Geocaching.com Waypoint File" 2
!insertmacro FILE_ASSOCIATION_ADD "slf" "Sigma Log File" 3
!insertmacro FILE_ASSOCIATION_ADD "geojson" "GeoJSON" 4
!insertmacro FILE_ASSOCIATION_ADD "cup" "SeeYou CUP file" 5
!insertmacro FILE_ASSOCIATION_ADD "cup" "SeeYou CUP File" 5
!insertmacro FILE_ASSOCIATION_ADD "gpi" "Garmin POI File" 6
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
@ -232,6 +233,7 @@ Section "Uninstall"
!insertmacro FILE_ASSOCIATION_REMOVE "slf"
!insertmacro FILE_ASSOCIATION_REMOVE "geojson"
!insertmacro FILE_ASSOCIATION_REMOVE "cup"
!insertmacro FILE_ASSOCIATION_REMOVE "gpi"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)'
SectionEnd
@ -262,4 +264,4 @@ LangString DESC_LOCALIZATION ${LANG_ENGLISH} \
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_MSVC} $(DESC_MSVC)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_APP} $(DESC_APP)
!insertmacro MUI_DESCRIPTION_TEXT ${SEC_LOCALIZATION} $(DESC_LOCALIZATION)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
!insertmacro MUI_FUNCTION_DESCRIPTION_END

View File

@ -2,12 +2,13 @@
#include <QApplication>
#include <QCursor>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include "map/map.h"
#include "tooltip.h"
#include "popup.h"
#include "areaitem.h"
QString AreaItem::toolTip() const
ToolTip AreaItem::toolTip() const
{
ToolTip tt;
@ -17,7 +18,7 @@ QString AreaItem::toolTip() const
tt.insert(qApp->translate("PolygonItem", "Description"),
_area.description());
return tt.toString();
return tt;
}
AreaItem::AreaItem(const Area &area, Map *map, QGraphicsItem *parent)
@ -35,8 +36,6 @@ AreaItem::AreaItem(const Area &area, Map *map, QGraphicsItem *parent)
setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true);
setToolTip(toolTip());
}
@ -171,3 +170,9 @@ void AreaItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
setZValue(zValue() - 1.0);
update();
}
void AreaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Popup::show(event->screenPos(), toolTip().toString(), event->widget());
QGraphicsItem::mousePressEvent(event);
}

View File

@ -3,6 +3,7 @@
#include <QGraphicsItem>
#include "data/area.h"
#include "tooltip.h"
class Map;
@ -26,13 +27,15 @@ public:
void setStyle(Qt::PenStyle style);
void setDigitalZoom(int zoom);
private:
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
QPainterPath painterPath(const Polygon &polygon);
void updatePainterPath();
QString toolTip() const;
ToolTip toolTip() const;
Area _area;
Map *_map;

View File

@ -7,10 +7,9 @@ CadenceGraphItem::CadenceGraphItem(const Graph &graph, GraphType type,
int width, const QColor &color, QGraphicsItem *parent)
: GraphItem(graph, type, width, color, parent)
{
setToolTip(toolTip());
}
QString CadenceGraphItem::toolTip() const
QString CadenceGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());

View File

@ -11,8 +11,7 @@ public:
CadenceGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent = 0);
private:
QString toolTip() const;
QString info() const;
};
#endif // CADENCEGRAPHITEM_H

View File

@ -24,15 +24,13 @@ ElevationGraphItem::ElevationGraphItem(const Graph &graph, GraphType type,
_descent += prev - cur;
}
}
setToolTip(toolTip(Metric));
}
QString ElevationGraphItem::toolTip(Units units) const
QString ElevationGraphItem::info() const
{
ToolTip tt;
qreal scale = (units == Metric) ? 1.0 : M2FT;
QString su = (units == Metric) ? tr("m") : tr("ft");
qreal scale = (_units == Metric) ? 1.0 : M2FT;
QString su = (_units == Metric) ? tr("m") : tr("ft");
QLocale l(QLocale::system());
tt.insert(tr("Ascent"), l.toString(ascent() * scale, 'f', 0)
@ -46,8 +44,3 @@ QString ElevationGraphItem::toolTip(Units units) const
return tt.toString();
}
void ElevationGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

View File

@ -16,11 +16,9 @@ public:
qreal max() const {return _max;}
qreal min() const {return _min;}
void setUnits(Units units);
QString info() const;
private:
QString toolTip(Units units) const;
qreal _ascent, _descent, _min, _max;
};

View File

@ -25,11 +25,9 @@ GearRatioGraphItem::GearRatioGraphItem(const Graph &graph, GraphType type,
}
}
_top = key;
setToolTip(toolTip());
}
QString GearRatioGraphItem::toolTip() const
QString GearRatioGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());

View File

@ -13,12 +13,11 @@ public:
const QColor &color, QGraphicsItem *parent = 0);
qreal top() const {return _top;}
const QMap<qreal, qreal> &map() const {return _map;}
private:
QString toolTip() const;
QString info() const;
private:
QMap<qreal, qreal> _map;
qreal _top;
};

48
src/GUI/graphicsscene.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <QGraphicsSceneHelpEvent>
#include <QGraphicsView>
#include "popup.h"
#include "graphicsscene.h"
/* Standard GraphicsScene::items() is not pixel accurate, so we use the
following function which has the same logic as used in the original
QGraphicsScene::helpEvent() function. */
QList<QGraphicsItem *> GraphicsScene::itemsAtPosition(const QPoint &screenPos,
const QPointF &scenePos, QWidget *widget) const
{
QGraphicsView *view = widget
? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
if (!view)
return items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder,
QTransform());
const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)),
QSizeF(1, 1));
if (!view->isTransformed())
return items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
const QTransform viewTransform = view->viewportTransform();
if (viewTransform.type() <= QTransform::TxScale)
return items(viewTransform.inverted().mapRect(pointRect),
Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
return items(viewTransform.inverted().map(pointRect),
Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
}
void GraphicsScene::helpEvent(QGraphicsSceneHelpEvent *event)
{
QList<QGraphicsItem *> list = itemsAtPosition(event->screenPos(),
event->scenePos(), event->widget());
for (int i = 0; i < list.size(); i++) {
if (list.at(i)->type() == QGraphicsItem::UserType + 1) {
GraphicsItem *mi = static_cast<GraphicsItem*>(list.at(i));
Popup::show(event->screenPos(), mi->info(), event->widget());
return;
}
}
/* No need to process QGraphicsScene::helpEvent() */
}

29
src/GUI/graphicsscene.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef GRAPHICSSCENE_H
#define GRAPHICSSCENE_H
#include <QGraphicsScene>
#include <QGraphicsItem>
class GraphicsItem : public QGraphicsItem
{
public:
GraphicsItem(QGraphicsItem *parent = 0) : QGraphicsItem(parent) {}
virtual QString info() const = 0;
int type() const {return QGraphicsItem::UserType + 1;}
};
class GraphicsScene : public QGraphicsScene
{
public:
GraphicsScene(QObject *parent = 0) : QGraphicsScene(parent) {}
protected:
void helpEvent(QGraphicsSceneHelpEvent *event);
private:
QList<QGraphicsItem *> itemsAtPosition(const QPoint &screenPos,
const QPointF &scenePos, QWidget *widget) const;
};
#endif // GRAPHICSSCENE_H

View File

@ -1,13 +1,16 @@
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include "popup.h"
#include "graphitem.h"
GraphItem::GraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent)
: QGraphicsObject(parent), _graph(graph), _type(type)
: GraphicsItem(parent), _graph(graph), _type(type)
{
Q_ASSERT(_graph.isValid());
_units = Metric;
_pen = QPen(color, width);
_sx = 0; _sy = 0;
_time = _graph.hasTime();
@ -231,7 +234,10 @@ void GraphItem::updateBounds()
}
}
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
if (left == right)
_bounds = QRectF();
else
_bounds = QRectF(QPointF(left, top), QPointF(right, bottom));
}
qreal GraphItem::max() const
@ -303,3 +309,9 @@ void GraphItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
emit selected(false);
}
void GraphItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Popup::show(event->screenPos(), info(), event->widget());
GraphicsItem::mousePressEvent(event);
}

View File

@ -5,8 +5,9 @@
#include <QPen>
#include "data/graph.h"
#include "units.h"
#include "graphicsscene.h"
class GraphItem : public QGraphicsObject
class GraphItem : public QObject, public GraphicsItem
{
Q_OBJECT
@ -15,6 +16,8 @@ public:
QGraphicsItem *parent = 0);
virtual ~GraphItem() {}
virtual QString info() const = 0;
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
@ -30,7 +33,7 @@ public:
void setGraphType(GraphType type);
void setColor(const QColor &color);
void setWidth(int width);
virtual void setUnits(Units units) {Q_UNUSED(units);}
void setUnits(Units units) {_units = units;}
qreal yAtX(qreal x);
qreal distanceAtTime(qreal time);
@ -45,10 +48,14 @@ public slots:
void emitSliderPositionChanged(qreal);
void hover(bool hover);
private:
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
Units _units;
private:
const GraphSegment *segment(qreal x, GraphType type) const;
void updatePath();
void updateShape();
@ -61,7 +68,6 @@ private:
QRectF _bounds;
qreal _sx, _sy;
QPen _pen;
bool _time;
};

View File

@ -15,6 +15,7 @@
#include "graphitem.h"
#include "pathitem.h"
#include "format.h"
#include "graphicsscene.h"
#include "graphview.h"
@ -23,7 +24,7 @@
GraphView::GraphView(QWidget *parent)
: QGraphicsView(parent)
{
_scene = new QGraphicsScene(this);
_scene = new GraphicsScene(this);
setScene(_scene);
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
@ -37,9 +38,9 @@ GraphView::GraphView(QWidget *parent)
_yAxis = new AxisItem(AxisItem::Y);
_yAxis->setZValue(1.0);
_slider = new SliderItem();
_slider->setZValue(3.0);
_slider->setZValue(4.0);
_sliderInfo = new SliderInfoItem(_slider);
_sliderInfo->setZValue(3.0);
_sliderInfo->setZValue(4.0);
_info = new InfoItem();
_grid = new GridItem();
_message = new QGraphicsSimpleTextItem(tr("Data not available"));
@ -165,6 +166,10 @@ void GraphView::setGraphType(GraphType type)
for (int i = 0; i < _graphs.count(); i++) {
GraphItem *gi = _graphs.at(i);
gi->setGraphType(type);
if (gi->bounds().isNull())
removeItem(gi);
else
addItem(gi);
_bounds |= gi->bounds();
}
@ -193,7 +198,8 @@ void GraphView::addGraph(GraphItem *graph)
SLOT(emitSliderPositionChanged(qreal)));
_graphs.append(graph);
_scene->addItem(graph);
if (!graph->bounds().isNull())
_scene->addItem(graph);
_bounds |= graph->bounds();
setXUnits();
@ -357,13 +363,13 @@ void GraphView::wheelEvent(QWheelEvent *e)
QGraphicsView::wheelEvent(e);
}
void GraphView::paintEvent(QPaintEvent *event)
void GraphView::paintEvent(QPaintEvent *e)
{
QRectF viewRect(mapToScene(rect()).boundingRect());
_info->setPos(QPointF(viewRect.left() + (viewRect.width()
- _info->boundingRect().width())/2.0, _info->pos().y()));
QGraphicsView::paintEvent(event);
QGraphicsView::paintEvent(e);
}
void GraphView::plot(QPainter *painter, const QRectF &target, qreal scale)

View File

@ -17,6 +17,7 @@ class GraphItem;
class PathItem;
class GridItem;
class QGraphicsSimpleTextItem;
class GraphicsScene;
class GraphView : public QGraphicsView
{
@ -48,10 +49,15 @@ signals:
protected:
void addGraph(GraphItem *graph);
void removeGraph(GraphItem *graph);
void setGraphType(GraphType type);
void setUnits(Units units);
void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
void changeEvent(QEvent *e);
void paintEvent(QPaintEvent *e);
const QString &yLabel() const {return _yLabel;}
const QString &yUnits() const {return _yUnits;}
qreal yScale() const {return _yScale;}
@ -88,13 +94,7 @@ private:
void removeItem(QGraphicsItem *item);
void addItem(QGraphicsItem *item);
void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e);
void wheelEvent(QWheelEvent *e);
void changeEvent(QEvent *e);
void paintEvent(QPaintEvent *event);
QGraphicsScene *_scene;
GraphicsScene *_scene;
AxisItem *_xAxis, *_yAxis;
SliderItem *_slider;

View File

@ -1580,7 +1580,6 @@ void GUI::keyPressEvent(QKeyEvent *event)
else
_movingTimeAction->trigger();
break;
case Qt::Key_Escape:
if (_fullscreenAction->isChecked()) {
_fullscreenAction->setChecked(false);

View File

@ -7,10 +7,9 @@ HeartRateGraphItem::HeartRateGraphItem(const Graph &graph, GraphType type,
int width, const QColor &color, QGraphicsItem *parent)
: GraphItem(graph, type, width, color, parent)
{
setToolTip(toolTip());
}
QString HeartRateGraphItem::toolTip() const
QString HeartRateGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());

View File

@ -11,8 +11,7 @@ public:
HeartRateGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent = 0);
private:
QString toolTip() const;
QString info() const;
};
#endif // HEARTRATEGRAPHITEM_H

View File

@ -16,6 +16,7 @@
#include "scaleitem.h"
#include "coordinatesitem.h"
#include "keys.h"
#include "graphicsscene.h"
#include "mapview.h"
@ -32,7 +33,7 @@ MapView::MapView(Map *map, POI *poi, QWidget *parent)
Q_ASSERT(map != 0);
Q_ASSERT(poi != 0);
_scene = new QGraphicsScene(this);
_scene = new GraphicsScene(this);
setScene(_scene);
setDragMode(QGraphicsView::ScrollHandDrag);
setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
@ -215,12 +216,12 @@ QList<PathItem *> MapView::loadData(const Data &data)
QList<PathItem *> paths;
int zoom = _map->zoom();
for (int i = 0; i < data.areas().count(); i++)
addArea(data.areas().at(i));
for (int i = 0; i < data.tracks().count(); i++)
paths.append(addTrack(data.tracks().at(i)));
for (int i = 0; i < data.routes().count(); i++)
paths.append(addRoute(data.routes().at(i)));
for (int i = 0; i < data.areas().count(); i++)
addArea(data.areas().at(i));
addWaypoints(data.waypoints());
if (_tracks.empty() && _routes.empty() && _waypoints.empty()

View File

@ -30,6 +30,7 @@ class PathItem;
class GraphItem;
class AreaItem;
class Area;
class GraphicsScene;
class MapView : public QGraphicsView
{
@ -120,7 +121,7 @@ private:
void mouseMoveEvent(QMouseEvent *event);
void leaveEvent(QEvent *event);
QGraphicsScene *_scene;
GraphicsScene *_scene;
ScaleItem *_mapScale;
CoordinatesItem *_coordinates;
QList<TrackItem*> _tracks;

View File

@ -1,9 +1,11 @@
#include <cmath>
#include <QCursor>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include "common/greatcircle.h"
#include "map/map.h"
#include "pathtickitem.h"
#include "popup.h"
#include "pathitem.h"
@ -20,7 +22,7 @@ static inline unsigned segments(qreal distance)
}
PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
: QGraphicsObject(parent), _path(path), _map(map)
: GraphicsItem(parent), _path(path), _map(map)
{
Q_ASSERT(_path.isValid());
@ -38,6 +40,7 @@ PathItem::PathItem(const Path &path, Map *map, QGraphicsItem *parent)
_markerDistance = _path.first().first().distance();
_marker = new MarkerItem(this);
_marker->setZValue(1);
_marker->setPos(position(_markerDistance));
setCursor(Qt::ArrowCursor);
@ -336,7 +339,6 @@ void PathItem::updateTicks()
_ticks[i] = new PathTickItem(tr, (i + 1) * ts, this);
_ticks[i]->setPos(position((i + 1) * ts * xInM()));
_ticks[i]->setColor(_pen.color());
_ticks[i]->setToolTip(toolTip());
}
}
@ -381,3 +383,9 @@ void PathItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
emit selected(false);
}
void PathItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Popup::show(event->screenPos(), info(), event->widget());
GraphicsItem::mousePressEvent(event);
}

View File

@ -6,16 +6,18 @@
#include "data/path.h"
#include "markeritem.h"
#include "units.h"
#include "graphicsscene.h"
class Map;
class PathTickItem;
class PathItem : public QGraphicsObject
class PathItem : public QObject, public GraphicsItem
{
Q_OBJECT
public:
PathItem(const Path &path, Map *map, QGraphicsItem *parent = 0);
virtual ~PathItem() {}
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}
@ -35,8 +37,6 @@ public:
void showMarker(bool show);
void showTicks(bool show);
Units units() const {return _units;}
public slots:
void moveMarker(qreal distance);
void hover(bool hover);
@ -44,6 +44,13 @@ public slots:
signals:
void selected(bool);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
Units _units;
private:
const PathSegment *segment(qreal x) const;
QPointF position(qreal distance) const;
@ -55,15 +62,11 @@ private:
unsigned tickSize() const;
void updateTicks();
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
Path _path;
Map *_map;
qreal _markerDistance;
int _digitalZoom;
Units _units;
qreal _width;
QPen _pen;
QPainterPath _shape;

View File

@ -1,6 +1,9 @@
#include <QPainter>
#include <QCursor>
#include <QGraphicsSceneMouseEvent>
#include "font.h"
#include "popup.h"
#include "pathitem.h"
#include "pathtickitem.h"
@ -17,7 +20,7 @@ static QFont defaultFont()
QFont PathTickItem::_font = defaultFont();
PathTickItem::PathTickItem(const QRectF &tickRect, int value,
QGraphicsItem *parent) : QGraphicsItem(parent), _tickRect(tickRect),
QGraphicsItem *parent) : GraphicsItem(parent), _tickRect(tickRect),
_text(QString::number(value))
{
_tickRect.moveCenter(QPointF(0, -_tickRect.height()/2.0 - 3));
@ -69,3 +72,10 @@ QRect PathTickItem::tickRect(int value)
return fm.boundingRect(QRect(), Qt::AlignCenter,
QString::number(qMax(value, 10))).adjusted(-2, 0, 2, 0);
}
void PathTickItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
const PathItem *pi = static_cast<PathItem*>(parentItem());
Popup::show(event->screenPos(), pi->info(), event->widget());
QGraphicsItem::mousePressEvent(event);
}

View File

@ -3,8 +3,9 @@
#include <QFont>
#include <QGraphicsItem>
#include "graphicsscene.h"
class PathTickItem : public QGraphicsItem
class PathTickItem : public GraphicsItem
{
public:
PathTickItem(const QRectF &tickRect, int value, QGraphicsItem *parent = 0);
@ -16,8 +17,14 @@ public:
void setPos(const QPointF &pos);
void setColor(const QColor &color) {_brush = QBrush(color);}
int type() const {return parentItem()->type();}
QString info() const {return static_cast<GraphicsItem*>(parentItem())->info();}
static QRect tickRect(int value);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
QRectF _tickRect;
QString _text;

165
src/GUI/popup.cpp Normal file
View File

@ -0,0 +1,165 @@
#include <QToolTip>
#include <QStyle>
#include <QStylePainter>
#include <QStyleOptionFrame>
#include <QLabel>
#include <QMouseEvent>
#include <QApplication>
#include <QDesktopWidget>
#include <QBasicTimer>
#include "popup.h"
class PopupLabel : public QLabel
{
public:
PopupLabel(const QString &text, QWidget *parent = 0);
~PopupLabel();
bool eventFilter(QObject *o, QEvent *ev);
void place(const QPoint &pos, QWidget *w);
void deleteAfterTimer();
void stopTimer() {_timer.stop();}
static PopupLabel *_instance;
protected:
void paintEvent(QPaintEvent *event);
void timerEvent(QTimerEvent *event);
void contextMenuEvent(QContextMenuEvent *) {}
private:
QBasicTimer _timer;
};
PopupLabel *PopupLabel::_instance = 0;
PopupLabel::PopupLabel(const QString &text, QWidget *parent)
: QLabel(text, parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
| Qt::WindowDoesNotAcceptFocus
#endif // QT5
)
{
delete _instance;
_instance = this;
setForegroundRole(QPalette::ToolTipText);
setBackgroundRole(QPalette::ToolTipBase);
setPalette(QToolTip::palette());
ensurePolished();
setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0,
this));
setFrameStyle(QFrame::NoFrame);
setAlignment(Qt::AlignLeft);
setIndent(1);
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0,
this) / 255.0);
setTextInteractionFlags(Qt::TextBrowserInteraction);
setOpenExternalLinks(true);
setWordWrap(true);
setMouseTracking(true);
qApp->installEventFilter(this);
}
PopupLabel::~PopupLabel()
{
_instance = 0;
}
void PopupLabel::paintEvent(QPaintEvent *event)
{
QStylePainter p(this);
QStyleOptionFrame opt;
opt.init(this);
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
p.end();
QLabel::paintEvent(event);
}
void PopupLabel::timerEvent(QTimerEvent *event)
{
if (event->timerId() == _timer.timerId()) {
_timer.stop();
deleteLater();
}
}
bool PopupLabel::eventFilter(QObject *o, QEvent *ev)
{
Q_UNUSED(o);
switch (ev->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease: {
const int key = static_cast<QKeyEvent *>(ev)->key();
if (key == Qt::Key_Escape) {
deleteLater();
return true;
}
break;
}
case QEvent::FocusIn:
case QEvent::FocusOut:
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
case QEvent::Close:
deleteLater();
break;
case QEvent::MouseMove: {
QRectF r(geometry().adjusted(-5, -20, 5, 20));
QPointF p(static_cast<QMouseEvent*>(ev)->globalPos());
if (!r.contains(p))
deleteAfterTimer();
break;
}
default:
break;
}
return false;
}
void PopupLabel::place(const QPoint &pos, QWidget *w)
{
QRect screen = QApplication::desktop()->screenGeometry(w);
QPoint p(pos.x() + 2, pos.y() + 16);
if (p.x() + width() > screen.x() + screen.width())
p.rx() -= 4 + width();
if (p.y() + height() > screen.y() + screen.height())
p.ry() -= 24 + height();
if (p.y() < screen.y())
p.setY(screen.y());
if (p.x() + width() > screen.x() + screen.width())
p.setX(screen.x() + screen.width() - width());
if (p.x() < screen.x())
p.setX(screen.x());
if (p.y() + height() > screen.y() + screen.height())
p.setY(screen.y() + screen.height() - height());
this->move(p);
}
void PopupLabel::deleteAfterTimer()
{
if (!_timer.isActive())
_timer.start(300, this);
}
void Popup::show(const QPoint &pos, const QString &text, QWidget *w)
{
if (PopupLabel::_instance) {
PopupLabel::_instance->stopTimer();
PopupLabel::_instance->setText(text);
} else
PopupLabel::_instance = new PopupLabel(text);
PopupLabel::_instance->resize(PopupLabel::_instance->sizeHint());
PopupLabel::_instance->place(pos, w);
PopupLabel::_instance->showNormal();
}

14
src/GUI/popup.h Normal file
View File

@ -0,0 +1,14 @@
#ifndef POPUP_H
#define POPUP_H
class QPoint;
class QString;
class QWidget;
class Popup
{
public:
static void show(const QPoint &pos, const QString &text, QWidget *w);
};
#endif // POPUP_H

View File

@ -7,10 +7,9 @@ PowerGraphItem::PowerGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent)
: GraphItem(graph, type, width, color, parent)
{
setToolTip(toolTip());
}
QString PowerGraphItem::toolTip() const
QString PowerGraphItem::info() const
{
ToolTip tt;
QLocale l(QLocale::system());

View File

@ -11,8 +11,7 @@ public:
PowerGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, QGraphicsItem *parent = 0);
private:
QString toolTip() const;
QString info() const;
};
#endif // POWERGRAPHITEM_H

View File

@ -7,7 +7,7 @@
#include "routeitem.h"
QString RouteItem::toolTip(Units units) const
QString RouteItem::info() const
{
ToolTip tt;
@ -16,7 +16,18 @@ QString RouteItem::toolTip(Units units) const
if (!_desc.isEmpty())
tt.insert(tr("Description"), _desc);
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
units));
_units));
if (!_links.isEmpty()) {
QString links;
for (int i = 0; i < _links.size(); i++) {
const Link &link = _links.at(i);
links.append(QString("<a href=\"%0\">%1</a>").arg(link.URL(),
link.text().isEmpty() ? link.URL() : link.text()));
if (i != _links.size() - 1)
links.append("<br/>");
}
tt.insert(tr("Links"), links);
}
return tt.toString();
}
@ -32,9 +43,8 @@ RouteItem::RouteItem(const Route &route, Map *map, QGraphicsItem *parent)
_name = route.name();
_desc = route.description();
_links = route.links();
_coordinatesFormat = DecimalDegrees;
setToolTip(toolTip(Metric));
}
void RouteItem::setMap(Map *map)
@ -47,15 +57,13 @@ void RouteItem::setMap(Map *map)
void RouteItem::setUnits(Units u)
{
if (units() == u)
if (_units == u)
return;
PathItem::setUnits(u);
setToolTip(toolTip(units()));
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setToolTipFormat(units(), _coordinatesFormat);
_waypoints[i]->setToolTipFormat(u, _coordinatesFormat);
PathItem::setUnits(u);
}
void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
@ -66,7 +74,7 @@ void RouteItem::setCoordinatesFormat(CoordinatesFormat format)
_coordinatesFormat = format;
for (int i = 0; i < _waypoints.count(); i++)
_waypoints[i]->setToolTipFormat(units(), _coordinatesFormat);
_waypoints[i]->setToolTipFormat(_units, _coordinatesFormat);
}
void RouteItem::showWaypoints(bool show)

View File

@ -5,6 +5,7 @@
#include "pathitem.h"
#include "units.h"
#include "format.h"
#include "graphicsscene.h"
class Map;
class WaypointItem;
@ -23,11 +24,12 @@ public:
void showWaypoints(bool show);
void showWaypointLabels(bool show);
private:
QString toolTip(Units units) const;
QString info() const;
private:
QString _name;
QString _desc;
QVector<Link> _links;
CoordinatesFormat _coordinatesFormat;
QVector<WaypointItem*> _waypoints;

View File

@ -152,7 +152,7 @@
#define ENABLE_HTTP2_SETTING "enableHTTP2"
#define ENABLE_HTTP2_DEFAULT true
#define PIXMAP_CACHE_SETTING "pixmapCache"
#define PIXMAP_CACHE_DEFAULT 64 /* MB */
#define PIXMAP_CACHE_DEFAULT 256 /* MB */
#define CONNECTION_TIMEOUT_SETTING "connectionTimeout"
#define CONNECTION_TIMEOUT_DEFAULT 30 /* s */
#define HIRES_PRINT_SETTING "hiresPrint"

View File

@ -8,17 +8,14 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type, int width,
const QColor &color, qreal movingTime, QGraphicsItem *parent)
: GraphItem(graph, type, width, color, parent)
{
_units = Metric;
_timeType = Total;
_max = GraphItem::max();
_avg = graph.last().last().s() / graph.last().last().t();
_mavg = graph.last().last().s() / movingTime;
setToolTip(toolTip());
}
QString SpeedGraphItem::toolTip() const
QString SpeedGraphItem::info() const
{
ToolTip tt;
qreal scale = (_units == Imperial) ? MS2MIH : (_units == Nautical)
@ -40,14 +37,7 @@ QString SpeedGraphItem::toolTip() const
return tt.toString();
}
void SpeedGraphItem::setUnits(Units units)
{
_units = units;
setToolTip(toolTip());
}
void SpeedGraphItem::setTimeType(TimeType type)
{
_timeType = type;
setToolTip(toolTip());
}

View File

@ -16,15 +16,13 @@ public:
qreal mavg() const {return _mavg;}
qreal max() const {return _max;}
void setUnits(Units units);
QString info() const;
void setTimeType(TimeType type);
private:
QString toolTip() const;
qreal _avg, _mavg, _max;
TimeType _timeType;
Units _units;
};
#endif // SPEEDGRAPHITEM_H

View File

@ -10,16 +10,14 @@ TemperatureGraphItem::TemperatureGraphItem(const Graph &graph, GraphType type,
_min = GraphItem::min();
_max = GraphItem::max();
_avg = GraphItem::avg();
setToolTip(toolTip(Metric));
}
QString TemperatureGraphItem::toolTip(Units units) const
QString TemperatureGraphItem::info() const
{
ToolTip tt;
qreal scale = (units == Metric) ? 1.0 : C2FS;
qreal offset = (units == Metric) ? 0 : C2FO;
QString su = (units == Metric) ?
qreal scale = (_units == Metric) ? 1.0 : C2FS;
qreal offset = (_units == Metric) ? 0 : C2FO;
QString su = (_units == Metric) ?
QChar(0x00B0) + tr("C") : QChar(0x00B0) + tr("F");
QLocale l(QLocale::system());
@ -32,8 +30,3 @@ QString TemperatureGraphItem::toolTip(Units units) const
return tt.toString();
}
void TemperatureGraphItem::setUnits(Units units)
{
setToolTip(toolTip(units));
}

View File

@ -15,11 +15,9 @@ public:
qreal min() const {return _min;}
qreal avg() const {return _avg;}
void setUnits(Units units);
QString info() const;
private:
QString toolTip(Units units) const;
qreal _min, _max, _avg;
};

View File

@ -1,4 +1,6 @@
#include <QImageReader>
#include <QLabel>
#include "popup.h"
#include "tooltip.h"
@ -26,7 +28,8 @@ QString ToolTip::toString() const
}
html += "<div align=\"center\">";
html += QString("<img src=\"file:%0\" width=\"%1\" height=\"%2\"/>")
html += QString("<a href=\"file:%0\">"
"<img src=\"%0\" width=\"%1\" height=\"%2\"/></a>")
.arg(_img.path(), QString::number(width), QString::number(height));
html += "</div>";
}

View File

@ -5,7 +5,7 @@
#include "trackitem.h"
QString TrackItem::toolTip(Units units) const
QString TrackItem::info() const
{
ToolTip tt;
@ -14,13 +14,24 @@ QString TrackItem::toolTip(Units units) const
if (!_desc.isEmpty())
tt.insert(tr("Description"), _desc);
tt.insert(tr("Distance"), Format::distance(path().last().last().distance(),
units));
_units));
if (_time > 0)
tt.insert(tr("Total time"), Format::timeSpan(_time));
if (_movingTime > 0)
tt.insert(tr("Moving time"), Format::timeSpan(_movingTime));
if (!_date.isNull())
tt.insert(tr("Date"), _date.toString(Qt::SystemLocaleShortDate));
if (!_links.isEmpty()) {
QString links;
for (int i = 0; i < _links.size(); i++) {
const Link &link = _links.at(i);
links.append(QString("<a href=\"%0\">%1</a>").arg(link.URL(),
link.text().isEmpty() ? link.URL() : link.text()));
if (i != _links.size() - 1)
links.append("<br/>");
}
tt.insert(tr("Links"), links);
}
return tt.toString();
}
@ -30,15 +41,8 @@ TrackItem::TrackItem(const Track &track, Map *map, QGraphicsItem *parent)
{
_name = track.name();
_desc = track.description();
_links = track.links();
_date = track.date();
_time = track.time();
_movingTime = track.movingTime();
setToolTip(toolTip(Metric));
}
void TrackItem::setUnits(Units units)
{
PathItem::setUnits(units);
setToolTip(toolTip(units));
}

View File

@ -6,6 +6,7 @@
#include "data/track.h"
#include "pathitem.h"
#include "units.h"
#include "graphicsscene.h"
class Map;
@ -16,13 +17,12 @@ class TrackItem : public PathItem
public:
TrackItem(const Track &track, Map *map, QGraphicsItem *parent = 0);
void setUnits(Units units);
QString info() const;
private:
QString toolTip(Units units) const;
QString _name;
QString _desc;
QVector<Link> _links;
QDateTime _date;
qreal _time;
qreal _movingTime;

View File

@ -1,7 +1,10 @@
#include <QApplication>
#include <QPainter>
#include <QGraphicsSceneMouseEvent>
#include <QLabel>
#include "font.h"
#include "tooltip.h"
#include "popup.h"
#include "waypointitem.h"
@ -10,30 +13,41 @@
#define FS(size) \
((int)((qreal)size * 1.41))
QString WaypointItem::toolTip(Units units, CoordinatesFormat format)
QString WaypointItem::info() const
{
ToolTip tt;
if (!_waypoint.name().isEmpty())
tt.insert(qApp->translate("WaypointItem", "Name"), _waypoint.name());
tt.insert(qApp->translate("WaypointItem", "Coordinates"),
Format::coordinates(_waypoint.coordinates(), format));
Format::coordinates(_waypoint.coordinates(), _format));
if (_waypoint.hasElevation())
tt.insert(qApp->translate("WaypointItem", "Elevation"),
Format::elevation(_waypoint.elevation(), units));
Format::elevation(_waypoint.elevation(), _units));
if (_waypoint.timestamp().isValid())
tt.insert(qApp->translate("WaypointItem", "Date"),
_waypoint.timestamp().toString(Qt::SystemLocaleShortDate));
if (!_waypoint.description().isEmpty())
tt.insert(qApp->translate("WaypointItem", "Description"),
_waypoint.description());
if (!_waypoint.links().isEmpty()) {
QString links;
for (int i = 0; i < _waypoint.links().size(); i++) {
const Link &link = _waypoint.links().at(i);
links.append(QString("<a href=\"%0\">%1</a>").arg(link.URL(),
link.text().isEmpty() ? link.URL() : link.text()));
if (i != _waypoint.links().size() - 1)
links.append("<br/>");
}
tt.insert(qApp->translate("WaypointItem", "Links"), links);
}
tt.setImage(_waypoint.image());
return tt.toString();
}
WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
QGraphicsItem *parent) : QGraphicsItem(parent)
QGraphicsItem *parent) : GraphicsItem(parent)
{
_waypoint = waypoint;
_showLabel = true;
@ -43,10 +57,12 @@ WaypointItem::WaypointItem(const Waypoint &waypoint, Map *map,
_font.setPixelSize(FS(_size));
_font.setFamily(FONT_FAMILY);
_units = Metric;
_format = DecimalDegrees;
updateCache();
setPos(map->ll2xy(waypoint.coordinates()));
setToolTip(toolTip(Metric, DecimalDegrees));
setCursor(Qt::ArrowCursor);
setAcceptHoverEvents(true);
}
@ -116,7 +132,8 @@ void WaypointItem::setColor(const QColor &color)
void WaypointItem::setToolTipFormat(Units units, CoordinatesFormat format)
{
setToolTip(toolTip(units, format));
_units = units;
_format = format;
}
void WaypointItem::showLabel(bool show)
@ -148,3 +165,10 @@ void WaypointItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
updateCache();
setZValue(zValue() - 1.0);
}
void WaypointItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Popup::show(event->screenPos(), info(), event->widget());
/* Do not propagate the event any further as lower stacked items (path
items) would replace the popup with their own popup */
}

View File

@ -3,12 +3,15 @@
#include <cmath>
#include <QGraphicsItem>
#include <QFont>
#include "data/waypoint.h"
#include "map/map.h"
#include "units.h"
#include "graphicsscene.h"
#include "format.h"
class WaypointItem : public QGraphicsItem
class WaypointItem : public GraphicsItem
{
public:
WaypointItem(const Waypoint &waypoint, Map *map, QGraphicsItem *parent = 0);
@ -16,23 +19,26 @@ public:
const Waypoint &waypoint() const {return _waypoint;}
void setMap(Map *map) {setPos(map->ll2xy(_waypoint.coordinates()));}
void setToolTipFormat(Units units, CoordinatesFormat format);
void setSize(int size);
void setColor(const QColor &color);
void showLabel(bool show);
void setDigitalZoom(int zoom) {setScale(pow(2, -zoom));}
void setToolTipFormat(Units units, CoordinatesFormat format);
QPainterPath shape() const {return _shape;}
QRectF boundingRect() const {return _shape.boundingRect();}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
private:
QString info() const;
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
void updateCache();
QString toolTip(Units units, CoordinatesFormat format);
Waypoint _waypoint;
QPainterPath _shape;
@ -41,6 +47,9 @@ private:
bool _showLabel;
QFont _font;
QRect _labelBB;
Units _units;
CoordinatesFormat _format;
};
#endif // WAYPOINTITEM_H

View File

@ -18,6 +18,7 @@
#endif // ENABLE_GEOJSON
#include "exifparser.h"
#include "cupparser.h"
#include "gpiparser.h"
#include "dem.h"
#include "data.h"
@ -39,6 +40,7 @@ static GeoJSONParser geojson;
#endif // ENABLE_GEOJSON
static EXIFParser exif;
static CUPParser cup;
static GPIParser gpi;
static QHash<QString, Parser*> parsers()
{
@ -63,6 +65,7 @@ static QHash<QString, Parser*> parsers()
hash.insert("jpeg", &exif);
hash.insert("jpg", &exif);
hash.insert("cup", &cup);
hash.insert("gpi", &gpi);
return hash;
}
@ -177,6 +180,7 @@ QString Data::formats()
#ifdef ENABLE_GEOJSON
+ qApp->translate("Data", "GeoJSON files") + " (*.geojson *.json);;"
#endif // ENABLE_GEOJSON
+ qApp->translate("Data", "GPI files") + " (*.gpi);;"
+ qApp->translate("Data", "GPX files") + " (*.gpx);;"
+ qApp->translate("Data", "IGC files") + " (*.igc);;"
+ qApp->translate("Data", "JPEG images") + " (*.jpg *.jpeg);;"

View File

@ -1,4 +1,9 @@
#include <QtEndian>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <QtCore/qmath.h>
#else // QT5
#include <QtMath>
#endif // QT5
#include <QDir>
#include <QFile>
#include "common/coordinates.h"
@ -37,10 +42,10 @@ static qreal height(const Coordinates &c, const QByteArray *data)
else
return NAN;
int row = (int)((c.lat() - (int)c.lat()) * (samples - 1));
int col = (int)((c.lon() - (int)c.lon()) * (samples - 1));
qreal dx = ((c.lon() - (int)c.lon()) * (samples - 1)) - col;
qreal dy = ((c.lat() - (int)c.lat()) * (samples - 1)) - row;
int row = (int)((c.lat() - qFloor(c.lat())) * (samples - 1));
int col = (int)((c.lon() - qFloor(c.lon())) * (samples - 1));
qreal dx = ((c.lon() - qFloor(c.lon())) * (samples - 1)) - col;
qreal dy = ((c.lat() - qFloor(c.lat())) * (samples - 1)) - row;
qreal p0 = value(col, row, samples, data);
qreal p1 = value(col + 1, row, samples, data);
@ -75,7 +80,7 @@ qreal DEM::elevation(const Coordinates &c)
if (_dir.isEmpty())
return NAN;
Key k((int)c.lon(), (int)c.lat());
Key k(qFloor(c.lon()), qFloor(c.lat()));
QByteArray *ba = _data[k];
if (!ba) {

View File

@ -265,6 +265,14 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
if (val != 0x7f)
ctx.trackpoint.setTemperature((qint8)val);
break;
case 73:
if (val != 0xffffffff)
ctx.trackpoint.setSpeed(val / 1000.0f);
break;
case 78:
if (val != 0xffffffff)
ctx.trackpoint.setElevation((val / 5.0) - 500);
break;
default:
break;

488
src/data/gpiparser.cpp Normal file
View File

@ -0,0 +1,488 @@
#include <QDataStream>
#include <QTextCodec>
#include <QtEndian>
#include <QUrl>
#include <QBuffer>
#include "gpiparser.h"
struct RecordHeader {
quint16 type;
quint16 flags;
quint32 size;
quint32 extra;
};
class TranslatedString {
public:
TranslatedString() {}
TranslatedString(const QString &lang, const QString &str)
: _lang(lang), _str(str) {}
const QString &str() const {return _str;}
const QString &lang() const {return _lang;}
private:
QString _lang;
QString _str;
};
#define BLOCK_KEY 0xf870b5
void demangle(quint8 *data, quint32 size, quint32 key)
{
static const unsigned char shuf[] = {
0xb, 0xc, 0xa, 0x0,
0x8, 0xf, 0x2, 0x1,
0x6, 0x4, 0x9, 0x3,
0xd, 0x5, 0x7, 0xe
};
int hiCnt = 0, loCnt;
quint8 sum = shuf[(key >> 0x10) + key + (key >> 0x18) + (key >> 8) & 0xf];
for (quint32 i = 0; i < size; i++) {
quint8 hiAdd = shuf[key >> (hiCnt << 2) & 0xf] + sum;
loCnt = (hiCnt > 6) ? 0 : hiCnt + 1;
quint8 loAdd = shuf[key >> (loCnt << 2) & 0xf] + sum;
quint8 hi = data[i] + hiAdd * 0xf0;
quint8 lo = data[i] - loAdd;
data[i] = (hi & 0xf0) | (lo & 0x0f);
hiCnt = (loCnt > 6) ? 0 : loCnt + 1;
}
}
static inline double toWGS(qint32 v)
{
return (double)(((double)v / (double)(1U<<31)) * (double)180);
}
static quint16 nextHeaderType(QDataStream &stream)
{
quint16 type = 0;
stream.device()->peek((char*)&type, sizeof(type));
return qFromLittleEndian(type);
}
static quint8 readRecordHeader(QDataStream &stream, RecordHeader &hdr)
{
stream >> hdr.type >> hdr.flags >> hdr.size;
if (hdr.flags & 0xA)
stream >> hdr.extra;
return (hdr.flags & 0xA) ? 12 : 8;
}
static quint32 skipRecord(QDataStream &stream)
{
RecordHeader rh;
quint8 rs = readRecordHeader(stream, rh);
stream.skipRawData(rh.size);
return rs + rh.size;
}
static quint32 readFprsRecord(QDataStream &stream)
{
RecordHeader rh;
quint16 s1;
quint8 rs, s2, s3, s4;
rs = readRecordHeader(stream, rh);
stream >> s1 >> s2 >> s3 >> s4;
return rs + 5;
}
static quint16 readString(QDataStream &stream, QTextCodec *codec, QString &str)
{
quint16 len;
stream >> len;
QByteArray ba;
ba.resize(len);
stream.readRawData(ba.data(), len);
str = codec ? codec->toUnicode(ba) : QString::fromLatin1(ba);
return len + 2;
}
static quint32 readTranslatedObjects(QDataStream &stream, QTextCodec *codec,
QList<TranslatedString> &objects)
{
qint32 size = 0, ret;
char lang[2];
objects.clear();
stream >> size;
ret = size + 4;
while (size > 0) {
QString str;
stream.readRawData(lang, sizeof(lang));
size -= readString(stream, codec, str) + 2;
objects.append(TranslatedString(lang, str));
}
if (size < 0)
stream.setStatus(QDataStream::ReadCorruptData);
return ret;
}
static quint32 readDescription(QDataStream &stream, QTextCodec *codec,
Waypoint &waypoint)
{
RecordHeader rh;
quint8 rs;
quint32 ds;
QList<TranslatedString> obj;
rs = readRecordHeader(stream, rh);
ds = readTranslatedObjects(stream, codec, obj);
if (!obj.isEmpty())
waypoint.setDescription(obj.first().str());
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static quint32 readNotes(QDataStream &stream, QTextCodec *codec,
Waypoint &waypoint)
{
RecordHeader rh;
quint8 rs, s1;
quint32 ds = 1;
rs = readRecordHeader(stream, rh);
stream >> s1;
if (s1 & 0x1) {
QList<TranslatedString> obj;
ds += readTranslatedObjects(stream, codec, obj);
if (!obj.isEmpty() && waypoint.description().isNull())
waypoint.setDescription(obj.first().str());
}
if (s1 & 0x2) {
QString str;
ds += readString(stream, codec, str);
if (!str.isEmpty() && waypoint.description().isNull())
waypoint.setDescription(str);
}
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static quint32 readContact(QDataStream &stream, QTextCodec *codec,
Waypoint &waypoint)
{
RecordHeader rh;
quint8 rs;
quint16 s1;
quint32 ds = 2;
QString str;
QList<TranslatedString> obj;
rs = readRecordHeader(stream, rh);
stream >> s1;
if (s1 & 0x1) // phone
ds += readString(stream, codec, str);
if (s1 & 0x2) // phone2
ds += readString(stream, codec, str);
if (s1 & 0x4) // fax
ds += readString(stream, codec, str);
if (s1 & 0x8) // mail
ds += readString(stream, codec, str);
if (s1 & 0x10) { // web
ds += readString(stream, codec, str);
QUrl url(str);
waypoint.addLink(Link(url.scheme().isEmpty()
? "http://" + str : str, str));
}
if (s1 & 0x20) // unknown
ds += readTranslatedObjects(stream, codec, obj);
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static quint32 readPOI(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints)
{
RecordHeader rh;
quint8 rs;
quint32 ds;
qint32 s1, s2;
quint16 s3;
QList<TranslatedString> obj;
rs = readRecordHeader(stream, rh);
stream >> s1 >> s2 >> s3;
stream.skipRawData(s3);
ds = 10 + s3;
ds += readTranslatedObjects(stream, codec, obj);
waypoints.append(Waypoint(Coordinates(toWGS(s2), toWGS(s1))));
if (!obj.isEmpty())
waypoints.last().setName(obj.first().str());
while (ds < rh.size) {
switch(nextHeaderType(stream)) {
case 10:
ds += readDescription(stream, codec, waypoints.last());
break;
case 12:
ds += readContact(stream, codec, waypoints.last());
break;
case 14:
ds += readNotes(stream, codec, waypoints.last());
break;
default:
ds += skipRecord(stream);
}
}
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static quint32 readSpatialIndex(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints)
{
RecordHeader rh;
quint32 ds, s5;
qint32 top, right, bottom, left;
quint16 s6;
quint8 rs;
rs = readRecordHeader(stream, rh);
stream >> top >> right >> bottom >> left >> s5 >> s6;
stream.skipRawData(s6);
ds = 22 + s6;
if (rh.flags & 0x8) {
while (ds < rh.size) {
switch(nextHeaderType(stream)) {
case 2:
ds += readPOI(stream, codec, waypoints);
break;
case 8:
ds += readSpatialIndex(stream, codec, waypoints);
break;
default:
ds += skipRecord(stream);
}
}
}
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
static quint32 readFileDataRecord(QDataStream &stream, QTextCodec *codec)
{
RecordHeader rh;
quint32 ds, s1;
quint16 s2, s3;
quint8 rs;
QList<TranslatedString> obj;
rs = readRecordHeader(stream, rh);
stream >> s1 >> s2 >> s3;
ds = 8;
ds += readTranslatedObjects(stream, codec, obj);
ds += readTranslatedObjects(stream, codec, obj);
if (s1 & 0x10) {
quint8 ss1, ss2;
quint16 ss3;
stream >> ss1 >> ss2 >> ss3;
ds += 4;
}
if (s1 & 0x100) {
quint32 ss1;
stream >> ss1;
if (ss1)
stream.skipRawData(ss1);
ds += ss1 + 4;
}
if (s1 & 0x400) {
QString str;
ds += readString(stream, codec, str);
}
if (s1 & 0x400000) {
quint16 ss1;
stream >> ss1;
if (ss1)
stream.skipRawData(ss1);
ds += ss1 + 2;
}
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
return rs + rh.size;
}
bool GPIParser::readFileHeader(QDataStream &stream, quint32 &ebs)
{
RecordHeader rh;
quint32 ds, s7;
quint16 s10;
quint8 s5, s6, s8, s9;
char magic[6];
readRecordHeader(stream, rh);
stream.readRawData(magic, sizeof(magic));
if (memcmp(magic, "GRMREC", sizeof(magic))) {
_errorString = "Not a GPI file";
return false;
}
stream >> s5 >> s6 >> s7 >> s8 >> s9 >> s10;
stream.skipRawData(s10);
ds = sizeof(magic) + 10 + s10;
if (rh.flags & 8)
ds += readFprsRecord(stream);
ebs = (s8 & 0x4) ? s9 * 8 + 8 : 0;
if (stream.status() != QDataStream::Ok || ds != rh.size) {
_errorString = "Invalid file header";
return false;
} else
return true;
}
bool GPIParser::readGPIHeader(QDataStream &stream, QTextCodec **codec)
{
RecordHeader rh;
char m1[6], m2[2];
quint16 codepage = 0;
quint8 s2, s3;
quint32 ds;
readRecordHeader(stream, rh);
stream.readRawData(m1, sizeof(m1));
stream.readRawData(m2, sizeof(m2));
stream >> codepage >> s2 >> s3;
ds = sizeof(m1) + sizeof(m2) + 4;
if (codepage == 65001)
*codec = QTextCodec::codecForName("UTF-8");
else if (codepage == 0)
*codec = 0;
else
*codec = QTextCodec::codecForName(QString("CP%1").arg(codepage)
.toLatin1());
if (s2 & 0x10)
ds += readFileDataRecord(stream, *codec);
if (stream.status() != QDataStream::Ok || ds != rh.size) {
_errorString = "Invalid GPI header";
return false;
} else
return true;
}
void GPIParser::readPOIDatabase(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints)
{
RecordHeader rh;
QList<TranslatedString> obj;
quint32 ds;
readRecordHeader(stream, rh);
ds = readTranslatedObjects(stream, codec, obj);
ds += readSpatialIndex(stream, codec, waypoints);
if (rh.flags & 0x8) {
while (ds < rh.size) {
switch(nextHeaderType(stream)) {
case 5: // symbol
case 7: // category
default:
ds += skipRecord(stream);
}
}
}
if (ds != rh.size)
stream.setStatus(QDataStream::ReadCorruptData);
}
bool GPIParser::readEntry(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints)
{
switch (nextHeaderType(stream)) {
case 0x09: // POI database
readPOIDatabase(stream, codec, waypoints);
break;
case 0xffff: // EOF
skipRecord(stream);
return false;
case 0x16: // route
case 0x15: // info header
default:
skipRecord(stream);
}
return true;
}
bool GPIParser::readData(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints)
{
while (stream.status() == QDataStream::Ok)
if (!readEntry(stream, codec, waypoints))
return stream.atEnd();
return false;
}
bool GPIParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Area> &polygons, QVector<Waypoint> &waypoints)
{
Q_UNUSED(tracks);
Q_UNUSED(routes);
Q_UNUSED(polygons);
QDataStream stream(file);
QTextCodec *codec = 0;
quint32 ebs;
bool ret;
stream.setByteOrder(QDataStream::LittleEndian);
if (!readFileHeader(stream, ebs) || !readGPIHeader(stream, &codec))
return false;
if (ebs) {
QByteArray ba(stream.device()->readAll());
for (int i = 0; i < (ba.size() / (int)ebs); i++)
demangle((quint8*)(ba.data() + i * ebs), ebs, BLOCK_KEY);
demangle((quint8*)(ba.data() + (ba.size() / (int)ebs) * ebs),
ba.size() - ((ba.size() / (int)ebs) * ebs), BLOCK_KEY);
QBuffer buffer(&ba);
buffer.open(QIODevice::ReadOnly);
QDataStream memStream(&buffer);
memStream.setByteOrder(QDataStream::LittleEndian);
ret = readData(memStream, codec, waypoints);
} else
ret = readData(stream, codec, waypoints);
if (!ret) {
_errorString = "Invalid/corrupted GPI data";
return false;
} else
return true;
}

30
src/data/gpiparser.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef GPIPARSER_H
#define GPIPARSER_H
#include "parser.h"
class QDataStream;
class QTextCodec;
class GPIParser : public Parser
{
public:
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Area> &polygons, QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;}
int errorLine() const {return 0;}
private:
bool readFileHeader(QDataStream &stream, quint32 &ebs);
bool readGPIHeader(QDataStream &stream, QTextCodec **codec);
bool readData(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints);
bool readEntry(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints);
void readPOIDatabase(QDataStream &stream, QTextCodec *codec,
QVector<Waypoint> &waypoints);
QString _errorString;
};
#endif // GPIPARSER_H

View File

@ -23,6 +23,21 @@ QDateTime GPXParser::time()
return d;
}
Link GPXParser::link()
{
QString URL = _reader.attributes().value("href").toString();
QString text;
while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("text"))
text = _reader.readElementText();
else
_reader.skipCurrentElement();
}
return Link(URL, text);
}
Coordinates GPXParser::coordinates()
{
bool res;
@ -134,6 +149,7 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
void GPXParser::waypointData(Waypoint &waypoint, SegmentData *autoRoute)
{
qreal gh = NAN;
Link link10;
while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("name"))
@ -146,12 +162,22 @@ void GPXParser::waypointData(Waypoint &waypoint, SegmentData *autoRoute)
gh = number();
else if (_reader.name() == QLatin1String("time"))
waypoint.setTimestamp(time());
else if (_reader.name() == QLatin1String("link")) {
Link l(link());
if (!l.URL().isEmpty())
waypoint.addLink(l);
} else if (_reader.name() == QLatin1String("url"))
link10.setURL(_reader.readElementText());
else if (_reader.name() == QLatin1String("urlname"))
link10.setText(_reader.readElementText());
else if (autoRoute && _reader.name() == QLatin1String("extensions"))
rteptExtensions(autoRoute);
else
_reader.skipCurrentElement();
}
if (!link10.URL().isEmpty())
waypoint.addLink(link10);
if (!std::isnan(gh) && !std::isnan(waypoint.elevation()))
waypoint.setElevation(waypoint.elevation() - gh);
}
@ -172,6 +198,7 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
TrackData autoRoute;
autoRoute.append(SegmentData());
SegmentData &autoRouteSegment = autoRoute.last();
Link link10;
while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("rtept")) {
@ -181,10 +208,21 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
route.setName(_reader.readElementText());
else if (_reader.name() == QLatin1String("desc"))
route.setDescription(_reader.readElementText());
else if (_reader.name() == QLatin1String("link")) {
Link l(link());
if (!l.URL().isEmpty())
route.addLink(l);
} else if (_reader.name() == QLatin1String("url"))
link10.setURL(_reader.readElementText());
else if (_reader.name() == QLatin1String("urlname"))
link10.setText(_reader.readElementText());
else
_reader.skipCurrentElement();
}
if (!link10.URL().isEmpty())
route.addLink(link10);
if (!autoRouteSegment.isEmpty()) {
autoRoute.setName(route.name());
autoRoute.setDescription(route.description());
@ -194,6 +232,8 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
void GPXParser::track(TrackData &track)
{
Link link10;
while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("trkseg")) {
track.append(SegmentData());
@ -202,9 +242,20 @@ void GPXParser::track(TrackData &track)
track.setName(_reader.readElementText());
else if (_reader.name() == QLatin1String("desc"))
track.setDescription(_reader.readElementText());
else if (_reader.name() == QLatin1String("link")) {
Link l(link());
if (!l.URL().isEmpty())
track.addLink(l);
} else if (_reader.name() == QLatin1String("url"))
link10.setURL(_reader.readElementText());
else if (_reader.name() == QLatin1String("urlname"))
link10.setText(_reader.readElementText());
else
_reader.skipCurrentElement();
}
if (!link10.URL().isEmpty())
track.addLink(link10);
}
void GPXParser::area(Area &area)

View File

@ -4,7 +4,6 @@
#include <QXmlStreamReader>
#include "parser.h"
class GPXParser : public Parser
{
public:
@ -30,6 +29,7 @@ private:
qreal number();
QDateTime time();
Coordinates coordinates();
Link link();
QXmlStreamReader _reader;
};

View File

@ -54,6 +54,7 @@ public:
return false;
return true;
}
bool hasTime() const
{
for (int i = 0; i < size(); i++) {

22
src/data/link.h Normal file
View File

@ -0,0 +1,22 @@
#ifndef LINK_H
#define LINK_H
#include <QString>
class Link {
public:
Link() {}
Link(const QString &URL, const QString &text = QString())
: _URL(URL), _text(text) {}
void setURL(const QString &URL) {_URL = URL;}
void setText(const QString &text) {_text = text;}
const QString &URL() const {return _URL;}
const QString &text() const {return _text;}
private:
QString _URL;
QString _text;
};
#endif // LINK_H

View File

@ -38,6 +38,11 @@ void LOCParser::waypoint(Waypoint &waypoint)
} else if (_reader.name() == QLatin1String("coord")) {
waypoint.setCoordinates(coordinates());
_reader.skipCurrentElement();
} else if (_reader.name() == QLatin1String("link")) {
const QXmlStreamAttributes &attr = _reader.attributes();
QString URL(_reader.readElementText());
if (!URL.isEmpty())
waypoint.addLink(Link(URL, attr.value("text").toString()));
} else
_reader.skipCurrentElement();
}

View File

@ -1,4 +1,3 @@
#include "dem.h"
#include "route.h"
@ -33,7 +32,8 @@ Graph Route::elevation() const
GraphSegment &gs = graph.last();
for (int i = 0; i < _data.size(); i++)
gs.append(GraphPoint(_distance.at(i), NAN, _data.at(i).elevation()));
if (_data.at(i).hasElevation())
gs.append(GraphPoint(_distance.at(i), NAN, _data.at(i).elevation()));
return graph;
}

View File

@ -21,6 +21,7 @@ public:
const QString &name() const {return _data.name();}
const QString &description() const {return _data.description();}
const QVector<Link> &links() const {return _data.links();}
bool isValid() const {return _data.size() >= 2;}

View File

@ -4,18 +4,23 @@
#include <QVector>
#include <QString>
#include "waypoint.h"
#include "link.h"
class RouteData : public QVector<Waypoint>
{
public:
const QString& name() const {return _name;}
const QString& description() const {return _desc;}
const QString &name() const {return _name;}
const QString &description() const {return _desc;}
const QVector<Link> &links() const {return _links;}
void setName(const QString &name) {_name = name;}
void setDescription(const QString &desc) {_desc = desc;}
void addLink(const Link &link) {_links.append(link);}
private:
QString _name;
QString _desc;
QVector<Link> _links;
};
#endif // ROUTEDATA_H

View File

@ -1,4 +1,3 @@
#include "dem.h"
#include "track.h"
@ -75,33 +74,50 @@ Track::Track(const TrackData &data) : _data(data), _pause(0)
for (int i = 0; i < _data.size(); i++) {
const SegmentData &sd = _data.at(i);
_segments.append(Segment());
if (sd.isEmpty())
continue;
// precompute distances, times, speeds and acceleration
QVector<qreal> acceleration;
_segments.append(Segment());
Segment &seg = _segments.last();
seg.distance.append(i ? _segments.at(i-1).distance.last() : 0);
seg.time.append(i ? _segments.at(i-1).time.last() :
seg.distance.append(i && !_segments.at(i-1).distance.isEmpty()
? _segments.at(i-1).distance.last() : 0);
seg.time.append(i && !_segments.at(i-1).time.isEmpty()
? _segments.at(i-1).time.last() :
sd.first().hasTimestamp() ? 0 : NAN);
seg.speed.append(sd.first().hasTimestamp() ? 0 : NAN);
acceleration.append(sd.first().hasTimestamp() ? 0 : NAN);
bool hasTime = !std::isnan(seg.time.first());
for (int j = 1; j < sd.size(); j++) {
ds = sd.at(j).coordinates().distanceTo(
sd.at(j-1).coordinates());
seg.distance.append(seg.distance.last() + ds);
if (sd.at(j).timestamp() >= sd.at(j-1).timestamp())
dt = sd.at(j-1).timestamp().msecsTo(
sd.at(j).timestamp()) / 1000.0;
else {
qWarning("%s: %s: time skew detected", qPrintable(_data.name()),
qPrintable(sd.at(j).timestamp().toString(Qt::ISODate)));
dt = 0;
if (hasTime && sd.at(j).timestamp().isValid()) {
if (sd.at(j).timestamp() > sd.at(j-1).timestamp())
dt = sd.at(j-1).timestamp().msecsTo(
sd.at(j).timestamp()) / 1000.0;
else {
qWarning("%s: %s: time skew detected", qPrintable(
_data.name()), qPrintable(sd.at(j).timestamp().toString(
Qt::ISODate)));
dt = 0;
}
} else {
dt = NAN;
if (hasTime) {
qWarning("%s: missing timestamp(s), time graphs disabled",
qPrintable(_data.name()));
hasTime = false;
for (int i = 0; i < seg.time.size(); i++)
seg.time[i] = NAN;
for (int i = 0; i < seg.speed.size(); i++)
seg.speed[i] = NAN;
}
}
seg.time.append(seg.time.last() + dt);
@ -126,7 +142,7 @@ Track::Track(const TrackData &data) : _data(data), _pause(0)
}
}
if (!_outlierEliminate)
if (!_outlierEliminate || !hasTime)
continue;
@ -177,7 +193,7 @@ Graph Track::elevation() const
GraphSegment gs;
for (int j = 0; j < sd.size(); j++) {
if (seg.outliers.contains(j))
if (!sd.at(j).hasElevation() || seg.outliers.contains(j))
continue;
gs.append(GraphPoint(seg.distance.at(j), seg.time.at(j),
sd.at(j).elevation()));

View File

@ -32,6 +32,7 @@ public:
const QString &name() const {return _data.name();}
const QString &description() const {return _data.description();}
const QVector<Link> &links() const {return _data.links();}
bool isValid() const;

View File

@ -5,20 +5,25 @@
#include <QVector>
#include <QString>
#include "trackpoint.h"
#include "link.h"
typedef QVector<Trackpoint> SegmentData;
class TrackData : public QList<SegmentData>
{
public:
const QString& name() const {return _name;}
const QString& description() const {return _desc;}
const QString &name() const {return _name;}
const QString &description() const {return _desc;}
const QVector<Link> &links() const {return _links;}
void setName(const QString &name) {_name = name;}
void setDescription(const QString &desc) {_desc = desc;}
void addLink(const Link &link) {_links.append(link);}
private:
QString _name;
QString _desc;
QVector<Link> _links;
};
#endif // TRACKDATA_H

View File

@ -7,6 +7,7 @@
#include <QDebug>
#include "common/coordinates.h"
#include "imageinfo.h"
#include "link.h"
class Waypoint
{
@ -19,6 +20,7 @@ public:
const QString &name() const {return _name;}
const QString &description() const {return _description;}
const ImageInfo &image() const {return _image;}
const QVector<Link> &links() const {return _links;}
const QDateTime &timestamp() const {return _timestamp;}
qreal elevation() const {return _elevation;}
@ -30,6 +32,7 @@ public:
void setTimestamp(const QDateTime &timestamp) {_timestamp = timestamp;}
void setElevation(qreal elevation) {_elevation = elevation;}
void setImage(const ImageInfo &image) {_image = image;}
void addLink(const Link &link) {_links.append(link);}
bool hasElevation() const {return !std::isnan(_elevation);}
@ -42,6 +45,7 @@ private:
QString _name;
QString _description;
ImageInfo _image;
QVector<Link> _links;
QDateTime _timestamp;
qreal _elevation;
};

View File

@ -9,7 +9,7 @@
#define CHECK(condition) \
if (!(condition)) { \
_errorString = "Invalid/corrupted IMG file"; \
_errorString = "Unsupported or invalid IMG file"; \
return; \
}
@ -85,11 +85,6 @@ IMG::IMG(const QString &fileName)
&& read(type, sizeof(type)) && readValue(size) && readValue(part));
SubFile::Type tt = SubFile::type(type);
if (tt == SubFile::GMP) {
_errorString = "NT maps not supported";
return;
}
QString fn(QByteArray(name, sizeof(name)));
if (SubFile::isTileFile(tt)) {
VectorTile *tile;
@ -101,7 +96,7 @@ IMG::IMG(const QString &fileName)
tile = *it;
SubFile *file = part ? tile->file(tt)
: tile->addFile(this, tt, size);
: tile->addFile(this, tt);
CHECK(file);
_file.seek(offset + 0x20);
@ -114,7 +109,7 @@ IMG::IMG(const QString &fileName)
} else if (tt == SubFile::TYP) {
SubFile *typ = 0;
if (typFile.isNull()) {
_typ = new SubFile(this, size);
_typ = new SubFile(this);
typ = _typ;
typFile = fn;
} else if (fn == typFile)
@ -166,7 +161,7 @@ void IMG::load()
{
Q_ASSERT(!_style);
if (_typ && _typ->isValid())
if (_typ)
_style = new Style(_typ);
else {
QFile typFile(ProgramPaths::typFile());

View File

@ -56,11 +56,11 @@ bool LBLFile::init()
quint16 codepage;
quint8 multiplier, poiMultiplier;
if (!(seek(hdl, 0x15) && readUInt32(hdl, _offset)
if (!(seek(hdl, _gmpOffset + 0x15) && readUInt32(hdl, _offset)
&& readUInt32(hdl, _size) && readByte(hdl, multiplier)
&& readByte(hdl, _encoding) && seek(hdl, 0x57)
&& readByte(hdl, _encoding) && seek(hdl, _gmpOffset + 0x57)
&& readUInt32(hdl, _poiOffset) && readUInt32(hdl, _poiSize)
&& readByte(hdl, poiMultiplier) && seek(hdl, 0xAA)
&& readByte(hdl, poiMultiplier) && seek(hdl, _gmpOffset + 0xAA)
&& readUInt16(hdl, codepage)))
return false;

View File

@ -9,9 +9,12 @@ class QTextCodec;
class LBLFile : public SubFile
{
public:
LBLFile(IMG *img, quint32 size)
: SubFile(img, size), _codec(0), _offset(0), _size(0), _poiOffset(0),
LBLFile(IMG *img)
: SubFile(img), _codec(0), _offset(0), _size(0), _poiOffset(0),
_poiSize(0), _poiMultiplier(0), _multiplier(0), _encoding(0) {}
LBLFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset),
_codec(0), _offset(0), _size(0), _poiOffset(0), _poiSize(0),
_poiMultiplier(0), _multiplier(0), _encoding(0) {}
Label label(Handle &hdl, quint32 offset, bool poi = false);

View File

@ -5,7 +5,7 @@ bool NETFile::init()
Handle hdl;
quint8 multiplier;
if (!(seek(hdl, 0x15) && readUInt32(hdl, _offset)
if (!(seek(hdl, _gmpOffset + 0x15) && readUInt32(hdl, _offset)
&& readUInt32(hdl, _size) && readByte(hdl, multiplier)))
return false;

View File

@ -6,8 +6,9 @@
class NETFile : public SubFile
{
public:
NETFile(IMG *img, quint32 size)
: SubFile(img, size), _offset(0), _size(0), _multiplier(0) {}
NETFile(IMG *img) : SubFile(img), _offset(0), _size(0), _multiplier(0) {}
NETFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset),
_offset(0), _size(0), _multiplier(0) {}
bool lblOffset(Handle &hdl, quint32 netOffset, quint32 &lblOffset);

View File

@ -1,10 +1,26 @@
#include "trefile.h"
#include "common/rectc.h"
#include "units.h"
#include "lblfile.h"
#include "netfile.h"
#include "rgnfile.h"
static int bitSize(quint8 baseSize, bool variableSign, bool extraBit)
{
int bits = 2;
if (baseSize <= 9)
bits += baseSize;
else
bits += 2 * baseSize - 9;
if (variableSign)
bits++;
if (extraBit)
bits++;
return bits;
}
bool RGNFile::BitStream::read(int bits, quint32 &val)
{
val = 0;
@ -34,29 +50,42 @@ bool RGNFile::BitStream::read(int bits, quint32 &val)
return true;
}
bool RGNFile::BitStream::readDelta(int bits, int sign, bool extraBit,
RGNFile::DeltaStream::DeltaStream(const SubFile &file, Handle &hdl,
quint32 length, quint8 info, bool extraBit, bool extended)
: BitStream(file, hdl, length), _readBits(0xFFFFFFFF)
{
_extraBit = extraBit ? 1 : 0;
if (!(sign(_lonSign) && sign(_latSign)))
return;
if (extended) {
quint32 b;
if (!read(1, b))
return;
}
_lonBits = bitSize(info & 0x0F, !_lonSign, extraBit);
_latBits = bitSize(info >> 4, !_latSign, false);
_readBits = _lonBits + _latBits;
}
bool RGNFile::DeltaStream::readDelta(int bits, int sign, int extraBit,
qint32 &delta)
{
quint32 value;
int bo = 0;
if (!read(bits, value))
return false;
if (extraBit) {
value>>=1;
bo = 1;
}
value >>= extraBit;
if (!sign) {
qint32 signMask = 1 << (bits - bo - 1);
qint32 signMask = 1 << (bits - extraBit - 1);
if (value & signMask) {
qint32 comp = value ^ signMask;
if (comp)
delta = comp - signMask;
else {
qint32 other;
if (!readDelta(bits - bo, sign, false, other))
if (!readDelta(bits - extraBit, sign, false, other))
return false;
if (other < 0)
delta = 1 - signMask + other;
@ -73,42 +102,15 @@ bool RGNFile::BitStream::readDelta(int bits, int sign, bool extraBit,
return true;
}
bool RGNFile::BitStream::finish()
{
while (_length--)
if (!_file.readByte(_hdl, _data))
return false;
return true;
}
bool RGNFile::init()
{
Handle hdl;
if (!(seek(hdl, 0x15) && readUInt32(hdl, _offset)
&& readUInt32(hdl, _size) && readUInt32(hdl, _polygonsOffset)
&& readUInt32(hdl, _polygonsSize) && seek(hdl, 0x39)
&& readUInt32(hdl, _linesOffset) && readUInt32(hdl, _linesSize)
&& seek(hdl, 0x55) && readUInt32(hdl, _pointsOffset)
&& readUInt32(hdl, _pointsSize)))
return false;
if (_offset + _size > size())
return false;
return true;
}
bool RGNFile::sign(BitStream &bs, int &val)
bool RGNFile::DeltaStream::sign(int &val)
{
quint32 bit;
val = 0;
if (!bs.read(1, bit))
if (!read(1, bit))
return false;
if (bit) {
if (!bs.read(1, bit))
if (!read(1, bit))
return false;
val = bit ? -1 : 1;
}
@ -116,20 +118,41 @@ bool RGNFile::sign(BitStream &bs, int &val)
return true;
}
int RGNFile::bitSize(quint8 baseSize, bool variableSign, bool extraBit)
bool RGNFile::init()
{
int bits = 2;
if (baseSize <= 9)
bits += baseSize;
else
bits += 2 * baseSize - 9;
Handle hdl;
quint16 hdrLen;
if (variableSign)
bits++;
if (extraBit)
bits++;
if (!(seek(hdl, _gmpOffset) && readUInt16(hdl, hdrLen)
&& seek(hdl, _gmpOffset + 0x15) && readUInt32(hdl, _offset)
&& readUInt32(hdl, _size)))
return false;
return bits;
if (hdrLen >= 0x5D) {
if (!(readUInt32(hdl, _polygonsOffset) && readUInt32(hdl, _polygonsSize)
&& seek(hdl, _gmpOffset + 0x39) && readUInt32(hdl, _linesOffset)
&& readUInt32(hdl, _linesSize) && seek(hdl, _gmpOffset + 0x55)
&& readUInt32(hdl, _pointsOffset) && readUInt32(hdl, _pointsSize)))
return false;
}
if (hdrLen >= 0x7D) {
quint32 dictOffset, dictSize;
if (!(seek(hdl, _gmpOffset + 0x71) && readUInt32(hdl, dictOffset)
&& readUInt32(hdl, dictSize)))
return false;
// NT maps
if (dictSize || dictOffset) {
qWarning("NT compression not supported");
return false;
}
}
_init = true;
return true;
}
bool RGNFile::polyObjects(const RectC &rect, Handle &hdl, const SubDiv *subdiv,
@ -167,28 +190,17 @@ bool RGNFile::polyObjects(const RectC &rect, Handle &hdl, const SubDiv *subdiv,
poly.type = (segment.type() == Segment::Polygon)
? ((quint32)(type & 0x7F)) << 8 : ((quint32)(type & 0x3F)) << 8;
RectC br;
QPoint pos(subdiv->lon() + ((qint32)lon<<(24-subdiv->bits())),
subdiv->lat() + ((qint32)lat<<(24-subdiv->bits())));
Coordinates c(toWGS84(pos.x()), toWGS84(pos.y()));
br = br.united(c);
RectC br(c, c);
poly.points.append(QPointF(c.lon(), c.lat()));
BitStream bs(*this, hdl, len);
int lonSign, latSign;
if (!sign(bs, lonSign) || !sign(bs, latSign))
return false;
bool extraBit = labelPtr & 0x400000;
int lonBits = bitSize(bitstreamInfo & 0x0F, !lonSign, extraBit);
int latBits = bitSize(bitstreamInfo >> 4, !latSign, false);
while (bs.hasNext(lonBits + latBits)) {
qint32 lonDelta, latDelta;
if (!(bs.readDelta(lonBits, lonSign, extraBit, lonDelta)
&& bs.readDelta(latBits, latSign, false, latDelta)))
return false;
qint32 lonDelta, latDelta;
DeltaStream stream(*this, hdl, len, bitstreamInfo, labelPtr & 0x400000,
false);
while (stream.readNext(lonDelta, latDelta)) {
pos.rx() += lonDelta<<(24-subdiv->bits());
pos.ry() += latDelta<<(24-subdiv->bits());
@ -196,7 +208,7 @@ bool RGNFile::polyObjects(const RectC &rect, Handle &hdl, const SubDiv *subdiv,
poly.points.append(QPointF(c.lon(), c.lat()));
br = br.united(c);
}
if (!bs.finish())
if (!(stream.atEnd() && stream.flush()))
return false;
if (!rect.intersects(br))
@ -222,10 +234,9 @@ bool RGNFile::extPolyObjects(const RectC &rect, Handle &hdl,
const SubDiv *subdiv, const Segment &segment, LBLFile *lbl, Handle &lblHdl,
QList<IMG::Poly> *polys) const
{
quint32 labelPtr;
quint8 type, subtype, len8, len82, bitstreamInfo;
quint32 len, labelPtr = 0;
quint8 type, subtype, bitstreamInfo;
qint16 lon, lat;
quint16 len;
if (!seek(hdl, segment.start()))
@ -235,7 +246,8 @@ bool RGNFile::extPolyObjects(const RectC &rect, Handle &hdl,
IMG::Poly poly;
if (!(readByte(hdl, type) && readByte(hdl, subtype)
&& readInt16(hdl, lon) && readInt16(hdl, lat) && readByte(hdl, len8)))
&& readInt16(hdl, lon) && readInt16(hdl, lat)
&& readVUInt32(hdl, len) && readByte(hdl, bitstreamInfo)))
return false;
if (subtype & 0x80) {
@ -243,40 +255,17 @@ bool RGNFile::extPolyObjects(const RectC &rect, Handle &hdl,
return false;
}
if (len8 & 0x01)
len = (len8>>1) - 1;
else {
if (!readByte(hdl, len82))
return false;
len = ((len8 | ((quint16)len82<<8))>>2) - 1;
}
if (!readByte(hdl, bitstreamInfo))
return false;
poly.type = 0x10000 + (quint16(type) << 8) + (subtype & 0x1F);
RectC br;
QPoint pos(subdiv->lon() + ((qint32)lon<<(24-subdiv->bits())),
subdiv->lat() + ((qint32)lat<<(24-subdiv->bits())));
Coordinates c(toWGS84(pos.x()), toWGS84(pos.y()));
br = br.united(c);
RectC br(c, c);
poly.points.append(QPointF(c.lon(), c.lat()));
BitStream bs(*this, hdl, len);
int lonSign, latSign;
if (!sign(bs, lonSign) || !sign(bs, latSign))
return false;
quint32 extraBit;
bs.read(1, extraBit);
int lonBits = bitSize(bitstreamInfo & 0x0F, !lonSign, extraBit);
int latBits = bitSize(bitstreamInfo >> 4, !latSign, extraBit);
while (bs.hasNext(lonBits + latBits)) {
qint32 lonDelta, latDelta;
if (!(bs.readDelta(lonBits, lonSign, false, lonDelta)
&& bs.readDelta(latBits, latSign, false, latDelta)))
return false;
qint32 lonDelta, latDelta;
DeltaStream stream(*this, hdl, len - 1, bitstreamInfo, false, true);
while (stream.readNext(lonDelta, latDelta)) {
pos.rx() += lonDelta<<(24-subdiv->bits());
pos.ry() += latDelta<<(24-subdiv->bits());
@ -284,19 +273,21 @@ bool RGNFile::extPolyObjects(const RectC &rect, Handle &hdl,
poly.points.append(QPointF(c.lon(), c.lat()));
br = br.united(c);
}
if (!bs.finish())
if (!(stream.atEnd() && stream.flush()))
return false;
if (subtype & 0x20) {
if ((subtype & 0x20)) {
if (!readUInt24(hdl, labelPtr))
return false;
if (lbl && (labelPtr & 0x3FFFFF))
poly.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF);
}
} else
labelPtr = 0;
if (!rect.intersects(br))
continue;
if (lbl && (labelPtr & 0x3FFFFF))
poly.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF);
polys->append(poly);
}
@ -404,7 +395,7 @@ void RGNFile::objects(const RectC &rect, const SubDiv *subdiv, LBLFile *lbl,
{
Handle rgnHdl, lblHdl, netHdl;
if (!_size && !init())
if (!_init && !init())
return;
QVector<RGNFile::Segment> seg(segments(rgnHdl, subdiv));
@ -436,7 +427,7 @@ void RGNFile::extObjects(const RectC &rect, const SubDiv *subdiv, LBLFile *lbl,
{
Handle rgnHdl, lblHdl;
if (!_size && !init())
if (!_init && !init())
return;
if (polygons && subdiv->polygonsOffset() != subdiv->polygonsEnd()) {

View File

@ -11,10 +11,13 @@ class NETFile;
class RGNFile : public SubFile
{
public:
RGNFile(IMG *img, quint32 size)
: SubFile(img, size), _offset(0), _size(0), _polygonsOffset(0),
_polygonsSize(), _linesOffset(), _linesSize(), _pointsOffset(),
_pointsSize() {}
RGNFile(IMG *img)
: SubFile(img), _offset(0), _size(0), _polygonsOffset(0),
_polygonsSize(0), _linesOffset(0), _linesSize(0), _pointsOffset(0),
_pointsSize(0), _init(false) {}
RGNFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset), _offset(0),
_size(0), _polygonsOffset(0), _polygonsSize(0), _linesOffset(0),
_linesSize(0), _pointsOffset(0), _pointsSize(0), _init(false) {}
void objects(const RectC &rect, const SubDiv *subdiv, LBLFile *lbl,
NETFile *net, QList<IMG::Poly> *polygons, QList<IMG::Poly> *lines,
@ -53,27 +56,45 @@ private:
class BitStream {
public:
BitStream(const SubFile &file, Handle &hdl, quint16 length)
BitStream(const SubFile &file, Handle &hdl, quint32 length)
: _file(file), _hdl(hdl), _length(length), _remaining(0) {}
bool read(int bits, quint32 &val);
bool readDelta(int bits, int sign, bool extraBit, qint32 &delta);
bool hasNext(int bits) const
{return _length * 8 + _remaining >= (quint32)bits;}
bool finish();
bool flush() {return _file.seek(_hdl, _hdl.pos + _length);}
quint32 bitsAvailable() const {return _length * 8 + _remaining;}
private:
const SubFile &_file;
Handle &_hdl;
quint16 _length;
quint32 _remaining;
quint32 _length, _remaining;
quint8 _data;
};
static bool sign(BitStream &bs, int &val);
static int bitSize(quint8 baseSize, bool variableSign, bool extraBit);
class DeltaStream : public BitStream {
public:
DeltaStream(const SubFile &file, Handle &hdl, quint32 length,
quint8 info, bool extraBit, bool extended);
bool readNext(qint32 &lonDelta, qint32 &latDelta)
{
return hasNext()
? (readDelta(_lonBits, _lonSign, _extraBit, lonDelta)
&& readDelta(_latBits, _latSign, false, latDelta))
: false;
}
bool atEnd() const {return (_readBits != 0xFFFFFFFF && !hasNext());}
private:
bool hasNext() const {return bitsAvailable() >= _readBits;}
bool sign(int &val);
bool readDelta(int bits, int sign, int extraBit, qint32 &delta);
int _lonSign, _latSign, _extraBit;
quint32 _lonBits, _latBits, _readBits;
};
bool init();
QVector<Segment> segments(Handle &hdl, const SubDiv *subdiv) const;
bool polyObjects(const RectC &rect, Handle &hdl, const SubDiv *subdiv,
const Segment &segment, LBLFile *lbl, Handle &lblHdl, NETFile *net,
@ -99,6 +120,8 @@ private:
quint32 _linesSize;
quint32 _pointsOffset;
quint32 _pointsSize;
bool _init;
};
#ifndef QT_NO_DEBUG

View File

@ -942,7 +942,7 @@ Style::Style(SubFile *typ)
defaultPolygonStyle();
defaultPointStyle();
if (typ && typ->isValid())
if (typ)
parseTYPFile(typ);
}

View File

@ -20,21 +20,13 @@ SubFile::Type SubFile::type(const char str[3])
return Unknown;
}
SubFile::SubFile(QFile *file) : _img(0), _file(file), _size(0)
SubFile::SubFile(QFile *file) :_gmpOffset(0), _img(0), _file(file), _blocks(0)
{
if (!_file->open(QIODevice::ReadOnly))
qWarning("Error opening %s: %s", qPrintable(_file->fileName()),
qPrintable(_file->errorString()));
}
bool SubFile::isValid() const
{
return _file
? _file->isOpen()
: ((quint32)_img->blockSize() * (quint32)_blocks.size() - _size
< (quint32)_img->blockSize());
}
bool SubFile::seek(Handle &handle, quint32 pos) const
{
Q_ASSERT(_img || _file);
@ -46,9 +38,9 @@ bool SubFile::seek(Handle &handle, quint32 pos) const
int blockNum = pos / blockSize;
if (handle.blockNum != blockNum) {
if (blockNum >= _blocks.size())
if (blockNum >= _blocks->size())
return false;
if (!_img->readBlock(_blocks.at(blockNum), handle.data))
if (!_img->readBlock(_blocks->at(blockNum), handle.data))
return false;
handle.blockNum = blockNum;
}
@ -74,9 +66,35 @@ bool SubFile::readByte(Handle &handle, quint8 &val) const
}
}
quint32 SubFile::size() const
bool SubFile::readVUInt32(Handle &hdl, quint32 &val) const
{
return _file ? (quint32)_file->size() : _size;
quint8 bytes, shift, b;
if (!readByte(hdl, b))
return false;
if ((b & 1) == 0) {
if ((b & 2) == 0) {
bytes = ((b >> 2) & 1) ^ 3;
shift = 5;
} else {
shift = 6;
bytes = 1;
}
} else {
shift = 7;
bytes = 0;
}
val = b >> (8 - shift);
for (int i = 1; i <= bytes; i++) {
if (!readByte(hdl, b))
return false;
val |= (((quint32)b) << (i * 8)) >> (8 - shift);
}
return true;
}
QString SubFile::fileName() const
@ -88,15 +106,15 @@ QString SubFile::fileName() const
QDebug operator<<(QDebug dbg, const SubFile &file)
{
bool continuous = true;
for (int i = 1; i < file._blocks.size(); i++) {
if (file._blocks.at(i) != file._blocks.at(i-1) + 1) {
for (int i = 1; i < file._blocks->size(); i++) {
if (file._blocks->at(i) != file._blocks->at(i-1) + 1) {
continuous = false;
break;
}
}
dbg.nospace() << "SubFile(" << file._size << ", " << file._blocks.size()
<< ", " << continuous << ")";
dbg.nospace() << "SubFile(" << file._blocks->size() << ", "
<< continuous << ")";
return dbg.space();
}
#endif // QT_NO_DEBUG

View File

@ -22,13 +22,14 @@ public:
int pos;
};
SubFile(IMG *img, quint32 size) : _img(img), _file(0), _size(size) {}
SubFile(IMG *img) : _gmpOffset(0), _img(img), _file(0),
_blocks(&_blockData) {}
SubFile(SubFile *gmp, quint32 offset) : _gmpOffset(offset), _img(gmp->_img),
_file(0), _blocks(&(gmp->_blockData)) {}
SubFile(QFile *file);
void addBlock(quint16 block) {_blocks.append(block);}
bool isValid() const;
void addBlock(quint16 block) {_blocks->append(block);}
quint32 size() const;
bool seek(Handle &handle, quint32 pos) const;
bool readByte(Handle &handle, quint8 &val) const;
@ -80,20 +81,28 @@ public:
return true;
}
quint16 offset() const {return _blocks.first();}
bool readVUInt32(Handle &hdl, quint32 &val) const;
quint16 offset() const {return _blocks->first();}
QString fileName() const;
static Type type(const char str[3]);
static bool isTileFile(Type type)
{return (type == TRE || type == LBL || type == RGN || type == NET);}
{
return (type == TRE || type == LBL || type == RGN || type == NET
|| type == GMP);
}
friend QDebug operator<<(QDebug dbg, const SubFile &file);
protected:
quint32 _gmpOffset;
private:
IMG *_img;
QFile *_file;
quint32 _size;
QVector<quint16> _blocks;
QVector<quint16> *_blocks;
QVector<quint16> _blockData;
};
#ifndef QT_NO_DEBUG

View File

@ -43,28 +43,28 @@ bool TREFile::init()
quint8 locked;
quint16 hdrLen;
if (!(seek(hdl, 0) && readUInt16(hdl, hdrLen)
&& seek(hdl, 0x0D) && readByte(hdl, locked)))
if (!(seek(hdl, _gmpOffset) && readUInt16(hdl, hdrLen)
&& seek(hdl, _gmpOffset + 0x0D) && readByte(hdl, locked)))
return false;
// Tile bounds
qint32 north, east, south, west;
if (!(seek(hdl, 0x15) && readInt24(hdl, north) && readInt24(hdl, east)
&& readInt24(hdl, south) && readInt24(hdl, west)))
if (!(seek(hdl, _gmpOffset + 0x15) && readInt24(hdl, north)
&& readInt24(hdl, east) && readInt24(hdl, south) && readInt24(hdl, west)))
return false;
_bounds = RectC(Coordinates(toWGS84(west), toWGS84(north)),
Coordinates(toWGS84(east), toWGS84(south)));
// Levels & subdivs info
quint32 levelsOffset, levelsSize, subdivSize;
if (!(seek(hdl, 0x21) && readUInt32(hdl, levelsOffset)
if (!(seek(hdl, _gmpOffset + 0x21) && readUInt32(hdl, levelsOffset)
&& readUInt32(hdl, levelsSize) && readUInt32(hdl, _subdivOffset)
&& readUInt32(hdl, subdivSize)))
return false;
// TRE7 info
if (hdrLen > 0x9A) {
if (!(seek(hdl, 0x7C) && readUInt32(hdl, _extended.offset)
if (!(seek(hdl, _gmpOffset + 0x7C) && readUInt32(hdl, _extended.offset)
&& readUInt32(hdl, _extended.size)
&& readUInt16(hdl, _extended.itemSize)))
return false;
@ -80,7 +80,7 @@ bool TREFile::init()
if (locked) {
quint32 key;
quint8 unlocked[64];
if (!seek(hdl, 0xAA) || !readUInt32(hdl, key))
if (!seek(hdl, _gmpOffset + 0xAA) || !readUInt32(hdl, key))
return false;
unlock(unlocked, levels, levelsSize, key);
memcpy(levels, unlocked, levelsSize);

View File

@ -13,7 +13,8 @@ class SubDiv;
class TREFile : public SubFile
{
public:
TREFile(IMG *img, quint32 size) : SubFile(img, size) {}
TREFile(IMG *img) : SubFile(img) {}
TREFile(SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {}
~TREFile();
bool init();

View File

@ -11,26 +11,31 @@ SubFile *VectorTile::file(SubFile::Type type)
return _lbl;
case SubFile::NET:
return _net;
case SubFile::GMP:
return _gmp;
default:
return 0;
}
}
SubFile *VectorTile::addFile(IMG *img, SubFile::Type type, quint32 size)
SubFile *VectorTile::addFile(IMG *img, SubFile::Type type)
{
switch (type) {
case SubFile::TRE:
_tre = new TREFile(img, size);
_tre = new TREFile(img);
return _tre;
case SubFile::RGN:
_rgn = new RGNFile(img, size);
_rgn = new RGNFile(img);
return _rgn;
case SubFile::LBL:
_lbl = new LBLFile(img, size);
_lbl = new LBLFile(img);
return _lbl;
case SubFile::NET:
_net = new NETFile(img, size);
_net = new NETFile(img);
return _net;
case SubFile::GMP:
_gmp = new SubFile(img);
return _gmp;
default:
return 0;
}
@ -38,14 +43,30 @@ SubFile *VectorTile::addFile(IMG *img, SubFile::Type type, quint32 size)
bool VectorTile::init()
{
if (!(_tre && _tre->isValid() && _tre->init() && _rgn
&& _rgn->isValid()))
if (_gmp && !initGMP())
return false;
if (_lbl && !_lbl->isValid())
if (!(_tre && _tre->init() && _rgn))
return false;
if (_net && !_net->isValid())
return true;
}
bool VectorTile::initGMP()
{
SubFile::Handle hdl;
quint32 tre, rgn, lbl, net;
if (!(_gmp->seek(hdl, 0x19) && _gmp->readUInt32(hdl, tre)
&& _gmp->readUInt32(hdl, rgn) && _gmp->readUInt32(hdl, lbl)
&& _gmp->readUInt32(hdl, net)))
return false;
_tre = new TREFile(_gmp, tre);
_rgn = new RGNFile(_gmp, rgn);
_lbl = new LBLFile(_gmp, lbl);
_net = new NETFile(_gmp, net);
return true;
}

View File

@ -10,8 +10,9 @@
class VectorTile {
public:
VectorTile() : _tre(0), _rgn(0), _lbl(0), _net(0) {}
~VectorTile() {delete _tre; delete _rgn; delete _lbl; delete _net;}
VectorTile() : _tre(0), _rgn(0), _lbl(0), _net(0), _gmp(0) {}
~VectorTile()
{delete _tre; delete _rgn; delete _lbl; delete _net; delete _gmp;}
bool init();
void clear() {_tre->clear();}
@ -19,7 +20,7 @@ public:
const RectC &bounds() const {return _tre->bounds();}
SubFile *file(SubFile::Type type);
SubFile *addFile(IMG *img, SubFile::Type type, quint32 size);
SubFile *addFile(IMG *img, SubFile::Type type);
void objects(const RectC &rect, int bits, QList<IMG::Poly> *polygons,
QList<IMG::Poly> *lines, QList<IMG::Point> *points) const;
@ -27,10 +28,13 @@ public:
friend QDebug operator<<(QDebug dbg, const VectorTile &tile);
private:
bool initGMP();
TREFile *_tre;
RGNFile *_rgn;
LBLFile *_lbl;
NETFile *_net;
SubFile *_gmp;
};
#ifndef QT_NO_DEBUG

View File

@ -16,8 +16,8 @@
#include "imgmap.h"
#define TILE_SIZE 256
#define TEXT_EXTENT 256
#define TILE_SIZE 384
#define TEXT_EXTENT 160
#define AREA(rect) \
(rect.size().width() * rect.size().height())
@ -419,7 +419,7 @@ void IMGMap::processShields(QList<IMG::Poly> &lines, const QRect &tileRect,
= shields.constBegin(); it != shields.constEnd(); ++it) {
const QPolygonF &p = it.value();
QRectF rect(p.boundingRect() & tileRect);
if (qSqrt(AREA(rect)) < 32)
if (qSqrt(AREA(rect)) < TILE_SIZE/8)
continue;
QMap<qreal, int> map;

View File

@ -124,7 +124,8 @@ void OnlineMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
Tile &t = tiles[i];
QPointF tp = _zoom ? QPointF(tl.x() + (t.xy().x() - tile.x())
* tileSize(), tl.y() + ((_invertY ? (1<<_zoom) - t.xy().y() - 1 :
t.xy().y()) - tile.y()) * tileSize()) : QPointF(-128, -128);
t.xy().y()) - tile.y()) * tileSize())
: QPointF(-_tileSize/2, -_tileSize/2);
if (!t.pixmap().isNull()) {
#ifdef ENABLE_HIDPI