Hi,
attached are two small patches for DEM and TDB drawing;
Currently, when the DEM doesn't cover the whole viewport, no data from
the DEM is displayed. With the first patch DEM data is also displayed
for part of the viewport only, which results in a better user experience
while panning close to the border of the DEM ;-)
The second patch fixes excessive detail when displaying more than one
TDB map: To reproduce go to Lake Constance on openmtbmap_austria, then
also enable openmtbmap_germany. I'm not 100% sure if this is the
correct fix, but at least it works for me.
Regards,
Michael
--
I wish there was a knob on the TV to turn up the intelligence.
There's a knob called "brightness", but it doesn't seem to work.
-- GallagherFrom 9a90f3527162425a92b5775115f9ab4ad75130b4 Mon Sep 17 00:00:00 2001
From: Michael Klein <[email protected]>
Date: Sat, 8 Oct 2011 23:31:10 +0200
Subject: [PATCH 1/2] partial DEM drawing if viewport is larger than DEM area
---
src/CMapDEM.cpp | 45 +++++++++++++++++++++++++++------------------
1 files changed, 27 insertions(+), 18 deletions(-)
diff --git a/src/CMapDEM.cpp b/src/CMapDEM.cpp
index e731e4d..773f176 100644
--- a/src/CMapDEM.cpp
+++ b/src/CMapDEM.cpp
@@ -425,21 +425,31 @@ void CMapDEM::draw()
pj_transform(pjtar, pjsrc, 1, 0, &_p1.u, &_p1.v, 0);
pj_transform(pjtar, pjsrc, 1, 0, &_p2.u, &_p2.v, 0);
+ // determine intersection rect
+ XY r1 = { std::max(_p1.u, xref1), std::min(_p1.v, yref1) };
+ XY r2 = { std::min(_p2.u, xref2), std::max(_p2.v, yref2) };
+
+ if (r1.u > p2.u || r1.v < p2.v || r2.u < p1.u || r2.v > p1.v)
+ {
+ // no interscetion
+ return;
+ }
+
// 2. get floating point offset of topleft corner
- double xoff1_f = (_p1.u - xref1) / xscale;
- double yoff1_f = (_p1.v - yref1) / yscale;
+ double xoff1_f = (r1.u - xref1) / xscale;
+ double yoff1_f = (r1.v - yref1) / yscale;
// 3. truncate floating point offset into integer offset
- int xoff1 = xoff1_f; //qDebug() << "xoff1:" << xoff1 << xoff1_f;
- int yoff1 = yoff1_f; //qDebug() << "yoff1:" << yoff1 << yoff1_f;
+ int xoff1 = xoff1_f;
+ int yoff1 = yoff1_f;
// 4. get floating point offset of bottom right corner
- double xoff2_f = (_p2.u - xref1) / xscale;
- double yoff2_f = (_p2.v - yref1) / yscale;
+ double xoff2_f = (r2.u - xref1) / xscale;
+ double yoff2_f = (r2.v - yref1) / yscale;
// 5. round up (!) floating point offset into integer offset
- int xoff2 = ceil(xoff2_f); //qDebug() << "xoff2:" << xoff2 << xoff2_f;
- int yoff2 = ceil(yoff2_f); //qDebug() << "yoff2:" << yoff2 << yoff2_f;
+ int xoff2 = ceil(xoff2_f);
+ int yoff2 = ceil(yoff2_f);
/*
The defined area into DEM data (xoff1,yoff1,xoff2,yoff2) covers a
larger or equal
@@ -451,31 +461,30 @@ void CMapDEM::draw()
/*
Calculate the width and the height of the area. Extend width until
it's a multiple of 4.
- This will be of advantag as QImage will process 32bit alligned bitmaps
much faster.
+ This will be of advantage as QImage will process 32bit aligned bitmaps
much faster.
*/
- int w1 = xoff2 - xoff1; while((w1 & 0x03) != 0) ++w1;
- int h1 = yoff2 - yoff1; //qDebug() << "w1:" << w1 << "h1:" << h1;
+ unsigned int w1 = (xoff2 - xoff1 + 3) & ~0x03;
+ unsigned int h1 = (yoff2 - yoff1);
// bail out if this is getting too big
if(w1 > 10000 || h1 > 10000) return;
// now calculate the actual width and height of the viewport
- int w2 = w1 * xscale / my_xscale;
- //qDebug() << "w2:" << w2 << "h2:" << h2;
- int h2 = h1 * yscale / my_yscale;
+ unsigned int w2 = w1 * xscale / my_xscale;
+ unsigned int h2 = h1 * yscale / my_yscale;
// as the first point off the DEM data will not match exactly the given
top left corner
// the bitmap has to be drawn with an offset.
- int pxx = (xoff1_f - xoff1) * xscale / my_xscale;
- //qDebug() << "pxx:" << pxx << "pxy:" << pxy;
- int pxy = (yoff1_f - yoff1) * yscale / my_yscale;
+ int pxx = ((xoff1_f - xoff1) * xscale - (r1.u - _p1.u)) / my_xscale;
+ int pxy = ((yoff1_f - yoff1) * yscale - (r1.v - _p1.v)) / my_yscale;
// read 16bit elevation data from GeoTiff
QVector<qint16> data(w1*h1);
GDALRasterBand * pBand;
pBand = dataset->GetRasterBand(1);
- CPLErr err = pBand->RasterIO(GF_Read, xoff1, yoff1, w1, h1, data.data(),
w1, h1, GDT_Int16, 0, 0);
+ CPLErr err = pBand->RasterIO(GF_Read, xoff1, yoff1, std::min(w1, xsize_px
- xoff1),
+ std::min(h1, ysize_px - yoff1), data.data(),
w1, h1, GDT_Int16, 0, 0);
if(err == CE_Failure)
{
return;
--
1.7.6.1
From 230763319e38ef26f68e021d7055f04ea2fc76c1 Mon Sep 17 00:00:00 2001
From: Michael Klein <[email protected]>
Date: Sun, 9 Oct 2011 22:27:48 +0200
Subject: [PATCH 2/2] fix detail level of TDB overlay
---
src/CMapTDB.cpp | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/src/CMapTDB.cpp b/src/CMapTDB.cpp
index b877314..a0630ff 100644
--- a/src/CMapTDB.cpp
+++ b/src/CMapTDB.cpp
@@ -1859,13 +1859,8 @@ void CMapTDB::getArea_n_Scaling(XY& p1, XY& p2, float&
my_xscale, float& my_ysca
p1 = topLeft;
p2 = bottomRight;
- XY p3;
- p3.u = p1.u;
- p3.v = p2.v;
-
my_xscale = zoomFactor * lon_factor;
my_yscale = zoomFactor * lat_factor;
-
}
@@ -1959,7 +1954,7 @@ void CMapTDB::draw(const QSize& s, bool needsRedraw,
QPainter& p)
for(i=0; i < MAX_IDX_ZOOM; ++i)
{
- if(scales[i].scale <= sx) break;
+ if(scales[i].scale <= zoomFactor) break;
}
zoomidx = i;
--
1.7.6.1
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users