1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-19 21:34:24 +02:00

Compare commits

...

28 Commits
13.18 ... 13.19

Author SHA1 Message Date
55de85579c Move the tables to the function where they are used 2024-04-20 19:57:52 +02:00
86f98aca42 Make it clear the tables are not modified during runtime 2024-04-20 19:50:33 +02:00
56425a3318 Always use the GPXSee icon theme on Mac and Windows 2024-04-20 16:23:23 +02:00
d045fed086 Swtch to Qt 6.7 in Windows CI builds 2024-04-19 20:19:47 +02:00
31cd65f15e Remove the zoom offset hack
Now that we are back to the map data defined tile size, it makes no sense any
more. Additionaly it crashes with world maps as zoom 0 becomes -1...
2024-04-18 20:35:31 +02:00
089ccfde71 Code cleanup 2024-04-18 20:35:05 +02:00
a0ce50e7e4 Use QVectors instead of plain arrays 2024-04-16 10:26:17 +02:00
031d82f689 Code cleanup 2024-04-16 09:17:18 +02:00
99f620f101 Fixed capitalization algorithm 2024-04-16 08:52:54 +02:00
5f3203d638 Switched the OS X Qt6 build to Qt 6.7.0 2024-04-15 00:03:09 +02:00
33cc1df601 Update to OpenSSL 3.2 2024-04-14 23:49:40 +02:00
5ef29bf827 Some more code cleanup 2024-04-14 23:32:44 +02:00
6f029d81a0 Code cleanup 2024-04-14 22:15:30 +02:00
90395a32dd Improve the capitalization algorithm 2024-04-14 17:33:49 +02:00
d4b10b091c Fit the extension placeholder into the template 2024-04-14 15:09:12 +02:00
6210d1b983 Switched back to diagonal pattern for national parks 2024-04-14 14:50:34 +02:00
5e71715f22 Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (474 of 474 strings)

Translation: GPXSee/Translations
Translate-URL: https://hosted.weblate.org/projects/gpxsee/translations/zh_Hans/
2024-04-06 18:02:00 +02:00
648f90f230 Improve FIT locations support 2024-04-03 02:30:26 +02:00
324168340b Do not blur the icons when resizing them 2024-04-03 02:18:00 +02:00
3e1bddbcfd Fixed line style combo box rendering on retina displays 2024-04-01 21:00:56 +02:00
b069d2ac3f Fixed broken error string encoding 2024-04-01 20:22:28 +02:00
9b46845568 Use the same color in the icon "alias" 2024-04-01 13:46:26 +02:00
f814d1f5a3 Use the water temperature as temperature data when no air temperature is present 2024-04-01 13:30:50 +02:00
0f05dd6ba3 Some more missing FIT course icons 2024-04-01 13:18:56 +02:00
8a069f113e Cosmetics 2024-04-01 12:37:06 +02:00
bfe31023e0 FIT course symbols instead of description 2024-04-01 12:28:50 +02:00
779f98a206 Ignore GeoJSON features with null geometries 2024-03-27 09:07:39 +01:00
a660cbd463 Version++ 2024-03-27 09:07:24 +01:00
60 changed files with 198 additions and 145 deletions

View File

@ -1,4 +1,4 @@
version: 13.18.{build}
version: 13.19.{build}
configuration:
- Release
@ -12,8 +12,8 @@ environment:
- QTDIR: C:\Qt\5.15\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v111-Win64\bin
NSISDEF: /DOPENSSL /DANGLE
- QTDIR: C:\Qt\6.5\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v30-Win64\bin
- QTDIR: C:\Qt\6.7\msvc2019_64
OPENSSLDIR: C:\OpenSSL-v32-Win64\bin
NSISDEF: /DQT6 /DOPENSSL
install:

View File

@ -39,7 +39,7 @@ jobs:
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '6.6.1'
version: '6.7.0'
modules: qtpositioning qtserialport qtimageformats
- name: Create localization
run: lrelease gpxsee.pro

View File

@ -3,7 +3,7 @@ unix:!macx:!android {
} else {
TARGET = GPXSee
}
VERSION = 13.18
VERSION = 13.19
QT += core \

View File

@ -4,7 +4,7 @@ while read e; do
IFS=":"; set $e
EXT=`echo $1 | tr /a-z/ /A-Z/`
sed -e "s/\$EXTENSION/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
sed -e "s/\$EXT/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
ICONSET=$1.iconset
mkdir $ICONSET

View File

@ -4,7 +4,7 @@ while read e; do
IFS=":"; set $e
EXT=`echo $1 | tr /a-z/ /A-Z/`
sed -e "s/\$EXTENSION/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
sed -e "s/\$EXT/$EXT/" -e "s/\$COLOR/$2/" icon-template.svg > $1.svg
convert -density 400 -background none $1.svg -define icon:auto-resize $1.ico
rm $1.svg
done < extensions

View File

@ -13,8 +13,8 @@
<g transform="translate(16.573463,124.9782)">
<rect y="0" x="0" id="textrect" height="50" width="120" style="fill:$COLOR;fill-opacity:1;stroke:none;"/>
<!--
<text y="28" x="60" dominant-baseline="central" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXTENSION</text>
<text y="28" x="60" dominant-baseline="central" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXT</text>
-->
<text y="25" x="60" dy="0.36em" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXTENSION</text>
<text y="25" x="60" dy="0.36em" text-anchor="middle" style="fill:#FFFFFF;font-size:39px;font-family:Helvetica;font-weight:bold;">$EXT</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
icons/symbols/Alert.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 987 B

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
icons/symbols/Danger.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

BIN
icons/symbols/First Aid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 B

After

Width:  |  Height:  |  Size: 822 B

BIN
icons/symbols/Food.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
icons/symbols/Gear.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 976 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
icons/symbols/Info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
icons/symbols/Left.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
icons/symbols/Obstacle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

BIN
icons/symbols/Overlook.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

BIN
icons/symbols/Rest Area.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 B

BIN
icons/symbols/Right.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

BIN
icons/symbols/Service.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

BIN
icons/symbols/Shelter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 826 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

BIN
icons/symbols/Sprint.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
icons/symbols/Store.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
icons/symbols/Straight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
icons/symbols/Toilet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

BIN
icons/symbols/Transport.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
icons/symbols/U-Turn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

BIN
icons/symbols/Valley.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1018 B

BIN
icons/symbols/Water.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 747 B

After

Width:  |  Height:  |  Size: 824 B

View File

@ -571,12 +571,12 @@
<message>
<location filename="../src/GUI/gui.cpp" line="457"/>
<source>Download data DEM</source>
<translation type="unfinished"></translation>
<translation> DEM </translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="463"/>
<source>Download map DEM</source>
<translation type="unfinished"></translation>
<translation> DEM </translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="468"/>
@ -586,7 +586,7 @@
<message>
<location filename="../src/GUI/gui.cpp" line="471"/>
<source>Show hillshading</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<location filename="../src/GUI/gui.cpp" line="480"/>
@ -1034,13 +1034,13 @@
<message>
<location filename="../src/GUI/gui.cpp" line="1986"/>
<source>DEM tiles download limit exceeded. If you really need data for such a huge area, download the files manually.</source>
<translation type="unfinished"></translation>
<translation> DEM </translation>
</message>
<message numerus="yes">
<location filename="../src/GUI/gui.cpp" line="1989"/>
<source>Download %n DEM tiles?</source>
<translation type="unfinished">
<numerusform></numerusform>
<translation>
<numerusform> %n DEM </numerusform>
</translation>
</message>
<message>

View File

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

View File

@ -29,9 +29,9 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
{
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
setApplicationName(APP_NAME);
#else
#else // Q_OS_WIN32 || Q_OS_MAC
setApplicationName(QString(APP_NAME).toLower());
#endif
#endif // Q_OS_WIN32 || Q_OS_MAC
setApplicationVersion(APP_VERSION);
QTranslator *app = new QTranslator(this);
@ -65,6 +65,9 @@ App::App(int &argc, char **argv) : QApplication(argc, argv)
loadPCSs();
Waypoint::loadSymbolIcons(ProgramPaths::symbolsDir());
#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

View File

@ -13,15 +13,18 @@ static Qt::PenStyle styles[] = {Qt::SolidLine, Qt::DashLine, Qt::DotLine,
QIcon StyleComboBox::icon(Qt::PenStyle style)
{
QPixmap pm(iconSize());
qreal ratio(devicePixelRatioF());
QSize size(iconSize());
QPixmap pm(size * ratio);
pm.setDevicePixelRatio(ratio);
pm.fill(Qt::transparent);
QBrush brush(QPalette().brush(QPalette::Active, QPalette::WindowText));
QPen pen(brush, pm.height() / LINE_WIDTH_RATIO, style);
QPen pen(brush, size.height() / LINE_WIDTH_RATIO, style);
QPainter painter(&pm);
painter.setPen(pen);
painter.drawLine(0, pm.height() / 2, pm.width(), pm.height() / 2);
painter.drawLine(0, size.height() / 2, size.width(), size.height() / 2);
return QIcon(pm);
}

View File

@ -170,8 +170,7 @@ void WaypointItem::paint(QPainter *painter,
if (_font.bold())
painter->drawPixmap(-_icon->width() * 0.625, icon.isNull()
? -_icon->height() * 1.25 : -_icon->height() * 0.625,
_icon->scaled(_icon->width() * 1.25, _icon->height() * 1.25,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_icon->scaled(_icon->width() * 1.25, _icon->height() * 1.25));
else
painter->drawPixmap(-_icon->width()/2.0, icon.isNull()
? -_icon->height() : -_icon->height()/2, *_icon);

View File

@ -106,7 +106,7 @@ Data::Data(const QString &fileName, bool tryUnknown)
_errorLine = 0;
if (!file.open(QFile::ReadOnly)) {
_errorString = qPrintable(file.errorString());
_errorString = file.errorString();
return;
}

View File

@ -64,7 +64,7 @@ public:
SegmentData segment;
};
static QMap<int, QString> coursePointDescInit()
static QMap<int, QString> coursePointSymbolsInit()
{
QMap<int, QString> map;
@ -76,28 +76,70 @@ static QMap<int, QString> coursePointDescInit()
map.insert(6, "Left");
map.insert(7, "Right");
map.insert(8, "Straight");
map.insert(9, "First aid");
map.insert(10, "Fourth category");
map.insert(11, "Third category");
map.insert(12, "Second category");
map.insert(13, "First category");
map.insert(14, "Hors category");
map.insert(9, "First Aid");
map.insert(10, "Fourth Category");
map.insert(11, "Third Category");
map.insert(12, "Second Category");
map.insert(13, "First Category");
map.insert(14, "Hors Category");
map.insert(15, "Sprint");
map.insert(16, "Left fork");
map.insert(17, "Right fork");
map.insert(18, "Middle fork");
map.insert(19, "Slight left");
map.insert(20, "Sharp left");
map.insert(21, "Slight right");
map.insert(22, "Sharp right");
map.insert(16, "Left Fork");
map.insert(17, "Right Fork");
map.insert(18, "Middle Fork");
map.insert(19, "Slight Left");
map.insert(20, "Sharp Left");
map.insert(21, "Slight Right");
map.insert(22, "Sharp Right");
map.insert(23, "U-Turn");
map.insert(24, "Segment start");
map.insert(25, "Segment end");
map.insert(24, "Segment Start");
map.insert(25, "Segment End");
map.insert(27, "Campground");
map.insert(28, "Aid Station");
map.insert(29, "Rest Area");
map.insert(30, "General Distance");
map.insert(31, "Service");
map.insert(32, "Energy Gel");
map.insert(33, "Sports Drink");
map.insert(34, "Mile Marker");
map.insert(35, "Checkpoint");
map.insert(36, "Shelter");
map.insert(37, "Meeting Spot");
map.insert(38, "Overlook");
map.insert(39, "Toilet");
map.insert(40, "Shower");
map.insert(41, "Gear");
map.insert(42, "Sharp Curve");
map.insert(43, "Steep Incline");
map.insert(44, "Tunnel");
map.insert(45, "Bridge");
map.insert(46, "Obstacle");
map.insert(47, "Crossing");
map.insert(48, "Store");
map.insert(49, "Transition");
map.insert(50, "Navaid");
map.insert(51, "Transport");
map.insert(52, "Alert");
map.insert(53, "Info");
return map;
}
static QMap<int, QString> coursePointDesc = coursePointDescInit();
static QMap<int, QString> locationPointSymbolsInit()
{
QMap<int, QString> map;
/* The location symbols are a typical GARMIN mess. Every GPS unit
has probably its own list, so we only add a few generic icons seen
"in the wild" most often. */
map.insert(94, "Flag, Blue");
map.insert(95, "Flag, Green");
map.insert(96, "Flag, Red");
return map;
}
static QMap<int, QString> coursePointSymbols = coursePointSymbolsInit();
static QMap<int, QString> locationPointSymbols = locationPointSymbolsInit();
bool FITParser::readData(QFile *file, char *data, size_t size)
@ -244,7 +286,7 @@ bool FITParser::readField(CTX &ctx, Field *field, QVariant &val, bool &valid)
ctx.len -= field->size;
ret = (ba.size() == field->size);
val = ret ? ba : QString();
valid = !ba.isEmpty();}
valid = (!ba.isEmpty() && ba.at(0) != 0);}
break;
default:
ret = skipValue(ctx, field->size);
@ -330,8 +372,8 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
} else if (def->globalId == COURSE_POINT) {
switch (field->id) {
case 1:
waypoint.setTimestamp(QDateTime::fromSecsSinceEpoch(val.toUInt()
+ 631065600, Qt::UTC));
waypoint.setTimestamp(QDateTime::fromSecsSinceEpoch(
val.toUInt() + 631065600, Qt::UTC));
break;
case 2:
waypoint.rcoordinates().setLat(
@ -342,7 +384,7 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
(val.toInt() / (double)0x7fffffff) * 180);
break;
case 5:
waypoint.setDescription(coursePointDesc.value(val.toUInt()));
waypoint.setSymbol(coursePointSymbols.value(val.toUInt()));
break;
case 6:
waypoint.setName(val.toString());
@ -361,6 +403,9 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
waypoint.rcoordinates().setLon(
(val.toInt() / (double)0x7fffffff) * 180);
break;
case 3:
waypoint.setSymbol(locationPointSymbols.value(val.toUInt()));
break;
case 4:
waypoint.setElevation((val.toUInt() / 5.0) - 500);
break;
@ -386,8 +431,8 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
}
} else if (def->globalId == RECORD_MESSAGE) {
if (ctx.trackpoint.coordinates().isValid()) {
ctx.trackpoint.setTimestamp(QDateTime::fromSecsSinceEpoch(ctx.timestamp
+ 631065600, Qt::UTC));
ctx.trackpoint.setTimestamp(QDateTime::fromSecsSinceEpoch(
ctx.timestamp + 631065600, Qt::UTC));
ctx.trackpoint.setRatio(ctx.ratio);
ctx.segment.append(ctx.trackpoint);
ctx.trackpoint = Trackpoint();

View File

@ -603,6 +603,8 @@ bool GeoJSONParser::geometryCollection(const QJsonObject &object,
bool GeoJSONParser::feature(const QJsonObject &object, const Projection &parent,
QList<TrackData> &tracks, QList<Area> &areas, QVector<Waypoint> &waypoints)
{
if (object["geometry"].isNull())
return true;
if (!object["geometry"].isObject()) {
_errorString = "Invalid/missing Feature geometry object";
return false;

View File

@ -76,6 +76,9 @@ void GPXParser::tpExtension(Trackpoint &trackpoint)
trackpoint.setHeartRate(number());
else if (_reader.name() == QLatin1String("atemp"))
trackpoint.setTemperature(number());
else if (_reader.name() == QLatin1String("wtemp")
&& !trackpoint.hasTemperature())
trackpoint.setTemperature(number());
else if (_reader.name() == QLatin1String("cad"))
trackpoint.setCadence(number());
else if (_reader.name() == QLatin1String("speed"))

View File

@ -7,53 +7,36 @@ using namespace IMG;
enum Charset {Normal, Symbol, Special};
static quint8 NORMAL_CHARS[] = {
' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '~', '~', '~', ' ', ' ',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
static quint8 SYMBOL_CHARS[] = {
'@', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', ':', ';', '<', '=', '>', '?',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', '~', '[', '\\', ']', '^', '_'
};
static quint8 SPECIAL_CHARS[] = {
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '~', '~', '~', '~', '~',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
static bool isAllUpperCase(const QString &str)
{
if (str.isEmpty())
return false;
for (int i = 0; i < str.size(); i++)
if (str.at(i).isLetter() && !(str.at(i).isUpper()
|| str.at(i) == QChar(0x00DF)))
for (int i = 0; i < str.size(); i++) {
QChar c(str.at(i));
if (c.isLetter() && !(c.isUpper() || c == QChar(0x00DF)))
return false;
}
return true;
}
static QString capitalized(const QString &str)
{
QString ret(str);
for (int i = 0; i < str.size(); i++)
if (i && !str.at(i-1).isSpace())
ret[i] = str.at(i).toLower();
else
ret[i] = str.at(i);
QString ret;
ret.resize(str.size());
if (!str.isEmpty())
ret[0] = str.at(0);
for (int i = 1; i < str.size(); i++) {
QChar last(str.at(i-1));
QChar c(str.at(i));
ret[i] = (last.isSpace() || last == '(') ? c : c.toLower();
}
return ret;
}
@ -65,11 +48,10 @@ static QByteArray ft2m(const QByteArray &str)
return ok ? QByteArray::number(qRound(number * 0.3048)) : str;
}
LBLFile::~LBLFile()
{
delete _huffmanText;
delete[] _table;
delete[] _rasters;
}
bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
@ -93,10 +75,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
return false;
if (size && recordSize) {
_table = new quint32[size / recordSize];
_table.resize(size / recordSize);
if (!seek(hdl, offset))
return false;
for (quint32 i = 0; i < size / recordSize; i++) {
for (quint32 i = 0; i < _table.size(); i++) {
if (!readVUInt32(hdl, recordSize, _table[i]))
return false;
}
@ -129,12 +111,10 @@ bool LBLFile::load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl)
void LBLFile::clear()
{
_table = QVector<quint32>();
_rasters = QVector<Image>();
delete _huffmanText;
delete[] _table;
delete[] _rasters;
_huffmanText = 0;
_table = 0;
_rasters = 0;
}
Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
@ -183,6 +163,30 @@ Label LBLFile::str2label(const QVector<quint8> &str, bool capitalize,
Label LBLFile::label6b(const SubFile *file, Handle &fileHdl, quint32 size,
bool capitalize, bool convert) const
{
static const quint8 NORMAL_CHARS[] = {
' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', '~', '~', '~', ' ', ' ',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
static const quint8 SYMBOL_CHARS[] = {
'@', '!', '"', '#', '$', '%', '&', '\'',
'(', ')', '*', '+', ',', '-', '.', '/',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', ':', ';', '<', '=', '>', '?',
'~', '~', '~', '~', '~', '~', '~', '~',
'~', '~', '~', '[', '\\', ']', '^', '_'
};
static const quint8 SPECIAL_CHARS[] = {
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '~', '~', '~', '~', '~',
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '~', '~', '~', '~', '~', '~'
};
Shield::Type shieldType = Shield::None;
QByteArray label, shieldLabel;
QByteArray *bap = &label;
@ -266,42 +270,41 @@ Label LBLFile::label8b(const SubFile *file, Handle &fileHdl, quint32 size,
Label LBLFile::labelHuffman(Handle &hdl, const SubFile *file, Handle &fileHdl,
quint32 size, bool capitalize, bool convert)
{
QVector<quint8> tpl;
if (!_huffmanText->decode(file, fileHdl, size, tpl))
return Label();
if (!_table.size())
return str2label(tpl, capitalize, convert);
QVector<quint8> str;
if (!_huffmanText->decode(file, fileHdl, size, str))
return Label();
if (!_table)
return str2label(str, capitalize, convert);
for (int i = 0; i < tpl.size(); i++) {
quint8 c(tpl.at(i));
quint32 val = (c < _table.size()) ? _table.at(c) : 0;
QVector<quint8> str2;
for (int i = 0; i < str.size(); i++) {
quint32 val = _table[str.at(i)];
if (val) {
quint32 off = _base.offset + ((val & 0x7fffff) << _shift);
if (!seek(hdl, off))
if (str.size() && str.back() == '\0')
str.back() = ' ';
else if (str.size())
str.append(' ');
quint32 offset = _base.offset + ((val & 0x7fffff) << _shift);
quint32 limit = _base.offset + _base.size - offset;
if (!seek(hdl, offset))
return Label();
if (str2.size() && str2.back() == '\0')
str2[str2.size() - 1] = ' ';
else if (str2.size())
str2.append(' ');
if (!_huffmanText->decode(this, hdl, _base.offset + _base.size - off,
str2))
if (!_huffmanText->decode(this, hdl, limit, str))
return Label();
} else {
if (str.at(i) == 7) {
str2.append(0);
break;
}
if (str2.size() && str2.back() == '\0')
str2[str2.size() - 1] = ' ';
str2.append(str.at(i));
if (str.size() && str.back() == '\0')
str.back() = ' ';
str.append(c);
}
}
return str2label(str2, capitalize, convert);
return str2label(str, capitalize, convert);
}
Label LBLFile::label(Handle &hdl, quint32 offset, bool poi, bool capitalize,
@ -347,15 +350,15 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
quint32 recordSize)
{
quint32 prev, cur;
quint32 imgCount = size / recordSize;
_imgCount = size / recordSize;
_imgIdSize = byteSize(_imgCount - 1);
_rasters = new Image[_imgCount];
_imgIdSize = byteSize(imgCount - 1);
_rasters.resize(imgCount);
if (!(seek(hdl, offset) && readVUInt32(hdl, recordSize, prev)))
return false;
for (quint32 i = 1; i < _imgCount; i++) {
for (quint32 i = 1; i < imgCount; i++) {
if (!readVUInt32(hdl, recordSize, cur))
return false;
@ -365,8 +368,8 @@ bool LBLFile::loadRasterTable(Handle &hdl, quint32 offset, quint32 size,
prev = cur;
}
_rasters[_imgCount-1].offset = prev;
_rasters[_imgCount-1].size = _img.size - prev;
_rasters[imgCount-1].offset = prev;
_rasters[imgCount-1].size = _img.size - prev;
return true;
}
@ -375,14 +378,14 @@ QPixmap LBLFile::image(Handle &hdl, quint32 id) const
{
QPixmap pm;
if (id >= _imgCount)
if (id >= _rasters.size())
return pm;
if (!seek(hdl, _img.offset + _rasters[id].offset))
if (!seek(hdl, _img.offset + _rasters.at(id).offset))
return pm;
QByteArray ba;
ba.resize(_rasters[id].size);
if (!read(hdl, ba.data(), _rasters[id].size))
ba.resize(_rasters.at(id).size);
if (!read(hdl, ba.data(), ba.size()))
return pm;
pm.loadFromData(ba, "jpeg");

View File

@ -16,14 +16,14 @@ class LBLFile : public SubFile
{
public:
LBLFile(const IMGData *img)
: SubFile(img), _huffmanText(0), _table(0), _rasters(0), _imgIdSize(0),
_poiShift(0), _shift(0), _encoding(0) {}
: SubFile(img), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
_encoding(0) {}
LBLFile(const QString *path)
: SubFile(path), _huffmanText(0), _table(0), _rasters(0), _imgIdSize(0),
_poiShift(0), _shift(0), _encoding(0) {}
: SubFile(path), _huffmanText(0), _imgIdSize(0), _poiShift(0), _shift(0),
_encoding(0) {}
LBLFile(const SubFile *gmp, quint32 offset)
: SubFile(gmp, offset), _huffmanText(0), _table(0), _rasters(0),
_imgIdSize(0), _poiShift(0), _shift(0), _encoding(0) {}
: SubFile(gmp, offset), _huffmanText(0), _imgIdSize(0), _poiShift(0),
_shift(0), _encoding(0) {}
~LBLFile();
bool load(Handle &hdl, const RGNFile *rgn, Handle &rgnHdl);
@ -55,11 +55,10 @@ private:
quint32 recordSize);
HuffmanText *_huffmanText;
quint32 *_table;
Image *_rasters;
QVector<Image> _rasters;
QVector<quint32> _table;
TextCodec _codec;
Section _base, _poi, _img;
quint32 _imgCount;
quint8 _imgIdSize;
quint8 _poiShift;
quint8 _shift;

View File

@ -187,7 +187,7 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(0x14)] = Polygon(QBrush(QColor(0xca, 0xdf, 0xaf)));
_polygons[TYPE(0x15)] = Polygon(QBrush(QColor(0xca, 0xdf, 0xaf)));
_polygons[TYPE(0x16)] = Polygon(QBrush(QColor(0x9a, 0xc2, 0x69),
Qt::Dense5Pattern));
Qt::BDiagPattern));
_polygons[TYPE(0x17)] = Polygon(QBrush(QColor(0xe4, 0xef, 0xcf)));
_polygons[TYPE(0x18)] = Polygon(QBrush(QColor(0xe3, 0xed, 0xc6)));
_polygons[TYPE(0x19)] = Polygon(QBrush(QColor(0xe3, 0xed, 0xc6)),
@ -195,9 +195,9 @@ void Style::defaultPolygonStyle()
_polygons[TYPE(0x1a)] = Polygon(QBrush(QColor(0, 0, 0), Qt::Dense6Pattern),
QPen(QColor(0xcd, 0xcc, 0xc4), 1));
_polygons[TYPE(0x1e)] = Polygon(QBrush(QColor(0x9a, 0xc2, 0x69),
Qt::Dense5Pattern));
Qt::BDiagPattern));
_polygons[TYPE(0x1f)] = Polygon(QBrush(QColor(0x9a, 0xc2, 0x69),
Qt::Dense5Pattern));
Qt::BDiagPattern));
_polygons[TYPE(0x28)] = Polygon(QBrush(QColor(0x9f, 0xc4, 0xe1)));
_polygons[TYPE(0x32)] = Polygon(QBrush(QColor(0x9f, 0xc4, 0xe1)));
_polygons[TYPE(0x3c)] = Polygon(QBrush(QColor(0x9f, 0xc4, 0xe1)));

View File

@ -23,17 +23,13 @@ namespace Mapsforge {
class RasterTile
{
public:
/* Most Mapsforge themes expect the zoom levels to be offset by one from
the standard OSM zoom levels! We decrease the zoom level internaly
here when initializing _zoom and return the propper (increased) value
back in zoom() */
RasterTile(const Projection &proj, const Transform &transform,
const Style *style, MapData *data, int zoom, const QRect &rect,
qreal ratio, bool hillShading)
: _proj(proj), _transform(transform), _style(style), _data(data),
_zoom(zoom - 1), _rect(rect), _ratio(ratio), _hillShading(hillShading) {}
_zoom(zoom), _rect(rect), _ratio(ratio), _hillShading(hillShading) {}
int zoom() const {return _zoom + 1;}
int zoom() const {return _zoom;}
QPoint xy() const {return _rect.topLeft();}
const QPixmap &pixmap() const {return _pixmap;}