1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-30 18:34:23 +02:00

Compare commits

..

11 Commits

10 changed files with 88 additions and 67 deletions

View File

@ -18,7 +18,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: Install dependencies - name: Install dependencies
run: | run: |
@ -26,7 +26,7 @@ jobs:
sudo apt-get install qtbase5-dev qtbase5-private-dev qtbase5-dev-tools qt5-qmake qttools5-dev-tools libqt5opengl5-dev qtpositioning5-dev libqt5svg5-dev libqt5serialport5-dev sudo apt-get install qtbase5-dev qtbase5-private-dev qtbase5-dev-tools qt5-qmake qttools5-dev-tools libqt5opengl5-dev qtpositioning5-dev libqt5svg5-dev libqt5serialport5-dev
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v3
with: with:
languages: ${{ matrix.language }} languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file. # If you wish to specify custom queries, you can do so here or in a config file.
@ -37,9 +37,9 @@ jobs:
# queries: security-extended,security-and-quality # queries: security-extended,security-and-quality
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v2 uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2 uses: github/codeql-action/analyze@v3
with: with:
category: "/language:${{matrix.language}}" category: "/language:${{matrix.language}}"

View File

@ -174,7 +174,7 @@ SETTING(markerInfo, "markerInfo", MarkerInfoItem::None );
SETTING(useStyles, "styles", true ); SETTING(useStyles, "styles", true );
/* DEM */ /* DEM */
SETTING(drawHillShading, "hillshading", false ); SETTING(drawHillShading, "hillshading", true );
/* Position */ /* Position */
SETTING(showPosition, "show", false ); SETTING(showPosition, "show", false );

View File

@ -16,15 +16,15 @@ static const quint8 Z[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
}; };
static const int J[] = { static const quint8 J[] = {
0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15 4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15
}; };
JLS::JLS(quint16 diff, quint16 factor) JLS::JLS(quint16 maxval, quint16 near)
{ {
_maxval = diff; _maxval = maxval;
_near = factor; _near = near;
_range = ((_maxval + _near * 2) / (_near * 2 + 1)) + 1; _range = ((_maxval + _near * 2) / (_near * 2 + 1)) + 1;
_qbpp = ceil(log2(_range)); _qbpp = ceil(log2(_range));
@ -129,16 +129,17 @@ bool JLS::readLine(BitStream &bs)
quint8 k; quint8 k;
uint MErrval; uint MErrval;
int Errval; int Errval;
int Rx = _last[1]; int Rx;
int last0 = _last[0]; int Ra = _last[1];
int last1 = _last[1]; int Rb = _last[1];
int Rc = _last[0];
uint col = 1; uint col = 1;
*_current = _last[1]; *_current = _last[1];
do { do {
if (abs(last1 - Rx) > _near) { if (abs(Rb - Ra) > _near) {
int Px = Rx + last1 - last0; int Px = Ra + Rb - Rc;
if (Px < 0) if (Px < 0)
Px = 0; Px = 0;
else if (Px > _maxval) else if (Px > _maxval)
@ -166,7 +167,7 @@ bool JLS::readLine(BitStream &bs)
} else } else
mes = mes * (_near * 2 + 1); mes = mes * (_near * 2 + 1);
Errval = (Rx < last1) ? mes : -mes; Errval = (Ra < Rb) ? mes : -mes;
Rx = Px + Errval; Rx = Px + Errval;
if (Rx < -_near) if (Rx < -_near)
@ -183,21 +184,26 @@ bool JLS::readLine(BitStream &bs)
_b[1] = _b[1] + mes; _b[1] = _b[1] + mes;
if (_n[1] == 0x40) { if (_n[1] == 0x40) {
_a[1] = _a[1] >> 1; _a[1] = _a[1] >> 1;
_b[1] = _b[1] >> 1; if (_b[1] >= 0)
_b[1] = _b[1] >> 1;
else
_b[1] = -((1 - _b[1]) >> 1);
_n[1] = 0x21; _n[1] = 0x21;
} else { } else
_n[1] = _n[1] + 1; _n[1] = _n[1] + 1;
}
if (_b[1] <= -_n[1]) { if (_b[1] <= -_n[1]) {
_b[1] = _b[1] + _n[1]; _b[1] = _b[1] + _n[1];
if (_b[1] <= -_n[1]) if (_b[1] <= -_n[1])
_b[1] = 1 - _n[1]; _b[1] = 1 - _n[1];
} else if (_b[1] > 0) } else if (_b[1] > 0) {
_b[1] = ((_b[1] - _n[1]) >> 0xf) & (_b[1] - _n[1]); _b[1] = _b[1] - _n[1];
if (_b[1] > 0)
_b[1] = 0;
}
last0 = last1; Rc = Rb;
last1 = _last[col + 1]; Rb = _last[col + 1];
} else { } else {
quint16 samples; quint16 samples;
if (!processRunMode(bs, _w - col + 1, samples)) if (!processRunMode(bs, _w - col + 1, samples))
@ -207,21 +213,21 @@ bool JLS::readLine(BitStream &bs)
for (int i = 0; i < samples; i++) { for (int i = 0; i < samples; i++) {
if (col > _w) if (col > _w)
return false; return false;
_current[col] = Rx; _current[col] = Ra;
col++; col++;
} }
if (col > _w) if (col > _w)
break; break;
last0 = _last[col]; Rc = _last[col];
last1 = _last[col + 1]; Rb = _last[col + 1];
} else { } else {
last0 = last1; Rc = Rb;
last1 = _last[col + 1]; Rb = _last[col + 1];
} }
rctx = (abs(last0 - Rx) <= _near); rctx = (abs(Rc - Ra) <= _near);
quint16 TEMP = _a[rctx + 2]; quint16 TEMP = _a[rctx + 2];
if (rctx) if (rctx)
TEMP += _n[rctx + 2] >> 1; TEMP += _n[rctx + 2] >> 1;
@ -249,15 +255,15 @@ bool JLS::readLine(BitStream &bs)
Errval *= (_near * 2 + 1); Errval *= (_near * 2 + 1);
if (!rctx) { if (!rctx) {
if (Rx == last0) if (Ra == Rc)
return false; return false;
if (Rx < last0) if (Ra < Rc)
Rx = last0 + Errval; Rx = Rc + Errval;
else else
Rx = last0 - Errval; Rx = Rc - Errval;
} else } else
Rx = Rx + Errval; Rx = Ra + Errval;
if (Rx < -_near) if (Rx < -_near)
Rx += (_near * 2 + 1) * _range; Rx += (_near * 2 + 1) * _range;
@ -272,13 +278,18 @@ bool JLS::readLine(BitStream &bs)
_a[ictx] = _a[ictx] + (evh - rctx); _a[ictx] = _a[ictx] + (evh - rctx);
if (_n[ictx] == 0x40) { if (_n[ictx] == 0x40) {
_a[ictx] = _a[ictx] >> 1; _a[ictx] = _a[ictx] >> 1;
_b[ictx] = _b[ictx] >> 1; if (_b[ictx] >= 0)
_b[ictx] = _b[ictx] >> 1;
else
_b[ictx] = -((1 - _b[ictx]) >> 1);
_n[ictx] = 0x21; _n[ictx] = 0x21;
} else } else
_n[ictx] = _n[ictx] + 1; _n[ictx] = _n[ictx] + 1;
} }
_current[col] = Rx; _current[col] = Rx;
Ra = Rx;
col = col + 1; col = col + 1;
} while (col <= _w); } while (col <= _w);

View File

@ -2,15 +2,15 @@
#define IMG_JLS_H #define IMG_JLS_H
#include <QVector> #include <QVector>
#include "bitstream.h"
#include "map/matrix.h" #include "map/matrix.h"
#include "subfile.h"
namespace IMG { namespace IMG {
class JLS class JLS
{ {
public: public:
JLS(quint16 diff, quint16 factor); JLS(quint16 maxval, quint16 near);
bool decode(const SubFile *file, SubFile::Handle &hdl, Matrix<qint16> &img); bool decode(const SubFile *file, SubFile::Handle &hdl, Matrix<qint16> &img);

View File

@ -477,12 +477,10 @@ MatrixD RasterTile::elevation(int extend) const
for (int i = 0; i < ll.size(); i++) for (int i = 0; i < ll.size(); i++)
rect = rect.united(ll.at(i)); rect = rect.united(ll.at(i));
// Extra margin for always including the next DEM tile on the map tile // Extra margin for always including the next DEM tile on the map tile
// edges (the DEM tile resolution is usally < 5% of the map tile) // edges (the DEM tile resolution is usally 0.5-15% of the map tile)
double delta = rect.width() / 16; double factor = 6 - (_zoom - 24) * 1.7;
rect = rect.united(Coordinates(rect.right() + delta, _data->elevations(rect.adjusted(0, 0, rect.width() / factor,
rect.bottom() - delta)); -rect.height() / factor), _zoom, &tiles);
_data->elevations(rect, _zoom, &tiles);
DEM::buildTree(tiles, tree); DEM::buildTree(tiles, tree);
for (int i = 0; i < ll.size(); i++) for (int i = 0; i < ll.size(); i++)
@ -500,8 +498,8 @@ MatrixD RasterTile::elevation(int extend) const
void RasterTile::drawHillShading(QPainter *painter) const void RasterTile::drawHillShading(QPainter *painter) const
{ {
if (_hillShading && _zoom >= 18 && _zoom <= 24) { if (_hillShading && _zoom >= 18 && _zoom <= 24) {
MatrixD dem(Filter::blur(elevation(BLUR_RADIUS), BLUR_RADIUS)); MatrixD dem(Filter::blur(elevation(BLUR_RADIUS + 1), BLUR_RADIUS));
QImage img(HillShading::render(dem, BLUR_RADIUS)); QImage img(HillShading::render(dem, BLUR_RADIUS + 1));
painter->drawImage(_rect.x(), _rect.y(), img); painter->drawImage(_rect.x(), _rect.y(), img);
} }
} }

View File

@ -279,7 +279,7 @@ void VectorTile::elevations(const RectC &rect, const Zoom &zoom,
// Shift the DEM level to get better data then what the map defines for // Shift the DEM level to get better data then what the map defines for
// the given zoom (we prefer rendering quality rather than speed). For // the given zoom (we prefer rendering quality rather than speed). For
// maps with a single level this has no effect. // maps with a single level this has no effect.
int level = _dem->level(zoom) / 2; int level = qMax(0, _dem->level(zoom) - 1);
QList<const DEMTile*> tiles(_dem->tiles(rect, level)); QList<const DEMTile*> tiles(_dem->tiles(rect, level));
for (int i = 0; i < tiles.size(); i++) { for (int i = 0; i < tiles.size(); i++) {
const DEMTile *tile = tiles.at(i); const DEMTile *tile = tiles.at(i);

View File

@ -99,16 +99,31 @@ MatrixD Filter::blur(const MatrixD &m, int radius)
{ {
MatrixD src(m); MatrixD src(m);
MatrixD dst(m.h(), m.w()); MatrixD dst(m.h(), m.w());
double sum = 0;
int cnt = 0;
for (int i = 0; i < m.size(); i++) for (int i = 0; i < m.size(); i++) {
if (std::isnan(m.at(i))) if (!std::isnan(m.at(i))) {
src.at(i) = -500; sum += m.at(i);
cnt++;
}
}
if (cnt != m.size()) {
double avg = sum / cnt;
for (int i = 0; i < m.size(); i++)
if (std::isnan(m.at(i)))
src.at(i) = avg;
}
gaussBlur4(src, dst, radius); gaussBlur4(src, dst, radius);
for (int i = 0; i < dst.size(); i++) if (cnt != m.size()) {
if (std::isnan(m.at(i))) for (int i = 0; i < dst.size(); i++)
dst.at(i) = NAN; if (std::isnan(m.at(i)))
dst.at(i) = NAN;
}
return dst; return dst;
} }

View File

@ -223,18 +223,6 @@ bool GCS::loadList(const QString &path)
return true; return true;
} }
Coordinates GCS::toWGS84(const Coordinates &c) const
{
return datum().toWGS84(Coordinates(_primeMeridian.toGreenwich(c.lon()),
c.lat()));
}
Coordinates GCS::fromWGS84(const Coordinates &c) const
{
Coordinates ds(datum().fromWGS84(c));
return Coordinates(_primeMeridian.fromGreenwich(ds.lon()), ds.lat());
}
QList<KV<int, QString> > GCS::list() QList<KV<int, QString> > GCS::list()
{ {
QList<KV<int, QString> > list; QList<KV<int, QString> > list;

View File

@ -29,8 +29,16 @@ public:
bool isValid() const {return _datum.isValid() && _angularUnits.isValid() bool isValid() const {return _datum.isValid() && _angularUnits.isValid()
&& _primeMeridian.isValid();} && _primeMeridian.isValid();}
Coordinates toWGS84(const Coordinates &c) const; Coordinates toWGS84(const Coordinates &c) const
Coordinates fromWGS84(const Coordinates &c) const; {
return datum().toWGS84(Coordinates(_primeMeridian.toGreenwich(c.lon()),
c.lat()));
}
Coordinates fromWGS84(const Coordinates &c) const
{
Coordinates ds(datum().fromWGS84(c));
return Coordinates(_primeMeridian.fromGreenwich(ds.lon()), ds.lat());
}
static GCS gcs(int id); static GCS gcs(int id);
static GCS gcs(int geodeticDatum, int primeMeridian, int angularUnits); static GCS gcs(int geodeticDatum, int primeMeridian, int angularUnits);

View File

@ -442,8 +442,9 @@ void RasterTile::drawPaths(QPainter *painter, const QList<MapData::Path> &paths,
painter->drawEllipse(ll2xy(point->coordinates), radius, radius); painter->drawEllipse(ll2xy(point->coordinates), radius, radius);
} else { } else {
if (_hillShading) { if (_hillShading) {
MatrixD dem(Filter::blur(elevation(BLUR_RADIUS), BLUR_RADIUS)); MatrixD dem(Filter::blur(elevation(BLUR_RADIUS + 1),
QImage img(HillShading::render(dem, BLUR_RADIUS)); BLUR_RADIUS));
QImage img(HillShading::render(dem, BLUR_RADIUS + 1));
painter->drawImage(_rect.x(), _rect.y(), img); painter->drawImage(_rect.x(), _rect.y(), img);
} }
} }