mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-04-21 04:39:10 +02:00
Compare commits
No commits in common. "ab7652199058b715a836677c042db8751c82f6f8" and "3af98b67858f2b749b18c8bddac81b8b71272e9b" have entirely different histories.
ab76521990
...
3af98b6785
@ -188,16 +188,12 @@ bool ISO8211::readDDA(QFile &file, const FieldDefinition &def, SubFields &fields
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISO8211::readDDR()
|
bool ISO8211::readDDR(QFile &file)
|
||||||
{
|
{
|
||||||
QVector<FieldDefinition> fields;
|
QVector<FieldDefinition> fields;
|
||||||
|
qint64 pos = file.pos();
|
||||||
|
int len = readDR(file, fields);
|
||||||
|
|
||||||
if (!_file.open(QIODevice::ReadOnly)) {
|
|
||||||
_errorString = _file.errorString();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int len = readDR(_file, fields);
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
_errorString = "Not a ISO8211 file";
|
_errorString = "Not a ISO8211 file";
|
||||||
return false;
|
return false;
|
||||||
@ -205,7 +201,7 @@ bool ISO8211::readDDR()
|
|||||||
|
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
SubFields def;
|
SubFields def;
|
||||||
if (!readDDA(_file, fields.at(i), def)) {
|
if (!readDDA(file, fields.at(i), def)) {
|
||||||
_errorString = QString("Error reading %1 DDA field")
|
_errorString = QString("Error reading %1 DDA field")
|
||||||
.arg(QString(fields.at(i).tag));
|
.arg(QString(fields.at(i).tag));
|
||||||
return false;
|
return false;
|
||||||
@ -213,7 +209,7 @@ bool ISO8211::readDDR()
|
|||||||
_map.insert(fields.at(i).tag, def);
|
_map.insert(fields.at(i).tag, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_file.pos() != len || fields.size() < 2) {
|
if (file.pos() != pos + len || fields.size() < 2) {
|
||||||
_errorString = "DDR format error";
|
_errorString = "DDR format error";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -235,7 +231,6 @@ bool ISO8211::readUDA(QFile &file, quint64 pos, const FieldDefinition &def,
|
|||||||
const char *dp = ba.constData();
|
const char *dp = ba.constData();
|
||||||
const char *ep = ba.constData() + ba.size() - 1;
|
const char *ep = ba.constData() + ba.size() - 1;
|
||||||
|
|
||||||
data.clear();
|
|
||||||
data.setFields(&fields);
|
data.setFields(&fields);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -292,14 +287,11 @@ bool ISO8211::readUDA(QFile &file, quint64 pos, const FieldDefinition &def,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ISO8211::readRecord(Record &record)
|
bool ISO8211::readRecord(QFile &file, Record &record)
|
||||||
{
|
{
|
||||||
if (_file.atEnd())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
QVector<FieldDefinition> fields;
|
QVector<FieldDefinition> fields;
|
||||||
qint64 pos = _file.pos();
|
qint64 pos = file.pos();
|
||||||
int len = readDR(_file, fields);
|
int len = readDR(file, fields);
|
||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
_errorString = "Error reading DR";
|
_errorString = "Error reading DR";
|
||||||
@ -321,7 +313,7 @@ bool ISO8211::readRecord(Record &record)
|
|||||||
|
|
||||||
f.setTag(def.tag);
|
f.setTag(def.tag);
|
||||||
|
|
||||||
if (!readUDA(_file, pos, def, it.value(), f.rdata())) {
|
if (!readUDA(file, pos, def, it.value(), f.rdata())) {
|
||||||
_errorString = QString("Error reading %1 record")
|
_errorString = QString("Error reading %1 record")
|
||||||
.arg(QString(def.tag));
|
.arg(QString(def.tag));
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#ifndef ENC_ISO8211_H
|
#ifndef ENC_ISO8211_H
|
||||||
#define ENC_ISO8211_H
|
#define ENC_ISO8211_H
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
class QFile;
|
||||||
|
|
||||||
#define UINT32(x) \
|
#define UINT32(x) \
|
||||||
(((quint32)*(const uchar*)(x)) \
|
(((quint32)*(const uchar*)(x)) \
|
||||||
| ((quint32)(*((const uchar*)(x) + 1)) << 8) \
|
| ((quint32)(*((const uchar*)(x) + 1)) << 8) \
|
||||||
@ -101,9 +102,8 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ISO8211(const QString &path) : _file(path) {}
|
bool readDDR(QFile &file);
|
||||||
bool readDDR();
|
bool readRecord(QFile &file, Record &record);
|
||||||
bool readRecord(Record &record);
|
|
||||||
|
|
||||||
const QString &errorString() const {return _errorString;}
|
const QString &errorString() const {return _errorString;}
|
||||||
|
|
||||||
@ -118,7 +118,6 @@ private:
|
|||||||
bool readUDA(QFile &file, quint64 pos, const FieldDefinition &def,
|
bool readUDA(QFile &file, quint64 pos, const FieldDefinition &def,
|
||||||
const SubFields &fields, Data &data) const;
|
const SubFields &fields, Data &data) const;
|
||||||
|
|
||||||
QFile _file;
|
|
||||||
FieldsMap _map;
|
FieldsMap _map;
|
||||||
QString _errorString;
|
QString _errorString;
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <QFile>
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "objects.h"
|
#include "objects.h"
|
||||||
#include "attributes.h"
|
#include "attributes.h"
|
||||||
@ -750,25 +751,31 @@ bool MapData::bounds(const QVector<ISO8211::Record> &gv, Rect &b)
|
|||||||
|
|
||||||
MapData::MapData(const QString &path): _fileName(path)
|
MapData::MapData(const QString &path): _fileName(path)
|
||||||
{
|
{
|
||||||
|
QFile file(_fileName);
|
||||||
QVector<ISO8211::Record> gv;
|
QVector<ISO8211::Record> gv;
|
||||||
ISO8211 ddf(_fileName);
|
ISO8211 ddf;
|
||||||
ISO8211::Record record;
|
|
||||||
uint COMF = 1;
|
uint COMF = 1;
|
||||||
|
|
||||||
if (!ddf.readDDR()) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
|
_errorString = file.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ddf.readDDR(file)) {
|
||||||
_errorString = ddf.errorString();
|
_errorString = ddf.errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (ddf.readRecord(record)) {
|
while (!file.atEnd()) {
|
||||||
|
ISO8211::Record record;
|
||||||
|
if (!ddf.readRecord(file, record)) {
|
||||||
|
_errorString = ddf.errorString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!processRecord(record, gv, COMF, _name)) {
|
if (!processRecord(record, gv, COMF, _name)) {
|
||||||
_errorString = "Invalid S-57 record";
|
_errorString = "Invalid S-57 record";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ddf.errorString().isNull()) {
|
|
||||||
_errorString = ddf.errorString();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rect b;
|
Rect b;
|
||||||
if (!bounds(gv, b)) {
|
if (!bounds(gv, b)) {
|
||||||
@ -800,22 +807,30 @@ MapData::~MapData()
|
|||||||
|
|
||||||
void MapData::load()
|
void MapData::load()
|
||||||
{
|
{
|
||||||
|
QFile file(_fileName);
|
||||||
RecordMap vi, vc, ve, vf;
|
RecordMap vi, vc, ve, vf;
|
||||||
QVector<ISO8211::Record> fe;
|
QVector<ISO8211::Record> fe;
|
||||||
ISO8211 ddf(_fileName);
|
uint COMF = 1, SOMF = 1;
|
||||||
ISO8211::Record record;
|
ISO8211 ddf;
|
||||||
uint PRIM, OBJL, COMF = 1, SOMF = 1;
|
uint PRIM, OBJL;
|
||||||
Poly *poly;
|
Poly *poly;
|
||||||
Line *line;
|
Line *line;
|
||||||
Point *point;
|
Point *point;
|
||||||
double min[2], max[2];
|
double min[2], max[2];
|
||||||
|
|
||||||
|
|
||||||
if (!ddf.readDDR())
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
return;
|
return;
|
||||||
while (ddf.readRecord(record))
|
|
||||||
|
if (!ddf.readDDR(file))
|
||||||
|
return;
|
||||||
|
while (!file.atEnd()) {
|
||||||
|
ISO8211::Record record;
|
||||||
|
if (!ddf.readRecord(file, record))
|
||||||
|
return;
|
||||||
if (!processRecord(record, fe, vi, vc, ve, vf, COMF, SOMF))
|
if (!processRecord(record, fe, vi, vc, ve, vf, COMF, SOMF))
|
||||||
qWarning("Invalid S-57 record");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < fe.size(); i++) {
|
for (int i = 0; i < fe.size(); i++) {
|
||||||
const ISO8211::Record &r = fe.at(i);
|
const ISO8211::Record &r = fe.at(i);
|
||||||
|
@ -381,7 +381,7 @@ void OziMap::setDevicePixelRatio(qreal deviceRatio, qreal mapRatio)
|
|||||||
Map *OziMap::createTAR(const QString &path, const Projection &, bool *isDir)
|
Map *OziMap::createTAR(const QString &path, const Projection &, bool *isDir)
|
||||||
{
|
{
|
||||||
if (isDir)
|
if (isDir)
|
||||||
*isDir = false;
|
*isDir = true;
|
||||||
|
|
||||||
return new OziMap(path, true);
|
return new OziMap(path, true);
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ Map *OziMap::createTAR(const QString &path, const Projection &, bool *isDir)
|
|||||||
Map *OziMap::createMAP(const QString &path, const Projection &, bool *isDir)
|
Map *OziMap::createMAP(const QString &path, const Projection &, bool *isDir)
|
||||||
{
|
{
|
||||||
if (isDir)
|
if (isDir)
|
||||||
*isDir = false;
|
*isDir = true;
|
||||||
|
|
||||||
return new OziMap(path, false);
|
return new OziMap(path, false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user