Skip to content
Permalink
Browse files
Allow source raster *subpixel* positioning on map canvasses. This all…
…ows zooming in on coarse rasters to be accurate (i.e. when 1 source pixel covers more than one screen pixel). This has only been proof-of-concept tested, therefore the author will not be offended if further refinements are committed. This addresses CVS bug 895502.

git-svn-id: http://svn.osgeo.org/qgis/trunk@3396 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed May 15, 2005
1 parent de40711 commit 001049be3e0eb71d0de5f541adc69e6e4983d776
Showing with 397 additions and 82 deletions.
  1. +8 −0 ChangeLog
  2. +1 −1 configure.in
  3. +8 −0 qgis.kdevelop
  4. +10 −5 src/qgsmaptopixel.cpp
  5. +8 −4 src/qgsmaptopixel.h
  6. +320 −48 src/qgsrasterlayer.cpp
  7. +42 −24 src/qgsrasterlayer.h
@@ -3,6 +3,14 @@
Version 0.6 'Simon' .... development version
QGIS Change Log

2005-05-15 [morb_au] 0.6devel21
** Fixed a memory leak in the postgres provider when retrieving features
** Raster layers now align to the map canvas with subpixel source accuracy
(most useful when zooming in very close and the source pixels cover many
screen pixels)

0.6devel20 ?

2005-05-13 [didge] 0.6devel19
** Tweaked makefile stuff and prepared for a release
2005-04-17 [mcoletti] 0.6devel18
@@ -25,7 +25,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=6
MICRO_VERSION=0
EXTRA_VERSION=20
EXTRA_VERSION=21
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
@@ -175,6 +175,14 @@
<tree>
<hidepatterns>*.o,*.lo,CVS</hidepatterns>
<hidenonprojectfiles>false</hidenonprojectfiles>
<showvcsfields>false</showvcsfields>
</tree>
</kdevfileview>
<kdevcvsservice>
<recursivewhenupdate>true</recursivewhenupdate>
<prunedirswhenupdate>true</prunedirswhenupdate>
<createdirswhenupdate>true</createdirswhenupdate>
<recursivewhencommitremove>true</recursivewhencommitremove>
<revertoptions>-C</revertoptions>
</kdevcvsservice>
</kdevelop>
@@ -22,8 +22,8 @@

QgsPoint QgsMapToPixel::toMapPoint(int x, int y)
{
double mx = x * mapUnitsPerPixel + xMin;
double my = -1 * ((y - yMax) * mapUnitsPerPixel - yMin);
double mx = x * mMapUnitsPerPixel + xMin;
double my = -1 * ((y - yMax) * mMapUnitsPerPixel - yMin);
return QgsPoint(mx, my);
}

@@ -40,7 +40,12 @@ QgsPoint QgsMapToPixel::toMapCoordinates(int x, int y)

void QgsMapToPixel::setMapUnitsPerPixel(double mupp)
{
mapUnitsPerPixel = mupp;
mMapUnitsPerPixel = mupp;
}

double QgsMapToPixel::mapUnitsPerPixel()
{
return mMapUnitsPerPixel;
}

void QgsMapToPixel::setYmax(double ymax)
@@ -60,7 +65,7 @@ void QgsMapToPixel::setXmin(double xmin)

void QgsMapToPixel::setParameters(double mupp, double xmin, double ymin, double ymax)
{
mapUnitsPerPixel = mupp;
mMapUnitsPerPixel = mupp;
xMin = xmin;
yMin = ymin;
yMax = ymax;
@@ -70,7 +75,7 @@ void QgsMapToPixel::setParameters(double mupp, double xmin, double ymin, double
QString QgsMapToPixel::showParameters()
{
QString rep;
QTextOStream(&rep) << "Map units/pixel: " << mapUnitsPerPixel
QTextOStream(&rep) << "Map units/pixel: " << mMapUnitsPerPixel
<< " X minimum: " << xMin << " Y minimum: " << yMin << " Y maximum: " << yMax;
return rep;

@@ -85,6 +85,10 @@ class QgsMapToPixel{
* @param mupp Map units per pixel
*/
void setMapUnitsPerPixel(double mupp);

//! Return current map units per pixel
double mapUnitsPerPixel();

//! Set maximum y value
void setYmax(double ymax);
//! Set minimum y value
@@ -102,7 +106,7 @@ class QgsMapToPixel{
QString showParameters();

private:
double mapUnitsPerPixel;
double mMapUnitsPerPixel;
double yMax;
double yMin;
double xMin;
@@ -114,7 +118,7 @@ inline QgsMapToPixel::QgsMapToPixel(double mupp,
double ymax,
double ymin,
double xmin)
: mapUnitsPerPixel(mupp),
: mMapUnitsPerPixel(mupp),
yMax(ymax),
yMin(ymin),
xMin(xmin),
@@ -156,8 +160,8 @@ inline void QgsMapToPixel::transform(QgsPoint* p)

inline void QgsMapToPixel::transformInPlace(double& x, double& y)
{
x = (x - xMin) / mapUnitsPerPixel;
y = yMax - (y - yMin) / mapUnitsPerPixel;
x = (x - xMin) / mMapUnitsPerPixel;
y = yMax - (y - yMin) / mMapUnitsPerPixel;
}

inline void QgsMapToPixel::transformInPlace(std::vector<double>& x,

0 comments on commit 001049b

Please sign in to comment.