Compare commits
91 Commits
a4449897a7
...
13.36
Author | SHA1 | Date | |
---|---|---|---|
71a757983f | |||
cc7209ad70 | |||
ba49497608 | |||
48404ea43b | |||
b9fb9eece3 | |||
0cac0369aa | |||
cdf198ec1d | |||
0896b54831 | |||
9f1808274f | |||
5d2465cffc | |||
2ab7bff3f8 | |||
060cfb574d | |||
5c178b4088 | |||
2f4a7f8053 | |||
5f1838ea30 | |||
bdf75169c5 | |||
9295f8f4a9 | |||
3fc8e69ebb | |||
4438bc8d52 | |||
f9e99fcc73 | |||
8041aa454c | |||
f494543e54 | |||
1ee60b4f96 | |||
70936cafe3 | |||
ca17ec9e5f | |||
74781d6462 | |||
d3781e7f0b | |||
466e8f2909 | |||
c4e44c8796 | |||
1c9dd610d5 | |||
59be4aaf1a | |||
538ec4f71b | |||
398ef2c4f5 | |||
9bb56032b0 | |||
5df43d3fb5 | |||
c3e76e1d3d | |||
ac41483530 | |||
766000458d | |||
e0000d7299 | |||
9059e6d30d | |||
0d029636be | |||
819a67158a | |||
89b4bc56e4 | |||
610dd0a009 | |||
08d09d038e | |||
41e8b7094a | |||
02c236a49e | |||
0ee28d7f45 | |||
98acd3f75a | |||
f67c262292 | |||
7cfd62ca97 | |||
a3459e34e0 | |||
d43f58deb9 | |||
73e7a1dbf4 | |||
319cdbf838 | |||
213ab73ceb | |||
db2d81042b | |||
e27bc437fa | |||
3dd21ade19 | |||
46ea3dd257 | |||
0ed630dd20 | |||
9cd82319e9 | |||
335df85fae | |||
f1b52c7005 | |||
b3fd46a225 | |||
c678866c22 | |||
e2764b6232 | |||
ad13a5b0cf | |||
2b967ce05e | |||
5ff99b13a2 | |||
7a161fa364 | |||
7ee681313f | |||
871cb8433c | |||
2a925b0c84 | |||
1219801910 | |||
25fb9e5f9b | |||
701f392a29 | |||
699e086618 | |||
eeee16ff9b | |||
001fa34cdd | |||
a97dc3b6c2 | |||
f2ae75d7f5 | |||
816681f267 | |||
d738555a68 | |||
4e466d16a1 | |||
b7bb3b649a | |||
e0e9fa660a | |||
67b91f62a0 | |||
0ab6e02e6c | |||
7f20e2e307 | |||
68f1f1fc3f |
@ -1,4 +1,4 @@
|
||||
version: 13.34.{build}
|
||||
version: 13.36.{build}
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
@ -12,9 +12,8 @@ environment:
|
||||
- QTDIR: C:\Qt\5.15\msvc2019_64
|
||||
OPENSSLDIR: C:\OpenSSL-v111-Win64\bin
|
||||
NSISDEF: /DOPENSSL /DANGLE
|
||||
- QTDIR: C:\Qt\6.8\msvc2019_64
|
||||
OPENSSLDIR: C:\OpenSSL-v33-Win64\bin
|
||||
NSISDEF: /DQT6 /DOPENSSL
|
||||
- QTDIR: C:\Qt\6.8\msvc2022_64
|
||||
NSISDEF: /DQT6
|
||||
|
||||
install:
|
||||
- cmd: |-
|
||||
@ -36,8 +35,8 @@ build_script:
|
||||
xcopy lang\*.qm installer\translations\ /sy
|
||||
xcopy icons\symbols installer\symbols /i
|
||||
copy licence.txt installer
|
||||
copy %OPENSSLDIR%\libcrypto-*-x64.dll installer
|
||||
copy %OPENSSLDIR%\libssl-*-x64.dll installer
|
||||
IF DEFINED OPENSSLDIR (copy %OPENSSLDIR%\libcrypto-*-x64.dll installer)
|
||||
IF DEFINED OPENSSLDIR (copy %OPENSSLDIR%\libssl-*-x64.dll installer)
|
||||
|
||||
makensis.exe %NSISDEF% installer\gpxsee64.nsi
|
||||
|
||||
|
7
.github/workflows/linux.yml
vendored
@ -8,7 +8,10 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
name: GPXSee
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
config: ['release', 'debug']
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
@ -19,6 +22,6 @@ jobs:
|
||||
- name: Create localization
|
||||
run: lrelease gpxsee.pro
|
||||
- name: Configure build
|
||||
run: qmake gpxsee.pro
|
||||
run: qmake CONFIG+=${{ matrix.config }} gpxsee.pro
|
||||
- name: Build project
|
||||
run: make -j2
|
||||
|
2
.github/workflows/osx.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
- name: Install Qt
|
||||
uses: jurplel/install-qt-action@v4
|
||||
with:
|
||||
version: '6.8.0'
|
||||
version: '6.8.2'
|
||||
modules: qtpositioning qtserialport qtimageformats
|
||||
- name: Create localization
|
||||
run: lrelease gpxsee.pro
|
||||
|
@ -6,6 +6,7 @@ GPS log file formats.
|
||||
* Opens GPX, TCX, FIT, KML, NMEA, IGC, CUP, SIGMA SLF, Suunto SML, LOC, GeoJSON,
|
||||
OziExplorer (PLT, RTE, WPT), Garmin GPI&CSV, TomTom OV2&ITN, ONmove OMD/GHP,
|
||||
TwoNav (TRK, RTE, WPT), GPSDump WPT and geotagged JPEG files.
|
||||
* Opens geo URIs (RFC 5870).
|
||||
* User-definable online maps (OpenStreetMap/Google tiles, WMTS, WMS, TMS,
|
||||
QuadTiles).
|
||||
* Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases,
|
||||
@ -28,8 +29,8 @@ GPS log file formats.
|
||||
|
||||
## Build
|
||||
Build requirements:
|
||||
* Qt5 >= 5.11 or Qt6 >= 6.2 (Android builds require Qt6)
|
||||
* C++11 or newer compiler (tested: msvc2019, gcc 7.5.0, clang/Apple LLVM version
|
||||
* Qt5 >= 5.15 or Qt6 >= 6.2 (Android builds require Qt6)
|
||||
* C++11 or newer compiler (tested: msvc2022, gcc 11, clang/Apple LLVM version
|
||||
10.0.0)
|
||||
|
||||
Build steps:
|
||||
|
@ -3,8 +3,7 @@ unix:!macx:!android {
|
||||
} else {
|
||||
TARGET = GPXSee
|
||||
}
|
||||
VERSION = 13.34
|
||||
|
||||
VERSION = 13.36
|
||||
|
||||
QT += core \
|
||||
gui \
|
||||
@ -118,6 +117,7 @@ HEADERS += src/common/config.h \
|
||||
src/data/gpsdumpparser.h \
|
||||
src/data/style.h \
|
||||
src/data/twonavparser.h \
|
||||
src/map/IMG/light.h \
|
||||
src/map/downloader.h \
|
||||
src/map/demloader.h \
|
||||
src/map/ENC/attributes.h \
|
||||
@ -523,7 +523,7 @@ win32 {
|
||||
RESOURCES += theme-color.qrc
|
||||
|
||||
QMAKE_TARGET_DESCRIPTION = GPXSee
|
||||
QMAKE_TARGET_COPYRIGHT = Copyright (c) 2015-2024 Martin Tuma
|
||||
QMAKE_TARGET_COPYRIGHT = Copyright (c) 2015-2025 Martin Tuma
|
||||
RC_ICONS = icons/app/gpxsee.ico \
|
||||
icons/formats/gpx.ico \
|
||||
icons/formats/tcx.ico \
|
||||
|
10
gpxsee.qrc
@ -193,6 +193,10 @@
|
||||
<file alias="overfalls.png">icons/map/marine/overfalls.png</file>
|
||||
<file alias="boarding-place.png">icons/map/marine/boarding-place.png</file>
|
||||
<file alias="light.png">icons/map/marine/light.png</file>
|
||||
<file alias="light-red.png">icons/map/marine/light-red.png</file>
|
||||
<file alias="light-green.png">icons/map/marine/light-green.png</file>
|
||||
<file alias="light-yellow.png">icons/map/marine/light-yellow.png</file>
|
||||
<file alias="light-white.png">icons/map/marine/light-white.png</file>
|
||||
<file alias="building.png">icons/map/marine/building.png</file>
|
||||
<file alias="fog-signal.png">icons/map/marine/fog-signal.png</file>
|
||||
<file alias="construction.png">icons/map/marine/construction.png</file>
|
||||
@ -206,6 +210,12 @@
|
||||
<file alias="kelp.png">icons/map/marine/kelp.png</file>
|
||||
<file alias="eddies.png">icons/map/marine/eddies.png</file>
|
||||
<file alias="dome.png">icons/map/marine/dome.png</file>
|
||||
<file alias="radar-reflector.png">icons/map/marine/radar-reflector.png</file>
|
||||
<file alias="24h-anchorage.png">icons/map/marine/24h-anchorage.png</file>
|
||||
<file alias="dw-anchorage.png">icons/map/marine/dw-anchorage.png</file>
|
||||
<file alias="tanker-anchorage.png">icons/map/marine/tanker-anchorage.png</file>
|
||||
<file alias="nature-reserve-line.png">icons/map/marine/nature-reserve-line.png</file>
|
||||
<file alias="sanctuary-line.png">icons/map/marine/sanctuary-line.png</file>
|
||||
</qresource>
|
||||
|
||||
<!-- Patterns (Mapsforge) -->
|
||||
|
BIN
icons/map/marine/24h-anchorage.png
Normal file
After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 294 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 202 B |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 215 B |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 393 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 190 B |
BIN
icons/map/marine/dw-anchorage.png
Normal file
After Width: | Height: | Size: 296 B |
Before Width: | Height: | Size: 259 B After Width: | Height: | Size: 189 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 382 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 238 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 219 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 220 B |
BIN
icons/map/marine/light-green.png
Normal file
After Width: | Height: | Size: 466 B |
BIN
icons/map/marine/light-red.png
Normal file
After Width: | Height: | Size: 417 B |
BIN
icons/map/marine/light-white.png
Normal file
After Width: | Height: | Size: 330 B |
BIN
icons/map/marine/light-yellow.png
Normal file
After Width: | Height: | Size: 330 B |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 401 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 286 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 261 B |
BIN
icons/map/marine/nature-reserve-line.png
Normal file
After Width: | Height: | Size: 217 B |
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 212 B |
BIN
icons/map/marine/radar-reflector.png
Normal file
After Width: | Height: | Size: 236 B |
BIN
icons/map/marine/sanctuary-line.png
Normal file
After Width: | Height: | Size: 127 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 243 B |
BIN
icons/map/marine/tanker-anchorage.png
Normal file
After Width: | Height: | Size: 413 B |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 266 B |
@ -486,17 +486,17 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="370"/>
|
||||
<source>All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>所有图层</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="374"/>
|
||||
<source>Raster only</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>仅栅格层</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="378"/>
|
||||
<source>Vector only</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>仅矢量层</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="385"/>
|
||||
@ -733,7 +733,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="695"/>
|
||||
<source>Layers</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>图层</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="704"/>
|
||||
@ -1692,7 +1692,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="388"/>
|
||||
<source>Detect pauses</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>检测暂停</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="391"/>
|
||||
@ -1796,7 +1796,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="537"/>
|
||||
<source>Detection:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>检测模式:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="538"/>
|
||||
@ -1821,7 +1821,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="552"/>
|
||||
<source>Pause detection</source>
|
||||
<translation>暂停检测</translation>
|
||||
<translation>检测暂停</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="564"/>
|
||||
@ -1870,7 +1870,7 @@
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="314"/>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="655"/>
|
||||
<source>Opacity:</source>
|
||||
<translation>透明度:</translation>
|
||||
<translation>不透明度:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="657"/>
|
||||
@ -1922,7 +1922,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="656"/>
|
||||
<source>Lightening:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>明亮度:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="713"/>
|
||||
|
@ -21,6 +21,12 @@
|
||||
<data android:scheme="content" android:mimeType="image/jpeg"/>
|
||||
<data android:scheme="content" android:mimeType="image/tiff"/>
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW"/>
|
||||
<category android:name="android.intent.category.DEFAULT"/>
|
||||
<category android:name="android.intent.category.BROWSABLE"/>
|
||||
<data android:scheme="geo"/>
|
||||
</intent-filter>
|
||||
|
||||
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
|
||||
<meta-data android:name="android.app.arguments" android:value="-- %%INSERT_APP_ARGUMENTS%% --"/>
|
||||
|
@ -17,6 +17,7 @@
|
||||
Garmin GPI & CSV, TomTom OV2 & ITN, ONmove OMD/GHP,
|
||||
TwoNav (TRK, RTE, WPT), GPSDump WPT and geotagged JPEG
|
||||
files.</li>
|
||||
<li>Opens geo URIs (RFC 5870).</li>
|
||||
<li>User-definable online maps (OpenStreetMap/Google tiles, WMTS,
|
||||
WMS, TMS, QuadTiles).</li>
|
||||
<li>Offline maps (MBTiles, OziExplorer maps, TrekBuddy maps/atlases,
|
||||
@ -112,5 +113,6 @@
|
||||
<mimetype>application/vnd.iho.s57-catalogue</mimetype>
|
||||
<mimetype>application/vnd.gpsdump.wpt</mimetype>
|
||||
<mimetype>application/vnd.gpstuner.gmi</mimetype>
|
||||
<mimetype>x-scheme-handler/geo</mimetype>
|
||||
</mimetypes>
|
||||
</component>
|
||||
|
@ -11,9 +11,9 @@ Comment[ru]=Программа для просмотра и анализа GPS
|
||||
Comment[sv]=GPS-loggfilsläsare och analysator
|
||||
Comment[tr]=GPS günlük dosyası görüntüleyici ve analizcisi
|
||||
Comment[uk]=Переглядач та аналізатор GPS логів
|
||||
Exec=gpxsee %F
|
||||
Exec=gpxsee %U
|
||||
Icon=gpxsee
|
||||
Terminal=false
|
||||
Type=Application
|
||||
Categories=Graphics;Viewer;Education;Geography;Maps;Sports;Qt
|
||||
MimeType=application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.cgtk.gemf;application/vnd.rmaps.sqlite;application/vnd.osmdroid.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2;application/vnd.tomtom.itn;application/vnd.esri.wld;application/vnd.onmove.omd;application/vnd.onmove.ghp;application/vnd.memory-map.qct;application/vnd.twonav.trk;application/vnd.twonav.rte;application/vnd.twonav.wpt;application/vnd.orux.map+xml;application/vnd.iho.s57-data;application/vnd.iho.s57-catalogue;application/vnd.gpsdump.wpt;application/vnd.gpstuner.gmi
|
||||
MimeType=x-scheme-handler/geo;application/gpx+xml;application/vnd.garmin.tcx+xml;application/vnd.ant.fit;application/vnd.google-earth.kml+xml;application/vnd.fai.igc;application/vnd.nmea.nmea;application/vnd.oziexplorer.plt;application/vnd.oziexplorer.rte;application/vnd.oziexplorer.wpt;application/vnd.groundspeak.loc+xml;application/vnd.sigma.slf+xml;application/geo+json;application/vnd.naviter.seeyou.cup;application/vnd.garmin.gpi;application/vnd.suunto.sml+xml;image/jpeg;text/csv;application/vnd.garmin.img;application/vnd.garmin.jnx;application/vnd.garmin.gmap+xml;image/vnd.maptech.kap;application/vnd.oziexplorer.map;application/vnd.mapbox.mbtiles;application/vnd.twonav.rmap;application/vnd.trekbuddy.tba;application/vnd.gpxsee.map+xml;application/x-tar;image/tiff;application/vnd.google-earth.kmz;application/vnd.alpinequest.aqm;application/vnd.cgtk.gemf;application/vnd.rmaps.sqlite;application/vnd.osmdroid.sqlite;application/vnd.mapsforge.map;application/vnd.tomtom.ov2;application/vnd.tomtom.itn;application/vnd.esri.wld;application/vnd.onmove.omd;application/vnd.onmove.ghp;application/vnd.memory-map.qct;application/vnd.twonav.trk;application/vnd.twonav.rte;application/vnd.twonav.wpt;application/vnd.orux.map+xml;application/vnd.iho.s57-data;application/vnd.iho.s57-catalogue;application/vnd.gpsdump.wpt;application/vnd.gpstuner.gmi
|
||||
|
@ -738,6 +738,20 @@
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
<key>CFBundleURLTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleURLSchemes</key>
|
||||
<array>
|
||||
<string>geo</string>
|
||||
</array>
|
||||
<key>CFBundleURLName</key>
|
||||
<string>org.geouri.geo</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
|
||||
<key>UTImportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
|
@ -18,6 +18,18 @@
|
||||
DeleteRegKey HKCR ".${EXT}"
|
||||
!macroend
|
||||
|
||||
; URI association
|
||||
!macro URI_ASSOCIATION_ADD PROTO
|
||||
WriteRegStr HKCR "${PROTO}" "" "URL:${PROTO}"
|
||||
WriteRegStr HKCR "${PROTO}" "URL Protocol" ""
|
||||
WriteRegStr HKCR "${PROTO}\DefaultIcon" "" "$INSTDIR\GPXSee.exe,0"
|
||||
WriteRegStr HKCR "${PROTO}\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||
!macroend
|
||||
|
||||
!macro URI_ASSOCIATION_REMOVE PROTO
|
||||
DeleteRegKey HKCR "${PROTO}"
|
||||
!macroend
|
||||
|
||||
; Translations
|
||||
!macro LOCALIZATION LANG CODE
|
||||
Section "${LANG}"
|
||||
@ -37,7 +49,7 @@ Unicode true
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "13.34"
|
||||
!define VERSION "13.36"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
@ -58,7 +70,7 @@ VIProductVersion "${VERSION}.0.0"
|
||||
VIAddVersionKey "ProductVersion" ${VERSION}
|
||||
VIAddVersionKey "FileVersion" "${VERSION}.0.0"
|
||||
VIAddVersionKey "ProductName" "GPXSee"
|
||||
VIAddVersionKey "LegalCopyright" "Copyright (c) 2015-2024 Martin Tůma"
|
||||
VIAddVersionKey "LegalCopyright" "Copyright (c) 2015-2025 Martin Tůma"
|
||||
VIAddVersionKey "FileDescription" "GPXSee installer (x64)"
|
||||
|
||||
; Registry key to check for directory (so if you install again, it will
|
||||
@ -200,6 +212,8 @@ Section "GPXSee" SEC_APP
|
||||
!insertmacro FILE_ASSOCIATION_ADD "plt" "OziExplorer Track File" 33
|
||||
!insertmacro FILE_ASSOCIATION_ADD "rte" "OziExplorer Route File" 34
|
||||
|
||||
!insertmacro URI_ASSOCIATION_ADD "geo"
|
||||
|
||||
WriteRegStr HKCR "Applications\GPXSee.exe\shell\open\command" "" "$\"$INSTDIR\GPXSee.exe$\" $\"%1$\""
|
||||
WriteRegStr HKCR ".gpx\OpenWithList" "GPXSee.exe" ""
|
||||
WriteRegStr HKCR ".tcx\OpenWithList" "GPXSee.exe" ""
|
||||
@ -426,6 +440,8 @@ Section "Uninstall"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "000"
|
||||
!insertmacro FILE_ASSOCIATION_REMOVE "031"
|
||||
|
||||
!insertmacro URI_ASSOCIATION_REMOVE "geo"
|
||||
|
||||
DeleteRegValue HKCR ".gpx\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".tcx\OpenWithList" "GPXSee.exe"
|
||||
DeleteRegValue HKCR ".kml\OpenWithList" "GPXSee.exe"
|
||||
|
@ -73,9 +73,7 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
|
||||
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
|
||||
QIcon::setThemeName(APP_NAME);
|
||||
#endif // Q_OS_WIN32 || Q_OS_MAC
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
|
||||
QIcon::setFallbackThemeName(APP_NAME);
|
||||
#endif // QT 5.12
|
||||
|
||||
_gui = new GUI();
|
||||
|
||||
|
@ -25,15 +25,6 @@
|
||||
#define IW(item) ((item)->boundingRect().width())
|
||||
#define IH(item) ((item)->boundingRect().height())
|
||||
|
||||
static inline QPoint POS(QWheelEvent *e)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
return e->pos();
|
||||
#else // QT 5.15
|
||||
return e->position().toPoint();
|
||||
#endif // QT 5.15
|
||||
}
|
||||
|
||||
static inline QPoint POS(QMouseEvent *e)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
@ -393,7 +384,7 @@ void GraphView::wheelEvent(QWheelEvent *e)
|
||||
return;
|
||||
_angleDelta = _angleDelta % (15 * 8);
|
||||
|
||||
QPointF pos = mapToScene(POS(e));
|
||||
QPointF pos = mapToScene(e->position().toPoint());
|
||||
QRectF gr(_grid->boundingRect());
|
||||
QPointF r(pos.x() / gr.width(), pos.y() / gr.height());
|
||||
|
||||
@ -404,7 +395,8 @@ void GraphView::wheelEvent(QWheelEvent *e)
|
||||
QPointF npos(mapFromScene(QPointF(r.x() * ngr.width(),
|
||||
r.y() * ngr.height())));
|
||||
QScrollBar *sb = horizontalScrollBar();
|
||||
sb->setSliderPosition(sb->sliderPosition() + npos.x() - POS(e).x());
|
||||
sb->setSliderPosition(sb->sliderPosition() + npos.x()
|
||||
- e->position().toPoint().x());
|
||||
|
||||
QGraphicsView::wheelEvent(e);
|
||||
}
|
||||
|
@ -164,7 +164,8 @@ void GUI::mapInitialized()
|
||||
_showMapAction->setEnabled(true);
|
||||
_clearMapCacheAction->setEnabled(true);
|
||||
} else {
|
||||
qWarning("%s: %s", qPrintable(map->path()), qPrintable(map->errorString()));
|
||||
qWarning("%s: %s", qUtf8Printable(map->path()),
|
||||
qUtf8Printable(map->errorString()));
|
||||
action->deleteLater();
|
||||
}
|
||||
}
|
||||
@ -1068,18 +1069,33 @@ void GUI::openDir()
|
||||
|
||||
bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
{
|
||||
QFileInfo fi(fileName);
|
||||
QString canonicalFileName(fi.canonicalFilePath());
|
||||
QString path;
|
||||
|
||||
if (_files.contains(canonicalFileName))
|
||||
QUrl url(fileName);
|
||||
if (url.scheme() == "geo") {
|
||||
if (loadURL(url, showError)) {
|
||||
_fileActionGroup->setEnabled(true);
|
||||
_reloadFileAction->setEnabled(false);
|
||||
return true;
|
||||
} else if (showError)
|
||||
return false;
|
||||
} else if (url.isLocalFile())
|
||||
path = url.toLocalFile();
|
||||
else
|
||||
path = fileName;
|
||||
|
||||
QFileInfo fi(path);
|
||||
QString canonicalPath(fi.canonicalFilePath());
|
||||
|
||||
if (_files.contains(canonicalPath))
|
||||
return true;
|
||||
|
||||
if (!loadFile(fileName, tryUnknown, showError))
|
||||
if (!loadFile(path, tryUnknown, showError))
|
||||
return false;
|
||||
|
||||
_files.append(canonicalFileName);
|
||||
_files.append(canonicalPath);
|
||||
#ifndef Q_OS_ANDROID
|
||||
_browser->setCurrent(fileName);
|
||||
_browser->setCurrent(path);
|
||||
#endif // Q_OS_ANDROID
|
||||
_fileActionGroup->setEnabled(true);
|
||||
// Explicitly enable the reload action as it may be disabled by loadMapDir()
|
||||
@ -1092,12 +1108,42 @@ bool GUI::openFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
if (_files.count() > 1)
|
||||
_mapView->showExtendedInfo(true);
|
||||
#ifndef Q_OS_ANDROID
|
||||
updateRecentFiles(canonicalFileName);
|
||||
updateRecentFiles(canonicalPath);
|
||||
#endif // Q_OS_ANDROID
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GUI::loadURL(const QUrl &url, int &showError)
|
||||
{
|
||||
Data data(url);
|
||||
|
||||
if (data.isValid()) {
|
||||
loadData(data);
|
||||
return true;
|
||||
} else {
|
||||
if (showError) {
|
||||
QString error = tr("Error loading geo URI:") + "\n" + url.toString()
|
||||
+ ": " + data.errorString();
|
||||
|
||||
if (showError > 1) {
|
||||
QMessageBox message(QMessageBox::Critical, APP_NAME, error,
|
||||
QMessageBox::Ok, this);
|
||||
QCheckBox checkBox(tr("Don't show again"));
|
||||
message.setCheckBox(&checkBox);
|
||||
message.exec();
|
||||
if (checkBox.isChecked())
|
||||
showError = 0;
|
||||
} else
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
} else
|
||||
qWarning("%s: %s", qUtf8Printable(url.toString()),
|
||||
qUtf8Printable(data.errorString()));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool GUI::loadFile(const QString &fileName, bool tryUnknown, int &showError)
|
||||
{
|
||||
Data data(fileName, tryUnknown);
|
||||
@ -1849,7 +1895,13 @@ bool GUI::loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
|
||||
|
||||
bool GUI::loadMap(const QString &fileName, MapAction *&action, int &showError)
|
||||
{
|
||||
TreeNode<Map*> maps(MapList::loadMaps(fileName, _mapView->inputProjection()));
|
||||
QString path;
|
||||
QUrl url(fileName);
|
||||
|
||||
path = url.isLocalFile() ? url.toLocalFile() : fileName;
|
||||
|
||||
|
||||
TreeNode<Map*> maps(MapList::loadMaps(path, _mapView->inputProjection()));
|
||||
QList<QAction*> existingActions(_mapsActionGroup->actions());
|
||||
|
||||
return loadMapNode(maps, action, existingActions, showError);
|
||||
@ -2446,12 +2498,8 @@ QGeoPositionInfoSource *GUI::positionSource(const Options &options)
|
||||
{
|
||||
QGeoPositionInfoSource *source;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
source = QGeoPositionInfoSource::createSource(options.plugin, this);
|
||||
#else // QT 5.14
|
||||
source = QGeoPositionInfoSource::createSource(options.plugin,
|
||||
options.pluginParams.value(options.plugin), this);
|
||||
#endif // QT 5.14
|
||||
if (source)
|
||||
source->setPreferredPositioningMethods(
|
||||
QGeoPositionInfoSource::SatellitePositioningMethods);
|
||||
|
@ -158,6 +158,7 @@ private:
|
||||
#endif // Q_OS_ANDROID
|
||||
bool openPOIFile(const QString &fileName);
|
||||
bool loadFile(const QString &fileName, bool tryUnknown, int &showError);
|
||||
bool loadURL(const QUrl &url, int &showError);
|
||||
void loadData(const Data &data);
|
||||
bool loadMapNode(const TreeNode<Map*> &node, MapAction *&action,
|
||||
const QList<QAction*> &existingActions, int &showError);
|
||||
|
@ -638,11 +638,7 @@ void MapView::wheelEvent(QWheelEvent *event)
|
||||
return;
|
||||
_wheelDelta = _wheelDelta % (15 * 8);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
zoom((delta > 0) ? 1 : -1, event->pos(), shift);
|
||||
#else // QT 5.15
|
||||
zoom((delta > 0) ? 1 : -1, event->position().toPoint(), shift);
|
||||
#endif // QT 5.15
|
||||
|
||||
/* Do not call QGraphicsView::wheelEvent() here as this would shift the
|
||||
view ! */
|
||||
@ -1258,7 +1254,7 @@ void MapView::drawHillShading(bool draw)
|
||||
setMap(_map);
|
||||
}
|
||||
|
||||
void MapView::selectLayers(Layers layers)
|
||||
void MapView::selectLayers(MapView::Layers layers)
|
||||
{
|
||||
_layers = layers;
|
||||
|
||||
|
@ -136,7 +136,7 @@ public slots:
|
||||
void showMotionInfo(bool show);
|
||||
void useStyles(bool use);
|
||||
void drawHillShading(bool draw);
|
||||
void selectLayers(Layers layers);
|
||||
void selectLayers(MapView::Layers layers);
|
||||
|
||||
private slots:
|
||||
void updatePOI();
|
||||
|
@ -676,21 +676,17 @@ QWidget *OptionsDialog::createPositionPage()
|
||||
_positionPlugin = new QComboBox();
|
||||
_positionPlugin->addItems(plugins);
|
||||
_positionPlugin->setCurrentIndex(_positionPlugin->findText(_options.plugin));
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
_pluginParameters = new PluginParameters(_positionPlugin->currentText(),
|
||||
_options.pluginParams);
|
||||
connect(_positionPlugin, &QComboBox::currentTextChanged, _pluginParameters,
|
||||
&PluginParameters::setPlugin);
|
||||
#endif // QT 5.14
|
||||
|
||||
QFormLayout *pluginLayout = new QFormLayout();
|
||||
pluginLayout->addRow(tr("Plugin:"), _positionPlugin);
|
||||
|
||||
QVBoxLayout *sourceLayout = new QVBoxLayout();
|
||||
sourceLayout->addLayout(pluginLayout);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
sourceLayout->addWidget(_pluginParameters);
|
||||
#endif // QT 5.14
|
||||
sourceLayout->addStretch();
|
||||
|
||||
QWidget *sourceTab = new QWidget();
|
||||
@ -1009,9 +1005,7 @@ void OptionsDialog::accept()
|
||||
_options.hillshadingZFactor = _hillshadingZFactor->value();
|
||||
|
||||
_options.plugin = _positionPlugin->currentText();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
_options.pluginParams = _pluginParameters->parameters();
|
||||
#endif // QT 5.14
|
||||
|
||||
_options.useOpenGL = _useOpenGL->isChecked();
|
||||
_options.enableHTTP2 = _enableHTTP2->isChecked();
|
||||
|
@ -193,9 +193,7 @@ private:
|
||||
QDoubleSpinBox *_hillshadingZFactor;
|
||||
// Position
|
||||
QComboBox *_positionPlugin;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
PluginParameters *_pluginParameters;
|
||||
#endif // QT 5.14
|
||||
// System
|
||||
QSpinBox *_pixmapCache;
|
||||
QSpinBox *_demCache;
|
||||
|
@ -10,13 +10,6 @@
|
||||
#include "markeritem.h"
|
||||
#include "pathitem.h"
|
||||
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
#define INTERSECTS intersect
|
||||
#else // QT 5.15
|
||||
#define INTERSECTS intersects
|
||||
#endif // QT 5.15
|
||||
|
||||
#define GEOGRAPHICAL_MILE 1855.3248
|
||||
|
||||
Units PathItem::_units = Metric;
|
||||
@ -79,14 +72,14 @@ bool PathItem::addSegment(const Coordinates &c1, const Coordinates &c2)
|
||||
QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() + 360,
|
||||
c2.lat()));
|
||||
QLineF dl(QPointF(180, -90), QPointF(180, 90));
|
||||
l.INTERSECTS(dl, &p);
|
||||
l.intersects(dl, &p);
|
||||
_painterPath.lineTo(_map->ll2xy(Coordinates(180, p.y())));
|
||||
_painterPath.moveTo(_map->ll2xy(Coordinates(-180, p.y())));
|
||||
} else {
|
||||
QLineF l(QPointF(c1.lon(), c1.lat()), QPointF(c2.lon() - 360,
|
||||
c2.lat()));
|
||||
QLineF dl(QPointF(-180, -90), QPointF(-180, 90));
|
||||
l.INTERSECTS(dl, &p);
|
||||
l.intersects(dl, &p);
|
||||
_painterPath.lineTo(_map->ll2xy(Coordinates(-180, p.y())));
|
||||
_painterPath.moveTo(_map->ll2xy(Coordinates(180, p.y())));
|
||||
}
|
||||
|
@ -9,9 +9,6 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QApplication>
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
#include <QDesktopWidget>
|
||||
#endif // QT 5.15
|
||||
#include "tooltip.h"
|
||||
#include "thumbnail.h"
|
||||
#include "flowlayout.h"
|
||||
@ -184,11 +181,7 @@ bool PopupFrame::eventFilter(QObject *o, QEvent *ev)
|
||||
|
||||
void PopupFrame::place(const QPoint &pos, QWidget *w)
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
|
||||
QRect screen = QApplication::desktop()->screenGeometry(w);
|
||||
#else // QT 5.15
|
||||
QRect screen = w->screen()->geometry();
|
||||
#endif // QT 5.15
|
||||
QPoint p(pos.x() + 2, pos.y() + 16);
|
||||
|
||||
if (p.x() + width() > screen.x() + screen.width())
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include "common/util.h"
|
||||
#include "map/crs.h"
|
||||
#include "gpxparser.h"
|
||||
#include "tcxparser.h"
|
||||
#include "csvparser.h"
|
||||
@ -127,11 +128,11 @@ Data::Data(const QString &fileName, bool tryUnknown)
|
||||
++it;
|
||||
}
|
||||
|
||||
qWarning("%s:", qPrintable(fileName));
|
||||
qWarning("%s:", qUtf8Printable(fileName));
|
||||
for (it = _parsers.find(suffix); it != _parsers.end()
|
||||
&& it.key() == suffix; it++)
|
||||
qWarning(" %s: line %d: %s", qPrintable(it.key()),
|
||||
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||
qWarning(" %s: line %d: %s", qUtf8Printable(it.key()),
|
||||
it.value()->errorLine(), qUtf8Printable(it.value()->errorString()));
|
||||
|
||||
} else if (tryUnknown) {
|
||||
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||
@ -144,16 +145,80 @@ Data::Data(const QString &fileName, bool tryUnknown)
|
||||
file.reset();
|
||||
}
|
||||
|
||||
qWarning("%s:", qPrintable(fileName));
|
||||
qWarning("%s:", qUtf8Printable(fileName));
|
||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||
qWarning(" %s: line %d: %s", qPrintable(it.key()),
|
||||
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||
qWarning(" %s: line %d: %s", qUtf8Printable(it.key()),
|
||||
it.value()->errorLine(), qUtf8Printable(it.value()->errorString()));
|
||||
|
||||
_errorLine = 0;
|
||||
_errorString = "Unknown format";
|
||||
}
|
||||
}
|
||||
|
||||
Data::Data(const QUrl &url)
|
||||
{
|
||||
bool caOk, cbOk, ccOk;
|
||||
Projection proj(GCS::WGS84());
|
||||
|
||||
_valid = false;
|
||||
|
||||
QStringList parts(url.path().split(';'));
|
||||
if (parts.size() < 1) {
|
||||
_errorString = "Syntax error";
|
||||
return;
|
||||
}
|
||||
QStringList coords(parts.at(0).split(','));
|
||||
if (coords.size() < 2 || coords.size() > 3) {
|
||||
_errorString = "Syntax error";
|
||||
return;
|
||||
}
|
||||
double ca = coords.at(0).toDouble(&caOk);
|
||||
double cb = coords.at(1).toDouble(&cbOk);
|
||||
double cc = NAN;
|
||||
if (!(caOk && cbOk)) {
|
||||
_errorString = "Invalid coordinates";
|
||||
return;
|
||||
}
|
||||
if (coords.size() > 2) {
|
||||
cc = coords.at(2).toDouble(&ccOk);
|
||||
if (!ccOk) {
|
||||
_errorString = "Invalid elevation";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (parts.size() > 1) {
|
||||
QStringList crsp(parts.at(1).split('='));
|
||||
if (crsp.size() != 2) {
|
||||
_errorString = "Syntax error";
|
||||
return;
|
||||
}
|
||||
if (!crsp.at(0).compare("crs", Qt::CaseInsensitive)) {
|
||||
if (crsp.at(1).compare("wgs84", Qt::CaseInsensitive)) {
|
||||
proj = CRS::projection(crsp.at(1));
|
||||
if (!proj.isValid()) {
|
||||
_errorString = "Unknown CRS";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CoordinateSystem::AxisOrder ao = proj.coordinateSystem().axisOrder();
|
||||
PointD p(ao == CoordinateSystem::XY ? PointD(ca, cb) : PointD(cb, ca));
|
||||
Coordinates c(proj.xy2ll(p));
|
||||
if (!c.isValid()) {
|
||||
_errorString = "Invalid coordinates";
|
||||
return;
|
||||
}
|
||||
|
||||
Waypoint w(c);
|
||||
w.setElevation(cc);
|
||||
_waypoints.append(w);
|
||||
|
||||
_valid = true;
|
||||
}
|
||||
|
||||
QString Data::formats()
|
||||
{
|
||||
return
|
||||
|
@ -14,6 +14,7 @@ class Data
|
||||
{
|
||||
public:
|
||||
Data(const QString &fileName, bool tryUnknown = true);
|
||||
Data(const QUrl &url);
|
||||
|
||||
bool isValid() const {return _valid;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
|
@ -245,7 +245,7 @@ bool IGCParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
/* The date H header is mandatory, but XCSOAR generates
|
||||
files without it, so add a dummy date in such case */
|
||||
qWarning("%s: Missing date header",
|
||||
qPrintable(file->fileName()));
|
||||
qUtf8Printable(file->fileName()));
|
||||
ctx.date = QDate(1970, 1, 1);
|
||||
}
|
||||
if (!track) {
|
||||
|
@ -28,11 +28,12 @@ bool OMDParser::readHeaderFile(const QString &omdPath, Header &hdr)
|
||||
char buffer[60];
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString()));
|
||||
qWarning("%s: %s", qUtf8Printable(path),
|
||||
qUtf8Printable(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
if (file.read(buffer, sizeof(buffer)) != sizeof(buffer)) {
|
||||
qWarning("%s: invalid OMH file", qPrintable(path));
|
||||
qWarning("%s: invalid OMH file", qUtf8Printable(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ bool OMDParser::readHeaderFile(const QString &omdPath, Header &hdr)
|
||||
|
||||
QDateTime date(QDate(Y + 2000, M, D), QTime(h, m), QTimeZone::utc());
|
||||
if (!date.isValid()) {
|
||||
qWarning("%s: invalid date", qPrintable(path));
|
||||
qWarning("%s: invalid date", qUtf8Printable(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -183,11 +184,12 @@ bool GHPParser::readHeaderFile(const QString &ghpPath, Header &hdr)
|
||||
char buffer[96];
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning("%s: %s", qPrintable(path), qPrintable(file.errorString()));
|
||||
qWarning("%s: %s", qUtf8Printable(path),
|
||||
qUtf8Printable(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
if (file.read(buffer, sizeof(buffer)) != sizeof(buffer)) {
|
||||
qWarning("%s: invalid GHT file", qPrintable(path));
|
||||
qWarning("%s: invalid GHT file", qUtf8Printable(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -202,7 +204,7 @@ bool GHPParser::readHeaderFile(const QString &ghpPath, Header &hdr)
|
||||
|
||||
QDateTime date(QDate(Y + 2000, M, D), QTime(h, m, s), QTimeZone::utc());
|
||||
if (!date.isValid()) {
|
||||
qWarning("%s: invalid date", qPrintable(path));
|
||||
qWarning("%s: invalid date", qUtf8Printable(path));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,8 @@ TreeNode<QString> POI::loadDir(const QString &path)
|
||||
if (loadFile(fi.absoluteFilePath()))
|
||||
tree.addItem(fi.absoluteFilePath());
|
||||
else
|
||||
qWarning("%s: %s", qPrintable(fi.absoluteFilePath()),
|
||||
qPrintable(_errorString));
|
||||
qWarning("%s: %s", qUtf8Printable(fi.absoluteFilePath()),
|
||||
qUtf8Printable(_errorString));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
void SLFParser::warning(const char *text) const
|
||||
{
|
||||
const QFile *file = static_cast<QFile *>(_reader.device());
|
||||
qWarning("%s:%lld: %s", qPrintable(file->fileName()),
|
||||
qWarning("%s:%lld: %s", qUtf8Printable(file->fileName()),
|
||||
_reader.lineNumber(), text);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
void TCXParser::warning(const char *text) const
|
||||
{
|
||||
const QFile *file = static_cast<QFile *>(_reader.device());
|
||||
qWarning("%s:%lld: %s", qPrintable(file->fileName()),
|
||||
qWarning("%s:%lld: %s", qUtf8Printable(file->fileName()),
|
||||
_reader.lineNumber(), text);
|
||||
}
|
||||
|
||||
|
@ -140,8 +140,7 @@ Track::Track(const TrackData &data) : _pause(0)
|
||||
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());
|
||||
ds = sd.at(j).coordinates().distanceTo(sd.at(j-1).coordinates());
|
||||
seg.distance.append(seg.distance.last() + ds);
|
||||
|
||||
if (hasTime && sd.at(j).timestamp().isValid()) {
|
||||
@ -149,16 +148,16 @@ Track::Track(const TrackData &data) : _pause(0)
|
||||
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)));
|
||||
qWarning("%s: %s: time skew detected",
|
||||
qUtf8Printable(_data.name()),
|
||||
qUtf8Printable(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()));
|
||||
qUtf8Printable(_data.name()));
|
||||
hasTime = false;
|
||||
for (int i = 0; i < seg.time.size(); i++)
|
||||
seg.time[i] = NAN;
|
||||
|
@ -2,13 +2,6 @@
|
||||
#include "map/gcs.h"
|
||||
#include "twonavparser.h"
|
||||
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
#define SKIP_EMPTY QString::SkipEmptyParts
|
||||
#else // Qt 5.14
|
||||
#define SKIP_EMPTY Qt::SkipEmptyParts
|
||||
#endif
|
||||
|
||||
static double lon(const QString &str)
|
||||
{
|
||||
QStringList l(str.split(QChar(0xBA)));
|
||||
@ -123,7 +116,8 @@ bool TwoNavParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
}}
|
||||
break;
|
||||
case 'T':
|
||||
{QStringList list(codec.toString(line).split(' ', SKIP_EMPTY));
|
||||
{QStringList list(codec.toString(line).split(' ',
|
||||
Qt::SkipEmptyParts));
|
||||
if (list.size() < 4) {
|
||||
_errorString = "Parse error";
|
||||
return false;
|
||||
@ -159,7 +153,8 @@ bool TwoNavParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
tracks.last().last().append(t);}
|
||||
break;
|
||||
case 'W':
|
||||
{QStringList list(codec.toString(line).split(' ', SKIP_EMPTY));
|
||||
{QStringList list(codec.toString(line).split(' ',
|
||||
Qt::SkipEmptyParts));
|
||||
if (list.size() < 5) {
|
||||
_errorString = "Parse error";
|
||||
return false;
|
||||
|
@ -37,7 +37,7 @@ void Waypoint::loadSymbolIcons(const QString &dir)
|
||||
QPixmap pm(files.at(i).absoluteFilePath());
|
||||
if (pm.isNull())
|
||||
qWarning("%s: error loading image",
|
||||
qPrintable(files.at(i).absoluteFilePath()));
|
||||
qUtf8Printable(files.at(i).absoluteFilePath()));
|
||||
else
|
||||
_symbolIcons.insert(files.at(i).baseName(), pm);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define CATDIS 21
|
||||
#define CATHAF 30
|
||||
#define CATLMK 35
|
||||
#define CATLIT 37
|
||||
#define CATMFA 38
|
||||
#define CATMOR 40
|
||||
#define CATTRK 54
|
||||
@ -16,16 +17,21 @@
|
||||
#define CATWAT 69
|
||||
#define CATWED 70
|
||||
#define CATWRK 71
|
||||
#define COLOUR 75
|
||||
#define COMCHA 77
|
||||
#define CURVEL 84
|
||||
#define DRVAL1 87
|
||||
#define ELEVAT 90
|
||||
#define FUNCTN 94
|
||||
#define LITVIS 108
|
||||
#define OBJNAM 116
|
||||
#define ORIENT 117
|
||||
#define RESTRN 131
|
||||
#define SECTR1 136
|
||||
#define SECTR2 137
|
||||
#define TRAFIC 172
|
||||
#define VALDCO 174
|
||||
#define VALNMR 178
|
||||
#define VERCLR 181
|
||||
#define WATLEV 187
|
||||
|
||||
|
@ -63,16 +63,17 @@ static QMap<uint,uint> orderMapInit()
|
||||
map.insert(TYPE(PILPNT), 34);
|
||||
map.insert(TYPE(ACHBRT), 35);
|
||||
map.insert(TYPE(I_ACHBRT), 35);
|
||||
map.insert(TYPE(CRANES), 36);
|
||||
map.insert(TYPE(I_CRANES), 36);
|
||||
map.insert(TYPE(I_WTWGAG), 37);
|
||||
map.insert(TYPE(PYLONS), 38);
|
||||
map.insert(TYPE(SLCONS), 39);
|
||||
map.insert(TYPE(LNDMRK), 40);
|
||||
map.insert(TYPE(SILTNK), 41);
|
||||
map.insert(TYPE(LNDELV), 42);
|
||||
map.insert(TYPE(SMCFAC), 43);
|
||||
map.insert(TYPE(BUISGL), 44);
|
||||
map.insert(TYPE(RADRFL), 36);
|
||||
map.insert(TYPE(CRANES), 37);
|
||||
map.insert(TYPE(I_CRANES), 37);
|
||||
map.insert(TYPE(I_WTWGAG), 38);
|
||||
map.insert(TYPE(PYLONS), 39);
|
||||
map.insert(TYPE(SLCONS), 40);
|
||||
map.insert(TYPE(LNDMRK), 41);
|
||||
map.insert(TYPE(SILTNK), 42);
|
||||
map.insert(TYPE(LNDELV), 43);
|
||||
map.insert(TYPE(SMCFAC), 44);
|
||||
map.insert(TYPE(BUISGL), 45);
|
||||
|
||||
map.insert(TYPE(I_DISMAR), 0xFFFFFFFE);
|
||||
map.insert(TYPE(SOUNDG), 0xFFFFFFFF);
|
||||
@ -169,6 +170,48 @@ static bool polygonCb(const MapData::Poly *polygon, void *context)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool polygonPointCb(const MapData::Poly *polygon, void *context)
|
||||
{
|
||||
QList<MapData::Point> *points = (QList<MapData::Point>*)context;
|
||||
uint type = polygon->type();
|
||||
uint baseType = type>>16;
|
||||
|
||||
if (baseType == TSSLPT || baseType == RCTLPT || baseType == I_TRNBSN
|
||||
|| baseType == BRIDGE || baseType == I_BRIDGE || baseType == BUAARE
|
||||
|| baseType == LNDARE || baseType == LNDRGN
|
||||
|| type == SUBTYPE(ACHARE, 2) || type == SUBTYPE(I_ACHARE, 2)
|
||||
|| type == SUBTYPE(ACHARE, 3) || type == SUBTYPE(I_ACHARE, 3)
|
||||
|| type == SUBTYPE(ACHARE, 9) || type == SUBTYPE(I_ACHARE, 9)
|
||||
|| type == SUBTYPE(I_BERTHS, 6)
|
||||
|| type == SUBTYPE(RESARE, 1) || type == SUBTYPE(I_RESARE, 1)
|
||||
|| type == SUBTYPE(RESARE, 2) || type == SUBTYPE(I_RESARE, 2)
|
||||
|| type == SUBTYPE(RESARE, 4) || type == SUBTYPE(I_RESARE, 4)
|
||||
|| type == SUBTYPE(RESARE, 5) || type == SUBTYPE(I_RESARE, 5)
|
||||
|| type == SUBTYPE(RESARE, 6) || type == SUBTYPE(I_RESARE, 6)
|
||||
|| type == SUBTYPE(RESARE, 7) || type == SUBTYPE(I_RESARE, 7)
|
||||
|| type == SUBTYPE(RESARE, 9) || type == SUBTYPE(I_RESARE, 9)
|
||||
|| type == SUBTYPE(RESARE, 12) || type == SUBTYPE(I_RESARE, 12)
|
||||
|| type == SUBTYPE(RESARE, 17) || type == SUBTYPE(I_RESARE, 17)
|
||||
|| type == SUBTYPE(RESARE, 22) || type == SUBTYPE(I_RESARE, 22)
|
||||
|| type == SUBTYPE(RESARE, 23) || type == SUBTYPE(I_RESARE, 23))
|
||||
points->append(MapData::Point(baseType, polygon->bounds().center(),
|
||||
polygon->attributes(), polygon->HUNI(), true));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool linePointCb(const MapData::Line *line, void *context)
|
||||
{
|
||||
QList<MapData::Point> *points = (QList<MapData::Point>*)context;
|
||||
uint baseType = line->type()>>16;
|
||||
|
||||
if (baseType == RDOCAL || baseType == I_RDOCAL)
|
||||
points->append(MapData::Point(baseType, line->bounds().center(),
|
||||
line->attributes(), 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static Coordinates coordinates(int x, int y, uint COMF)
|
||||
{
|
||||
return Coordinates(x / (double)COMF, y / (double)COMF);
|
||||
@ -186,10 +229,8 @@ static Coordinates point(const ISO8211::Record &r, uint COMF)
|
||||
return coordinates(x, y, COMF);
|
||||
}
|
||||
|
||||
static uint depthLevel(const QByteArray &ba)
|
||||
static uint depthLevel(double minDepth)
|
||||
{
|
||||
double minDepth = ba.isEmpty() ? -1 : ba.toDouble();
|
||||
|
||||
if (minDepth < 0)
|
||||
return 0;
|
||||
else if (minDepth < 2)
|
||||
@ -254,64 +295,171 @@ static QString weed(uint type)
|
||||
}
|
||||
}
|
||||
|
||||
MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
|
||||
const QVector<QByteArray> ¶ms) : _type(type), _pos(c), _label(label)
|
||||
static uint restrictionCategory(uint type, const MapData::Attributes &attr)
|
||||
{
|
||||
_id = ((quint64)order(type))<<32 | (uint)qHash(c);
|
||||
uint catrea = attr.value(CATREA).toUInt();
|
||||
|
||||
if (type>>16 == I_DISMAR && params.size()) {
|
||||
_label = hUnits((type>>8)&0xFF) + " " + QString::fromLatin1(params.at(0));
|
||||
_type = SUBTYPE(I_DISMAR, type & 0xFF);
|
||||
} else if ((type>>16 == I_RDOCAL || type>>16 == RDOCAL) && params.size() > 1) {
|
||||
if (!params.at(1).isEmpty())
|
||||
_label = QString("VHF ") + QString::fromLatin1(params.at(1));
|
||||
_param = QVariant(params.at(0).toDouble());
|
||||
} else if (type>>16 == CURENT && params.size() > 1) {
|
||||
if (!params.at(1).isEmpty())
|
||||
_label = QString::fromLatin1(params.at(1))
|
||||
+ QString::fromUtf8("\xE2\x80\x89kt");
|
||||
_param = QVariant(params.at(0).toDouble());
|
||||
} else if (type>>16 == I_SISTAT || type>>16 == SISTAT) {
|
||||
if (_label.isEmpty())
|
||||
_label = sistat(type & 0xFF);
|
||||
_type = TYPE(SISTAT);
|
||||
} else if (type>>16 == WEDKLP) {
|
||||
if (_label.isEmpty())
|
||||
_label = weed(type & 0xFF);
|
||||
} else if (type>>16 == LNDELV && params.size()) {
|
||||
if (_label.isEmpty())
|
||||
_label = QString::fromLatin1(params.at(0))
|
||||
+ QString::fromUtf8("\xE2\x80\x89m");
|
||||
if (!catrea) {
|
||||
uint restrn = attr.value(
|
||||
(type == RESARE) ? RESTRN : I_RESTRN).toUInt();
|
||||
|
||||
if (restrn == 1)
|
||||
return 2;
|
||||
else if (restrn == 7)
|
||||
return 17;
|
||||
else
|
||||
_label += "\n(" + QString::fromLatin1(params.at(0))
|
||||
+ "\xE2\x80\x89m)";
|
||||
}
|
||||
return 0;
|
||||
} else
|
||||
return catrea;
|
||||
}
|
||||
|
||||
MapData::Poly::Poly(uint type, const Polygon &path, const QString &label,
|
||||
const QVector<QByteArray> ¶ms, uint HUNI) : _type(type), _path(path)
|
||||
MapData::Point::Point(uint type, const Coordinates &c, const QString &label)
|
||||
: _type(SUBTYPE(type, 0)), _pos(c), _label(label), _polygon(false)
|
||||
{
|
||||
if (type == TYPE(DEPARE) && params.size())
|
||||
_type = SUBTYPE(DEPARE, depthLevel(params.at(0)));
|
||||
else if (type == TYPE(TSSLPT) && params.size())
|
||||
_param = QVariant(params.at(0).toDouble());
|
||||
else if ((type == TYPE(BRIDGE) || type == TYPE(I_BRIDGE))
|
||||
&& params.size()) {
|
||||
double clr = params.at(0).toDouble();
|
||||
_id = ((quint64)order(_type))<<32 | (uint)qHash(c);
|
||||
}
|
||||
|
||||
MapData::Point::Point(uint type, const Coordinates &c, const Attributes &attr,
|
||||
uint HUNI, bool polygon) : _pos(c), _attr(attr), _polygon(polygon)
|
||||
{
|
||||
uint subtype = 0;
|
||||
|
||||
if (type == HRBFAC)
|
||||
subtype = CATHAF;
|
||||
else if (type == I_HRBFAC)
|
||||
subtype = I_CATHAF;
|
||||
else if (type == LNDMRK)
|
||||
subtype = CATLMK;
|
||||
else if (type == WRECKS)
|
||||
subtype = CATWRK;
|
||||
else if (type == MORFAC)
|
||||
subtype = CATMOR;
|
||||
else if (type == UWTROC)
|
||||
subtype = WATLEV;
|
||||
else if (type == BUAARE)
|
||||
subtype = CATBUA;
|
||||
else if (type == SMCFAC)
|
||||
subtype = CATSCF;
|
||||
else if (type == BUISGL)
|
||||
subtype = FUNCTN;
|
||||
else if (type == WATTUR)
|
||||
subtype = CATWAT;
|
||||
else if (type == RDOCAL)
|
||||
subtype = TRAFIC;
|
||||
else if (type == I_RDOCAL)
|
||||
subtype = TRAFIC;
|
||||
else if (type == SILTNK)
|
||||
subtype = CATSIL;
|
||||
else if (type == WEDKLP)
|
||||
subtype = CATWED;
|
||||
else if (type == LIGHTS)
|
||||
subtype = CATLIT;
|
||||
else if (type == I_DISMAR)
|
||||
subtype = CATDIS;
|
||||
else if (type == I_BERTHS)
|
||||
subtype = I_CATBRT;
|
||||
else if (type == ACHARE)
|
||||
subtype = CATACH;
|
||||
else if (type == I_ACHARE)
|
||||
subtype = I_CATACH;
|
||||
|
||||
QList<QByteArray> list(_attr.value(subtype).split(','));
|
||||
std::sort(list.begin(), list.end());
|
||||
_type = (type == RESARE || type == I_RESARE)
|
||||
? SUBTYPE(type, restrictionCategory(type, _attr))
|
||||
: SUBTYPE(type, list.first().toUInt());
|
||||
_id = ((quint64)order(_type))<<32 | (uint)qHash(c);
|
||||
_label = QString::fromLatin1(_attr.value(OBJNAM));
|
||||
|
||||
if (type == I_DISMAR) {
|
||||
if (_attr.contains(I_WTWDIS) && _attr.contains(I_HUNITS))
|
||||
_label = hUnits(_attr.value(I_HUNITS).toUInt()) + " "
|
||||
+ QString::fromLatin1(_attr.value(I_WTWDIS));
|
||||
} else if (type == I_RDOCAL || type == RDOCAL) {
|
||||
QByteArray cc(_attr.value(COMCHA));
|
||||
if (!cc.isEmpty())
|
||||
_label = QString("VHF ") + QString::fromLatin1(cc);
|
||||
} else if (type == CURENT) {
|
||||
QByteArray cv(_attr.value(CURVEL));
|
||||
if (!cv.isEmpty())
|
||||
_label = QString::fromLatin1(cv) + QString::fromUtf8("\xE2\x80\x89kt");
|
||||
} else if (type == SISTAT) {
|
||||
if (_label.isEmpty() && _attr.contains(CATSIT))
|
||||
_label = sistat(_attr.value(CATSIT).toUInt());
|
||||
} else if (type == I_SISTAT) {
|
||||
if (_label.isEmpty() && _attr.contains(I_CATSIT))
|
||||
_label = sistat(_attr.value(I_CATSIT).toUInt());
|
||||
} else if (type == WEDKLP) {
|
||||
if (_label.isEmpty())
|
||||
_label = weed(_type & 0xFF);
|
||||
} else if (type == LNDELV) {
|
||||
if (_label.isEmpty())
|
||||
_label = QString::fromLatin1(_attr.value(ELEVAT))
|
||||
+ QString::fromUtf8("\xE2\x80\x89m");
|
||||
else
|
||||
_label += "\n(" + QString::fromLatin1(_attr.value(ELEVAT))
|
||||
+ "\xE2\x80\x89m)";
|
||||
} else if (type == BRIDGE || type == I_BRIDGE) {
|
||||
double clr = _attr.value(VERCLR).toDouble();
|
||||
if (clr > 0) {
|
||||
_label = QString::fromUtf8("\xE2\x86\x95") + UNIT_SPACE
|
||||
+ QString::number(clr) + UNIT_SPACE + hUnits(HUNI);
|
||||
}
|
||||
} else if (type>>16 == LNDARE || type>>16 == SEAARE)
|
||||
_label = label;
|
||||
}
|
||||
}
|
||||
|
||||
MapData::Poly::Poly(uint type, const Polygon &path, const Attributes &attr,
|
||||
uint HUNI) : _path(path), _attr(attr), _HUNI(HUNI)
|
||||
{
|
||||
uint subtype = 0;
|
||||
|
||||
if (type == ACHARE)
|
||||
subtype = CATACH;
|
||||
else if (type == I_ACHARE)
|
||||
subtype = I_CATACH;
|
||||
else if (type == HRBFAC)
|
||||
subtype = CATHAF;
|
||||
else if (type == MARKUL)
|
||||
subtype = CATMFA;
|
||||
else if (type == I_BERTHS)
|
||||
subtype = I_CATBRT;
|
||||
|
||||
switch (type) {
|
||||
case DEPARE:
|
||||
_type = SUBTYPE(type, depthLevel(_attr.value(DRVAL1).toDouble()));
|
||||
break;
|
||||
case RESARE:
|
||||
case I_RESARE:
|
||||
_type = SUBTYPE(type, restrictionCategory(type, attr));
|
||||
break;
|
||||
default:
|
||||
_type = SUBTYPE(type, _attr.value(subtype).toUInt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MapData::Line::Line(uint type, const QVector<Coordinates> &path,
|
||||
const QString &label, const QVector<QByteArray> ¶ms)
|
||||
: _type(type), _path(path), _label(label)
|
||||
const Attributes &attr) : _path(path), _attr(attr)
|
||||
{
|
||||
if ((type == TYPE(DEPCNT) || type == TYPE(LNDELV)) && params.size())
|
||||
_label = QString::fromLatin1(params.at(0));
|
||||
uint subtype = 0;
|
||||
|
||||
if (type == RECTRC)
|
||||
subtype = CATTRK;
|
||||
else if (type == RCRTCL)
|
||||
subtype = CATTRK;
|
||||
else if (type == RDOCAL)
|
||||
subtype = TRAFIC;
|
||||
else if (type == I_RDOCAL)
|
||||
subtype = TRAFIC;
|
||||
|
||||
_type = SUBTYPE(type, _attr.value(subtype).toUInt());
|
||||
|
||||
if (type == DEPCNT)
|
||||
_label = QString::fromLatin1(_attr.value(VALDCO));
|
||||
else if (type == LNDELV)
|
||||
_label = QString::fromLatin1(_attr.value(ELEVAT));
|
||||
else
|
||||
_label = QString::fromLatin1(_attr.value(OBJNAM));
|
||||
}
|
||||
|
||||
RectC MapData::Line::bounds() const
|
||||
@ -552,166 +700,46 @@ Polygon MapData::polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
|
||||
return path;
|
||||
}
|
||||
|
||||
MapData::Attr MapData::pointAttr(const ISO8211::Record &r, uint OBJL)
|
||||
MapData::Attributes MapData::attributes(const ISO8211::Record &r)
|
||||
{
|
||||
QString label;
|
||||
QVector<QByteArray> params(2);
|
||||
uint subtype = 0;
|
||||
Attributes attr;
|
||||
|
||||
const ISO8211::Field *ATTF = ISO8211::field(r, "ATTF");
|
||||
if (!(ATTF && ATTF->data().at(0).size() == 2))
|
||||
return Attr();
|
||||
return attr;
|
||||
|
||||
for (int i = 0; i < ATTF->data().size(); i++) {
|
||||
const QVector<QVariant> &av = ATTF->data().at(i);
|
||||
uint key = av.at(0).toUInt();
|
||||
|
||||
if (key == OBJNAM)
|
||||
label = QString::fromLatin1(av.at(1).toByteArray());
|
||||
|
||||
if ((OBJL == HRBFAC && key == CATHAF)
|
||||
|| (OBJL == I_HRBFAC && key == I_CATHAF)
|
||||
|| (OBJL == LNDMRK && key == CATLMK)
|
||||
|| (OBJL == WRECKS && key == CATWRK)
|
||||
|| (OBJL == MORFAC && key == CATMOR)
|
||||
|| (OBJL == UWTROC && key == WATLEV)
|
||||
|| (OBJL == BUAARE && key == CATBUA)
|
||||
|| (OBJL == SMCFAC && key == CATSCF)
|
||||
|| (OBJL == BUISGL && key == FUNCTN)
|
||||
|| (OBJL == WATTUR && key == CATWAT)
|
||||
|| (OBJL == SISTAT && key == CATSIT)
|
||||
|| (OBJL == I_SISTAT && key == I_CATSIT)
|
||||
|| (OBJL == RDOCAL && key == TRAFIC)
|
||||
|| (OBJL == I_RDOCAL && key == TRAFIC)
|
||||
|| (OBJL == SILTNK && key == CATSIL)
|
||||
|| (OBJL == WEDKLP && key == CATWED))
|
||||
subtype = av.at(1).toByteArray().toUInt();
|
||||
else if (OBJL == I_DISMAR && key == CATDIS)
|
||||
subtype |= av.at(1).toByteArray().toUInt();
|
||||
else if (OBJL == I_DISMAR && key == I_HUNITS)
|
||||
subtype |= av.at(1).toByteArray().toUInt() << 8;
|
||||
|
||||
if ((OBJL == I_DISMAR && key == I_WTWDIS)
|
||||
|| (OBJL == RDOCAL && key == ORIENT)
|
||||
|| (OBJL == I_RDOCAL && key == ORIENT)
|
||||
|| (OBJL == CURENT && key == ORIENT)
|
||||
|| (OBJL == LNDELV && key == ELEVAT))
|
||||
params[0] = av.at(1).toByteArray();
|
||||
if ((OBJL == I_RDOCAL && key == COMCHA)
|
||||
|| (OBJL == RDOCAL && key == COMCHA)
|
||||
|| (OBJL == CURENT && key == CURVEL))
|
||||
params[1] = av.at(1).toByteArray();
|
||||
attr.insert(av.at(0).toUInt(), av.at(1).toByteArray());
|
||||
}
|
||||
|
||||
return Attr(subtype, label, params);
|
||||
}
|
||||
|
||||
MapData::Attr MapData::lineAttr(const ISO8211::Record &r, uint OBJL)
|
||||
{
|
||||
QString label;
|
||||
QVector<QByteArray> params(1);
|
||||
uint subtype = 0;
|
||||
|
||||
const ISO8211::Field *ATTF = ISO8211::field(r, "ATTF");
|
||||
if (!(ATTF && ATTF->data().at(0).size() == 2))
|
||||
return Attr();
|
||||
|
||||
for (int i = 0; i < ATTF->data().size(); i++) {
|
||||
const QVector<QVariant> &av = ATTF->data().at(i);
|
||||
uint key = av.at(0).toUInt();
|
||||
|
||||
if (key == OBJNAM)
|
||||
label = QString::fromLatin1(av.at(1).toByteArray());
|
||||
|
||||
if ((OBJL == RECTRC || OBJL == RCRTCL) && key == CATTRK)
|
||||
subtype = av.at(1).toByteArray().toUInt();
|
||||
|
||||
if ((OBJL == DEPCNT && key == VALDCO)
|
||||
|| (OBJL == LNDELV && key == ELEVAT))
|
||||
params[0] = av.at(1).toByteArray();
|
||||
}
|
||||
|
||||
return Attr(subtype, label, params);
|
||||
}
|
||||
|
||||
MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
|
||||
{
|
||||
QString label;
|
||||
QVector<QByteArray> params(1);
|
||||
uint subtype = 0;
|
||||
|
||||
const ISO8211::Field *ATTF = ISO8211::field(r, "ATTF");
|
||||
if (!(ATTF && ATTF->data().at(0).size() == 2))
|
||||
return Attr();
|
||||
|
||||
for (int i = 0; i < ATTF->data().size(); i++) {
|
||||
const QVector<QVariant> &av = ATTF->data().at(i);
|
||||
uint key = av.at(0).toUInt();
|
||||
|
||||
if (key == OBJNAM)
|
||||
label = QString::fromLatin1(av.at(1).toByteArray());
|
||||
|
||||
if ((OBJL == RESARE && key == CATREA)
|
||||
|| (OBJL == I_RESARE && key == CATREA)
|
||||
|| (OBJL == ACHARE && key == CATACH)
|
||||
|| (OBJL == I_ACHARE && key == I_CATACH)
|
||||
|| (OBJL == HRBFAC && key == CATHAF)
|
||||
|| (OBJL == MARKUL && key == CATMFA)
|
||||
|| (OBJL == I_BERTHS && key == I_CATBRT))
|
||||
subtype = av.at(1).toByteArray().toUInt();
|
||||
else if ((OBJL == RESARE && key == RESTRN)
|
||||
|| (OBJL == I_RESARE && key == I_RESTRN)) {
|
||||
if (av.at(1).toByteArray().toUInt() == 1)
|
||||
subtype = 2;
|
||||
if (av.at(1).toByteArray().toUInt() == 7)
|
||||
subtype = 17;
|
||||
}
|
||||
|
||||
if ((OBJL == TSSLPT && key == ORIENT)
|
||||
|| (OBJL == DEPARE && key == DRVAL1))
|
||||
params[0] = av.at(1).toByteArray();
|
||||
if ((OBJL == BRIDGE && key == VERCLR)
|
||||
|| (OBJL == I_BRIDGE && key == VERCLR))
|
||||
params[0] = av.at(1).toByteArray();
|
||||
}
|
||||
|
||||
return Attr(subtype, label, params);
|
||||
return attr;
|
||||
}
|
||||
|
||||
MapData::Point *MapData::pointObject(const Sounding &s)
|
||||
{
|
||||
return new Point(TYPE(SOUNDG), s.c, QString::number(s.depth),
|
||||
QVector<QByteArray>());
|
||||
return new Point(SOUNDG, s.c, QString::number(s.depth));
|
||||
}
|
||||
|
||||
MapData::Point *MapData::pointObject(const ISO8211::Record &r,
|
||||
const RecordMap &vi, const RecordMap &vc, uint COMF, uint OBJL)
|
||||
const RecordMap &vi, const RecordMap &vc, uint COMF, uint OBJL, uint HUNI)
|
||||
{
|
||||
Coordinates c(pointGeometry(r, vi, vc, COMF));
|
||||
Attr attr(pointAttr(r, OBJL));
|
||||
|
||||
return (c.isNull() ? 0 : new Point(SUBTYPE(OBJL,attr.subtype()), c,
|
||||
attr.label(), attr.params()));
|
||||
return (c.isNull() ? 0 : new Point(OBJL, c, attributes(r), HUNI));
|
||||
}
|
||||
|
||||
MapData::Line *MapData::lineObject(const ISO8211::Record &r,
|
||||
const RecordMap &vc, const RecordMap &ve, uint COMF, uint OBJL)
|
||||
{
|
||||
QVector<Coordinates> path(lineGeometry(r, vc, ve, COMF));
|
||||
Attr attr(lineAttr(r, OBJL));
|
||||
|
||||
return (path.isEmpty() ? 0 : new Line(SUBTYPE(OBJL, attr.subtype()), path,
|
||||
attr.label(), attr.params()));
|
||||
return (path.isEmpty() ? 0 : new Line(OBJL, path, attributes(r)));
|
||||
}
|
||||
|
||||
MapData::Poly *MapData::polyObject(const ISO8211::Record &r,
|
||||
const RecordMap &vc, const RecordMap &ve, uint COMF, uint OBJL, uint HUNI)
|
||||
{
|
||||
Polygon path(polyGeometry(r, vc, ve, COMF));
|
||||
Attr attr(polyAttr(r, OBJL));
|
||||
|
||||
return (path.isEmpty() ? 0 : new Poly(SUBTYPE(OBJL, attr.subtype()), path,
|
||||
attr.label(), attr.params(), HUNI));
|
||||
return (path.isEmpty() ? 0 : new Poly(OBJL, path, attributes(r), HUNI));
|
||||
}
|
||||
|
||||
bool MapData::processRecord(const ISO8211::Record &record,
|
||||
@ -796,7 +824,7 @@ MapData::MapData(const QString &path)
|
||||
_points.Insert(min, max, point);
|
||||
}
|
||||
} else {
|
||||
if ((point = pointObject(r, vi, vc, COMF, OBJL))) {
|
||||
if ((point = pointObject(r, vi, vc, COMF, OBJL, HUNI))) {
|
||||
pointBounds(point->pos(), min, max);
|
||||
_points.Insert(min, max, point);
|
||||
} else
|
||||
@ -842,6 +870,8 @@ void MapData::points(const RectC &rect, QList<Point> *points) const
|
||||
|
||||
rectcBounds(rect, min, max);
|
||||
_points.Search(min, max, pointCb, points);
|
||||
_areas.Search(min, max, polygonPointCb, points);
|
||||
_lines.Search(min, max, linePointCb, points);
|
||||
}
|
||||
|
||||
void MapData::lines(const RectC &rect, QList<Line> *lines) const
|
||||
|
@ -11,49 +11,53 @@ namespace ENC {
|
||||
class MapData
|
||||
{
|
||||
public:
|
||||
typedef QMap<uint, QByteArray> Attributes;
|
||||
|
||||
class Poly {
|
||||
public:
|
||||
Poly(uint type, const Polygon &path, const QString &label,
|
||||
const QVector<QByteArray> ¶ms, uint HUNI);
|
||||
Poly(uint type, const Polygon &path, const Attributes &attr, uint HUNI);
|
||||
|
||||
RectC bounds() const {return _path.boundingRect();}
|
||||
const Polygon &path() const {return _path;}
|
||||
uint type() const {return _type;}
|
||||
const QString &label() const {return _label;}
|
||||
const QVariant ¶m() const {return _param;}
|
||||
const Attributes &attributes() const {return _attr;}
|
||||
uint HUNI() const {return _HUNI;}
|
||||
|
||||
private:
|
||||
uint _type;
|
||||
Polygon _path;
|
||||
QString _label;
|
||||
QVariant _param;
|
||||
Attributes _attr;
|
||||
uint _HUNI;
|
||||
};
|
||||
|
||||
class Line {
|
||||
public:
|
||||
Line(uint type, const QVector<Coordinates> &path, const QString &label,
|
||||
const QVector<QByteArray> ¶ms);
|
||||
Line(uint type, const QVector<Coordinates> &path, const Attributes &attr);
|
||||
|
||||
RectC bounds() const;
|
||||
const QVector<Coordinates> &path() const {return _path;}
|
||||
uint type() const {return _type;}
|
||||
const QString &label() const {return _label;}
|
||||
const Attributes &attributes() const {return _attr;}
|
||||
|
||||
private:
|
||||
uint _type;
|
||||
QVector<Coordinates> _path;
|
||||
QString _label;
|
||||
Attributes _attr;
|
||||
};
|
||||
|
||||
class Point {
|
||||
public:
|
||||
Point(uint type, const Coordinates &c, const QString &label,
|
||||
const QVector<QByteArray> ¶ms);
|
||||
Point(uint type, const Coordinates &c, const Attributes &attr,
|
||||
uint HUNI, bool polygon = false);
|
||||
Point(uint type, const Coordinates &s, const QString &label);
|
||||
|
||||
const Coordinates &pos() const {return _pos;}
|
||||
uint type() const {return _type;}
|
||||
const QString &label() const {return _label;}
|
||||
const QVariant ¶m() const {return _param;}
|
||||
const Attributes &attributes() const {return _attr;}
|
||||
bool polygon() const {return _polygon;}
|
||||
|
||||
bool operator<(const Point &other) const
|
||||
{return _id < other._id;}
|
||||
@ -63,7 +67,8 @@ public:
|
||||
Coordinates _pos;
|
||||
QString _label;
|
||||
quint64 _id;
|
||||
QVariant _param;
|
||||
Attributes _attr;
|
||||
bool _polygon;
|
||||
};
|
||||
|
||||
MapData(const QString &path);
|
||||
@ -74,23 +79,6 @@ public:
|
||||
void points(const RectC &rect, QList<Point> *points) const;
|
||||
|
||||
private:
|
||||
class Attr {
|
||||
public:
|
||||
Attr() : _subtype(0) {}
|
||||
Attr(uint subtype, const QString &label,
|
||||
const QVector<QByteArray> ¶ms)
|
||||
: _subtype(subtype), _label(label), _params(params) {}
|
||||
|
||||
unsigned subtype() const {return _subtype;}
|
||||
const QString &label() const {return _label;}
|
||||
const QVector<QByteArray> ¶ms() const {return _params;}
|
||||
|
||||
private:
|
||||
unsigned _subtype;
|
||||
QString _label;
|
||||
QVector<QByteArray> _params;
|
||||
};
|
||||
|
||||
struct Sounding {
|
||||
Sounding() : depth(NAN) {}
|
||||
Sounding(const Coordinates &c, double depth) : c(c), depth(depth) {}
|
||||
@ -115,12 +103,10 @@ private:
|
||||
const RecordMap &vc, const RecordMap &ve, uint COMF);
|
||||
static Polygon polyGeometry(const ISO8211::Record &r, const RecordMap &vc,
|
||||
const RecordMap &ve, uint COMF);
|
||||
static Attr pointAttr(const ISO8211::Record &r, uint OBJL);
|
||||
static Attr lineAttr(const ISO8211::Record &r, uint OBJL);
|
||||
static Attr polyAttr(const ISO8211::Record &r, uint OBJL);
|
||||
static Attributes attributes(const ISO8211::Record &r);
|
||||
static Point *pointObject(const Sounding &s);
|
||||
static Point *pointObject(const ISO8211::Record &r, const RecordMap &vi,
|
||||
const RecordMap &vc, uint COMF, uint OBJL);
|
||||
const RecordMap &vc, uint COMF, uint OBJL, uint HUNI);
|
||||
static Line *lineObject(const ISO8211::Record &r, const RecordMap &vc,
|
||||
const RecordMap &ve, uint COMF, uint OBJL);
|
||||
static Poly *polyObject(const ISO8211::Record &r, const RecordMap &vc,
|
||||
|
@ -51,6 +51,7 @@
|
||||
#define LAKARE 69
|
||||
#define LNDARE 71
|
||||
#define LNDELV 72
|
||||
#define LNDRGN 73
|
||||
#define LNDMRK 74
|
||||
#define LIGHTS 75
|
||||
#define LOKBSN 79
|
||||
@ -67,6 +68,7 @@
|
||||
#define PONTON 95
|
||||
#define PRCARE 96
|
||||
#define PYLONS 98
|
||||
#define RADRFL 101
|
||||
#define RADSTA 102
|
||||
#define RTPBCN 103
|
||||
#define RDOCAL 104
|
||||
@ -74,6 +76,7 @@
|
||||
#define RAILWY 106
|
||||
#define RCRTCL 108
|
||||
#define RECTRC 109
|
||||
#define RCTLPT 110
|
||||
#define RSCSTA 111
|
||||
#define RESARE 112
|
||||
#define RIVERS 114
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "map/textpointitem.h"
|
||||
#include "map/rectd.h"
|
||||
#include "objects.h"
|
||||
#include "attributes.h"
|
||||
#include "style.h"
|
||||
#include "rastertile.h"
|
||||
|
||||
@ -12,8 +13,8 @@ using namespace ENC;
|
||||
|
||||
#define TEXT_EXTENT 160
|
||||
#define TSSLPT_SIZE 24
|
||||
|
||||
typedef QSet<Coordinates> PointSet;
|
||||
#define RANGE_FACTOR 4
|
||||
#define MAJOR_RANGE 10
|
||||
|
||||
static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
||||
static const QColor tsslptPen = QColor(0xeb, 0x49, 0xeb);
|
||||
@ -40,31 +41,6 @@ static bool showLabel(const QImage *img, const Range &range, int zoom, int type)
|
||||
return true;
|
||||
}
|
||||
|
||||
QPointF RasterTile::centroid(const QVector<Coordinates> &polygon) const
|
||||
{
|
||||
Q_ASSERT(polygon.size() > 3);
|
||||
Q_ASSERT(polygon.first() == polygon.last());
|
||||
|
||||
double area = 0;
|
||||
double cx = 0, cy = 0;
|
||||
QPointF pi;
|
||||
QPointF pj(ll2xy(polygon.at(0)));
|
||||
|
||||
for (int i = 0; i < polygon.size() - 1; i++) {
|
||||
pi = pj;
|
||||
pj = ll2xy(polygon.at(i + 1));
|
||||
|
||||
double f = pi.x() * pj.y() - pj.x() * pi.y();
|
||||
area += f;
|
||||
cx += (pi.x() + pj.x()) * f;
|
||||
cy += (pi.y() + pj.y()) * f;
|
||||
}
|
||||
|
||||
double factor = 1.0 / (3.0 * area);
|
||||
|
||||
return QPointF(cx * factor, cy * factor);
|
||||
}
|
||||
|
||||
QPainterPath RasterTile::painterPath(const Polygon &polygon) const
|
||||
{
|
||||
QPainterPath path;
|
||||
@ -150,25 +126,34 @@ QPolygonF RasterTile::tsslptArrow(const QPointF &p, qreal angle) const
|
||||
return polygon;
|
||||
}
|
||||
|
||||
void RasterTile::drawArrows(QPainter *painter,
|
||||
const QList<MapData::Poly> &polygons)
|
||||
static void drawArrow(QPainter *painter, const QPolygonF &polygon, uint type)
|
||||
{
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
const MapData::Poly &poly = polygons.at(i);
|
||||
if (type>>16 == RCTLPT) {
|
||||
painter->setPen(QPen(tsslptPen, 1, Qt::DashLine));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
} else {
|
||||
painter->setPen(QPen(tsslptPen, 1));
|
||||
painter->setBrush(QBrush(tsslptBrush));
|
||||
}
|
||||
painter->drawPolygon(polygon);
|
||||
}
|
||||
|
||||
if (poly.type()>>16 == TSSLPT) {
|
||||
QPolygonF polygon(tsslptArrow(centroid(poly.path().first()),
|
||||
deg2rad(poly.param().toDouble())));
|
||||
void RasterTile::drawArrows(QPainter *painter,
|
||||
const QList<MapData::Point> &points) const
|
||||
{
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
const MapData::Point &point = points.at(i);
|
||||
|
||||
painter->setPen(QPen(tsslptPen, 1));
|
||||
painter->setBrush(QBrush(tsslptBrush));
|
||||
painter->drawPolygon(polygon);
|
||||
if (point.type()>>16 == TSSLPT || point.type()>>16 == RCTLPT) {
|
||||
QPolygonF polygon(tsslptArrow(ll2xy(point.pos()),
|
||||
deg2rad(point.attributes().value(ORIENT).toDouble())));
|
||||
drawArrow(painter, polygon, point.type());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::drawPolygons(QPainter *painter,
|
||||
const QList<MapData::Poly> &polygons)
|
||||
const QList<MapData::Poly> &polygons) const
|
||||
{
|
||||
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
@ -200,7 +185,7 @@ void RasterTile::drawPolygons(QPainter *painter,
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::drawLines(QPainter *painter, const QList<MapData::Line> &lines)
|
||||
void RasterTile::drawLines(QPainter *painter, const QList<MapData::Line> &lines) const
|
||||
{
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
|
||||
@ -218,7 +203,7 @@ void RasterTile::drawLines(QPainter *painter, const QList<MapData::Line> &lines)
|
||||
}
|
||||
|
||||
void RasterTile::drawTextItems(QPainter *painter,
|
||||
const QList<TextItem*> &textItems)
|
||||
const QList<TextItem*> &textItems) const
|
||||
{
|
||||
QRectF rect(_rect);
|
||||
|
||||
@ -229,50 +214,56 @@ void RasterTile::drawTextItems(QPainter *painter,
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::processPolygons(const QList<MapData::Poly> &polygons,
|
||||
QList<TextItem*> &textItems)
|
||||
static QRectF lightRect(const QPointF &pos, double range)
|
||||
{
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
const MapData::Poly &poly = polygons.at(i);
|
||||
uint type = poly.type()>>16;
|
||||
const QImage *img = 0;
|
||||
const QString *label = 0;
|
||||
const QFont *fnt = 0;
|
||||
const QColor *color = 0, *hColor = 0;
|
||||
QPoint offset(0, 0);
|
||||
double r = qMin(range * RANGE_FACTOR, (double)TEXT_EXTENT);
|
||||
return QRect(pos.x() - r, pos.y() - r, 2 * r, 2 * r);
|
||||
}
|
||||
|
||||
if (!poly.label().isEmpty()) {
|
||||
const Style::Point &style = _style->point(poly.type());
|
||||
fnt = _style->font(style.textFontSize());
|
||||
color = &style.textColor();
|
||||
hColor = style.haloColor().isValid() ? &style.haloColor() : 0;
|
||||
label = &poly.label();
|
||||
}
|
||||
if (type == HRBFAC || type == I_TRNBSN
|
||||
|| poly.type() == SUBTYPE(I_BERTHS, 6)) {
|
||||
const Style::Point &style = _style->point(poly.type());
|
||||
img = style.img().isNull() ? 0 : &style.img();
|
||||
offset = style.offset();
|
||||
void RasterTile::drawSectorLights(QPainter *painter,
|
||||
const QList<SectorLight> &lights) const
|
||||
{
|
||||
for (int i = 0; i < lights.size(); i++) {
|
||||
const SectorLight &l = lights.at(i);
|
||||
QPointF pos(ll2xy(l.pos));
|
||||
QRectF rect(lightRect(pos, (l.range == 0) ? 6 : l.range));
|
||||
double a1 = -(l.end + 90);
|
||||
double a2 = -(l.start + 90);
|
||||
if (a1 > a2)
|
||||
a2 += 360;
|
||||
double as = (a2 - a1);
|
||||
if (as == 0)
|
||||
as = 360;
|
||||
|
||||
if (l.visibility == 3 || l.visibility >= 6)
|
||||
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||
else {
|
||||
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap));
|
||||
painter->drawArc(rect, a1 * 16, as * 16);
|
||||
painter->setPen(QPen(Style::color(l.color), 4, Qt::SolidLine,
|
||||
Qt::FlatCap));
|
||||
}
|
||||
|
||||
if ((!label || !fnt) && !img)
|
||||
continue;
|
||||
painter->drawArc(rect, a1 * 16, as * 16);
|
||||
|
||||
TextPointItem *item = new TextPointItem(offset +
|
||||
centroid(poly.path().first()).toPoint(), label, fnt, img, color,
|
||||
hColor, 0, 0);
|
||||
if (item->isValid() && _rect.contains(item->boundingRect().toRect())
|
||||
&& !item->collides(textItems))
|
||||
textItems.append(item);
|
||||
else
|
||||
delete item;
|
||||
if (a2 - a1 != 0) {
|
||||
QLineF ln(pos, QPointF(pos.x() + rect.width(), pos.y()));
|
||||
ln.setAngle(a1);
|
||||
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||
painter->drawLine(ln);
|
||||
ln.setAngle(a2);
|
||||
painter->drawLine(ln);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lights)
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
||||
QList<SectorLight> §orLights)
|
||||
{
|
||||
PointSet lightsSet, signalsSet;
|
||||
LightMap lightsMap;
|
||||
SignalSet signalsSet;
|
||||
QSet<Coordinates> slMap;
|
||||
int i;
|
||||
|
||||
std::sort(points.begin(), points.end());
|
||||
@ -280,9 +271,21 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
/* Lights & Signals */
|
||||
for (i = 0; i < points.size(); i++) {
|
||||
const MapData::Point &point = points.at(i);
|
||||
if (point.type()>>16 == LIGHTS)
|
||||
lightsSet.insert(point.pos());
|
||||
else if (point.type()>>16 == FOGSIG)
|
||||
|
||||
if (point.type()>>16 == LIGHTS) {
|
||||
const MapData::Attributes &attr = point.attributes();
|
||||
Style::Color color = (Style::Color)(attr.value(COLOUR).toUInt());
|
||||
double range = attr.value(VALNMR).toDouble();
|
||||
|
||||
if (attr.contains(SECTR1)
|
||||
|| (range >= MAJOR_RANGE && !(point.type() & 0xFFFF))) {
|
||||
sectorLights.append(SectorLight(point.pos(), color,
|
||||
attr.value(LITVIS).toUInt(), range,
|
||||
attr.value(SECTR1).toDouble(), attr.value(SECTR2).toDouble()));
|
||||
slMap.insert(point.pos());
|
||||
} else
|
||||
lightsMap.insert(point.pos(), color);
|
||||
} else if (point.type()>>16 == FOGSIG)
|
||||
signalsSet.insert(point.pos());
|
||||
else
|
||||
break;
|
||||
@ -301,7 +304,7 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
const QColor *color = &style.textColor();
|
||||
const QColor *hColor = style.haloColor().isValid()
|
||||
? &style.haloColor() : 0;
|
||||
double rotate = angle(point.type(), point.param());
|
||||
double rotate = angle(point.type(), point.attributes().value(ORIENT));
|
||||
|
||||
if ((!label || !fnt) && !img)
|
||||
continue;
|
||||
@ -310,11 +313,12 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
|
||||
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
||||
color, hColor, 0, 2, rotate);
|
||||
if (item->isValid() && !item->collides(textItems)) {
|
||||
if (item->isValid() && (slMap.contains(point.pos())
|
||||
|| (point.polygon() && img) || !item->collides(textItems))) {
|
||||
textItems.append(item);
|
||||
if (lightsSet.contains(point.pos()))
|
||||
if (lightsMap.contains(point.pos()))
|
||||
lights.append(new TextPointItem(pos + _style->lightOffset(),
|
||||
0, 0, _style->light(), 0, 0, 0, 0));
|
||||
0, 0, _style->light(lightsMap.value(point.pos())), 0, 0, 0, 0));
|
||||
if (signalsSet.contains(point.pos()))
|
||||
lights.append(new TextPointItem(pos + _style->signalOffset(),
|
||||
0, 0, _style->signal(), 0, 0, 0, 0));
|
||||
@ -382,14 +386,14 @@ void RasterTile::render()
|
||||
QList<MapData::Poly> polygons;
|
||||
QList<MapData::Point> points;
|
||||
QList<TextItem*> textItems, lights;
|
||||
QList<SectorLight> sectorLights;
|
||||
|
||||
img.setDevicePixelRatio(_ratio);
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
fetchData(polygons, lines, points);
|
||||
|
||||
processPoints(points, textItems, lights);
|
||||
processPolygons(polygons, textItems);
|
||||
processPoints(points, textItems, lights, sectorLights);
|
||||
processLines(lines, textItems);
|
||||
|
||||
QPainter painter(&img);
|
||||
@ -399,9 +403,11 @@ void RasterTile::render()
|
||||
|
||||
drawPolygons(&painter, polygons);
|
||||
drawLines(&painter, lines);
|
||||
drawArrows(&painter, polygons);
|
||||
drawArrows(&painter, points);
|
||||
|
||||
|
||||
drawTextItems(&painter, lights);
|
||||
drawSectorLights(&painter, sectorLights);
|
||||
drawTextItems(&painter, textItems);
|
||||
|
||||
qDeleteAll(textItems);
|
||||
|
@ -34,6 +34,23 @@ public:
|
||||
void render();
|
||||
|
||||
private:
|
||||
struct SectorLight
|
||||
{
|
||||
SectorLight(const Coordinates &pos, Style::Color color, uint visibility,
|
||||
double range, double start, double end) : pos(pos), color(color),
|
||||
visibility(visibility), range(range), start(start), end(end) {}
|
||||
|
||||
Coordinates pos;
|
||||
Style::Color color;
|
||||
uint visibility;
|
||||
double range;
|
||||
double start;
|
||||
double end;
|
||||
};
|
||||
|
||||
typedef QMap<Coordinates, Style::Color> LightMap;
|
||||
typedef QSet<Coordinates> SignalSet;
|
||||
|
||||
void fetchData(QList<MapData::Poly> &polygons, QList<MapData::Line> &lines,
|
||||
QList<MapData::Point> &points);
|
||||
QPointF ll2xy(const Coordinates &c) const
|
||||
@ -44,17 +61,15 @@ private:
|
||||
QPolygonF tsslptArrow(const QPointF &p, qreal angle) const;
|
||||
QPointF centroid(const QVector<Coordinates> &polygon) const;
|
||||
void processPoints(QList<MapData::Point> &points,
|
||||
QList<TextItem*> &textItems, QList<TextItem *> &lights);
|
||||
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
||||
QList<SectorLight> §orLights);
|
||||
void processLines(const QList<MapData::Line> &lines,
|
||||
QList<TextItem*> &textItems);
|
||||
void processPolygons(const QList<MapData::Poly> &polygons,
|
||||
QList<TextItem*> &textItems);
|
||||
void drawBitmapPath(QPainter *painter, const QImage &img,
|
||||
const Polygon &polygon);
|
||||
void drawArrows(QPainter *painter, const QList<MapData::Poly> &polygons);
|
||||
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons);
|
||||
void drawLines(QPainter *painter, const QList<MapData::Line> &lines);
|
||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
|
||||
void drawArrows(QPainter *painter, const QList<MapData::Point> &points) const;
|
||||
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons) const;
|
||||
void drawLines(QPainter *painter, const QList<MapData::Line> &lines) const;
|
||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
||||
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
|
||||
|
||||
static bool polyCb(MapData *data, void *context);
|
||||
static bool pointCb(MapData *data, void *context);
|
||||
|
@ -70,19 +70,48 @@ void Style::polygonStyle()
|
||||
_polygons[TYPE(DRGARE)] = Polygon(QBrush(QColor(0xa0, 0xa0, 0xff),
|
||||
Qt::Dense4Pattern));
|
||||
_polygons[TYPE(UNSARE)] = Polygon(QBrush(QColor(0x99, 0x99, 0x99)));
|
||||
_polygons[SUBTYPE(RESARE, 1)] = Polygon(QImage(":/marine/safety-zone-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 2)] = Polygon(QImage(":/marine/noanchor-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 4)] = Polygon(QImage(":/marine/nature-reserve-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 5)] = Polygon(QImage(":/marine/sanctuary-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 6)] = Polygon(QImage(":/marine/sanctuary-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 7)] = Polygon(QImage(":/marine/sanctuary-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 9)] = Polygon(QBrush(QColor(0xff, 0x00, 0x00),
|
||||
Qt::BDiagPattern));
|
||||
_polygons[SUBTYPE(RESARE, 2)] = Polygon(QImage(":/marine/noanchor-line.png"));
|
||||
_polygons[SUBTYPE(I_RESARE, 2)] = Polygon(QImage(":/marine/noanchor-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 17)] = Polygon(
|
||||
QImage(":/marine/entry-prohibited-line.png"));
|
||||
_polygons[SUBTYPE(I_RESARE, 17)] = Polygon(
|
||||
QImage(":/marine/entry-prohibited-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 12)] = Polygon(QImage(":/marine/safety-zone-line.png"));
|
||||
_polygons[SUBTYPE(I_RESARE, 12)] = Polygon(QImage(":/marine/safety-zone-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 1)] = Polygon(QImage(":/marine/safety-zone-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 17)] = Polygon(QImage(":/marine/entry-prohibited-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 22)] = Polygon(QImage(":/marine/sanctuary-line.png"));
|
||||
_polygons[SUBTYPE(RESARE, 23)] = Polygon(QImage(":/marine/nature-reserve-line.png"));
|
||||
_polygons[SUBTYPE(I_RESARE, 1)] = _polygons[SUBTYPE(RESARE, 1)];
|
||||
_polygons[SUBTYPE(I_RESARE, 2)] = _polygons[SUBTYPE(RESARE, 2)];
|
||||
_polygons[SUBTYPE(I_RESARE, 4)] = _polygons[SUBTYPE(RESARE, 4)];
|
||||
_polygons[SUBTYPE(I_RESARE, 9)] = _polygons[SUBTYPE(RESARE, 9)];
|
||||
_polygons[SUBTYPE(I_RESARE, 12)] = _polygons[SUBTYPE(RESARE, 12)];
|
||||
_polygons[SUBTYPE(I_RESARE, 17)] = _polygons[SUBTYPE(RESARE, 17)];
|
||||
_polygons[SUBTYPE(I_RESARE, 22)] = _polygons[SUBTYPE(RESARE, 22)];
|
||||
_polygons[SUBTYPE(I_RESARE, 23)] = _polygons[SUBTYPE(RESARE, 23)];
|
||||
_polygons[SUBTYPE(ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png"));
|
||||
_polygons[SUBTYPE(I_ACHARE, 1)] = Polygon(QImage(":/marine/anchor-line.png"));
|
||||
_polygons[SUBTYPE(ACHARE, 2)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(ACHARE, 3)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(ACHARE, 4)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(ACHARE, 5)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(ACHARE, 6)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(ACHARE, 7)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(ACHARE, 8)] = Polygon(Qt::NoBrush,
|
||||
QPen(QColor(0xeb, 0x49, 0xeb), 1, Qt::DashLine));
|
||||
_polygons[SUBTYPE(ACHARE, 9)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 1)] = _polygons[SUBTYPE(ACHARE, 1)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 2)] = _polygons[SUBTYPE(ACHARE, 2)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 3)] = _polygons[SUBTYPE(ACHARE, 3)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 4)] = _polygons[SUBTYPE(ACHARE, 4)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 5)] = _polygons[SUBTYPE(ACHARE, 5)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 6)] = _polygons[SUBTYPE(ACHARE, 6)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 7)] = _polygons[SUBTYPE(ACHARE, 7)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 8)] = _polygons[SUBTYPE(ACHARE, 8)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 9)] = _polygons[SUBTYPE(ACHARE, 9)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 10)] = _polygons[SUBTYPE(I_ACHARE, 1)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 11)] = _polygons[SUBTYPE(I_ACHARE, 1)];
|
||||
_polygons[SUBTYPE(I_ACHARE, 12)] = _polygons[SUBTYPE(I_ACHARE, 1)];
|
||||
_polygons[TYPE(PRCARE)] = Polygon(QBrush(QColor(0xeb, 0x49, 0xeb),
|
||||
Qt::BDiagPattern));
|
||||
_polygons[TYPE(DAMCON)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)),
|
||||
@ -113,8 +142,12 @@ void Style::polygonStyle()
|
||||
_polygons[TYPE(CBLARE)] = Polygon(QImage(":/marine/cable-area-line.png"));
|
||||
_polygons[TYPE(PIPARE)] = Polygon(QImage(":/marine/pipeline-area-line.png"));
|
||||
_polygons[SUBTYPE(MARKUL, 3)] = Polygon(QImage(":/marine/fishing-farm-line.png"));
|
||||
_polygons[SUBTYPE(I_BERTHS, 6)] = Polygon(Qt::NoBrush,
|
||||
QPen(QColor(0xeb, 0x49, 0xeb), 1, Qt::DashLine));
|
||||
_polygons[TYPE(BERTHS)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb),
|
||||
1, Qt::DashLine));
|
||||
_polygons[TYPE(I_BERTHS)] = _polygons[TYPE(BERTHS)];
|
||||
_polygons[SUBTYPE(I_BERTHS, 6)] = _polygons[TYPE(BERTHS)];
|
||||
_polygons[TYPE(I_TRNBSN)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb),
|
||||
1, Qt::DashLine));
|
||||
_polygons[TYPE(CONZNE)] = Polygon(Qt::NoBrush, QPen(QColor(0xeb, 0x49, 0xeb),
|
||||
1, Qt::DashDotLine));
|
||||
|
||||
@ -129,13 +162,25 @@ void Style::polygonStyle()
|
||||
<< TYPE(I_TERMNL) << TYPE(SLCONS) << TYPE(I_SLCONS) << TYPE(PONTON)
|
||||
<< TYPE(I_PONTON) << TYPE(HULKES) << TYPE(I_HULKES) << TYPE(FLODOC)
|
||||
<< TYPE(I_FLODOC) << TYPE(DRYDOC) << TYPE(DAMCON) << TYPE(PYLONS)
|
||||
<< TYPE(MORFAC) << TYPE(GATCON) << TYPE(I_GATCON) << SUBTYPE(I_BERTHS, 6)
|
||||
<< TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(OBSTRN) << TYPE(UWTROC)
|
||||
<< TYPE(DWRTPT) << SUBTYPE(ACHARE, 1) << SUBTYPE(I_ACHARE, 1)
|
||||
<< SUBTYPE(RESARE, 9) << SUBTYPE(RESARE, 2) << SUBTYPE(I_RESARE, 2)
|
||||
<< SUBTYPE(RESARE, 17) << SUBTYPE(I_RESARE, 17) << SUBTYPE(RESARE, 12)
|
||||
<< SUBTYPE(I_RESARE, 12) << SUBTYPE(RESARE, 1) << TYPE(CBLARE)
|
||||
<< TYPE(PIPARE) << TYPE(PRCARE) << SUBTYPE(MARKUL, 3) << TYPE(CONZNE);
|
||||
<< TYPE(MORFAC) << TYPE(GATCON) << TYPE(I_GATCON) << TYPE(BERTHS)
|
||||
<< TYPE(I_BERTHS) << SUBTYPE(I_BERTHS, 6) << TYPE(DMPGRD) << TYPE(TSEZNE)
|
||||
<< TYPE(OBSTRN) << TYPE(UWTROC) << TYPE(DWRTPT) << SUBTYPE(ACHARE, 1)
|
||||
<< SUBTYPE(ACHARE, 2) << SUBTYPE(ACHARE, 3) << SUBTYPE(ACHARE, 4)
|
||||
<< SUBTYPE(ACHARE, 5) << SUBTYPE(ACHARE, 6) << SUBTYPE(ACHARE, 7)
|
||||
<< SUBTYPE(ACHARE, 8) << SUBTYPE(ACHARE, 9) << SUBTYPE(I_ACHARE, 1)
|
||||
<< SUBTYPE(I_ACHARE, 2) << SUBTYPE(I_ACHARE, 3) << SUBTYPE(I_ACHARE, 4)
|
||||
<< SUBTYPE(I_ACHARE, 5) << SUBTYPE(I_ACHARE, 6) << SUBTYPE(I_ACHARE, 7)
|
||||
<< SUBTYPE(I_ACHARE, 8) << SUBTYPE(I_ACHARE, 9) << SUBTYPE(I_ACHARE, 10)
|
||||
<< SUBTYPE(I_ACHARE, 11) << SUBTYPE(I_ACHARE, 12) << SUBTYPE(RESARE, 1)
|
||||
<< SUBTYPE(I_RESARE, 1) << SUBTYPE(RESARE, 2) << SUBTYPE(I_RESARE, 2)
|
||||
<< SUBTYPE(RESARE, 4) << SUBTYPE(I_RESARE, 4) << SUBTYPE(RESARE, 5)
|
||||
<< SUBTYPE(I_RESARE, 5) << SUBTYPE(RESARE, 6) << SUBTYPE(I_RESARE, 6)
|
||||
<< SUBTYPE(RESARE, 7) << SUBTYPE(I_RESARE, 7) << SUBTYPE(RESARE, 9)
|
||||
<< SUBTYPE(I_RESARE, 9) << SUBTYPE(RESARE, 12) << SUBTYPE(I_RESARE, 12)
|
||||
<< SUBTYPE(RESARE, 17) << SUBTYPE(I_RESARE, 17) << SUBTYPE(RESARE, 22)
|
||||
<< SUBTYPE(I_RESARE, 22) << SUBTYPE(RESARE, 23) << SUBTYPE(I_RESARE, 23)
|
||||
<< SUBTYPE(RESARE, 1) << TYPE(CBLARE) << TYPE(PIPARE) << TYPE(PRCARE)
|
||||
<< TYPE(I_TRNBSN) << SUBTYPE(MARKUL, 3) << TYPE(CONZNE);
|
||||
}
|
||||
|
||||
void Style::lineStyle(qreal ratio)
|
||||
@ -152,7 +197,7 @@ void Style::lineStyle(qreal ratio)
|
||||
_lines[TYPE(CBLSUB)].setTextFontSize(Small);
|
||||
_lines[TYPE(PIPSOL)] = Line(QImage(":/marine/pipeline.png"));
|
||||
_lines[TYPE(PIPSOL)].setTextFontSize(Small);
|
||||
_lines[TYPE(NAVLNE)] = Line(QPen(QColor(0xeb, 0x49, 0xeb), 1, Qt::DashLine));
|
||||
_lines[TYPE(NAVLNE)] = Line(QPen(QColor(0, 0, 0), 1, Qt::DashLine));
|
||||
_lines[TYPE(COALNE)] = Line(QPen(QColor(0, 0, 0), 1, Qt::SolidLine));
|
||||
_lines[TYPE(SLCONS)] = Line(QPen(QColor(0, 0, 0), 2, Qt::SolidLine));
|
||||
_lines[TYPE(I_SLCONS)] = Line(QPen(QColor(0, 0, 0), 2, Qt::SolidLine));
|
||||
@ -191,6 +236,14 @@ void Style::lineStyle(qreal ratio)
|
||||
_lines[TYPE(PIPOHD)] = Line(QImage(":/marine/pipeline-overhead.png"));
|
||||
_lines[TYPE(I_PIPOHD)] = Line(QImage(":/marine/pipeline-overhead.png"));
|
||||
_lines[TYPE(CANALS)] = Line(QPen(QColor(0x9f, 0xc4, 0xe1), 2));
|
||||
_lines[SUBTYPE(RDOCAL, 1)] = Line(QPen(QColor(0xeb, 0x49, 0xeb), 1,
|
||||
Qt::DashLine));
|
||||
_lines[SUBTYPE(RDOCAL, 2)] = Line(QPen(QColor(0xeb, 0x49, 0xeb), 1,
|
||||
Qt::DashLine));
|
||||
_lines[SUBTYPE(RDOCAL, 3)] = Line(QPen(QColor(0xeb, 0x49, 0xeb), 1,
|
||||
Qt::DashLine));
|
||||
_lines[SUBTYPE(RDOCAL, 4)] = Line(QPen(QColor(0xeb, 0x49, 0xeb), 1,
|
||||
Qt::DashLine));
|
||||
}
|
||||
|
||||
void Style::pointStyle(qreal ratio)
|
||||
@ -235,6 +288,7 @@ void Style::pointStyle(qreal ratio)
|
||||
_points[SUBTYPE(LNDMRK, 7)] = Point(QImage(":/marine/pylon.png"), Small);
|
||||
_points[SUBTYPE(LNDMRK, 9)] = Point(QImage(":/marine/monument.png"), Small,
|
||||
QPoint(0, -7));
|
||||
_points[SUBTYPE(LNDMRK, 10)] = Point(QImage(":/marine/pylon.png"), Small);
|
||||
_points[SUBTYPE(LNDMRK, 15)] = Point(QImage(":/marine/dome.png"), Small,
|
||||
QPoint(0, -5));
|
||||
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"), Small,
|
||||
@ -270,7 +324,9 @@ void Style::pointStyle(qreal ratio)
|
||||
_points[SUBTYPE(I_HRBFAC, 5)] = Point(QImage(":/marine/yacht-harbor.png"));
|
||||
_points[SUBTYPE(I_HRBFAC, 9)] = Point(QImage(":/marine/shipyard.png"));
|
||||
_points[TYPE(ACHBRT)] = Point(QImage(":/marine/anchorage.png"));
|
||||
_points[TYPE(I_ACHBRT)] = Point(QImage(":/marine/anchorage.png"));
|
||||
_points[TYPE(ACHBRT)].setTextColor(QColor(0xeb, 0x49, 0xeb));
|
||||
_points[TYPE(ACHBRT)].setHaloColor(QColor());
|
||||
_points[TYPE(I_ACHBRT)] = _points[TYPE(ACHBRT)];
|
||||
_points[TYPE(OFSPLF)] = Point(QImage(":/marine/platform.png"));
|
||||
_points[TYPE(PILPNT)] = Point(QImage(":/marine/pile.png"), Small);
|
||||
_points[SUBTYPE(MORFAC, 1)] = Point(QImage(":/marine/pile.png"), Small);
|
||||
@ -323,7 +379,6 @@ void Style::pointStyle(qreal ratio)
|
||||
_points[SUBTYPE(I_RDOCAL, 3)].setTextColor(QColor(0xeb, 0x49, 0xeb));
|
||||
_points[SUBTYPE(I_RDOCAL, 4)].setTextColor(QColor(0xeb, 0x49, 0xeb));
|
||||
_points[TYPE(PYLONS)] = Point(QImage(":/marine/pylon.png"));
|
||||
_points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png"));
|
||||
_points[SUBTYPE(WATTUR, 1)] = Point(QImage(":/marine/breakers.png"));
|
||||
_points[SUBTYPE(WATTUR, 2)] = Point(QImage(":/marine/eddies.png"));
|
||||
_points[SUBTYPE(WATTUR, 3)] = Point(QImage(":/marine/overfalls.png"));
|
||||
@ -335,6 +390,47 @@ void Style::pointStyle(qreal ratio)
|
||||
_points[SUBTYPE(WEDKLP, 0)] = Point(QImage(":/marine/kelp.png"));
|
||||
_points[SUBTYPE(WEDKLP, 1)] = Point(QImage(":/marine/kelp.png"));
|
||||
_points[TYPE(SEAARE)].setHaloColor(QColor());
|
||||
_points[TYPE(LNDARE)].setHaloColor(QColor());
|
||||
_points[TYPE(LNDRGN)].setHaloColor(QColor());
|
||||
_points[TYPE(RADRFL)] = Point(QImage(":/marine/radar-reflector.png"));
|
||||
|
||||
_points[SUBTYPE(I_BERTHS, 6)] = Point(QImage(":/marine/fleeting-area.png"),
|
||||
Small);
|
||||
_points[SUBTYPE(I_BERTHS, 6)].setTextColor(QColor(0xeb, 0x49, 0xeb));
|
||||
_points[SUBTYPE(I_BERTHS, 6)].setHaloColor(QColor());
|
||||
_points[SUBTYPE(ACHARE, 2)] = Point(QImage(":/marine/dw-anchorage.png"),
|
||||
Small);
|
||||
_points[SUBTYPE(ACHARE, 3)] = Point(QImage(":/marine/tanker-anchorage.png"),
|
||||
Small);
|
||||
_points[SUBTYPE(ACHARE, 9)] = Point(QImage(":/marine/24h-anchorage.png"),
|
||||
Small);
|
||||
_points[SUBTYPE(I_ACHARE, 2)] = _points[SUBTYPE(ACHARE, 2)];
|
||||
_points[SUBTYPE(I_ACHARE, 3)] = _points[SUBTYPE(ACHARE, 3)];
|
||||
_points[SUBTYPE(I_ACHARE, 9)] = _points[SUBTYPE(ACHARE, 9)];
|
||||
_points[SUBTYPE(RESARE, 1)].setTextColor(QColor(0xeb, 0x49, 0xeb));
|
||||
_points[SUBTYPE(RESARE, 1)].setHaloColor(QColor());
|
||||
_points[SUBTYPE(RESARE, 2)] = _points[SUBTYPE(RESARE, 1)];
|
||||
_points[SUBTYPE(RESARE, 4)].setTextColor(QColor(0x30, 0xa0, 0x1b));
|
||||
_points[SUBTYPE(RESARE, 4)].setHaloColor(QColor());
|
||||
_points[SUBTYPE(RESARE, 5)] = _points[SUBTYPE(RESARE, 4)];
|
||||
_points[SUBTYPE(RESARE, 6)] = _points[SUBTYPE(RESARE, 4)];
|
||||
_points[SUBTYPE(RESARE, 7)] = _points[SUBTYPE(RESARE, 4)];
|
||||
_points[SUBTYPE(RESARE, 9)] = _points[SUBTYPE(RESARE, 1)];
|
||||
_points[SUBTYPE(RESARE, 12)] = _points[SUBTYPE(RESARE, 1)];
|
||||
_points[SUBTYPE(RESARE, 17)] = _points[SUBTYPE(RESARE, 1)];
|
||||
_points[SUBTYPE(RESARE, 22)] = _points[SUBTYPE(RESARE, 4)];
|
||||
_points[SUBTYPE(RESARE, 23)] = _points[SUBTYPE(RESARE, 4)];
|
||||
_points[SUBTYPE(I_RESARE, 1)] = _points[SUBTYPE(RESARE, 1)];
|
||||
_points[SUBTYPE(I_RESARE, 2)] = _points[SUBTYPE(RESARE, 2)];
|
||||
_points[SUBTYPE(I_RESARE, 4)] = _points[SUBTYPE(RESARE, 4)];
|
||||
_points[SUBTYPE(I_RESARE, 5)] = _points[SUBTYPE(RESARE, 5)];
|
||||
_points[SUBTYPE(I_RESARE, 6)] = _points[SUBTYPE(RESARE, 6)];
|
||||
_points[SUBTYPE(I_RESARE, 7)] = _points[SUBTYPE(RESARE, 7)];
|
||||
_points[SUBTYPE(I_RESARE, 9)] = _points[SUBTYPE(RESARE, 9)];
|
||||
_points[SUBTYPE(I_RESARE, 12)] = _points[SUBTYPE(RESARE, 12)];
|
||||
_points[SUBTYPE(I_RESARE, 17)] = _points[SUBTYPE(RESARE, 17)];
|
||||
_points[SUBTYPE(I_RESARE, 22)] = _points[SUBTYPE(RESARE, 22)];
|
||||
_points[SUBTYPE(I_RESARE, 23)] = _points[SUBTYPE(RESARE, 23)];
|
||||
|
||||
_points[SUBTYPE(SMCFAC, 7)] = Point(svg2img(":/POI/restaurant-11.svg",
|
||||
ratio), Small);
|
||||
@ -383,6 +479,9 @@ void Style::pointStyle(qreal ratio)
|
||||
Style::Style(qreal ratio)
|
||||
{
|
||||
_light = QImage(":/marine/light.png");
|
||||
_lightRed = QImage(":/marine/light-red.png");
|
||||
_lightGreen = QImage(":/marine/light-green.png");
|
||||
_lightYellow = QImage(":/marine/light-yellow.png");
|
||||
_lightOffset = QPoint(11, 11);
|
||||
_signal = QImage(":/marine/fog-signal.png");
|
||||
_signalOffset = QPoint(-9, 9);
|
||||
@ -433,3 +532,37 @@ const QFont *Style::font(Style::FontSize size) const
|
||||
return &_normal;
|
||||
}
|
||||
}
|
||||
|
||||
const QImage *Style::light(Color color) const
|
||||
{
|
||||
switch (color) {
|
||||
case Red:
|
||||
return &_lightRed;
|
||||
case Green:
|
||||
return &_lightGreen;
|
||||
case White:
|
||||
case Yellow:
|
||||
case Amber:
|
||||
case Orange:
|
||||
return &_lightYellow;
|
||||
default:
|
||||
return &_light;
|
||||
}
|
||||
}
|
||||
|
||||
QColor Style::color(Style::Color c)
|
||||
{
|
||||
switch (c) {
|
||||
case Red:
|
||||
return Qt::red;
|
||||
case Green:
|
||||
return Qt::green;
|
||||
case White:
|
||||
case Yellow:
|
||||
case Amber:
|
||||
case Orange:
|
||||
return Qt::yellow;
|
||||
default:
|
||||
return Qt::magenta;
|
||||
}
|
||||
}
|
||||
|
@ -89,6 +89,11 @@ public:
|
||||
QPoint _offset;
|
||||
};
|
||||
|
||||
enum Color {
|
||||
Unknown, White, Black, Red, Green, Blue, Yellow, Gray,
|
||||
Brown, Amber, Violet, Orange, Magenta, Pink
|
||||
};
|
||||
|
||||
Style(qreal ratio);
|
||||
|
||||
const Line &line(uint type) const;
|
||||
@ -97,11 +102,13 @@ public:
|
||||
const QVector<uint> &drawOrder() const {return _drawOrder;}
|
||||
|
||||
const QFont *font(Style::FontSize size) const;
|
||||
const QImage *light() const {return &_light;}
|
||||
const QImage *light(Color color) const;
|
||||
const QImage *signal() const {return &_signal;}
|
||||
const QPoint &lightOffset() const {return _lightOffset;}
|
||||
const QPoint &signalOffset() const {return _signalOffset;}
|
||||
|
||||
static QColor color(Color c);
|
||||
|
||||
private:
|
||||
void polygonStyle();
|
||||
void lineStyle(qreal ratio);
|
||||
@ -114,7 +121,7 @@ private:
|
||||
|
||||
/* Fonts and images must be initialized after QGuiApplication! */
|
||||
QFont _small, _normal, _large;
|
||||
QImage _light, _signal;
|
||||
QImage _light, _lightRed, _lightGreen, _lightYellow, _signal;
|
||||
QPoint _lightOffset, _signalOffset;
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@ class DEMFile : public SubFile
|
||||
{
|
||||
public:
|
||||
DEMFile(const IMGData *img) : SubFile(img) {}
|
||||
DEMFile(const QString *path) : SubFile(path) {}
|
||||
DEMFile(const QString &path) : SubFile(path) {}
|
||||
DEMFile(const SubFile *gmp, quint32 offset) : SubFile(gmp, offset) {}
|
||||
|
||||
bool load(Handle &hdl);
|
||||
|
@ -111,3 +111,13 @@ double DEMTree::elevation(const Coordinates &c) const
|
||||
|
||||
return ele;
|
||||
}
|
||||
|
||||
MatrixD DEMTree::elevation(const MatrixC &m) const
|
||||
{
|
||||
MatrixD ret(m.h(), m.w());
|
||||
|
||||
for (int i = 0; i < m.size(); i++)
|
||||
ret.at(i) = elevation(m.at(i));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define IMG_DEMTREE_H
|
||||
|
||||
#include "common/rtree.h"
|
||||
#include "map/matrix.h"
|
||||
#include "mapdata.h"
|
||||
|
||||
namespace IMG {
|
||||
@ -11,6 +12,7 @@ public:
|
||||
DEMTree(const QList<MapData::Elevation> &tiles);
|
||||
|
||||
double elevation(const Coordinates &c) const;
|
||||
MatrixD elevation(const MatrixC &m) const;
|
||||
|
||||
private:
|
||||
typedef RTree<const MapData::Elevation*, double, 2> Tree;
|
||||
|
@ -87,13 +87,17 @@ bool GMAPData::loadTile(const QDir &dir)
|
||||
const QFileInfo &fi = ml.at(i);
|
||||
SubFile::Type tt = tileType(fi.suffix());
|
||||
if (VectorTile::isTileFile(tt)) {
|
||||
_files.append(new QString(fi.absoluteFilePath()));
|
||||
tile->addFile(_files.last(), tt);
|
||||
if (!tile->addFile(fi.absoluteFilePath(), tt)) {
|
||||
qWarning("%s: Invalid map tile structure",
|
||||
qUtf8Printable(dir.path()));
|
||||
delete tile;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!tile->init(0)) {
|
||||
qWarning("%s: Invalid map tile", qPrintable(dir.path()));
|
||||
if (!tile->init()) {
|
||||
qWarning("%s: Invalid map tile", qUtf8Printable(dir.path()));
|
||||
delete tile;
|
||||
return false;
|
||||
}
|
||||
@ -131,10 +135,8 @@ GMAPData::GMAPData(const QString &fileName) : MapData(fileName)
|
||||
loadTile(QDir(fi.absoluteFilePath()));
|
||||
}
|
||||
|
||||
if (baseDir.exists(typFilePath)) {
|
||||
_files.append(new QString(baseDir.filePath(typFilePath)));
|
||||
_typ = new SubFile(_files.last());
|
||||
}
|
||||
if (baseDir.exists(typFilePath))
|
||||
_typ = new SubFile(baseDir.filePath(typFilePath));
|
||||
|
||||
if (!_tileTree.Count())
|
||||
_errorString = "No usable map tile found";
|
||||
@ -143,8 +145,3 @@ GMAPData::GMAPData(const QString &fileName) : MapData(fileName)
|
||||
|
||||
computeZooms();
|
||||
}
|
||||
|
||||
GMAPData::~GMAPData()
|
||||
{
|
||||
qDeleteAll(_files);
|
||||
}
|
||||
|
@ -12,15 +12,13 @@ class GMAPData : public MapData
|
||||
{
|
||||
public:
|
||||
GMAPData(const QString &fileName);
|
||||
~GMAPData();
|
||||
|
||||
private:
|
||||
bool readXML(const QString &path, QString &dataDir, QString &typFile);
|
||||
void mapProduct(QXmlStreamReader &reader, QString &dataDir, QString &typFile);
|
||||
void mapProduct(QXmlStreamReader &reader, QString &dataDir,
|
||||
QString &typFile);
|
||||
void subProduct(QXmlStreamReader &reader, QString &dataDir);
|
||||
bool loadTile(const QDir &dir);
|
||||
|
||||
QList<const QString*> _files;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -117,8 +117,7 @@ bool IMGData::readFAT(QFile *file, TileMap &tileMap)
|
||||
} else
|
||||
tile = *it;
|
||||
|
||||
SubFile *subFile = part ? tile->file(tt)
|
||||
: tile->addFile(this, tt);
|
||||
SubFile *subFile = part ? tile->file(tt) : tile->addFile(this, tt);
|
||||
if (!(subFile && readSubFileBlocks(file, offset, subFile)))
|
||||
return false;
|
||||
} else if (tt == SubFile::TYP) {
|
||||
@ -147,8 +146,8 @@ bool IMGData::createTileTree(QFile *file, const TileMap &tileMap)
|
||||
VectorTile *tile = it.value();
|
||||
|
||||
if (!tile->init(file)) {
|
||||
qWarning("%s: %s: Invalid map tile", qPrintable(_fileName),
|
||||
qPrintable(it.key()));
|
||||
qWarning("%s: %s: Invalid map tile", qUtf8Printable(_fileName),
|
||||
qUtf8Printable(it.key()));
|
||||
delete tile;
|
||||
continue;
|
||||
}
|
||||
|
@ -60,18 +60,14 @@ private:
|
||||
struct Context
|
||||
{
|
||||
Context(quint16 width, quint16 range)
|
||||
: data(QVector<quint16>((width + 3) * 2)), w(width), rg(1),
|
||||
runIndex(0), rk(0), lrk(0)
|
||||
{
|
||||
w = width;
|
||||
data = QVector<quint16>((w + 3) * 2);
|
||||
quint16 A = qMax(2, (range + 32) / 64);
|
||||
|
||||
last = data.data();
|
||||
current = data.data() + (w + 3);
|
||||
|
||||
runIndex = 0;
|
||||
rk = 0;
|
||||
rg = 1;
|
||||
lrk = 0;
|
||||
|
||||
quint16 A = qMax(2, (range + 32) / 64);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
a[i] = A;
|
||||
b[i] = 0;
|
||||
@ -79,18 +75,17 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
quint8 runIndex;
|
||||
quint8 rk;
|
||||
QVector<quint16> data;
|
||||
quint16 *current;
|
||||
quint16 *last;
|
||||
quint16 w;
|
||||
quint16 rg;
|
||||
quint16 n[4];
|
||||
quint16 a[4];
|
||||
qint16 b[4];
|
||||
quint8 runIndex;
|
||||
quint8 rk;
|
||||
quint8 lrk;
|
||||
|
||||
quint16 w;
|
||||
QVector<quint16> data;
|
||||
quint16 *current;
|
||||
quint16 *last;
|
||||
};
|
||||
|
||||
bool readLine(BitStream &bs, Context &ctx) const;
|
||||
|
@ -40,11 +40,10 @@ static QString capitalized(const QString &str)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static QByteArray ft2m(const QByteArray &str)
|
||||
static QByteArray ft2m(const QByteArray &str, bool *ok)
|
||||
{
|
||||
bool ok;
|
||||
double number = str.toDouble(&ok);
|
||||
return ok ? QByteArray::number(qRound(number * 0.3048)) : str;
|
||||
double number = str.toDouble(ok);
|
||||
return *ok ? QByteArray::number(qRound(number * 0.3048)) : str;
|
||||
}
|
||||
|
||||
|
||||
@ -123,6 +122,7 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
|
||||
QByteArray label, shieldLabel;
|
||||
QByteArray *bap = &label;
|
||||
int split = -1;
|
||||
bool ok;
|
||||
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
const quint8 &c = str.at(i);
|
||||
@ -137,7 +137,7 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
|
||||
bap = &label;
|
||||
else {
|
||||
if (!bap->isEmpty())
|
||||
bap->append('\n');
|
||||
bap->append(' ');
|
||||
if (c == 0x1f && split < 0)
|
||||
split = bap->size();
|
||||
}
|
||||
@ -150,10 +150,14 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
|
||||
bap->append(c);
|
||||
}
|
||||
|
||||
if (split >= 0)
|
||||
label = label.left(split) + ft2m(label.mid(split));
|
||||
else if (convert)
|
||||
label = ft2m(label);
|
||||
if (convert && split >= 0) {
|
||||
QByteArray num(ft2m(label.mid(split), &ok));
|
||||
if (ok) {
|
||||
QByteArray name(label.left(split - 1));
|
||||
label = name.isEmpty() ? num : name + "\n" + num;
|
||||
}
|
||||
} else if (convert)
|
||||
label = ft2m(label, &ok);
|
||||
QString text(_codec.toString(label));
|
||||
return Label(capitalize && isAllUpperCase(text) ? capitalized(text) : text,
|
||||
Shield(shieldType, _codec.toString(shieldLabel)));
|
||||
@ -193,6 +197,7 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size,
|
||||
Charset charset = Normal;
|
||||
quint8 b1, b2, b3;
|
||||
int split = -1;
|
||||
bool ok;
|
||||
|
||||
for (quint32 i = 0; i < size; i = i + 3) {
|
||||
if (!(file->readByte(fileHdl, &b1) && file->readByte(fileHdl, &b2)
|
||||
@ -203,10 +208,14 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size,
|
||||
|
||||
for (int cpt = 0; cpt < 4; cpt++) {
|
||||
if (c[cpt] > 0x2f || (charset == Normal && c[cpt] == 0x1d)) {
|
||||
if (split >= 0)
|
||||
label = label.left(split) + ft2m(label.mid(split));
|
||||
else if (convert)
|
||||
label = ft2m(label);
|
||||
if (convert && split >= 0) {
|
||||
QByteArray num(ft2m(label.mid(split), &ok));
|
||||
if (ok) {
|
||||
QByteArray name(label.left(split - 1));
|
||||
label = name.isEmpty() ? num : name + "\n" + num;
|
||||
}
|
||||
} else if (convert)
|
||||
label = ft2m(label, &ok);
|
||||
QString text(QString::fromLatin1(label));
|
||||
return Label(capitalize && isAllUpperCase(text)
|
||||
? capitalized(text) : text, Shield(shieldType, shieldLabel));
|
||||
@ -222,7 +231,7 @@ Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size,
|
||||
bap = &label;
|
||||
else {
|
||||
if (!bap->isEmpty())
|
||||
bap->append('\n');
|
||||
bap->append(' ');
|
||||
if (c[cpt] == 0x1f && split < 0)
|
||||
split = bap->size();
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
LBLFile(const IMGData *img)
|
||||
: SubFile(img), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
|
||||
_encoding(0) {}
|
||||
LBLFile(const QString *path)
|
||||
LBLFile(const QString &path)
|
||||
: SubFile(path), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
|
||||
_encoding(0) {}
|
||||
LBLFile(const SubFile *gmp, quint32 offset)
|
||||
|
64
src/map/IMG/light.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef IMG_LIGHT_H
|
||||
#define IMG_LIGHT_H
|
||||
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
|
||||
namespace IMG {
|
||||
|
||||
class Light
|
||||
{
|
||||
public:
|
||||
enum Color {None, Red, Green, White, Blue, Yellow, Violet, Amber};
|
||||
|
||||
class Sector
|
||||
{
|
||||
public:
|
||||
Sector() : _color(None), _angle(0), _range(0) {}
|
||||
Sector(Color color, quint32 angle, quint32 range)
|
||||
: _color(color), _angle(angle), _range(range) {}
|
||||
|
||||
Color color() const {return _color;}
|
||||
quint32 angle() const {return _angle;}
|
||||
quint32 range() const {return _range;}
|
||||
|
||||
private:
|
||||
Color _color;
|
||||
quint32 _angle;
|
||||
quint32 _range;
|
||||
};
|
||||
|
||||
Light() : _color(None), _range(0) {}
|
||||
Light(Color color, quint32 range) : _color(color), _range(range) {}
|
||||
Light(const QVector<Sector> §ors)
|
||||
: _color(None), _range(0), _sectors(sectors) {}
|
||||
|
||||
Color color() const {return _color;}
|
||||
quint32 range() const {return _range;}
|
||||
const QVector<Sector> §ors() const {return _sectors;}
|
||||
|
||||
private:
|
||||
Color _color;
|
||||
quint32 _range;
|
||||
QVector<Sector> _sectors;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::Light::Sector §or)
|
||||
{
|
||||
dbg.nospace() << "Sector(" << sector.color() << ", " << sector.angle()
|
||||
<< ", " << sector.range() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
|
||||
inline QDebug operator<<(QDebug dbg, const IMG::Light &light)
|
||||
{
|
||||
dbg.nospace() << "Light(" << light.color() << ", " << light.range() << ", "
|
||||
<< light.sectors() << ")";
|
||||
return dbg.space();
|
||||
}
|
||||
#endif // QT_NO_DEBUG
|
||||
|
||||
#endif // IMG_LIGHT_H
|
@ -99,14 +99,14 @@ void MapData::load(qreal ratio)
|
||||
Q_ASSERT(!_style);
|
||||
|
||||
if (_typ)
|
||||
_style = new Style(0, ratio, _typ);
|
||||
_style = new Style(ratio, _typ);
|
||||
else {
|
||||
QString typFile(ProgramPaths::typFile());
|
||||
if (QFileInfo::exists(typFile)) {
|
||||
SubFile typ(&typFile);
|
||||
_style = new Style(0, ratio, &typ);
|
||||
SubFile typ(typFile);
|
||||
_style = new Style(ratio, &typ);
|
||||
} else
|
||||
_style = new Style(0, ratio);
|
||||
_style = new Style(ratio);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "map/matrix.h"
|
||||
#include "label.h"
|
||||
#include "raster.h"
|
||||
#include "light.h"
|
||||
#include "zoom.h"
|
||||
|
||||
namespace IMG {
|
||||
@ -51,11 +52,11 @@ public:
|
||||
enum Flags {
|
||||
NoFlag = 0,
|
||||
ClassLabel = 1,
|
||||
Light = 2
|
||||
};
|
||||
|
||||
Coordinates coordinates;
|
||||
Label label;
|
||||
QVector<Light> lights;
|
||||
quint64 id;
|
||||
quint32 type;
|
||||
quint32 flags;
|
||||
|
@ -18,7 +18,7 @@ class NETFile : public SubFile
|
||||
public:
|
||||
NETFile(const IMGData *img)
|
||||
: SubFile(img), _huffmanTable(0), _tp(0), _netShift(0), _linksShift(0) {}
|
||||
NETFile(const QString *path)
|
||||
NETFile(const QString &path)
|
||||
: SubFile(path), _huffmanTable(0), _tp(0), _netShift(0), _linksShift(0) {}
|
||||
NETFile(const SubFile *gmp, quint32 offset)
|
||||
: SubFile(gmp, offset), _huffmanTable(0), _tp(0), _netShift(0),
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
NODFile(const IMGData *img)
|
||||
: SubFile(img), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0),
|
||||
_blockShift(0), _nodeShift(0), _indexIdSize(0) {}
|
||||
NODFile(const QString *path)
|
||||
NODFile(const QString &path)
|
||||
: SubFile(path), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0),
|
||||
_blockShift(0), _nodeShift(0), _indexIdSize(0) {}
|
||||
NODFile(const SubFile *gmp, quint32 offset)
|
||||
|
@ -18,13 +18,14 @@ using namespace IMG;
|
||||
|
||||
#define TEXT_EXTENT 160
|
||||
#define ICON_PADDING 2
|
||||
#define RANGE_FACTOR 4
|
||||
#define MAJOR_RANGE 10
|
||||
#define ROAD 0
|
||||
#define WATER 1
|
||||
|
||||
#define AREA(rect) \
|
||||
(rect.size().width() * rect.size().height())
|
||||
|
||||
#define ROAD 0
|
||||
#define WATER 1
|
||||
|
||||
static const QColor textColor(Qt::black);
|
||||
static const QColor haloColor(Qt::white);
|
||||
static const QColor shieldColor(Qt::white);
|
||||
@ -152,7 +153,7 @@ void RasterTile::drawPolygons(QPainter *painter,
|
||||
bool insert = false;
|
||||
SubFile::Handle *hdl = hc.object(poly.raster.lbl());
|
||||
if (!hdl) {
|
||||
hdl = new SubFile::Handle(_file, poly.raster.lbl());
|
||||
hdl = new SubFile::Handle(poly.raster.lbl(), _file);
|
||||
insert = true;
|
||||
}
|
||||
QPixmap pm(poly.raster.lbl()->image(*hdl, poly.raster.id()));
|
||||
@ -226,7 +227,84 @@ void RasterTile::drawTextItems(QPainter *painter,
|
||||
}
|
||||
}
|
||||
|
||||
static void removeDuplicitLabel(QList<TextItem *> &labels, const QString &text,
|
||||
static QRect lightRect(const QPoint &pos, quint32 range)
|
||||
{
|
||||
quint32 r = qMin(range * RANGE_FACTOR, (quint32)TEXT_EXTENT);
|
||||
return QRect(pos.x() - r, pos.y() - r, 2 * r, 2 * r);
|
||||
}
|
||||
|
||||
void RasterTile::drawSectorLights(QPainter *painter,
|
||||
const QList<const MapData::Point*> &lights) const
|
||||
{
|
||||
for (int i = 0; i < lights.size(); i++) {
|
||||
const MapData::Point *p = lights.at(i);
|
||||
QPoint pos(p->coordinates.lon(), p->coordinates.lat());
|
||||
QMap<Sector, quint32> rangeMap;
|
||||
|
||||
for (int j = 0; j < p->lights.size(); j++) {
|
||||
const Light &l = p->lights.at(j);
|
||||
|
||||
if (l.sectors().size()) {
|
||||
for (int k = 0; k < l.sectors().size(); k++) {
|
||||
const Light::Sector &start = l.sectors().at(k);
|
||||
const Light::Sector &end = (k == l.sectors().size() - 1)
|
||||
? l.sectors().at(0) : l.sectors().at(k+1);
|
||||
quint32 angle = end.angle() - start.angle();
|
||||
|
||||
if (start.color() && (angle || start.range() >= MAJOR_RANGE)) {
|
||||
quint32 range = start.range() ? start.range() : 6;
|
||||
Sector s(start.color(), start.angle(), end.angle());
|
||||
if (rangeMap.value(s) >= range)
|
||||
continue;
|
||||
else
|
||||
rangeMap.insert(s, range);
|
||||
|
||||
double a1 = -(end.angle() / 10.0 + 90.0);
|
||||
double a2 = -(start.angle() / 10.0 + 90.0);
|
||||
if (a1 > a2)
|
||||
a2 += 360;
|
||||
double as = (a2 - a1);
|
||||
if (as == 0)
|
||||
as = 360;
|
||||
|
||||
QRect rect(lightRect(pos, range));
|
||||
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine,
|
||||
Qt::FlatCap));
|
||||
painter->drawArc(rect, a1 * 16, as * 16);
|
||||
painter->setPen(QPen(Style::color(start.color()), 4,
|
||||
Qt::SolidLine, Qt::FlatCap));
|
||||
painter->drawArc(rect, a1 * 16, as * 16);
|
||||
|
||||
if (angle) {
|
||||
QLineF ln(pos, QPointF(pos.x() + rect.width(),
|
||||
pos.y()));
|
||||
ln.setAngle(a1);
|
||||
painter->setPen(QPen(Qt::black, 1, Qt::DashLine));
|
||||
painter->drawLine(ln);
|
||||
ln.setAngle(a2);
|
||||
painter->drawLine(ln);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (l.color() && l.range() >= MAJOR_RANGE) {
|
||||
Sector s(l.color(), 0, 3600);
|
||||
if (rangeMap.value(s) >= l.range())
|
||||
continue;
|
||||
else
|
||||
rangeMap.insert(s, l.range());
|
||||
|
||||
QRect rect(lightRect(pos, l.range()));
|
||||
painter->setPen(QPen(Qt::black, 6, Qt::SolidLine, Qt::FlatCap));
|
||||
painter->drawArc(rect, 0, 360 * 16);
|
||||
painter->setPen(QPen(Style::color(l.color()), 4, Qt::SolidLine,
|
||||
Qt::FlatCap));
|
||||
painter->drawArc(rect, 0, 360 * 16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void removeDuplicitLabel(QList<TextItem*> &labels, const QString &text,
|
||||
const QRectF &tileRect)
|
||||
{
|
||||
for (int i = 0; i < labels.size(); i++) {
|
||||
@ -397,8 +475,47 @@ void RasterTile::processShields(const QList<MapData::Poly> &lines,
|
||||
}
|
||||
}
|
||||
|
||||
static bool sectorLight(const QVector<Light> &lights)
|
||||
{
|
||||
for (int i = 0; i < lights.size(); i++) {
|
||||
const Light &l = lights.at(i);
|
||||
if (l.color() && l.range() >= MAJOR_RANGE)
|
||||
return true;
|
||||
for (int j = 0; j < l.sectors().size(); j++) {
|
||||
const Light::Sector &start = l.sectors().at(j);
|
||||
const Light::Sector &end = (j == l.sectors().size() - 1)
|
||||
? l.sectors().at(0) : l.sectors().at(j+1);
|
||||
quint32 angle = end.angle() - start.angle();
|
||||
if (start.color() && (angle || start.range() >= MAJOR_RANGE))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static Light::Color ordinaryLight(const QVector<Light> &lights)
|
||||
{
|
||||
for (int i = 0; i < lights.size(); i++) {
|
||||
const Light &l = lights.at(i);
|
||||
if (l.color() && l.range() < MAJOR_RANGE)
|
||||
return l.color();
|
||||
for (int j = 0; j < l.sectors().size(); j++) {
|
||||
const Light::Sector &start = l.sectors().at(j);
|
||||
const Light::Sector &end = (j == l.sectors().size() - 1)
|
||||
? l.sectors().at(0) : l.sectors().at(j+1);
|
||||
quint32 angle = end.angle() - start.angle();
|
||||
if (start.color() && !angle && start.range() < MAJOR_RANGE)
|
||||
return start.color();
|
||||
}
|
||||
}
|
||||
|
||||
return Light::None;
|
||||
}
|
||||
|
||||
void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
QList<TextItem*> &textItems)
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
||||
QList<const MapData::Point*> §orLights)
|
||||
{
|
||||
std::sort(points.begin(), points.end());
|
||||
|
||||
@ -407,6 +524,10 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
const Style *style = _data->style();
|
||||
const Style::Point &ps = style->point(point.type);
|
||||
bool poi = Style::isPOI(point.type);
|
||||
bool sl = sectorLight(point.lights);
|
||||
|
||||
if (sl)
|
||||
sectorLights.append(&point);
|
||||
|
||||
const QString *label = point.label.text().isEmpty()
|
||||
? 0 : &(point.label.text());
|
||||
@ -428,14 +549,17 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
||||
|
||||
TextPointItem *item = new TextPointItem(pos + offset, label, fnt, img,
|
||||
color, hcolor, 0, ICON_PADDING);
|
||||
if (item->isValid() && !item->collides(textItems)) {
|
||||
if (item->isValid() && (sl || !item->collides(textItems))) {
|
||||
textItems.append(item);
|
||||
if (Style::isLight(point.type) || point.flags & MapData::Point::Light)
|
||||
textItems.append(new TextPointItem(pos + style->lightOffset(),
|
||||
0, 0, style->light(), 0, 0, 0, 0));
|
||||
Light::Color color = ordinaryLight(point.lights);
|
||||
if (color)
|
||||
lights.append(new TextPointItem(pos + style->lightOffset(),
|
||||
0, 0, style->light(color), 0, 0, 0, 0));
|
||||
} else
|
||||
delete item;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void RasterTile::fetchData(QList<MapData::Poly> &polygons,
|
||||
@ -445,7 +569,11 @@ void RasterTile::fetchData(QList<MapData::Poly> &polygons,
|
||||
|
||||
if (dynamic_cast<IMGData*>(_data)) {
|
||||
_file = new QFile(_data->fileName());
|
||||
_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
|
||||
if (!_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered)) {
|
||||
qWarning("%s: %s", qUtf8Printable(_file->fileName()),
|
||||
qUtf8Printable(_file->errorString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y()
|
||||
@ -479,22 +607,18 @@ MatrixD RasterTile::elevation(int extend) const
|
||||
|
||||
if (_data->hasDEM()) {
|
||||
RectC rect;
|
||||
QList<MapData::Elevation> tiles;
|
||||
|
||||
for (int i = 0; i < ll.size(); i++)
|
||||
rect = rect.united(ll.at(i));
|
||||
// Extra margin for always including the next DEM tile on the map tile
|
||||
// edges (the DEM tile resolution is usally 0.5-15% of the map tile)
|
||||
/* Extra margin for always including the next DEM tile on the map tile
|
||||
edges (the DEM tile resolution is usally 0.5-15% of the map tile) */
|
||||
double factor = 6 - (_zoom - 24) * 1.7;
|
||||
_data->elevations(_file, rect.adjusted(0, 0, rect.width() / factor,
|
||||
-rect.height() / factor), _zoom, &tiles);
|
||||
RectC br(rect.adjusted(0, 0, rect.width() / factor, -rect.height()
|
||||
/ factor));
|
||||
|
||||
DEMTree tree(tiles);
|
||||
MatrixD m(ll.h(), ll.w());
|
||||
for (int i = 0; i < ll.size(); i++)
|
||||
m.at(i) = tree.elevation(ll.at(i));
|
||||
QList<MapData::Elevation> tiles;
|
||||
_data->elevations(_file, br, _zoom, &tiles);
|
||||
|
||||
return m;
|
||||
return DEMTree(tiles).elevation(ll);
|
||||
} else
|
||||
return DEM::elevation(ll);
|
||||
}
|
||||
@ -520,7 +644,8 @@ void RasterTile::render()
|
||||
QList<MapData::Poly> polygons;
|
||||
QList<MapData::Poly> lines;
|
||||
QList<MapData::Point> points;
|
||||
QList<TextItem*> textItems;
|
||||
QList<TextItem*> textItems, lights;
|
||||
QList<const MapData::Point*> sectorLights;
|
||||
QImage arrows[2];
|
||||
|
||||
arrows[ROAD] = Util::svg2img(":/symbols/oneway.svg", _ratio);
|
||||
@ -531,7 +656,7 @@ void RasterTile::render()
|
||||
ll2xy(lines);
|
||||
ll2xy(points);
|
||||
|
||||
processPoints(points, textItems);
|
||||
processPoints(points, textItems, lights, sectorLights);
|
||||
processPolygons(polygons, textItems);
|
||||
processLines(lines, textItems, arrows);
|
||||
|
||||
@ -546,8 +671,11 @@ void RasterTile::render()
|
||||
drawPolygons(&painter, polygons);
|
||||
drawHillShading(&painter);
|
||||
drawLines(&painter, lines);
|
||||
drawTextItems(&painter, lights);
|
||||
drawSectorLights(&painter, sectorLights);
|
||||
drawTextItems(&painter, textItems);
|
||||
|
||||
qDeleteAll(lights);
|
||||
qDeleteAll(textItems);
|
||||
|
||||
//painter.setPen(Qt::red);
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "style.h"
|
||||
|
||||
class QPainter;
|
||||
class IMGMap;
|
||||
class TextItem;
|
||||
|
||||
namespace IMG {
|
||||
@ -32,21 +31,30 @@ public:
|
||||
void render();
|
||||
|
||||
private:
|
||||
typedef RTree<const MapData::Elevation*, double, 2> DEMTRee;
|
||||
struct Sector
|
||||
{
|
||||
Sector(Light::Color color, quint32 start, quint32 end)
|
||||
: color(color), start(start), end(end) {}
|
||||
|
||||
struct ElevationCTX {
|
||||
ElevationCTX(const DEMTRee &tree, const Coordinates &c, double &ele)
|
||||
: tree(tree), c(c), ele(ele) {}
|
||||
bool operator==(const Sector &other) const
|
||||
{
|
||||
return (color == other.color && start == other.start
|
||||
&& end == other.end);
|
||||
}
|
||||
bool operator<(const Sector &other) const
|
||||
{
|
||||
if (color == other.color) {
|
||||
if (start == other.start)
|
||||
return end < other.end;
|
||||
else
|
||||
return start < other.start;
|
||||
} else
|
||||
return color < other.color;
|
||||
}
|
||||
|
||||
const DEMTRee &tree;
|
||||
const Coordinates &c;
|
||||
double &ele;
|
||||
};
|
||||
struct EdgeCTX {
|
||||
EdgeCTX(const Coordinates &c, double &ele) : c(c), ele(ele) {}
|
||||
|
||||
const Coordinates &c;
|
||||
double &ele;
|
||||
Light::Color color;
|
||||
quint32 start;
|
||||
quint32 end;
|
||||
};
|
||||
|
||||
void fetchData(QList<MapData::Poly> &polygons, QList<MapData::Poly> &lines,
|
||||
@ -58,17 +66,22 @@ private:
|
||||
void ll2xy(QList<MapData::Poly> &polys) const;
|
||||
void ll2xy(QList<MapData::Point> &points) const;
|
||||
|
||||
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons) const;
|
||||
void drawPolygons(QPainter *painter,
|
||||
const QList<MapData::Poly> &polygons) const;
|
||||
void drawLines(QPainter *painter, const QList<MapData::Poly> &lines) const;
|
||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
||||
void drawTextItems(QPainter *painter,
|
||||
const QList<TextItem*> &textItems) const;
|
||||
void drawHillShading(QPainter *painter) const;
|
||||
void drawSectorLights(QPainter *painter,
|
||||
const QList<const MapData::Point*> &lights) const;
|
||||
|
||||
void processPolygons(const QList<MapData::Poly> &polygons,
|
||||
QList<TextItem *> &textItems);
|
||||
QList<TextItem*> &textItems);
|
||||
void processLines(QList<MapData::Poly> &lines, QList<TextItem*> &textItems,
|
||||
const QImage (&arrows)[2]);
|
||||
void processPoints(QList<MapData::Point> &points,
|
||||
QList<TextItem*> &textItems);
|
||||
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
||||
QList<const MapData::Point*> §orLights);
|
||||
void processShields(const QList<MapData::Poly> &lines,
|
||||
QList<TextItem*> &textItems);
|
||||
void processStreetNames(const QList<MapData::Poly> &lines,
|
||||
|
@ -13,6 +13,7 @@ using namespace Garmin;
|
||||
using namespace IMG;
|
||||
|
||||
#define MASK(bits) ((1U << (bits)) - 1U)
|
||||
#define COLOR(color) static_cast<Light::Color>(color)
|
||||
|
||||
static quint64 pointId(const QPoint &pos, quint32 type, const QString &label)
|
||||
{
|
||||
@ -107,7 +108,8 @@ bool RGNFile::readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RGNFile::readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) const
|
||||
bool RGNFile::readBuoyInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
MapData::Point *point) const
|
||||
{
|
||||
quint16 val;
|
||||
quint8 lc;
|
||||
@ -115,7 +117,7 @@ bool RGNFile::readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) con
|
||||
if ((flags & 0xe0) != 0xe0)
|
||||
return true;
|
||||
|
||||
if (!readUInt16(hdl, val))
|
||||
if (!(size >= 2 && readUInt16(hdl, val)))
|
||||
return false;
|
||||
|
||||
lc = (val >> 10) & 0x0f;
|
||||
@ -123,7 +125,107 @@ bool RGNFile::readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) con
|
||||
lc = (val >> 6) & 7;
|
||||
|
||||
if (lc)
|
||||
point->flags |= MapData::Point::Light;
|
||||
point->lights.append(Light(COLOR(lc), 0));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RGNFile::readLightInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
MapData::Point *point) const
|
||||
{
|
||||
quint16 flags1;
|
||||
quint8 flags2;
|
||||
quint32 unused;
|
||||
|
||||
if (!(size >= 3 && readUInt16(hdl, flags1) && readUInt8(hdl, flags2)))
|
||||
return false;
|
||||
size -= 3;
|
||||
if (flags2 >> 6) {
|
||||
if (!(size >= (flags2 >> 6) && readVUInt32(hdl, (flags2 >> 6), unused)))
|
||||
return false;
|
||||
size -= (flags2 >> 6);
|
||||
}
|
||||
if (flags2 >> 2 & 3) {
|
||||
if (!(size >= (flags2 >> 2 & 3)
|
||||
&& readVUInt32(hdl, (flags2 >> 2 & 3), unused)))
|
||||
return false;
|
||||
size -= (flags2 >> 2 & 3);
|
||||
}
|
||||
if (flags1 & 0xc0) {
|
||||
if (flags1 & 0x80) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
unused |= ((flags1 & 0x40) << 2);
|
||||
size--;
|
||||
} else {
|
||||
if (!(size >= 2 && readUInt16(hdl, unused)))
|
||||
return false;
|
||||
size -= 2;
|
||||
}
|
||||
}
|
||||
if (flags & 2) {
|
||||
if (!(size >= 3 && readUInt24(hdl, unused)))
|
||||
return false;
|
||||
size -= 3;
|
||||
}
|
||||
if (flags & 4) {
|
||||
if (!(size >= 3 && readUInt24(hdl, unused)))
|
||||
return false;
|
||||
size -= 3;
|
||||
}
|
||||
if (flags & 8) {
|
||||
if (!(size >= 3 && readUInt24(hdl, unused)))
|
||||
return false;
|
||||
size -= 3;
|
||||
}
|
||||
if (flags1 & 0x200) {
|
||||
if (!(size >= 2 && readUInt16(hdl, unused)))
|
||||
return false;
|
||||
size -= 2;
|
||||
}
|
||||
if (flags1 & 0x400) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
}
|
||||
if (flags1 & 0x800) {
|
||||
quint16 la;
|
||||
quint8 cf, range = 0;
|
||||
QVector<Light::Sector> sectors;
|
||||
|
||||
do {
|
||||
if (!(size >= 2 && readUInt16(hdl, la)))
|
||||
return false;
|
||||
size -= 2;
|
||||
|
||||
cf = la >> 8;
|
||||
Light::Color c = COLOR(cf >> 4 & 7);
|
||||
if (c) {
|
||||
if (!(size >= 1 && readUInt8(hdl, range)))
|
||||
return false;
|
||||
size--;
|
||||
}
|
||||
sectors.append(Light::Sector(c, la & 0xfff, range));
|
||||
} while (!(cf >> 7));
|
||||
|
||||
point->lights.append(Light(sectors));
|
||||
} else {
|
||||
quint8 v1, v2, range;
|
||||
|
||||
if (!(size >= 1 && readUInt8(hdl, v1)))
|
||||
return false;
|
||||
size--;
|
||||
|
||||
range = v1 & 0x1f;
|
||||
if ((v1 & 0x1f) == 0x1f) {
|
||||
if (!(size >= 1 && readUInt8(hdl, v2)))
|
||||
return false;
|
||||
size--;
|
||||
range += v2;
|
||||
}
|
||||
|
||||
point->lights.append(Light(COLOR(v1 >> 5), range));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -183,13 +285,183 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
|
||||
if (point && Style::isObstructionPoint(point->type))
|
||||
readObstructionInfo(hdl, flags, rs, point);
|
||||
if (point && Style::isBuoy(point->type))
|
||||
readBuoyInfo(hdl, flags, point);
|
||||
readBuoyInfo(hdl, flags, rs, point);
|
||||
if (point && Style::isLight(point->type))
|
||||
readLightInfo(hdl, flags, rs, point);
|
||||
|
||||
return seek(hdl, off + rs);
|
||||
}
|
||||
|
||||
bool RGNFile::skipLclFields(Handle &hdl, const quint32 flags[3]) const
|
||||
bool RGNFile::readLclSectors(Handle &hdl, quint32 &size, quint32 flags,
|
||||
Light &light) const
|
||||
{
|
||||
quint32 unused, cnt = flags & 0x1f;
|
||||
QVector<Light::Sector> sectors;
|
||||
|
||||
for (quint32 j = 0; j < cnt; j++) {
|
||||
quint32 cf, range = 0;
|
||||
|
||||
if (!(size >= 1 && readUInt8(hdl, cf)))
|
||||
return false;
|
||||
size--;
|
||||
if (cf >> 6) {
|
||||
if (!(size >= (cf >> 6) && readVUInt32(hdl, cf >> 6, range)))
|
||||
return false;
|
||||
size -= (cf >> 6);
|
||||
}
|
||||
|
||||
if (cnt > 1) {
|
||||
quint32 angle;
|
||||
|
||||
if (!(size >= 2 && readUInt16(hdl, angle)))
|
||||
return false;
|
||||
size -= 2;
|
||||
if ((flags >> 0x13) & 1) {
|
||||
quint32 sflags;
|
||||
|
||||
if (!(size >= 1 && readUInt8(hdl, sflags)))
|
||||
return false;
|
||||
size--;
|
||||
if (0x3f < sflags) {
|
||||
if (sflags & 0x80) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
unused |= (sflags & 0x40) << 2;
|
||||
} else {
|
||||
if (!(size >= 2 && readUInt16(hdl, unused)))
|
||||
return false;
|
||||
size -= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sectors.append(Light::Sector(COLOR(cf & 0x7), angle, range));
|
||||
} else {
|
||||
light = Light(COLOR(cf & 0x7), range);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
light = Light(sectors);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RGNFile::readLclLights(Handle &hdl, quint32 &size, quint32 lights,
|
||||
MapData::Point *point) const
|
||||
{
|
||||
quint32 unused;
|
||||
|
||||
for (quint32 i = 0; i < lights; i++) {
|
||||
quint32 fs, vs, flags;
|
||||
Light light;
|
||||
|
||||
if (!(readVUInt32(hdl, fs, &vs) && size >= vs))
|
||||
return false;
|
||||
size -= vs;
|
||||
if (!(size >= 4 && readUInt32(hdl, flags)))
|
||||
return false;
|
||||
size -= 4;
|
||||
if (flags >> 0x11 & 3) {
|
||||
if (!(size >= (flags >> 0x11 & 3)
|
||||
&& readVUInt32(hdl, flags >> 0x11 & 3, unused)))
|
||||
return false;
|
||||
size -= (flags >> 0x11 & 3);
|
||||
}
|
||||
if (flags & 0x3000) {
|
||||
if (flags & 0x2000) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
unused |= (flags >> 4) & 0x100;
|
||||
} else {
|
||||
if (!(size >= 2 && readUInt16(hdl, unused)))
|
||||
return false;
|
||||
size -= 2;
|
||||
}
|
||||
}
|
||||
if (flags & 0x100000) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
if (unused & 0x80) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!readLclSectors(hdl, size, flags, light))
|
||||
return false;
|
||||
|
||||
point->lights.append(light);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RGNFile::readLclNavaid(Handle &hdl, quint32 size,
|
||||
MapData::Point *point) const
|
||||
{
|
||||
quint32 unused, flags;
|
||||
|
||||
// Discard the class lights info if any (marine points may have both!)
|
||||
point->lights.clear();
|
||||
|
||||
if (!(size >= 4 && readUInt32(hdl, flags)))
|
||||
return false;
|
||||
size -= 4;
|
||||
if (flags & 1) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
}
|
||||
if (flags & 2) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
}
|
||||
if (flags & 4) {
|
||||
if (!(size >= 1 && readUInt8(hdl, unused)))
|
||||
return false;
|
||||
size--;
|
||||
}
|
||||
if (flags & 8) {
|
||||
if (!(size >= 3 && readUInt24(hdl, unused)))
|
||||
return false;
|
||||
size -= 3;
|
||||
}
|
||||
if (flags & 0x10) {
|
||||
if (!(size >= 3 && readUInt24(hdl, unused)))
|
||||
return false;
|
||||
size -= 3;
|
||||
}
|
||||
if (flags & 0x20) {
|
||||
if (!(size >= 3 && readUInt24(hdl, unused)))
|
||||
return false;
|
||||
size -= 3;
|
||||
}
|
||||
if (flags & 0x200) {
|
||||
quint8 b;
|
||||
do {
|
||||
if (!(size >= 1 && readUInt8(hdl, b)))
|
||||
return false;
|
||||
size--;
|
||||
} while (b & 0x80);
|
||||
}
|
||||
|
||||
if (!readLclLights(hdl, size, (flags >> 6) & 7, point))
|
||||
return false;
|
||||
|
||||
return (size == 0);
|
||||
}
|
||||
|
||||
bool RGNFile::readLclFields(Handle &hdl, const quint32 flags[3],
|
||||
SegmentType segmentType, void *object) const
|
||||
{
|
||||
MapData::Point *point = (segmentType == Point)
|
||||
? (MapData::Point *) object : 0;
|
||||
quint32 bitfield = 0xFFFFFFFF;
|
||||
|
||||
if (flags[0] & 0x20000000)
|
||||
@ -201,14 +473,20 @@ bool RGNFile::skipLclFields(Handle &hdl, const quint32 flags[3]) const
|
||||
if (bitfield & 1) {
|
||||
quint32 m = flags[(j >> 4) + 1] >> ((j * 2) & 0x1e) & 3;
|
||||
|
||||
quint32 skip = 0;
|
||||
quint32 size = 0;
|
||||
if (m == 3) {
|
||||
if (!readVUInt32(hdl, skip))
|
||||
if (!readVUInt32(hdl, size))
|
||||
return false;
|
||||
} else
|
||||
skip = m + 1;
|
||||
if (!seek(hdl, pos(hdl) + skip))
|
||||
return false;
|
||||
size = m + 1;
|
||||
|
||||
if (i == 2 && point) {
|
||||
if (!readLclNavaid(hdl, size, point))
|
||||
return false;
|
||||
} else {
|
||||
if (!seek(hdl, pos(hdl) + size))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bitfield >>= 1;
|
||||
j++;
|
||||
@ -462,8 +740,8 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
|
||||
if (subtype & 0x80 && !readClassFields(hdl, segmentType, &poly, lbl,
|
||||
lblHdl))
|
||||
return false;
|
||||
if (subtype & 0x40 && !skipLclFields(hdl, segmentType == Line
|
||||
? _linesLclFlags : _polygonsLclFlags))
|
||||
if (subtype & 0x40 && !readLclFields(hdl, segmentType == Line
|
||||
? _linesLclFlags : _polygonsLclFlags, segmentType, &poly))
|
||||
return false;
|
||||
quint32 gblFlags = (segmentType == Line)
|
||||
? _linesGblFlags : _polygonsGblFlags;
|
||||
@ -516,7 +794,8 @@ bool RGNFile::pointObjects(Handle &hdl, const SubDiv *subdiv,
|
||||
if (lbl && (labelPtr & 0x3FFFFF))
|
||||
point.label = lbl->label(lblHdl, labelPtr & 0x3FFFFF,
|
||||
labelPtr & 0x400000, !(Style::isCountry(point.type)
|
||||
|| Style::isState(point.type)), Style::isSpot(point.type));
|
||||
|| Style::isState(point.type)), Style::isSpot(point.type)
|
||||
|| Style::isSummit(point.type));
|
||||
point.id = pointId(pos, point.type, point.label.text());
|
||||
|
||||
points->append(point);
|
||||
@ -552,7 +831,7 @@ bool RGNFile::extPointObjects(Handle &hdl, const SubDiv *subdiv,
|
||||
return false;
|
||||
if (subtype & 0x80 && !readClassFields(hdl, Point, &point, lbl, lblHdl))
|
||||
return false;
|
||||
if (subtype & 0x40 && !skipLclFields(hdl, _pointsLclFlags))
|
||||
if (subtype & 0x40 && !readLclFields(hdl, _pointsLclFlags, Point, &point))
|
||||
return false;
|
||||
if (_pointsGblFlags && !skipGblFields(hdl, _pointsGblFlags))
|
||||
return false;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
};
|
||||
|
||||
RGNFile(const IMGData *img) : SubFile(img), _huffmanTable(0) {}
|
||||
RGNFile(const QString *path) : SubFile(path), _huffmanTable(0) {}
|
||||
RGNFile(const QString &path) : SubFile(path), _huffmanTable(0) {}
|
||||
RGNFile(const SubFile *gmp, quint32 offset)
|
||||
: SubFile(gmp, offset), _huffmanTable(0) {}
|
||||
~RGNFile();
|
||||
@ -56,7 +56,8 @@ private:
|
||||
bool segments(Handle &hdl, SubDiv *subdiv, SubDiv::Segment seg[5]) const;
|
||||
bool readClassFields(Handle &hdl, SegmentType segmentType, void *object,
|
||||
LBLFile *lbl, Handle &lblHdl) const;
|
||||
bool skipLclFields(Handle &hdl, const quint32 flags[3]) const;
|
||||
bool readLclFields(Handle &hdl, const quint32 flags[3],
|
||||
SegmentType segmentType, void *object) const;
|
||||
bool skipGblFields(Handle &hdl, quint32 flags) const;
|
||||
bool readRasterInfo(Handle &hdl, const LBLFile *lbl, quint32 size,
|
||||
MapData::Poly *poly) const;
|
||||
@ -64,9 +65,18 @@ private:
|
||||
MapData::Point *point) const;
|
||||
bool readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
MapData::Point *point) const;
|
||||
bool readBuoyInfo(Handle &hdl, quint8 flags, MapData::Point *point) const;
|
||||
bool readBuoyInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
MapData::Point *point) const;
|
||||
bool readLightInfo(Handle &hdl, quint8 flags, quint32 size,
|
||||
MapData::Point *point) const;
|
||||
bool readLabel(Handle &hdl, LBLFile *lbl, Handle &lblHdl,
|
||||
quint8 flags, quint32 size, MapData::Point *point) const;
|
||||
bool readLclNavaid(Handle &hdl, quint32 size,
|
||||
MapData::Point *point) const;
|
||||
bool readLclSectors(Handle &hdl, quint32 &size, quint32 flags,
|
||||
Light &light) const;
|
||||
bool readLclLights(Handle &hdl, quint32 &size, quint32 lights,
|
||||
MapData::Point *point) const;
|
||||
|
||||
HuffmanTable *_huffmanTable;
|
||||
Section _base, _dict, _polygons, _lines, _points;
|
||||
|
@ -323,6 +323,8 @@ void Style::defaultPolygonStyle()
|
||||
Qt::FDiagPattern));
|
||||
_polygons[0x10503] = Polygon(QBrush(QColor(0xff, 0x40, 0x40),
|
||||
Qt::FDiagPattern));
|
||||
_polygons[0x10504] = Polygon(QBrush(QColor(0xff, 0x40, 0x40),
|
||||
Qt::FDiagPattern));
|
||||
_polygons[0x10601] = Polygon(QBrush(QColor(0xaa, 0xaa, 0xaa)));
|
||||
_polygons[0x1060a] = Polygon(QBrush(QColor(0xfc, 0xb4, 0xfc)));
|
||||
_polygons[0x10614] = Polygon(QBrush(QColor(0xff, 0xff, 0xff)));
|
||||
@ -348,7 +350,8 @@ void Style::defaultPolygonStyle()
|
||||
<< TYPE(0x0a) << 0x10907 << TYPE(0x0b) << 0x10908 << TYPE(0x0c) << 0x10909
|
||||
<< TYPE(0x26) << TYPE(0x0d) << 0x1090a << TYPE(0x0e) << 0x1090b << TYPE(0x0f)
|
||||
<< TYPE(0x10) << TYPE(0x11) << TYPE(0x12) << TYPE(0x19) << 0x1090d
|
||||
<< TYPE(0x13) << 0x10900 << 0x10613 << 0x10409 << 0x10503 << 0x1060a;
|
||||
<< TYPE(0x13) << 0x10900 << 0x10613 << 0x10409 << 0x10503 << 0x10504
|
||||
<< 0x1060a;
|
||||
}
|
||||
|
||||
void Style::defaultLineStyle(qreal ratio)
|
||||
@ -464,7 +467,9 @@ void Style::defaultLineStyle(qreal ratio)
|
||||
_lines[0x10409] = Line(QPen(QColor(0, 0, 0), 1, Qt::DotLine));
|
||||
_lines[0x10501] = Line(QImage(":/marine/noanchor-line.png"));
|
||||
_lines[0x10503] = Line(QPen(QColor(0xe7, 0x28, 0xe7), 1, Qt::DashLine));
|
||||
_lines[0x10504] = Line(QPen(QColor(0xe7, 0x28, 0xe7), 1, Qt::DashLine));
|
||||
_lines[0x10505] = Line(QImage(":/marine/safety-zone-line.png"));
|
||||
_lines[0x10506] = Line(QImage(":/marine/nature-reserve-line.png"));
|
||||
_lines[0x10507] = Line(QPen(QColor(0xe7, 0x28, 0xe7), 1, Qt::DashLine));
|
||||
_lines[0x10601] = Line(QPen(QColor(0, 0, 0), 1, Qt::SolidLine));
|
||||
_lines[0x10603] = Line(QPen(QColor(0xe7, 0x28, 0xe7), 2, Qt::DashDotLine));
|
||||
@ -1177,7 +1182,7 @@ bool Style::parsePolygons(SubFile *file, SubFile::Handle &hdl,
|
||||
|
||||
if (!parsePolygon(file, hdl, section, info, type))
|
||||
qWarning("%s: %x: broken polygon style",
|
||||
qPrintable(file->fileName()), type);
|
||||
qUtf8Printable(file->fileName()), type);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1201,8 +1206,8 @@ bool Style::parseLines(SubFile *file, SubFile::Handle &hdl,
|
||||
? 0x10000 | (info.type << 8) | info.subtype : (info.type << 8);
|
||||
|
||||
if (!parseLine(file, hdl, section, info, type))
|
||||
qWarning("%s: %x: broken line style", qPrintable(file->fileName()),
|
||||
type);
|
||||
qWarning("%s: %x: broken line style",
|
||||
qUtf8Printable(file->fileName()), type);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1227,8 +1232,8 @@ bool Style::parsePoints(SubFile *file, SubFile::Handle &hdl,
|
||||
: (info.type << 8) | info.subtype;
|
||||
|
||||
if (!parsePoint(file, hdl, section, info, type))
|
||||
qWarning("%s: %x: broken point style", qPrintable(file->fileName()),
|
||||
type);
|
||||
qWarning("%s: %x: broken point style",
|
||||
qUtf8Printable(file->fileName()), type);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1268,9 +1273,9 @@ bool Style::parseDrawOrder(SubFile *file, SubFile::Handle &hdl,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Style::parseTYPFile(QFile *file, SubFile *typ)
|
||||
bool Style::parseTYPFile(SubFile *typ)
|
||||
{
|
||||
SubFile::Handle hdl(file, typ);
|
||||
SubFile::Handle hdl(typ);
|
||||
Section points, lines, polygons, order;
|
||||
quint16 tmp16, codepage;
|
||||
|
||||
@ -1304,14 +1309,14 @@ bool Style::parseTYPFile(QFile *file, SubFile *typ)
|
||||
&& parsePolygons(typ, hdl, polygons)
|
||||
&& parseDrawOrder(typ, hdl, order))) {
|
||||
qWarning("%s: Invalid TYP file, using default style",
|
||||
qPrintable(typ->fileName()));
|
||||
qUtf8Printable(typ->fileName()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Style::Style(QFile *file, qreal ratio, SubFile *typ)
|
||||
Style::Style(qreal ratio, SubFile *typ)
|
||||
{
|
||||
_large = pixelSizeFont(16);
|
||||
_normal = pixelSizeFont(14);
|
||||
@ -1319,6 +1324,10 @@ Style::Style(QFile *file, qreal ratio, SubFile *typ)
|
||||
_extraSmall = pixelSizeFont(10);
|
||||
|
||||
_light = QImage(":/marine/light.png");
|
||||
_lightRed = QImage(":/marine/light-red.png");
|
||||
_lightGreen = QImage(":/marine/light-green.png");
|
||||
_lightYellow = QImage(":/marine/light-yellow.png");
|
||||
_lightWhite = QImage(":/marine/light-white.png");
|
||||
_lightOffset = QPoint(11, 11);
|
||||
|
||||
defaultLineStyle(ratio);
|
||||
@ -1326,7 +1335,7 @@ Style::Style(QFile *file, qreal ratio, SubFile *typ)
|
||||
defaultPointStyle(ratio);
|
||||
|
||||
if (typ)
|
||||
parseTYPFile(file, typ);
|
||||
parseTYPFile(typ);
|
||||
}
|
||||
|
||||
const Style::Line &Style::line(quint32 type) const
|
||||
@ -1373,6 +1382,40 @@ const QFont *Style::font(Style::FontSize size, Style::FontSize defaultSize) cons
|
||||
}
|
||||
}
|
||||
|
||||
const QImage *Style::light(Light::Color color) const
|
||||
{
|
||||
switch (color) {
|
||||
case Light::Red:
|
||||
return &_lightRed;
|
||||
case Light::Green:
|
||||
return &_lightGreen;
|
||||
case Light::White:
|
||||
return &_lightWhite;
|
||||
case Light::Yellow:
|
||||
case Light::Amber:
|
||||
return &_lightYellow;
|
||||
default:
|
||||
return &_light;
|
||||
}
|
||||
}
|
||||
|
||||
QColor Style::color(Light::Color c)
|
||||
{
|
||||
switch (c) {
|
||||
case Light::Red:
|
||||
return Qt::red;
|
||||
case Light::Green:
|
||||
return Qt::green;
|
||||
case Light::White:
|
||||
return Qt::white;
|
||||
case Light::Yellow:
|
||||
case Light::Amber:
|
||||
return Qt::yellow;
|
||||
default:
|
||||
return Qt::magenta;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_DEBUG
|
||||
static QString penColor(const QPen &pen)
|
||||
{
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QBrush>
|
||||
#include <QFont>
|
||||
#include <QDebug>
|
||||
#include "light.h"
|
||||
#include "subfile.h"
|
||||
|
||||
#define TYPE(t) ((t)<<8)
|
||||
@ -104,7 +105,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
Style(QFile *file, qreal ratio, SubFile *typ = 0);
|
||||
Style(qreal ratio, SubFile *typ = 0);
|
||||
|
||||
const Line &line(quint32 type) const;
|
||||
const Polygon &polygon(quint32 type) const;
|
||||
@ -112,8 +113,7 @@ public:
|
||||
const QList<quint32> &drawOrder() const {return _drawOrder;}
|
||||
const QFont *font(Style::FontSize size, Style::FontSize defaultSize
|
||||
= Style::Normal) const;
|
||||
|
||||
const QImage *light() const {return &_light;}
|
||||
const QImage *light(Light::Color color) const;
|
||||
const QPoint &lightOffset() const {return _lightOffset;}
|
||||
|
||||
static bool isPOI(quint32 type)
|
||||
@ -134,6 +134,8 @@ public:
|
||||
{return (type == TYPE(0x16) || type == 0x10a03);}
|
||||
static bool isSpot(quint32 type)
|
||||
{return (type == TYPE(0x62) || type == TYPE(0x63));}
|
||||
static bool isSummit(quint32 type)
|
||||
{return (type == 0x6616);}
|
||||
static bool isMajorRoad(quint32 type)
|
||||
{return (type <= TYPE(0x04));}
|
||||
static bool isCountry(quint32 type)
|
||||
@ -155,6 +157,8 @@ public:
|
||||
static bool isMarina(quint32 type)
|
||||
{return type == 0x10703;}
|
||||
|
||||
static QColor color(Light::Color c);
|
||||
|
||||
private:
|
||||
struct Section {
|
||||
quint32 offset;
|
||||
@ -171,7 +175,7 @@ private:
|
||||
bool extended;
|
||||
};
|
||||
|
||||
bool parseTYPFile(QFile *file, SubFile *typ);
|
||||
bool parseTYPFile(SubFile *typ);
|
||||
bool parsePoints(SubFile *file, SubFile::Handle &hdl,
|
||||
const Section §ion);
|
||||
bool parsePoint(SubFile *file, SubFile::Handle &hdl,
|
||||
@ -201,7 +205,7 @@ private:
|
||||
/* Fonts and images must be initialized after QGuiApplication! */
|
||||
QFont _large, _normal, _small, _extraSmall;
|
||||
|
||||
QImage _light;
|
||||
QImage _light, _lightRed, _lightGreen, _lightYellow, _lightWhite;
|
||||
QPoint _lightOffset;
|
||||
};
|
||||
|
||||
|
@ -41,7 +41,7 @@ bool SubFile::seek(Handle &handle, quint32 pos) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SubFile::readVUInt32(Handle &hdl, quint32 &val) const
|
||||
bool SubFile::readVUInt32(Handle &hdl, quint32 &val, quint32 *size) const
|
||||
{
|
||||
quint8 bytes, shift, b;
|
||||
|
||||
@ -69,6 +69,9 @@ bool SubFile::readVUInt32(Handle &hdl, quint32 &val) const
|
||||
val |= (((quint32)b) << (i * 8)) >> (8 - shift);
|
||||
}
|
||||
|
||||
if (size)
|
||||
*size = 1 + bytes;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,7 @@
|
||||
#include <QFile>
|
||||
#include "imgdata.h"
|
||||
|
||||
|
||||
#define BLOCK_BITS 12 /* 4096 bytes */
|
||||
#define BLOCK_BITS 9 /* 512 bytes */
|
||||
|
||||
namespace IMG {
|
||||
|
||||
@ -18,7 +17,7 @@ public:
|
||||
class Handle
|
||||
{
|
||||
public:
|
||||
Handle(QFile *file, const SubFile *subFile)
|
||||
Handle(const SubFile *subFile, QFile *file = 0)
|
||||
: _file(file), _blockNum(-1), _blockPos(-1), _pos(-1), _delete(false)
|
||||
{
|
||||
if (!subFile)
|
||||
@ -26,7 +25,9 @@ public:
|
||||
|
||||
if (!_file) {
|
||||
_file = new QFile(subFile->fileName());
|
||||
_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
|
||||
if (!_file->open(QIODevice::ReadOnly | QIODevice::Unbuffered))
|
||||
qWarning("%s: %s", qUtf8Printable(_file->fileName()),
|
||||
qUtf8Printable(_file->errorString()));
|
||||
_delete = true;
|
||||
}
|
||||
_data.resize(subFile->blockSize());
|
||||
@ -51,13 +52,18 @@ public:
|
||||
SubFile(const IMGData *img)
|
||||
: _gmpOffset(0), _img(img), _blocks(new QVector<quint16>()), _path(0) {}
|
||||
SubFile(const SubFile *gmp, quint32 offset) : _gmpOffset(offset),
|
||||
_img(gmp->_img), _blocks(gmp->_blocks), _path(gmp->_path) {}
|
||||
SubFile(const QString *path)
|
||||
: _gmpOffset(0), _img(0), _blocks(0), _path(path) {}
|
||||
_img(gmp->_img), _blocks(gmp->_blocks), _path(gmp->_path)
|
||||
{
|
||||
Q_ASSERT(offset);
|
||||
}
|
||||
SubFile(const QString &path)
|
||||
: _gmpOffset(0), _img(0), _blocks(0), _path(new QString(path)) {}
|
||||
~SubFile()
|
||||
{
|
||||
if (!_gmpOffset)
|
||||
if (!_gmpOffset) {
|
||||
delete _blocks;
|
||||
delete _path;
|
||||
}
|
||||
}
|
||||
|
||||
void addBlock(quint16 block) {_blocks->append(block);}
|
||||
@ -163,7 +169,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
bool readVUInt32(Handle &hdl, quint32 &val) const;
|
||||
bool readVUInt32(Handle &hdl, quint32 &val, quint32 *size = 0) const;
|
||||
bool readVUInt32(Handle &hdl, quint32 bytes, quint32 &val) const;
|
||||
bool readVBitfield32(Handle &hdl, quint32 &bitfield) const;
|
||||
|
||||
|
@ -51,7 +51,7 @@ TREFile::~TREFile()
|
||||
|
||||
bool TREFile::init(QFile *file)
|
||||
{
|
||||
Handle hdl(file, this);
|
||||
Handle hdl(this, file);
|
||||
quint8 locked, levels[64];
|
||||
quint16 hdrLen;
|
||||
qint32 north, east, south, west;
|
||||
@ -156,7 +156,7 @@ int TREFile::readExtEntry(Handle &hdl, quint32 &polygons, quint32 &lines,
|
||||
|
||||
bool TREFile::load(QFile *file, int idx)
|
||||
{
|
||||
Handle hdl(file, this);
|
||||
Handle hdl(this, file);
|
||||
QList<SubDiv*> sl;
|
||||
SubDiv *s = 0;
|
||||
SubDivTree *tree = new SubDivTree();
|
||||
|
@ -18,7 +18,7 @@ class TREFile : public SubFile
|
||||
public:
|
||||
TREFile(const IMGData *img)
|
||||
: SubFile(img), _flags(0), _extItemSize(0) {}
|
||||
TREFile(const QString *path)
|
||||
TREFile(const QString &path)
|
||||
: SubFile(path), _flags(0), _extItemSize(0) {}
|
||||
TREFile(const SubFile *gmp, quint32 offset)
|
||||
: SubFile(gmp, offset), _flags(0), _extItemSize(0) {}
|
||||
|
@ -53,9 +53,12 @@ bool VectorTile::init(QFile *file)
|
||||
|
||||
bool VectorTile::initGMP(QFile *file)
|
||||
{
|
||||
SubFile::Handle hdl(file, _gmp);
|
||||
SubFile::Handle hdl(_gmp, file);
|
||||
quint32 tre, rgn, lbl, net, nod, dem;
|
||||
|
||||
if (_tre || _rgn || _lbl || _net || _nod || _dem)
|
||||
return false;
|
||||
|
||||
if (!(_gmp->seek(hdl, 0x19) && _gmp->readUInt32(hdl, tre)
|
||||
&& _gmp->readUInt32(hdl, rgn) && _gmp->readUInt32(hdl, lbl)
|
||||
&& _gmp->readUInt32(hdl, net) && _gmp->readUInt32(hdl, nod)
|
||||
@ -133,10 +136,10 @@ void VectorTile::polys(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
}
|
||||
|
||||
if (!_loaded) {
|
||||
rgnHdl = new SubFile::Handle(file, _rgn);
|
||||
lblHdl = new SubFile::Handle(file, _lbl);
|
||||
netHdl = new SubFile::Handle(file, _net);
|
||||
nodHdl = new SubFile::Handle(file, _nod);
|
||||
rgnHdl = new SubFile::Handle(_rgn, file);
|
||||
lblHdl = new SubFile::Handle(_lbl, file);
|
||||
netHdl = new SubFile::Handle(_net, file);
|
||||
nodHdl = new SubFile::Handle(_nod, file);
|
||||
|
||||
if (!load(*rgnHdl, *lblHdl, *netHdl, *nodHdl)) {
|
||||
_lock.unlock();
|
||||
@ -159,9 +162,9 @@ void VectorTile::polys(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
quint32 shift = _tre->shift(subdiv->bits());
|
||||
|
||||
if (!rgnHdl) {
|
||||
rgnHdl = new SubFile::Handle(file, _rgn);
|
||||
lblHdl = new SubFile::Handle(file, _lbl);
|
||||
netHdl = new SubFile::Handle(file, _net);
|
||||
rgnHdl = new SubFile::Handle(_rgn, file);
|
||||
lblHdl = new SubFile::Handle(_lbl, file);
|
||||
netHdl = new SubFile::Handle(_net, file);
|
||||
}
|
||||
|
||||
if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv)) {
|
||||
@ -182,9 +185,9 @@ void VectorTile::polys(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
|
||||
if (_net && _net->hasLinks()) {
|
||||
if (!nodHdl)
|
||||
nodHdl = new SubFile::Handle(file, _nod);
|
||||
nodHdl = new SubFile::Handle(_nod, file);
|
||||
if (!nodHdl2)
|
||||
nodHdl2 = new SubFile::Handle(file, _nod);
|
||||
nodHdl2 = new SubFile::Handle(_nod, file);
|
||||
_rgn->links(*rgnHdl, subdiv, shift, _net, *netHdl, _nod, *nodHdl,
|
||||
*nodHdl2, _lbl, *lblHdl, &polys->lines);
|
||||
}
|
||||
@ -221,10 +224,10 @@ void VectorTile::points(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
}
|
||||
|
||||
if (!_loaded) {
|
||||
rgnHdl = new SubFile::Handle(file, _rgn);
|
||||
lblHdl = new SubFile::Handle(file, _lbl);
|
||||
SubFile::Handle nodHdl(file, _nod);
|
||||
SubFile::Handle netHdl(file, _net);
|
||||
rgnHdl = new SubFile::Handle(_rgn, file);
|
||||
lblHdl = new SubFile::Handle(_lbl, file);
|
||||
SubFile::Handle nodHdl(_nod, file);
|
||||
SubFile::Handle netHdl(_net, file);
|
||||
|
||||
if (!load(*rgnHdl, *lblHdl, netHdl, nodHdl)) {
|
||||
_lock.unlock();
|
||||
@ -245,8 +248,8 @@ void VectorTile::points(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
cacheLock->unlock();
|
||||
|
||||
if (!rgnHdl) {
|
||||
rgnHdl = new SubFile::Handle(file, _rgn);
|
||||
lblHdl = new SubFile::Handle(file, _lbl);
|
||||
rgnHdl = new SubFile::Handle(_rgn, file);
|
||||
lblHdl = new SubFile::Handle(_lbl, file);
|
||||
}
|
||||
|
||||
if (!subdiv->initialized() && !_rgn->subdivInit(*rgnHdl, subdiv)) {
|
||||
@ -290,7 +293,7 @@ void VectorTile::elevations(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
}
|
||||
|
||||
if (!_demLoaded) {
|
||||
hdl = new SubFile::Handle(file, _dem);
|
||||
hdl = new SubFile::Handle(_dem, file);
|
||||
|
||||
if (!loadDem(*hdl)) {
|
||||
_demLock.unlock();
|
||||
@ -315,7 +318,7 @@ void VectorTile::elevations(QFile *file, const RectC &rect, const Zoom &zoom,
|
||||
cacheLock->unlock();
|
||||
|
||||
if (!hdl)
|
||||
hdl = new SubFile::Handle(file, _dem);
|
||||
hdl = new SubFile::Handle(_dem, file);
|
||||
|
||||
el = _dem->elevations(*hdl, level, tile);
|
||||
if (!el->m.isNull())
|
||||
|
@ -21,7 +21,7 @@ public:
|
||||
delete _dem; delete _gmp;
|
||||
}
|
||||
|
||||
bool init(QFile *file);
|
||||
bool init(QFile *file = 0);
|
||||
void clear();
|
||||
|
||||
const RectC &bounds() const {return _tre->bounds();}
|
||||
@ -49,25 +49,37 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
SubFile *addFile(T *container, SubFile::Type type)
|
||||
SubFile *addFile(T container, SubFile::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case SubFile::TRE:
|
||||
if (_tre)
|
||||
return 0;
|
||||
_tre = new TREFile(container);
|
||||
return _tre;
|
||||
case SubFile::RGN:
|
||||
if (_rgn)
|
||||
return 0;
|
||||
_rgn = new RGNFile(container);
|
||||
return _rgn;
|
||||
case SubFile::LBL:
|
||||
if (_lbl)
|
||||
return 0;
|
||||
_lbl = new LBLFile(container);
|
||||
return _lbl;
|
||||
case SubFile::NET:
|
||||
if (_net)
|
||||
return 0;
|
||||
_net = new NETFile(container);
|
||||
return _net;
|
||||
case SubFile::NOD:
|
||||
if (_nod)
|
||||
return 0;
|
||||
_nod = new NODFile(container);
|
||||
return _nod;
|
||||
case SubFile::DEM:
|
||||
if (_dem)
|
||||
return 0;
|
||||
_dem = new DEMFile(container);
|
||||
return _dem;
|
||||
case SubFile::GMP:
|
||||
|
@ -258,7 +258,9 @@ void AQMMap::load(const Projection &in, const Projection &out,
|
||||
Q_UNUSED(out);
|
||||
|
||||
_mapRatio = hidpi ? deviceRatio : 1.0;
|
||||
_file.open(QIODevice::ReadOnly);
|
||||
if (!_file.open(QIODevice::ReadOnly))
|
||||
qWarning("%s: %s", qUtf8Printable(_file.fileName()),
|
||||
qUtf8Printable(_file.errorString()));
|
||||
}
|
||||
|
||||
void AQMMap::unload()
|
||||
|
@ -156,7 +156,8 @@ Atlas::Atlas(const QString &fileName, bool TAR, const Projection &proj,
|
||||
OziMap::CalibrationType type;
|
||||
QString cf(calibrationFile(path, type));
|
||||
if (cf.isNull()) {
|
||||
qWarning("%s: no calibration file found", qPrintable(path));
|
||||
qWarning("%s: no calibration file found",
|
||||
qUtf8Printable(path));
|
||||
continue;
|
||||
}
|
||||
map = new OziMap(cf, type, proj, this);
|
||||
@ -165,8 +166,8 @@ Atlas::Atlas(const QString &fileName, bool TAR, const Projection &proj,
|
||||
if (map->isValid())
|
||||
_maps.append(map);
|
||||
else {
|
||||
qWarning("%s: %s", qPrintable(map->path()),
|
||||
qPrintable(map->errorString()));
|
||||
qWarning("%s: %s", qUtf8Printable(map->path()),
|
||||
qUtf8Printable(map->errorString()));
|
||||
delete map;
|
||||
}
|
||||
}
|
||||
|
@ -141,18 +141,18 @@ bool Conversion::loadList(const QString &path)
|
||||
bool res;
|
||||
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
qWarning("Error opening projections file: %s: %s", qPrintable(path),
|
||||
qPrintable(file.errorString()));
|
||||
qWarning("%s: %s", qUtf8Printable(path),
|
||||
qUtf8Printable(file.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
while (!csv.atEnd()) {
|
||||
if (!csv.readEntry(entry)) {
|
||||
qWarning("%s:%d: Parse error", qPrintable(path), csv.line());
|
||||
qWarning("%s:%d: Parse error", qUtf8Printable(path), csv.line());
|
||||
return false;
|
||||
}
|
||||
if (entry.size() < 26) {
|
||||
qWarning("%s:%d: Invalid column count", qPrintable(path),
|
||||
qWarning("%s:%d: Invalid column count", qUtf8Printable(path),
|
||||
csv.line() - 1);
|
||||
return false;
|
||||
}
|
||||
@ -160,42 +160,42 @@ bool Conversion::loadList(const QString &path)
|
||||
QString name(entry.at(0));
|
||||
int proj = entry.at(1).toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid projection code", qPrintable(path),
|
||||
qWarning("%s:%d: Invalid projection code", qUtf8Printable(path),
|
||||
csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
int units = entry.at(2).toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid linear units code", qPrintable(path),
|
||||
qWarning("%s:%d: Invalid linear units code", qUtf8Printable(path),
|
||||
csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
int transform = entry.at(3).toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid coordinate transformation code",
|
||||
qPrintable(path), csv.line() - 1);
|
||||
qUtf8Printable(path), csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
int cs = entry.at(4).toInt(&res);
|
||||
if (!res) {
|
||||
qWarning("%s:%d: Invalid coordinate system code",
|
||||
qPrintable(path), csv.line() - 1);
|
||||
qUtf8Printable(path), csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!LinearUnits(units).isValid()) {
|
||||
qWarning("%s:%d: Unknown linear units code", qPrintable(path),
|
||||
qWarning("%s:%d: Unknown linear units code", qUtf8Printable(path),
|
||||
csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
if (!Method(transform).isValid()) {
|
||||
qWarning("%s:%d: Unknown coordinate transformation code",
|
||||
qPrintable(path), csv.line() - 1);
|
||||
qUtf8Printable(path), csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
if (!CoordinateSystem(cs).isValid()) {
|
||||
qWarning("%s:%d: Unknown coordinate system code", qPrintable(path),
|
||||
csv.line() - 1);
|
||||
qWarning("%s:%d: Unknown coordinate system code",
|
||||
qUtf8Printable(path), csv.line() - 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ bool Conversion::loadList(const QString &path)
|
||||
int pn = projectionSetup(entry, setup);
|
||||
if (pn) {
|
||||
qWarning("%s: %d: Invalid projection parameter #%d",
|
||||
qPrintable(path), csv.line(), pn);
|
||||
qUtf8Printable(path), csv.line(), pn);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,8 @@ DEM::Entry *DEM::loadTile(const Tile &tile)
|
||||
} else {
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qWarning("%s: %s", qPrintable(file.fileName()),
|
||||
qPrintable(file.errorString()));
|
||||
qWarning("%s: %s", qUtf8Printable(file.fileName()),
|
||||
qUtf8Printable(file.errorString()));
|
||||
return new Entry();
|
||||
} else
|
||||
return new Entry(file.readAll());
|
||||
|
@ -57,7 +57,7 @@ bool DEMLoader::loadTiles(const RectC &rect)
|
||||
/* Create the user DEM dir only when a download is requested as it will
|
||||
override the global DEM dir. */
|
||||
if (!_dir.mkpath(_dir.absolutePath())) {
|
||||
qWarning("%s: %s", qPrintable(_dir.canonicalPath()),
|
||||
qWarning("%s: %s", qUtf8Printable(_dir.canonicalPath()),
|
||||
"Error creating DEM directory");
|
||||
return false;
|
||||
}
|
||||
|