Skip to content

Commit

Permalink
Some fixes for graticule creation when origin is > endpoint
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8121 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 8, 2008
1 parent 3db89f1 commit 4cbb41d
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions src/plugins/grid_maker/graticulecreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,28 @@ void GraticuleCreator::generatePointGraticule(
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)
{
Expand All @@ -82,6 +99,22 @@ void GraticuleCreator::generatePointGraticule(
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"
Expand Down Expand Up @@ -175,11 +208,26 @@ void GraticuleCreator::generatePolygonGraticule(
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)
{
Expand Down

0 comments on commit 4cbb41d

Please sign in to comment.