[QGIS Commit] r8121 - trunk/qgis/src/plugins/grid_maker
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Feb 8 08:26:44 EST 2008
Author: timlinux
Date: 2008-02-08 08:26:43 -0500 (Fri, 08 Feb 2008)
New Revision: 8121
Modified:
trunk/qgis/src/plugins/grid_maker/graticulecreator.cpp
Log:
Some fixes for graticule creation when origin is > endpoint
Modified: trunk/qgis/src/plugins/grid_maker/graticulecreator.cpp
===================================================================
--- trunk/qgis/src/plugins/grid_maker/graticulecreator.cpp 2008-02-08 12:43:21 UTC (rev 8120)
+++ trunk/qgis/src/plugins/grid_maker/graticulecreator.cpp 2008-02-08 13:26:43 UTC (rev 8121)
@@ -61,11 +61,28 @@
mFields,
QGis::WKBPoint,
&mSRS);
+ //
+ // Order our loop so that it goes from smallest to biggest
+ //
+ if (theXEndPoint < theXOrigin)
+ {
+ double myBuffer = theXOrigin;
+ theXOrigin = theXEndPoint;
+ theXEndPoint = myBuffer;
+ }
+ if (theYEndPoint < theYOrigin)
+ {
+ double myBuffer = theYOrigin;
+ theYOrigin = theYEndPoint;
+ theYEndPoint = myBuffer;
+ }
+
+
for (double i=theXOrigin;
i<=theXEndPoint;
i+=theXInterval)
{
- for (double j=-theYOrigin;
+ for (double j=theYOrigin;
j<=theYEndPoint;
j+=theYInterval)
{
@@ -82,6 +99,22 @@
QgsFeature myFeature;
myFeature.setTypeName("WKBPoint");
myFeature.setGeometry(mypPointGeometry);
+ if (i==theXOrigin && j==theYEndPoint) //labels for bottom right corner
+ {
+ myFeature.addAttribute(0,i);//"LabelX"
+ myFeature.addAttribute(1,j);//"LabelY"
+ myFeature.addAttribute(2,-20);//"LabelOffsetX"
+ myFeature.addAttribute(3,-20);//"LabelOffsetY"
+ myFeature.addAttribute(4,QString::number(i) + "," + QString::number(j));//"Label"
+ }
+ else if (i==theXEndPoint && j==theYOrigin) //labels for top left corner
+ {
+ myFeature.addAttribute(0,i);//"LabelX"
+ myFeature.addAttribute(1,j);//"LabelY"
+ myFeature.addAttribute(2,20);//"LabelOffsetX"
+ myFeature.addAttribute(3,20);//"LabelOffsetY"
+ myFeature.addAttribute(4,QString::number(i) + "," + QString::number(j));//"Label"
+ }
if (i==theXOrigin && j==theYOrigin) //labels for bottom left corner
{
myFeature.addAttribute(0,i);//"LabelX"
@@ -175,11 +208,26 @@
mFields,
QGis::WKBPolygon,
&mSRS);
+ //
+ // Order our loop so that it goes from smallest to biggest
+ //
+ if (theXEndPoint < theXOrigin)
+ {
+ double myBuffer = theXOrigin;
+ theXOrigin = theXEndPoint;
+ theXEndPoint = myBuffer;
+ }
+ if (theYEndPoint < theYOrigin)
+ {
+ double myBuffer = theYOrigin;
+ theYOrigin = theYEndPoint;
+ theYEndPoint = myBuffer;
+ }
for (double i=theXOrigin;
i<=theXEndPoint;
i+=theXInterval)
{
- for (double j=-theYOrigin;
+ for (double j=theYOrigin;
j<=theYEndPoint;
j+=theYInterval)
{
More information about the QGIS-commit
mailing list