mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-07-24 07:34:22 +02:00
Compare commits
37 Commits
13.22
...
21da89cad1
Author | SHA1 | Date | |
---|---|---|---|
21da89cad1 | |||
f8deb573b0 | |||
df8e8d76b8 | |||
1034c52b39 | |||
cc8704ff20 | |||
7a9e4171f9 | |||
625451c041 | |||
ef7b863003 | |||
c7f76f3009 | |||
7700ded936 | |||
e8fee5e587 | |||
450b6a3c39 | |||
e73b9f36c5 | |||
0d79dca72e | |||
e49b217b55 | |||
1067ef7352 | |||
80f3f74b47 | |||
e741fab183 | |||
7c434381a3 | |||
22c2204047 | |||
b0af165e53 | |||
0e0dcdd721 | |||
02a7445f86 | |||
55cae2d0cd | |||
9f5e09a664 | |||
1d90ae460c | |||
4c97b427fe | |||
095897d016 | |||
0596c86ea1 | |||
33f6ce2e0e | |||
5b2ac6cde2 | |||
7ff8002387 | |||
515d801e58 | |||
b75d805947 | |||
ae27b53eb1 | |||
edae24f443 | |||
d1dc4251f0 |
@ -1,4 +1,4 @@
|
||||
version: 13.22.{build}
|
||||
version: 13.23.{build}
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
@ -3,7 +3,7 @@ unix:!macx:!android {
|
||||
} else {
|
||||
TARGET = GPXSee
|
||||
}
|
||||
VERSION = 13.22
|
||||
VERSION = 13.23
|
||||
|
||||
|
||||
QT += core \
|
||||
|
@ -168,6 +168,7 @@
|
||||
<file alias="deviation-dolphin.png">icons/map/marine/deviation-dolphin.png</file>
|
||||
<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>
|
||||
</qresource>
|
||||
|
||||
<!-- Mapsforge rendertheme -->
|
||||
|
BIN
icons/map/marine/dome.png
Normal file
BIN
icons/map/marine/dome.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 263 B |
@ -1870,7 +1870,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="645"/>
|
||||
<source>Lightening:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Világosítás:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
|
||||
|
@ -1033,7 +1033,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="1961"/>
|
||||
<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>Nedlastingsgrensen for DEM-fliser er overskredet. Hvis du virkelig trenger data for et så stort område, last ned filene manuelt.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/gui.cpp" line="1977"/>
|
||||
@ -1770,7 +1770,7 @@
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="265"/>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="628"/>
|
||||
<source>px</source>
|
||||
<translation type="unfinished">px</translation>
|
||||
<translation>px</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="301"/>
|
||||
@ -1887,7 +1887,7 @@
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="645"/>
|
||||
<source>Lightening:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Bleking:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/GUI/optionsdialog.cpp" line="702"/>
|
||||
|
@ -37,7 +37,7 @@ Unicode true
|
||||
; The name of the installer
|
||||
Name "GPXSee"
|
||||
; Program version
|
||||
!define VERSION "13.22"
|
||||
!define VERSION "13.23"
|
||||
|
||||
; The file to write
|
||||
OutFile "GPXSee-${VERSION}_x64.exe"
|
||||
|
@ -197,6 +197,7 @@ bool Downloader::doDownload(const Download &dl, const QList<HTTPHeader> &headers
|
||||
if (!file->open(QIODevice::WriteOnly)) {
|
||||
qWarning("%s: %s", qPrintable(file->fileName()),
|
||||
qPrintable(file->errorString()));
|
||||
delete file;
|
||||
_errorDownloads.insert(url, RETRIES);
|
||||
return false;
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ public:
|
||||
private:
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || defined(Q_OS_ANDROID)
|
||||
QTextCodec *_codec;
|
||||
#else // QT 6.5
|
||||
#else // QT 6 || ANDROID
|
||||
QStringDecoder _decoder;
|
||||
#endif // QT 6.5
|
||||
#endif // QT 6 || ANDROID
|
||||
};
|
||||
|
||||
#endif // TEXTCODEC_H
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include <QtEndian>
|
||||
#include "fitparser.h"
|
||||
|
||||
|
||||
#define FIT_MAGIC 0x5449462E // .FIT
|
||||
|
||||
#define RECORD_MESSAGE 20
|
||||
@ -10,60 +9,6 @@
|
||||
#define COURSE_POINT 32
|
||||
#define TIMESTAMP_FIELD 253
|
||||
|
||||
class Event {
|
||||
public:
|
||||
Event() : id(0), type(0), data(0) {}
|
||||
|
||||
quint8 id;
|
||||
quint8 type;
|
||||
quint32 data;
|
||||
};
|
||||
|
||||
struct FileHeader {
|
||||
quint8 headerSize;
|
||||
quint8 protocolVersion;
|
||||
quint16 profileVersion;
|
||||
quint32 dataSize;
|
||||
quint32 magic;
|
||||
};
|
||||
|
||||
struct FITParser::Field {
|
||||
quint8 id;
|
||||
quint8 size;
|
||||
quint8 type;
|
||||
};
|
||||
|
||||
class FITParser::MessageDefinition {
|
||||
public:
|
||||
MessageDefinition() : endian(0), globalId(0), numFields(0), fields(0),
|
||||
numDevFields(0), devFields(0) {}
|
||||
~MessageDefinition() {delete[] fields; delete[] devFields;}
|
||||
|
||||
quint8 endian;
|
||||
quint16 globalId;
|
||||
quint8 numFields;
|
||||
Field *fields;
|
||||
quint8 numDevFields;
|
||||
Field *devFields;
|
||||
};
|
||||
|
||||
class FITParser::CTX {
|
||||
public:
|
||||
CTX(QFile *file, QVector<Waypoint> &waypoints)
|
||||
: file(file), waypoints(waypoints), len(0), endian(0), timestamp(0),
|
||||
ratio(NAN) {}
|
||||
|
||||
QFile *file;
|
||||
QVector<Waypoint> &waypoints;
|
||||
quint32 len;
|
||||
quint8 endian;
|
||||
quint32 timestamp;
|
||||
MessageDefinition defs[16];
|
||||
qreal ratio;
|
||||
Trackpoint trackpoint;
|
||||
SegmentData segment;
|
||||
};
|
||||
|
||||
static QMap<int, QString> coursePointSymbolsInit()
|
||||
{
|
||||
QMap<int, QString> map;
|
||||
@ -178,22 +123,14 @@ bool FITParser::skipValue(CTX &ctx, quint8 size)
|
||||
|
||||
bool FITParser::parseDefinitionMessage(CTX &ctx, quint8 header)
|
||||
{
|
||||
int local_id = header & 0x0f;
|
||||
MessageDefinition *def = &(ctx.defs[local_id]);
|
||||
quint8 i;
|
||||
MessageDefinition *def = &(ctx.defs[header & 0x0f]);
|
||||
quint8 numFields;
|
||||
|
||||
|
||||
if (def->fields) {
|
||||
delete[] def->fields;
|
||||
def->fields = 0;
|
||||
}
|
||||
if (def->devFields) {
|
||||
delete[] def->devFields;
|
||||
def->devFields = 0;
|
||||
}
|
||||
def->fields.clear();
|
||||
def->devFields.clear();
|
||||
|
||||
// reserved/unused
|
||||
if (!readValue(ctx, i))
|
||||
if (!skipValue(ctx, 1))
|
||||
return false;
|
||||
|
||||
// endianness
|
||||
@ -209,40 +146,35 @@ bool FITParser::parseDefinitionMessage(CTX &ctx, quint8 header)
|
||||
if (!readValue(ctx, def->globalId))
|
||||
return false;
|
||||
|
||||
// number of records
|
||||
if (!readValue(ctx, def->numFields))
|
||||
// definition records
|
||||
if (!readValue(ctx, numFields))
|
||||
return false;
|
||||
|
||||
// definition records
|
||||
def->fields = new Field[def->numFields];
|
||||
for (i = 0; i < def->numFields; i++) {
|
||||
static_assert(sizeof(def->fields[i]) == 3, "Invalid Field alignment");
|
||||
if (!readData(ctx.file, (char*)&(def->fields[i]),
|
||||
sizeof(def->fields[i])))
|
||||
def->fields.resize(numFields);
|
||||
for (int i = 0; i < def->fields.size(); i++) {
|
||||
if (!readData(ctx.file, (char*)&(def->fields[i]), sizeof(Field)))
|
||||
return false;
|
||||
ctx.len -= sizeof(def->fields[i]);
|
||||
ctx.len -= sizeof(Field);
|
||||
}
|
||||
|
||||
// developer definition records
|
||||
if (header & 0x20) {
|
||||
if (!readValue(ctx, def->numDevFields))
|
||||
if (!readValue(ctx, numFields))
|
||||
return false;
|
||||
|
||||
def->devFields = new Field[def->numDevFields];
|
||||
for (i = 0; i < def->numDevFields; i++) {
|
||||
static_assert(sizeof(def->fields[i]) == 3, "Invalid Field alignment");
|
||||
if (!readData(ctx.file, (char*)&(def->devFields[i]),
|
||||
sizeof(def->devFields[i])))
|
||||
def->devFields.resize(numFields);
|
||||
for (int i = 0; i < def->devFields.size(); i++) {
|
||||
if (!readData(ctx.file, (char*)&(def->devFields[i]), sizeof(Field)))
|
||||
return false;
|
||||
ctx.len -= sizeof(def->devFields[i]);
|
||||
ctx.len -= sizeof(Field);
|
||||
}
|
||||
} else
|
||||
def->numDevFields = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FITParser::readField(CTX &ctx, Field *field, QVariant &val, bool &valid)
|
||||
bool FITParser::readField(CTX &ctx, const Field *field, QVariant &val,
|
||||
bool &valid)
|
||||
{
|
||||
bool ret;
|
||||
|
||||
@ -299,22 +231,20 @@ bool FITParser::readField(CTX &ctx, Field *field, QVariant &val, bool &valid)
|
||||
|
||||
bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
|
||||
{
|
||||
Field *field;
|
||||
QVariant val;
|
||||
bool valid;
|
||||
Event event;
|
||||
Waypoint waypoint;
|
||||
|
||||
|
||||
if (!def->fields && !def->devFields) {
|
||||
if (!def->fields.size() && !def->devFields.size()) {
|
||||
_errorString = "Undefined data message";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctx.endian = def->endian;
|
||||
|
||||
for (int i = 0; i < def->numFields; i++) {
|
||||
field = &def->fields[i];
|
||||
for (int i = 0; i < def->fields.size(); i++) {
|
||||
const Field *field = &def->fields.at(i);
|
||||
if (!readField(ctx, field, val, valid))
|
||||
return false;
|
||||
if (!valid)
|
||||
@ -416,12 +346,9 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < def->numDevFields; i++) {
|
||||
field = &def->devFields[i];
|
||||
if (!readField(ctx, field, val, valid))
|
||||
for (int i = 0; i < def->devFields.size(); i++)
|
||||
if (!readField(ctx, &def->devFields.at(i), val, valid))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (def->globalId == EVENT_MESSAGE) {
|
||||
if ((event.id == 42 || event.id == 43) && event.type == 3) {
|
||||
@ -453,15 +380,15 @@ bool FITParser::parseData(CTX &ctx, const MessageDefinition *def)
|
||||
|
||||
bool FITParser::parseDataMessage(CTX &ctx, quint8 header)
|
||||
{
|
||||
int local_id = header & 0xf;
|
||||
MessageDefinition *def = &(ctx.defs[local_id]);
|
||||
int localId = header & 0xf;
|
||||
MessageDefinition *def = &(ctx.defs[localId]);
|
||||
return parseData(ctx, def);
|
||||
}
|
||||
|
||||
bool FITParser::parseCompressedMessage(CTX &ctx, quint8 header)
|
||||
{
|
||||
int local_id = (header >> 5) & 3;
|
||||
MessageDefinition *def = &(ctx.defs[local_id]);
|
||||
int localId = (header >> 5) & 3;
|
||||
MessageDefinition *def = &(ctx.defs[localId]);
|
||||
ctx.timestamp += header & 0x1f;
|
||||
return parseData(ctx, def);
|
||||
}
|
||||
@ -487,7 +414,6 @@ bool FITParser::parseHeader(CTX &ctx)
|
||||
quint16 crc;
|
||||
qint64 len;
|
||||
|
||||
static_assert(sizeof(hdr) == 12, "Invalid FileHeader alignment");
|
||||
len = ctx.file->read((char*)&hdr, sizeof(hdr));
|
||||
if (len < 0) {
|
||||
_errorString = "I/O error";
|
||||
@ -515,7 +441,6 @@ bool FITParser::parse(QFile *file, QList<TrackData> &tracks,
|
||||
Q_UNUSED(polygons);
|
||||
CTX ctx(file, waypoints);
|
||||
|
||||
|
||||
if (!parseHeader(ctx))
|
||||
return false;
|
||||
|
||||
|
@ -3,25 +3,72 @@
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
class QFile;
|
||||
|
||||
class FITParser : public Parser
|
||||
{
|
||||
public:
|
||||
FITParser()
|
||||
{
|
||||
static_assert(sizeof(Field) == 3, "Invalid Field alignment");
|
||||
static_assert(sizeof(FileHeader) == 12, "Invalid FileHeader alignment");
|
||||
}
|
||||
|
||||
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
|
||||
QList<Area> &polygons, QVector<Waypoint> &waypoints);
|
||||
QString errorString() const {return _errorString;}
|
||||
int errorLine() const {return 0;}
|
||||
|
||||
private:
|
||||
struct Field;
|
||||
class MessageDefinition;
|
||||
class CTX;
|
||||
struct Event
|
||||
{
|
||||
Event() : data(0), id(0), type(0) {}
|
||||
|
||||
quint32 data;
|
||||
quint8 id;
|
||||
quint8 type;
|
||||
};
|
||||
struct FileHeader
|
||||
{
|
||||
quint8 headerSize;
|
||||
quint8 protocolVersion;
|
||||
quint16 profileVersion;
|
||||
quint32 dataSize;
|
||||
quint32 magic;
|
||||
};
|
||||
struct Field
|
||||
{
|
||||
quint8 id;
|
||||
quint8 size;
|
||||
quint8 type;
|
||||
};
|
||||
struct MessageDefinition
|
||||
{
|
||||
MessageDefinition() : globalId(0), endian(0) {}
|
||||
|
||||
QVector<Field> fields;
|
||||
QVector<Field> devFields;
|
||||
quint16 globalId;
|
||||
quint8 endian;
|
||||
};
|
||||
struct CTX {
|
||||
CTX(QFile *file, QVector<Waypoint> &waypoints)
|
||||
: file(file), waypoints(waypoints), len(0), endian(0), timestamp(0),
|
||||
ratio(NAN) {}
|
||||
|
||||
QFile *file;
|
||||
QVector<Waypoint> &waypoints;
|
||||
quint32 len;
|
||||
quint8 endian;
|
||||
quint32 timestamp;
|
||||
MessageDefinition defs[16];
|
||||
qreal ratio;
|
||||
Trackpoint trackpoint;
|
||||
SegmentData segment;
|
||||
};
|
||||
|
||||
bool readData(QFile *file, char *data, size_t size);
|
||||
template<class T> bool readValue(CTX &ctx, T &val);
|
||||
bool skipValue(CTX &ctx, quint8 size);
|
||||
bool readField(CTX &ctx, Field *field, QVariant &val, bool &valid);
|
||||
bool readField(CTX &ctx, const Field *field, QVariant &val, bool &valid);
|
||||
|
||||
bool parseHeader(CTX &ctx);
|
||||
bool parseRecord(CTX &ctx);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define RESTRN 131
|
||||
#define TRAFIC 172
|
||||
#define VALDCO 174
|
||||
#define VERCLR 181
|
||||
#define WATLEV 187
|
||||
|
||||
#define I_CATACH 17000
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "GUI/units.h"
|
||||
#include "objects.h"
|
||||
#include "attributes.h"
|
||||
#include "mapdata.h"
|
||||
@ -288,12 +289,20 @@ MapData::Point::Point(uint type, const Coordinates &c, const QString &label,
|
||||
}
|
||||
|
||||
MapData::Poly::Poly(uint type, const Polygon &path,
|
||||
const QVector<QByteArray> ¶ms) : _type(type), _path(path)
|
||||
const QVector<QByteArray> ¶ms, uint HUNI) : _type(type), _path(path)
|
||||
{
|
||||
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();
|
||||
if (clr > 0) {
|
||||
_label = QString::fromUtf8("\xE2\x86\x95") + UNIT_SPACE
|
||||
+ QString::number(clr) + UNIT_SPACE + hUnits(HUNI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MapData::Line::Line(uint type, const QVector<Coordinates> &path,
|
||||
@ -657,6 +666,9 @@ MapData::Attr MapData::polyAttr(const ISO8211::Record &r, uint OBJL)
|
||||
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);
|
||||
@ -689,18 +701,18 @@ MapData::Line *MapData::lineObject(const ISO8211::Record &r,
|
||||
}
|
||||
|
||||
MapData::Poly *MapData::polyObject(const ISO8211::Record &r,
|
||||
const RecordMap &vc, const RecordMap &ve, uint COMF, uint OBJL)
|
||||
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.params()));
|
||||
attr.params(), HUNI));
|
||||
}
|
||||
|
||||
bool MapData::processRecord(const ISO8211::Record &record,
|
||||
QVector<ISO8211::Record> &fe, RecordMap &vi, RecordMap &vc, RecordMap &ve,
|
||||
RecordMap &vf, uint &COMF, uint &SOMF)
|
||||
RecordMap &vf, uint &COMF, uint &SOMF, uint &HUNI)
|
||||
{
|
||||
if (record.size() < 2)
|
||||
return false;
|
||||
@ -735,6 +747,8 @@ bool MapData::processRecord(const ISO8211::Record &record,
|
||||
} else if (ba == "DSPM") {
|
||||
if (!(f.subfield("COMF", &COMF) && f.subfield("SOMF", &SOMF)))
|
||||
return false;
|
||||
if (!f.subfield("HUNI", &HUNI))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -746,7 +760,7 @@ MapData::MapData(const QString &path)
|
||||
QVector<ISO8211::Record> fe;
|
||||
ISO8211 ddf(path);
|
||||
ISO8211::Record record;
|
||||
uint PRIM, OBJL, COMF = 1, SOMF = 1;
|
||||
uint PRIM, OBJL, COMF = 1, SOMF = 1, HUNI = 1;
|
||||
Poly *poly;
|
||||
Line *line;
|
||||
Point *point;
|
||||
@ -756,7 +770,7 @@ MapData::MapData(const QString &path)
|
||||
if (!ddf.readDDR())
|
||||
return;
|
||||
while (ddf.readRecord(record))
|
||||
if (!processRecord(record, fe, vi, vc, ve, vf, COMF, SOMF))
|
||||
if (!processRecord(record, fe, vi, vc, ve, vf, COMF, SOMF, HUNI))
|
||||
qWarning("Invalid S-57 record");
|
||||
|
||||
for (int i = 0; i < fe.size(); i++) {
|
||||
@ -793,7 +807,7 @@ MapData::MapData(const QString &path)
|
||||
warning(f, PRIM);
|
||||
break;
|
||||
case PRIM_A:
|
||||
if ((poly = polyObject(r, vc, ve, COMF, OBJL))) {
|
||||
if ((poly = polyObject(r, vc, ve, COMF, OBJL, HUNI))) {
|
||||
rectcBounds(poly->bounds(), min, max);
|
||||
_areas.Insert(min, max, poly);
|
||||
} else
|
||||
|
@ -13,16 +13,19 @@ class MapData
|
||||
public:
|
||||
class Poly {
|
||||
public:
|
||||
Poly(uint type, const Polygon &path, const QVector<QByteArray> ¶ms);
|
||||
Poly(uint type, const Polygon &path, const QVector<QByteArray> ¶ms,
|
||||
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;}
|
||||
|
||||
private:
|
||||
uint _type;
|
||||
Polygon _path;
|
||||
QString _label;
|
||||
QVariant _param;
|
||||
};
|
||||
|
||||
@ -121,11 +124,11 @@ private:
|
||||
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,
|
||||
const RecordMap &ve, uint COMF,uint OBJL);
|
||||
const RecordMap &ve, uint COMF, uint OBJL, uint HUNI);
|
||||
|
||||
static bool processRecord(const ISO8211::Record &record,
|
||||
QVector<ISO8211::Record> &fe, RecordMap &vi, RecordMap &vc, RecordMap &ve,
|
||||
RecordMap &vf, uint &COMF, uint &SOMF);
|
||||
RecordMap &vf, uint &COMF, uint &SOMF, uint &HUNI);
|
||||
|
||||
PolygonTree _areas;
|
||||
LineTree _lines;
|
||||
|
@ -12,7 +12,7 @@
|
||||
using namespace ENC;
|
||||
|
||||
#define TEXT_EXTENT 160
|
||||
#define TSSLPT_SIZE 0.005 /* ll */
|
||||
#define TSSLPT_SIZE 24
|
||||
|
||||
typedef QSet<Coordinates> PointSet;
|
||||
|
||||
@ -20,40 +20,6 @@ static const float C1 = 0.866025f; /* sqrt(3)/2 */
|
||||
static const QColor tsslptPen = QColor(0xeb, 0x49, 0xeb);
|
||||
static const QColor tsslptBrush = QColor(0xeb, 0x49, 0xeb, 0x80);
|
||||
|
||||
static double area(const QVector<Coordinates> &polygon)
|
||||
{
|
||||
double area = 0;
|
||||
|
||||
for (int i = 0; i < polygon.size() - 1; i++) {
|
||||
const Coordinates &pi = polygon.at(i);
|
||||
const Coordinates &pj = polygon.at(i+1);
|
||||
area += pi.lon() * pj.lat();
|
||||
area -= pi.lat() * pj.lon();
|
||||
}
|
||||
area /= 2.0;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
static Coordinates centroid(const QVector<Coordinates> &polygon)
|
||||
{
|
||||
Q_ASSERT(polygon.size() > 3);
|
||||
Q_ASSERT(polygon.first() == polygon.last());
|
||||
|
||||
double cx = 0, cy = 0;
|
||||
double factor = 1.0 / (6.0 * area(polygon));
|
||||
|
||||
for (int i = 0; i < polygon.size() - 1; i++) {
|
||||
const Coordinates &pi = polygon.at(i);
|
||||
const Coordinates &pj = polygon.at(i+1);
|
||||
double f = (pi.lon() * pj.lat() - pj.lon() * pi.lat());
|
||||
cx += (pi.lon() + pj.lon()) * f;
|
||||
cy += (pi.lat() + pj.lat()) * f;
|
||||
}
|
||||
|
||||
return Coordinates(cx * factor, cy * factor);
|
||||
}
|
||||
|
||||
static double angle(uint type, const QVariant ¶m)
|
||||
{
|
||||
uint bt = type>>16;
|
||||
@ -75,6 +41,31 @@ 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;
|
||||
@ -136,27 +127,26 @@ QVector<QPolygonF> RasterTile::polylineM(const QVector<Coordinates> &path) const
|
||||
return polys;
|
||||
}
|
||||
|
||||
QPolygonF RasterTile::tsslptArrow(const Coordinates &c, qreal angle) const
|
||||
QPolygonF RasterTile::tsslptArrow(const QPointF &p, qreal angle) const
|
||||
{
|
||||
Coordinates t[3], r[4];
|
||||
QPointF t[3], r[4];
|
||||
QPolygonF polygon;
|
||||
|
||||
t[0] = c;
|
||||
t[1] = Coordinates(t[0].lon() - qCos(angle - M_PI/3) * TSSLPT_SIZE,
|
||||
t[0].lat() - qSin(angle - M_PI/3) * TSSLPT_SIZE);
|
||||
t[2] = Coordinates(t[0].lon() - qCos(angle - M_PI + M_PI/3) * TSSLPT_SIZE,
|
||||
t[0].lat() - qSin(angle - M_PI + M_PI/3) * TSSLPT_SIZE);
|
||||
t[0] = p;
|
||||
t[1] = QPointF(t[0].x() - qCos(angle - M_PI/3) * TSSLPT_SIZE,
|
||||
t[0].y() - qSin(angle - M_PI/3) * TSSLPT_SIZE);
|
||||
t[2] = QPointF(t[0].x() - qCos(angle - M_PI + M_PI/3) * TSSLPT_SIZE,
|
||||
t[0].y() - qSin(angle - M_PI + M_PI/3) * TSSLPT_SIZE);
|
||||
|
||||
LineC l(t[1], t[2]);
|
||||
QLineF l(t[1], t[2]);
|
||||
r[0] = l.pointAt(0.25);
|
||||
r[1] = l.pointAt(0.75);
|
||||
r[2] = Coordinates(r[0].lon() - C1 * TSSLPT_SIZE * qCos(angle - M_PI/2),
|
||||
r[0].lat() - C1 * TSSLPT_SIZE * qSin(angle - M_PI/2));
|
||||
r[3] = Coordinates(r[1].lon() - C1 * TSSLPT_SIZE * qCos(angle - M_PI/2),
|
||||
r[1].lat() - C1 * TSSLPT_SIZE * qSin(angle - M_PI/2));
|
||||
r[2] = QPointF(r[0].x() - C1 * TSSLPT_SIZE * qCos(angle - M_PI/2),
|
||||
r[0].y() - C1 * TSSLPT_SIZE * qSin(angle - M_PI/2));
|
||||
r[3] = QPointF(r[1].x() - C1 * TSSLPT_SIZE * qCos(angle - M_PI/2),
|
||||
r[1].y() - C1 * TSSLPT_SIZE * qSin(angle - M_PI/2));
|
||||
|
||||
polygon << ll2xy(t[0]) << ll2xy(t[2]) << ll2xy(r[1]) << ll2xy(r[3])
|
||||
<< ll2xy(r[2]) << ll2xy(r[0]) << ll2xy(t[1]);
|
||||
polygon << t[0] << t[2] << r[1] << r[3] << r[2] << r[0] << t[1];
|
||||
|
||||
return polygon;
|
||||
}
|
||||
@ -169,7 +159,7 @@ void RasterTile::drawArrows(QPainter *painter,
|
||||
|
||||
if (poly.type()>>16 == TSSLPT) {
|
||||
QPolygonF polygon(tsslptArrow(centroid(poly.path().first()),
|
||||
deg2rad(180 - poly.param().toDouble())));
|
||||
deg2rad(poly.param().toDouble())));
|
||||
|
||||
painter->setPen(QPen(tsslptPen, 1));
|
||||
painter->setBrush(QBrush(tsslptBrush));
|
||||
@ -241,19 +231,34 @@ void RasterTile::processPolygons(const QList<MapData::Poly> &polygons,
|
||||
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);
|
||||
|
||||
if (!(type == HRBFAC || type == I_TRNBSN
|
||||
|| poly.type() == SUBTYPE(I_BERTHS, 6)))
|
||||
continue;
|
||||
const Style::Point &style = _style->point(poly.type());
|
||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||
if (!img)
|
||||
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();
|
||||
}
|
||||
|
||||
if ((!label || !fnt) && !img)
|
||||
continue;
|
||||
|
||||
TextPointItem *item = new TextPointItem(
|
||||
ll2xy(centroid(poly.path().first())).toPoint(),
|
||||
0, 0, img, 0, 0, 0, 0);
|
||||
if (item->isValid() && !item->collides(textItems))
|
||||
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;
|
||||
@ -379,8 +384,8 @@ void RasterTile::render()
|
||||
|
||||
fetchData(polygons, lines, points);
|
||||
|
||||
processPolygons(polygons, textItems);
|
||||
processPoints(points, textItems, lights);
|
||||
processPolygons(polygons, textItems);
|
||||
processLines(lines, textItems);
|
||||
|
||||
QPainter painter(&img);
|
||||
|
@ -41,7 +41,8 @@ private:
|
||||
QPainterPath painterPath(const Polygon &polygon) const;
|
||||
QPolygonF polyline(const QVector<Coordinates> &path) const;
|
||||
QVector<QPolygonF> polylineM(const QVector<Coordinates> &path) const;
|
||||
QPolygonF tsslptArrow(const Coordinates &c, qreal angle) const;
|
||||
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);
|
||||
void processLines(const QList<MapData::Line> &lines,
|
||||
|
@ -235,6 +235,8 @@ 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, 15)] = Point(QImage(":/marine/dome.png"), Small,
|
||||
QPoint(0, -5));
|
||||
_points[SUBTYPE(LNDMRK, 17)] = Point(QImage(":/marine/tower.png"), Small,
|
||||
QPoint(0, -11));
|
||||
_points[SUBTYPE(LNDMRK, 18)] = Point(QImage(":/marine/windmill.png"), Small);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef DEMFILE_H
|
||||
#define DEMFILE_H
|
||||
#ifndef IMG_DEMFILE_H
|
||||
#define IMG_DEMFILE_H
|
||||
|
||||
#include "common/rtree.h"
|
||||
#include "subfile.h"
|
||||
@ -55,4 +55,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // DEMFILE_H
|
||||
#endif // IMG_DEMFILE_H
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef DEMTILE_H
|
||||
#define DEMTILE_H
|
||||
#ifndef IMG_DEMTILE_H
|
||||
#define IMG_DEMTILE_H
|
||||
|
||||
#include "common/rectc.h"
|
||||
|
||||
@ -33,4 +33,4 @@ private:
|
||||
|
||||
}
|
||||
|
||||
#endif // DEMTILE_H
|
||||
#endif // IMG_DEMTILE_H
|
||||
|
@ -70,33 +70,22 @@ static int minShieldZoom(Shield::Type type)
|
||||
}
|
||||
}
|
||||
|
||||
static qreal area(const QVector<QPointF> &polygon)
|
||||
{
|
||||
qreal area = 0;
|
||||
|
||||
for (int i = 0; i < polygon.size(); i++) {
|
||||
int j = (i + 1) % polygon.size();
|
||||
area += polygon.at(i).x() * polygon.at(j).y();
|
||||
area -= polygon.at(i).y() * polygon.at(j).x();
|
||||
}
|
||||
area /= 2.0;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
static QPointF centroid(const QVector<QPointF> &polygon)
|
||||
{
|
||||
qreal area = 0;
|
||||
qreal cx = 0, cy = 0;
|
||||
qreal factor = 1.0 / (6.0 * area(polygon));
|
||||
|
||||
for (int i = 0; i < polygon.size(); i++) {
|
||||
int j = (i + 1) % polygon.size();
|
||||
int j = (i == polygon.size() - 1) ? 0 : i + 1;
|
||||
qreal f = (polygon.at(i).x() * polygon.at(j).y() - polygon.at(j).x()
|
||||
* polygon.at(i).y());
|
||||
area += f;
|
||||
cx += (polygon.at(i).x() + polygon.at(j).x()) * f;
|
||||
cy += (polygon.at(i).y() + polygon.at(j).y()) * f;
|
||||
}
|
||||
|
||||
qreal factor = 1.0 / (3.0 * area);
|
||||
|
||||
return QPointF(cx * factor, cy * factor);
|
||||
}
|
||||
|
||||
|
@ -15,33 +15,22 @@ using namespace Mapsforge;
|
||||
|
||||
static double LIMIT = cos(deg2rad(170));
|
||||
|
||||
static qreal area(const QPainterPath &polygon)
|
||||
{
|
||||
qreal area = 0;
|
||||
|
||||
for (int i = 0; i < polygon.elementCount(); i++) {
|
||||
int j = (i + 1) % polygon.elementCount();
|
||||
area += polygon.elementAt(i).x * polygon.elementAt(j).y;
|
||||
area -= polygon.elementAt(i).y * polygon.elementAt(j).x;
|
||||
}
|
||||
area /= 2.0;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
static QPointF centroid(const QPainterPath &polygon)
|
||||
{
|
||||
qreal area = 0;
|
||||
qreal cx = 0, cy = 0;
|
||||
qreal factor = 1.0 / (6.0 * area(polygon));
|
||||
|
||||
for (int i = 0; i < polygon.elementCount(); i++) {
|
||||
int j = (i + 1) % polygon.elementCount();
|
||||
int j = (i == polygon.elementCount() - 1) ? 0 : i + 1;
|
||||
qreal f = (polygon.elementAt(i).x * polygon.elementAt(j).y
|
||||
- polygon.elementAt(j).x * polygon.elementAt(i).y);
|
||||
area += f;
|
||||
cx += (polygon.elementAt(i).x + polygon.elementAt(j).x) * f;
|
||||
cy += (polygon.elementAt(i).y + polygon.elementAt(j).y) * f;
|
||||
}
|
||||
|
||||
qreal factor = 1.0 / (3.0 * area);
|
||||
|
||||
return QPointF(cx * factor, cy * factor);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user