Skip to content

Commit

Permalink
Allow source raster *subpixel* positioning on map canvasses. This all…
Browse files Browse the repository at this point in the history
…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 001049b
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 82 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions qgis.kdevelop
Expand Up @@ -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>
15 changes: 10 additions & 5 deletions src/qgsmaptopixel.cpp
Expand Up @@ -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);
}

Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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;

Expand Down
12 changes: 8 additions & 4 deletions src/qgsmaptopixel.h
Expand Up @@ -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
Expand All @@ -102,7 +106,7 @@ class QgsMapToPixel{
QString showParameters();

private:
double mapUnitsPerPixel;
double mMapUnitsPerPixel;
double yMax;
double yMin;
double xMin;
Expand All @@ -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),
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 001049b

Please sign in to comment.