1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-03 22:39:15 +02:00

Compare commits

..

29 Commits
10.5 ... 10.7

Author SHA1 Message Date
8f9af0d973 Be more tolerant to broken TYP files
Where possible, only skip the point/line/polygon entry, not the whole TYP file.
2022-04-24 17:19:26 +02:00
208e31c6de Explicitly marking the basemaps is not required 2022-04-24 09:17:28 +02:00
959d08ba94 Removed broken coordinates adjustment 2022-04-22 22:26:47 +02:00
5f16f7b367 Fixed/improved IMG basemaps handling 2022-04-20 19:40:44 +02:00
baee8b3484 Version++ 2022-04-19 22:19:44 +02:00
c694c3e300 A (hopefully) complete path shape parsing fix
fixes #430
2022-04-19 22:17:19 +02:00
1458d66798 Fixed path shape parsing 2022-04-16 23:39:03 +02:00
62fa0cce36 Merge branch 'origin/master' into Weblate. 2022-04-14 23:33:26 +02:00
b115c041be Do not recompute the adjacency info offset as we are lready there 2022-04-14 23:32:50 +02:00
f63c1fee1c Translated using Weblate (Esperanto)
Currently translated at 94.0% (413 of 439 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/eo/
2022-04-14 18:10:22 +02:00
88d9f10a78 Translated using Weblate (Ukrainian)
Currently translated at 92.4% (406 of 439 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/uk/
2022-04-14 18:10:21 +02:00
ec06793a19 Code cleanup 2022-04-14 04:31:46 +02:00
53cdc86aa0 Improved error handling + code cleanup 2022-04-13 22:13:57 +02:00
82ea54cacc Added some more missing marine symbols 2022-04-12 23:44:57 +02:00
d8fb7cb41e Merge branch 'origin/master' into Weblate. 2022-04-11 00:58:36 +02:00
5041d935f0 Increase marinas rendering priority 2022-04-11 00:59:26 +02:00
98f9aab9d9 Translated using Weblate (Norwegian Bokmål)
Currently translated at 99.7% (438 of 439 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2022-04-10 13:07:16 +02:00
8bc91c760a Only read the node offset when it is actually present 2022-04-08 00:23:45 +02:00
e96400e564 Merge branch 'origin/master' into Weblate. 2022-04-08 00:23:17 +02:00
e088f03cf9 Translated using Weblate (Norwegian Bokmål)
Currently translated at 99.7% (438 of 439 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/nb_NO/
2022-04-06 18:06:33 +02:00
e3582cc5cf Added missing "Established direction of traffic flow" line 2022-04-04 23:17:46 +02:00
fc033826a1 Code cleanup 2022-04-04 22:27:57 +02:00
8cf4c474f2 Added missing buoy icons 2022-04-04 22:26:57 +02:00
351a969606 Properly center the beacon symbol 2022-04-04 22:25:42 +02:00
2234245e81 Extend obstruction info 2022-04-03 21:20:21 +02:00
681de81b1c Version++ 2022-04-03 18:52:33 +02:00
a5ae41f8ad Added pile symbol 2022-04-03 18:51:15 +02:00
576a063dcb Added support for depth points 2022-04-03 18:21:26 +02:00
c5e46957a8 Removed unused image metadata 2022-03-27 19:25:38 +02:00
31 changed files with 770 additions and 630 deletions

View File

@ -1,4 +1,4 @@
version: 10.5.{build}
version: 10.7.{build}
configuration:
- Release

View File

@ -3,7 +3,7 @@ unix:!macx {
} else {
TARGET = GPXSee
}
VERSION = 10.5
VERSION = 10.7
QT += core \
gui \

View File

@ -155,6 +155,11 @@
<file alias="church.png">icons/IMG/marine/church.png</file>
<file alias="triangulation-point.png">icons/IMG/marine/triangulation-point.png</file>
<file alias="yacht-harbor.png">icons/IMG/marine/yacht-harbor.png</file>
<file alias="pile.png">icons/IMG/marine/pile.png</file>
<file alias="spar-buoy.png">icons/IMG/marine/spar-buoy.png</file>
<file alias="mooring-buoy.png">icons/IMG/marine/mooring-buoy.png</file>
<file alias="tower.png">icons/IMG/marine/tower.png</file>
<file alias="chimney.png">icons/IMG/marine/chimney.png</file>
</qresource>
<!-- Mapsforge rendertheme -->

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 B

BIN
icons/IMG/marine/pile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

BIN
icons/IMG/marine/tower.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 B

View File

@ -516,7 +516,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="418"/>
<source>Download DEM data</source>
<translation type="unfinished"></translation>
<translation>Elŝuti DEM-datumojn</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="423"/>
@ -1192,17 +1192,17 @@
<message>
<location filename="../src/GUI/motioninfoitem.cpp" line="87"/>
<source>kn</source>
<translation type="unfinished">kn</translation>
<translation>kn</translation>
</message>
<message>
<location filename="../src/GUI/motioninfoitem.cpp" line="90"/>
<source>mi/h</source>
<translation type="unfinished">mi/h</translation>
<translation>mi/h</translation>
</message>
<message>
<location filename="../src/GUI/motioninfoitem.cpp" line="93"/>
<source>km/h</source>
<translation type="unfinished">km/h</translation>
<translation>km/h</translation>
</message>
<message>
<location filename="../src/GUI/motioninfoitem.cpp" line="100"/>
@ -1629,7 +1629,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="290"/>
<source>Info color:</source>
<translation type="unfinished"></translation>
<translation>Teksta koloro:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="523"/>
@ -1687,7 +1687,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="622"/>
<source>Plugin:</source>
<translation type="unfinished"></translation>
<translation>Kromprogramo:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="642"/>

View File

@ -864,7 +864,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="996"/>
<source>Error loading POI file:</source>
<translation>Kunne ikke laste inn interessepunktfil:</translation>
<translation>Feil ved innlasting av interessepunktfil:</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="1226"/>
@ -1129,7 +1129,7 @@
<message>
<location filename="../src/map/maplist.cpp" line="127"/>
<source>Garmin IMG maps</source>
<translation>Garming IMG-kart</translation>
<translation>Garmin IMG-kart</translation>
</message>
<message>
<location filename="../src/map/maplist.cpp" line="130"/>
@ -1164,7 +1164,7 @@
<message>
<location filename="../src/map/maplist.cpp" line="139"/>
<source>TrekBuddy maps/atlases</source>
<translation>TrekBuddy kart/atlas</translation>
<translation>TrekBuddy-kart/atlas</translation>
</message>
<message>
<location filename="../src/map/maplist.cpp" line="140"/>
@ -1225,17 +1225,17 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="66"/>
<source>Standard</source>
<translation>Forvalg</translation>
<translation>Standard</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="71"/>
<source>Non-HiDPI maps are loaded as HiDPI maps. The map is sharp but map objects are small/hard to read.</source>
<translation>Ikke-HiDPI -kart lastes som HiDPI-kart. Kartet er skarpt, men kartobjekter kan være små/vanskelige å lese.</translation>
<translation>Ikke-HiDPI-kart lastes som HiDPI-kart. Kartet er skarpt, men kartobjekter er små/vanskelige å lese.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="73"/>
<source>Non-HiDPI maps are loaded such as they are. Map objects have the expected size but the map is blurry.</source>
<translation>Ikke-HiDPI -kart lastes som de er. Kartobjekter har forventet størrelse, men kartet er uskarpt.</translation>
<translation>Ikke-HiDPI-kart lastes som de er. Kartobjekter har forventet størrelse, men kartet er uskarpt.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="117"/>
@ -1347,7 +1347,7 @@
<location filename="../src/GUI/optionsdialog.cpp" line="148"/>
<location filename="../src/GUI/optionsdialog.cpp" line="249"/>
<source>Use anti-aliasing</source>
<translation>Bruk kanutjevning</translation>
<translation>Bruk kantutjevning</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="218"/>
@ -1437,7 +1437,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="310"/>
<source>Moving average window size</source>
<translation>Flytter gjennomsnittlig kartstørrelse</translation>
<translation>Vindusstørrelse for glidende gjennomsnitt</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="335"/>
@ -1463,7 +1463,7 @@
<location filename="../src/GUI/optionsdialog.cpp" line="338"/>
<location filename="../src/GUI/optionsdialog.cpp" line="348"/>
<source>Cadence:</source>
<translation>Stegfrekvens:</translation>
<translation>Kadens:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="339"/>
@ -1490,7 +1490,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="376"/>
<source>mi/h</source>
<translation>mi/t</translation>
<translation>mi/h</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="379"/>
@ -1586,7 +1586,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="523"/>
<source>Pause detection</source>
<translation>Sett oppdagelse pause</translation>
<translation>Pausedetektering</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="545"/>
@ -1658,7 +1658,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="566"/>
<source>Use HTTP authentication</source>
<translation>Bruk HTTP-identitetsbekreftelse</translation>
<translation>Bruk HTTP-autentisering</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="572"/>
@ -1695,7 +1695,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="648"/>
<source>The printed area is approximately the display area. The map zoom level does not change.</source>
<translation>Det utskrevne området er omentrent det samme som visningsområdet. Kartforstørrelsesnivået endrer seg ikke.</translation>
<translation>Det utskrevne området er omtrent det samme som visningsområdet. Kartforstørrelsesnivået endrer seg ikke.</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="650"/>

View File

@ -6,7 +6,7 @@
<message>
<location filename="../src/GUI/authenticationwidget.cpp" line="15"/>
<source>Username:</source>
<translation type="unfinished"></translation>
<translation>Ім&apos;я користувача:</translation>
</message>
<message>
<location filename="../src/GUI/authenticationwidget.cpp" line="16"/>
@ -157,7 +157,7 @@
<message>
<location filename="../src/data/data.cpp" line="167"/>
<source>TwoNav files</source>
<translation type="unfinished"></translation>
<translation>TwoNav файли</translation>
</message>
<message>
<location filename="../src/data/data.cpp" line="168"/>
@ -379,7 +379,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="263"/>
<source>Unselect all files</source>
<translation type="unfinished"></translation>
<translation>Скасування виділення всіх файлів</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="268"/>
@ -436,7 +436,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="335"/>
<source>Show position</source>
<translation type="unfinished"></translation>
<translation>Показати позицію</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="341"/>
@ -446,7 +446,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="346"/>
<source>Show coordinates</source>
<translation type="unfinished"></translation>
<translation>Показати координати</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="352"/>
@ -516,7 +516,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="418"/>
<source>Download DEM data</source>
<translation type="unfinished"></translation>
<translation>Завантажити DEM дані</translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="423"/>
@ -1208,7 +1208,7 @@
<message>
<location filename="../src/GUI/motioninfoitem.cpp" line="100"/>
<source>ft/min</source>
<translation type="unfinished"></translation>
<translation>фут/хв</translation>
</message>
<message>
<location filename="../src/GUI/motioninfoitem.cpp" line="103"/>
@ -1603,7 +1603,7 @@
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="289"/>
<source>Crosshair color:</source>
<translation type="unfinished"></translation>
<translation>Колір перехрестя:</translation>
</message>
<message>
<location filename="../src/GUI/optionsdialog.cpp" line="290"/>

View File

@ -37,7 +37,7 @@ Unicode true
; The name of the installer
Name "GPXSee"
; Program version
!define VERSION "10.5"
!define VERSION "10.7"
; The file to write
OutFile "GPXSee-${VERSION}_x64.exe"

View File

@ -10,11 +10,17 @@ public:
Range() {_min = 0; _max = 0;}
Range(int min, int max) : _min(min), _max(max) {}
bool operator==(const Range &other) const
{return _min == other._min && _max == other._max;}
bool operator!=(const Range &other) const
{return _min != other._min || _max != other._max;}
int min() const {return _min;}
int max() const {return _max;}
int size() const {return (_max - _min);}
bool isValid() const {return size() >= 0;}
bool isNull() const {return _min == 0 && _max == 0;}
void setMin(int min) {_min = min;}
void setMax(int max) {_max = max;}

View File

@ -94,8 +94,6 @@ bool GMAPData::loadTile(const QDir &dir, bool baseMap)
delete tile;
return false;
}
if (baseMap)
tile->markAsBasemap();
double min[2], max[2];
min[0] = tile->bounds().left();
@ -108,6 +106,9 @@ bool GMAPData::loadTile(const QDir &dir, bool baseMap)
if (tile->zooms().min() < _zooms.min())
_zooms.setMin(tile->zooms().min());
if (baseMap)
_baseMap = tile->zooms();
return true;
}
@ -124,10 +125,7 @@ GMAPData::GMAPData(const QString &fileName) : MapData(fileName)
}
QDir dataDir(baseDir.filePath(dataDirPath));
QFileInfoList ml = dataDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfo baseMap(dataDir.filePath(baseMapPath));
_baseMap = !baseMapPath.isEmpty() && baseMap.exists();
for (int i = 0; i < ml.size(); i++) {
const QFileInfo &fi = ml.at(i);

View File

@ -84,10 +84,7 @@ public:
bool readNext(qint32 &lonDelta, qint32 &latDelta)
{
if (!(readDelta(_lonSign, lonDelta) && readDelta(_latSign, latDelta)))
return false;
return (lonDelta || latDelta);
return (readDelta(_lonSign, lonDelta) && readDelta(_latSign, latDelta));
}
protected:

View File

@ -137,8 +137,6 @@ bool IMGData::readFAT(QFile &file, TileMap &tileMap)
bool IMGData::createTileTree(const TileMap &tileMap)
{
int minMapZoom = 24;
for (TileMap::const_iterator it = tileMap.constBegin();
it != tileMap.constEnd(); ++it) {
VectorTile *tile = it.value();
@ -160,23 +158,31 @@ bool IMGData::createTileTree(const TileMap &tileMap)
_bounds |= tile->bounds();
if (tile->zooms().min() < _zooms.min())
_zooms.setMin(tile->zooms().min());
if (tile->zooms().min() < minMapZoom)
minMapZoom = tile->zooms().min();
}
// Detect and mark basemap
TileTree::Iterator it;
bool baseMap = false;
for (_tileTree.GetFirst(it); !_tileTree.IsNull(it); _tileTree.GetNext(it)) {
VectorTile *tile = _tileTree.GetAt(it);
if (tile->zooms().min() > minMapZoom)
_baseMap = true;
if (tile->zooms().min() == minMapZoom)
tile->markAsBasemap();
if (tile->zooms().min() > _zooms.min()) {
baseMap = true;
break;
}
}
// Allow some extra zoom out on maps without basemaps, but not too much as
// this would kill the rendering performance
if (!_baseMap)
if (baseMap) {
for (_tileTree.GetFirst(it); !_tileTree.IsNull(it);
_tileTree.GetNext(it)) {
VectorTile *tile = _tileTree.GetAt(it);
if (tile->zooms().min() == _zooms.min())
_baseMap = tile->zooms();
}
} else {
/* Allow some extra zoom out on maps without basemaps, but not too much
as this would kill the rendering performance. */
_zooms.setMin(_zooms.min() - 2);
}
return (_tileTree.Count() > 0);
}

View File

@ -26,8 +26,7 @@ bool MapData::pointCb(VectorTile *tile, void *context)
MapData::MapData(const QString &fileName)
: _fileName(fileName), _typ(0), _style(0), _zooms(24, 28), _baseMap(false),
_valid(false)
: _fileName(fileName), _typ(0), _style(0), _zooms(24, 28), _valid(false)
{
_polyCache.setMaxCost(CACHED_SUBDIVS_COUNT);
_pointCache.setMaxCost(CACHED_SUBDIVS_COUNT);

View File

@ -79,7 +79,7 @@ protected:
Style *_style;
TileTree _tileTree;
Range _zooms;
bool _baseMap;
Range _baseMap;
bool _valid;
QString _errorString;
@ -96,7 +96,7 @@ private:
struct PolyCTX
{
PolyCTX(const RectC &rect, int bits, bool baseMap,
PolyCTX(const RectC &rect, int bits, const Range &baseMap,
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
QCache<const SubDiv*, MapData::Polys> *polyCache)
: rect(rect), bits(bits), baseMap(baseMap), polygons(polygons),
@ -104,7 +104,7 @@ private:
const RectC &rect;
int bits;
bool baseMap;
const Range &baseMap;
QList<MapData::Poly> *polygons;
QList<MapData::Poly> *lines;
QCache<const SubDiv*, MapData::Polys> *polyCache;
@ -112,7 +112,7 @@ private:
struct PointCTX
{
PointCTX(const RectC &rect, int bits, bool baseMap,
PointCTX(const RectC &rect, int bits, const Range &baseMap,
QList<MapData::Point> *points,
QCache<const SubDiv*, QList<MapData::Point> > *pointCache)
: rect(rect), bits(bits), baseMap(baseMap), points(points),
@ -120,7 +120,7 @@ private:
const RectC &rect;
int bits;
bool baseMap;
const Range &baseMap;
QList<MapData::Point> *points;
QCache<const SubDiv*, QList<MapData::Point> > *pointCache;
};

View File

@ -152,9 +152,10 @@ bool NETFile::readLine(BitStream4R &bs, const SubDiv *subdiv,
qint32 lonDelta, latDelta;
while (stream.readNext(lonDelta, latDelta)) {
if (!(lonDelta | latDelta))
break;
pos.rx() += LS(lonDelta, 32-subdiv->bits());
if (pos.rx() < 0 && subdiv->lon() >= 0)
pos.rx() = 0x7fffffff;
pos.ry() += LS(latDelta, 32-subdiv->bits());
Coordinates c(toWGS32(pos.x()), toWGS32(pos.y()));
@ -235,10 +236,12 @@ bool NETFile::readShape(const NODFile *nod, SubFile::Handle &nodHdl,
if (!stream.readNext(lonDelta, latDelta))
break;
if (hasAdjustBit && !stream.read(1, adjustBit))
return false;
if (!(lonDelta | latDelta) && !startWithStream && !hasAdjustBit)
break;
stepsCnt++;
if (useEosBit) {

View File

@ -6,6 +6,8 @@ using namespace IMG;
#define ARRAY_SIZE(array) \
(sizeof(array) / sizeof(array[0]))
#define DELTA(val, llBits, maxBits) \
(((int)((val) << (32 - (llBits))) >> (32 - (llBits))) << (32 - (maxBits)))
static const struct
{
@ -166,64 +168,60 @@ bool NODFile::linkInfo(Handle &hdl, const BlockInfo &blockInfo, quint32 linkId,
if (!(linkInfo.flags & 0x100)) {
if (!bs.read(s1, linkInfo.linkOffset))
return false;
linkInfo.nodeOffset = 0xFFFFFFFF;
} else {
if (!bs.read(s1 - s2, linkInfo.linkOffset))
return false;
linkInfo.linkOffset += blockInfo.hdr.linkInfoOffsetBase;
}
if (!bs.read(s2, linkInfo.nodeOffset))
return false;
linkInfo.nodeOffset = (blockInfo.offset - linkInfo.nodeOffset)
>> _nodeShift;
if (!bs.read(s2, linkInfo.nodeOffset))
return false;
linkInfo.nodeOffset = (blockInfo.offset - linkInfo.nodeOffset)
>> _nodeShift;
}
return true;
}
bool NODFile::nodeInfo(Handle &hdl, const BlockInfo &blockInfo,
quint32 nodeOffset, NodeInfo &nodeInfo) const
bool NODFile::nodeInfo(Handle &hdl, AdjacencyInfo &adj) const
{
quint32 infoOffset = (nodeOffset << _nodeShift) + _block.offset;
if (infoOffset > _block.offset + _block.size || infoOffset < blockInfo.offset)
quint32 infoOffset = (adj.nodeOffset << _nodeShift) + _block.offset;
if (infoOffset > _block.offset + _block.size
|| infoOffset < adj.blockInfo.offset)
return false;
if (!seek(hdl, infoOffset))
return false;
BitStream1 bs(*this, hdl, _block.offset + _block.size - infoOffset);
if (!bs.read(8, nodeInfo.flags))
if (!bs.read(8, adj.nodeInfo.flags))
return false;
if ((nodeInfo.flags & 7) >= ARRAY_SIZE(LLBITS))
if ((adj.nodeInfo.flags & 7) >= ARRAY_SIZE(LLBITS))
return false;
quint8 lonBits = LLBITS[nodeInfo.flags & 7].lon;
quint8 latBits = LLBITS[nodeInfo.flags & 7].lat;
quint8 lonBits = LLBITS[adj.nodeInfo.flags & 7].lon;
quint8 latBits = LLBITS[adj.nodeInfo.flags & 7].lat;
quint8 maxBits = ((_flags >> 10) & 7) | 0x18;
quint32 lon, lat;
if (!(bs.read(lonBits, lon) && bs.read(latBits, lat)))
return false;
quint8 lonShift = 0x20 - lonBits;
quint8 latShift = 0x20 - latBits;
quint8 shift = 0x20 - maxBits;
QPoint pos(
(((int)(lon << lonShift) >> lonShift) << shift) + blockInfo.hdr.nodeLonBase,
(((int)(lat << latShift) >> latShift) << shift) + blockInfo.hdr.nodeLatBase);
nodeInfo.bytes = ((lonBits + latBits) >> 3) + 1;
adj.blockInfo.hdr.nodeLonBase + DELTA(lon, lonBits, maxBits),
adj.blockInfo.hdr.nodeLatBase + DELTA(lat, latBits, maxBits));
if ((maxBits < 0x1c) && (nodeInfo.flags & 8)) {
if ((maxBits < 0x1c) && (adj.nodeInfo.flags & 8)) {
quint8 extraBits = 0x1c - maxBits;
quint32 extraLon, extraLat;
if (!(bs.read(extraBits, extraLon) && bs.read(extraBits, extraLat)))
return false;
pos.setX(pos.x() | extraLon << 4); pos.setY(pos.y() | extraLat << 4);
nodeInfo.bytes++;
}
// TODO?: check and adjust (shift) coordinates
nodeInfo.pos = pos;
adj.nodeInfo.pos = pos;
return true;
}
@ -282,11 +280,7 @@ bool NODFile::nodeBlock(Handle &hdl, quint32 nodeOffset,
bool NODFile::absAdjInfo(Handle &hdl, AdjacencyInfo &adj) const
{
quint32 infoOffset = (adj.nodeOffset << _nodeShift) + _block.offset
+ adj.nodeInfo.bytes;
if (!seek(hdl, infoOffset))
return false;
BitStream1 bs(*this, hdl, _block.offset + _block.size - infoOffset);
BitStream1 bs(*this, hdl, _block.offset + _block.size - pos(hdl));
quint8 linkId = adj.blockInfo.hdr.linksCount;
quint32 m2p = 2;
@ -386,12 +380,7 @@ bool NODFile::absAdjInfo(Handle &hdl, AdjacencyInfo &adj) const
bool NODFile::relAdjInfo(Handle &hdl, AdjacencyInfo &adj) const
{
quint32 infoOffset = (adj.nodeOffset << _nodeShift) + _block.offset
+ adj.nodeInfo.bytes;
if (!seek(hdl, infoOffset))
return false;
BitStream1 bs(*this, hdl, _block.offset + _block.size - infoOffset);
BitStream1 bs(*this, hdl, _block.offset + _block.size - pos(hdl));
quint32 linkId = adj.blockInfo.hdr.linksCount;
quint32 skip = 8;
@ -480,14 +469,14 @@ bool NODFile::relAdjInfo(Handle &hdl, AdjacencyInfo &adj) const
return true;
}
int NODFile::nextNode(Handle &hdl, AdjacencyInfo &adjInfo) const
int NODFile::nextNode(Handle &hdl, AdjacencyInfo &adj) const
{
if (adjInfo.nodeOffset == 0xFFFFFFFF)
if (adj.nodeOffset == 0xFFFFFFFF)
return 1;
if (!nodeInfo(hdl, adjInfo.blockInfo, adjInfo.nodeOffset, adjInfo.nodeInfo))
if (!nodeInfo(hdl, adj))
return -1;
if (!adjacencyInfo(hdl, adjInfo))
if (!adjacencyInfo(hdl, adj))
return -1;
return 0;

View File

@ -40,7 +40,6 @@ public:
{
QPoint pos;
quint8 flags;
quint8 bytes;
};
struct AdjacencyInfo
@ -78,13 +77,14 @@ public:
LinkInfo &linkInfo) const;
bool linkType(Handle &hdl, const BlockInfo &blockInfo, quint8 linkId,
quint32 &type) const;
int nextNode(Handle &hdl, AdjacencyInfo &adjInfo) const;
int nextNode(Handle &hdl, AdjacencyInfo &adj) const;
private:
bool nodeInfo(Handle &hdl, const BlockInfo &blockInfo, quint32 nodeOffset,
NodeInfo &nodeInfo) const;
bool nodeOffset(Handle &hdl, const BlockInfo &blockInfo, quint8 nodeId,
quint32 &nodeOffset) const;
bool nodeBlock(Handle &hdl, quint32 nodeOffset, BlockInfo &blockInfo) const;
bool readBlock(Handle &hdl, quint32 blockOffset, BlockInfo &blockInfo) const;
bool nodeInfo(Handle &hdl, AdjacencyInfo &adj) const;
bool absAdjInfo(Handle &hdl, AdjacencyInfo &adj) const;
bool relAdjInfo(Handle &hdl, AdjacencyInfo &adj) const;
bool adjacencyInfo(Handle &hdl, AdjacencyInfo &adj) const
@ -92,8 +92,6 @@ private:
return (adj.nodeInfo.flags & 0x20) ? absAdjInfo(hdl, adj)
: relAdjInfo(hdl, adj);
}
bool nodeBlock(Handle &hdl, quint32 nodeOffset, BlockInfo &blockInfo) const;
bool readBlock(Handle &hdl, quint32 blockOffset, BlockInfo &blockInfo) const;
Section _block, _index;
quint32 _flags, _indexFlags;

View File

@ -20,23 +20,114 @@ static quint64 pointId(const QPoint &pos, quint32 type, quint32 labelPtr)
uint hash = (uint)qHash(QPair<uint,uint>((uint)qHash(
QPair<int, int>(pos.x(), pos.y())), labelPtr));
id = ((quint64)type)<<32 | hash;
// Make country labels precedent over city labels
if (!Style::isCountry(type))
// Increase rendering priorities for some special items
if (!Style::isCountry(type) && !Style::isMarina(type))
id |= 1ULL<<63;
return id;
}
static double d2m(quint32 val, quint32 flags)
{
return (flags & 1) ? val / 10.0 : val;
}
RGNFile::~RGNFile()
{
delete _huffmanTable;
}
bool RGNFile::readRasterInfo(Handle &hdl, const LBLFile *lbl, quint32 size,
MapData::Poly *poly) const
{
quint32 id;
quint32 top, right, bottom, left;
if (!(lbl && lbl->imageIdSize()))
return false;
if (size < lbl->imageIdSize() + 16U)
return false;
if (!(readVUInt32(hdl, lbl->imageIdSize(), id)
&& readUInt32(hdl, top) && readUInt32(hdl, right)
&& readUInt32(hdl, bottom) && readUInt32(hdl, left)))
return false;
poly->raster = Raster(lbl, id, QRect(QPoint(left, top), QPoint(right,
bottom)));
return true;
}
bool RGNFile::readDepthInfo(Handle &hdl, quint8 flags, quint32 size,
MapData::Point *point) const
{
quint32 depth = 0;
quint32 units = (flags >> 3) & 3;
quint32 val;
if (!size) {
depth = flags & 0x3f;
units = (flags >> 5) & 2;
} else if (size == 1) {
if (!readUInt8(hdl, val))
return false;
depth = val | ((quint32)flags & 7) << 8;
} else if (size < 4) {
Q_ASSERT(!(flags & 4));
if (!readVUInt32(hdl, size, val))
return false;
depth = val | ((quint32)flags & 3) << (size * 8);
} else
return false;
point->label = QString::number(d2m(depth, units));
return true;
}
bool RGNFile::readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
MapData::Point *point) const
{
quint32 val, rb = size;
quint32 units = (flags >> 3) & 3;
if (!size)
return false;
if ((flags & 7) == 7) {
if (!readUInt8(hdl, val))
return false;
rb--;
}
if (!readVUInt32(hdl, rb, val))
return false;
point->label = QString::number(d2m(val, units));
return true;
}
bool RGNFile::readLabel(Handle &hdl, const LBLFile *lbl, Handle &lblHdl,
quint8 flags, quint32 size, MapData::Point *point) const
{
if (!(flags & 1))
return true;
if (!lbl)
return false;
point->label = lbl->label(lblHdl, this, hdl, size);
point->classLabel = true;
return true;
}
bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
void *object, const LBLFile *lbl, Handle &lblHdl) const
{
quint8 flags;
quint32 rs;
quint32 rs = 0;
MapData::Poly *poly = (segmentType == Polygon)
? (MapData::Poly *) object : 0;
MapData::Point *point = (segmentType == Point)
@ -59,32 +150,18 @@ bool RGNFile::readClassFields(Handle &hdl, SegmentType segmentType,
if (!readVUInt32(hdl, rs))
return false;
break;
default:
rs = 0;
break;
}
quint32 off = pos(hdl);
if (poly && Style::isRaster(poly->type) && lbl && lbl->imageIdSize()) {
quint32 id;
quint32 top, right, bottom, left;
if (rs < lbl->imageIdSize() + 16U)
return false;
if (!(readVUInt32(hdl, lbl->imageIdSize(), id)
&& readUInt32(hdl, top) && readUInt32(hdl, right)
&& readUInt32(hdl, bottom) && readUInt32(hdl, left)))
return false;
poly->raster = Raster(lbl, id, QRect(QPoint(left, top), QPoint(right,
bottom)));
}
if (point && (flags & 1) && lbl) {
point->label = lbl->label(lblHdl, this, hdl, rs);
point->classLabel = true;
}
if (poly && Style::isRaster(poly->type))
readRasterInfo(hdl, lbl, rs, poly);
if (point && Style::isDepthPoint(point->type))
readDepthInfo(hdl, flags, rs, point);
if (point && Style::isObstructionPoint(point->type))
readObstructionInfo(hdl, flags, rs, point);
if (point && !Style::isMarinePoint(point->type))
readLabel(hdl, lbl, lblHdl, flags, rs, point);
return seek(hdl, off + rs);
}
@ -310,9 +387,10 @@ bool RGNFile::extPolyObjects(Handle &hdl, const SubDiv *subdiv, quint32 shift,
poly.points.append(QPointF(c.lon(), c.lat()));
while (stream.readNext(lonDelta, latDelta)) {
if (!(lonDelta | latDelta))
break;
pos.rx() += LS(lonDelta, 32-subdiv->bits()-shift);
if (pos.rx() < 0 && subdiv->lon() >= 0)
pos.rx() = 0x7fffffff;
pos.ry() += LS(latDelta, 32-subdiv->bits()-shift);
Coordinates c(toWGS32(pos.x()), toWGS32(pos.y()));

View File

@ -58,6 +58,14 @@ private:
const LBLFile *lbl, Handle &lblHdl) const;
bool skipLclFields(Handle &hdl, const quint32 flags[3]) const;
bool skipGblFields(Handle &hdl, quint32 flags) const;
bool readRasterInfo(Handle &hdl, const LBLFile *lbl, quint32 size,
MapData::Poly *poly) const;
bool readDepthInfo(Handle &hdl, quint8 flags, quint32 size,
MapData::Point *point) const;
bool readObstructionInfo(Handle &hdl, quint8 flags, quint32 size,
MapData::Point *point) const;
bool readLabel(Handle &hdl, const LBLFile *lbl, Handle &lblHdl,
quint8 flags, quint32 size, MapData::Point *point) const;
HuffmanTable *_huffmanTable;
Section _base, _dict, _polygons, _lines, _points;

File diff suppressed because it is too large Load Diff

View File

@ -119,6 +119,14 @@ public:
{return (type == TYPE(0x1e));}
static bool isRaster(quint32 type)
{return (type == 0x10613);}
static bool isDepthPoint(quint32 type)
{return (type == 0x10301);}
static bool isObstructionPoint(quint32 type)
{return (type >= 0x10400 && type <= 0x10401);}
static bool isMarinePoint(quint32 type)
{return type >= 0x10100 && type < 0x10a00;}
static bool isMarina(quint32 type)
{return type == 0x10703;}
private:
struct Section {
@ -139,18 +147,25 @@ private:
bool parseTYPFile(SubFile *file);
bool parsePoints(SubFile *file, SubFile::Handle &hdl,
const Section &section);
bool parsePoint(SubFile *file, SubFile::Handle &hdl,
const Section &section, const ItemInfo &info, quint32 type);
bool parseLines(SubFile *file, SubFile::Handle &hdl,
const Section &section);
bool parseLine(SubFile *file, SubFile::Handle &hdl,
const Section &section, const ItemInfo &info, quint32 type);
bool parsePolygons(SubFile *file, SubFile::Handle &hdl,
const Section &section);
bool parsePolygon(SubFile *file, SubFile::Handle &hdl,
const Section &section, const ItemInfo &info, quint32 type);
bool parseDrawOrder(SubFile *file, SubFile::Handle &hdl,
const Section &section);
bool itemInfo(SubFile *file, SubFile::Handle &hdl,
const Section &section, ItemInfo &info);
void defaultPolygonStyle();
void defaultLineStyle();
void defaultPointStyle();
static bool itemInfo(SubFile *file, SubFile::Handle &hdl,
const Section &section, ItemInfo &info);
QMap<quint32, Line> _lines;
QMap<quint32, Polygon> _polygons;
QMap<quint32, Point> _points;

View File

@ -122,8 +122,6 @@ bool TREFile::init()
}
}
_isBaseMap = false;
return (_firstLevel >= 0);
}
@ -284,12 +282,12 @@ void TREFile::clear()
_subdivs.clear();
}
int TREFile::level(int bits, bool baseMap)
int TREFile::level(int bits, const Range &baseMap)
{
if (baseMap) {
if (!_isBaseMap && _levels.at(_firstLevel).bits > bits)
if (!baseMap.isNull()) {
if (zooms() != baseMap && bits <= baseMap.max())
return -1;
if (_isBaseMap && bits > _levels.last().bits)
if (zooms() == baseMap && bits > baseMap.max())
return -1;
}
@ -314,7 +312,8 @@ static bool cb(SubDiv *subdiv, void *context)
return true;
}
QList<SubDiv*> TREFile::subdivs(const RectC &rect, int bits, bool baseMap)
QList<SubDiv*> TREFile::subdivs(const RectC &rect, int bits,
const Range &baseMap)
{
QList<SubDiv*> list;
SubDivTree *tree = _subdivs.value(level(bits, baseMap));

View File

@ -25,11 +25,10 @@ public:
~TREFile();
bool init();
void markAsBasemap() {_isBaseMap = true;}
void clear();
const RectC &bounds() const {return _bounds;}
QList<SubDiv*> subdivs(const RectC &rect, int bits, bool baseMap);
QList<SubDiv*> subdivs(const RectC &rect, int bits, const Range &baseMap);
quint32 shift(quint8 bits) const
{return (bits == _levels.last().bits) ? (_flags >> 0xb) & 7 : 0;}
Range zooms() const
@ -46,7 +45,7 @@ private:
friend QDebug operator<<(QDebug dbg, const MapLevel &level);
bool load(int idx);
int level(int bits, bool baseMap);
int level(int bits, const Range &baseMap);
int readExtEntry(Handle &hdl, quint32 &polygons, quint32 &lines,
quint32 &points);
@ -56,7 +55,6 @@ private:
quint32 _flags;
quint16 _extItemSize;
int _firstLevel;
bool _isBaseMap;
QMap<int, SubDivTree*> _subdivs;
};

View File

@ -100,7 +100,7 @@ void VectorTile::clear()
_loaded = 0;
}
void VectorTile::polys(const RectC &rect, int bits, bool baseMap,
void VectorTile::polys(const RectC &rect, int bits, const Range &baseMap,
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
QCache<const SubDiv *, MapData::Polys> *polyCache)
{
@ -169,7 +169,7 @@ void VectorTile::polys(const RectC &rect, int bits, bool baseMap,
delete rgnHdl; delete lblHdl; delete netHdl; delete nodHdl; delete nodHdl2;
}
void VectorTile::points(const RectC &rect, int bits, bool baseMap,
void VectorTile::points(const RectC &rect, int bits, const Range &baseMap,
QList<MapData::Point> *points, QCache<const SubDiv *,
QList<MapData::Point> > *pointCache)
{

View File

@ -20,7 +20,6 @@ public:
}
bool init();
void markAsBasemap() {_tre->markAsBasemap();}
void clear();
const RectC &bounds() const {return _tre->bounds();}
@ -28,10 +27,10 @@ public:
SubFile *file(SubFile::Type type);
void polys(const RectC &rect, int bits, bool baseMap,
void polys(const RectC &rect, int bits, const Range &baseMap,
QList<MapData::Poly> *polygons, QList<MapData::Poly> *lines,
QCache<const SubDiv *, MapData::Polys> *polyCache);
void points(const RectC &rect, int bits, bool baseMap,
void points(const RectC &rect, int bits, const Range &baseMap,
QList<MapData::Point> *points, QCache<const SubDiv*,
QList<MapData::Point> > *pointCache);