Skip to content

Commit 4cbb41d

Browse files
author
timlinux
committedFeb 8, 2008

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed
 

‎src/plugins/grid_maker/graticulecreator.cpp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,28 @@ void GraticuleCreator::generatePointGraticule(
6161
mFields,
6262
QGis::WKBPoint,
6363
&mSRS);
64+
//
65+
// Order our loop so that it goes from smallest to biggest
66+
//
67+
if (theXEndPoint < theXOrigin)
68+
{
69+
double myBuffer = theXOrigin;
70+
theXOrigin = theXEndPoint;
71+
theXEndPoint = myBuffer;
72+
}
73+
if (theYEndPoint < theYOrigin)
74+
{
75+
double myBuffer = theYOrigin;
76+
theYOrigin = theYEndPoint;
77+
theYEndPoint = myBuffer;
78+
}
79+
80+
6481
for (double i=theXOrigin;
6582
i<=theXEndPoint;
6683
i+=theXInterval)
6784
{
68-
for (double j=-theYOrigin;
85+
for (double j=theYOrigin;
6986
j<=theYEndPoint;
7087
j+=theYInterval)
7188
{
@@ -82,6 +99,22 @@ void GraticuleCreator::generatePointGraticule(
8299
QgsFeature myFeature;
83100
myFeature.setTypeName("WKBPoint");
84101
myFeature.setGeometry(mypPointGeometry);
102+
if (i==theXOrigin && j==theYEndPoint) //labels for bottom right corner
103+
{
104+
myFeature.addAttribute(0,i);//"LabelX"
105+
myFeature.addAttribute(1,j);//"LabelY"
106+
myFeature.addAttribute(2,-20);//"LabelOffsetX"
107+
myFeature.addAttribute(3,-20);//"LabelOffsetY"
108+
myFeature.addAttribute(4,QString::number(i) + "," + QString::number(j));//"Label"
109+
}
110+
else if (i==theXEndPoint && j==theYOrigin) //labels for top left corner
111+
{
112+
myFeature.addAttribute(0,i);//"LabelX"
113+
myFeature.addAttribute(1,j);//"LabelY"
114+
myFeature.addAttribute(2,20);//"LabelOffsetX"
115+
myFeature.addAttribute(3,20);//"LabelOffsetY"
116+
myFeature.addAttribute(4,QString::number(i) + "," + QString::number(j));//"Label"
117+
}
85118
if (i==theXOrigin && j==theYOrigin) //labels for bottom left corner
86119
{
87120
myFeature.addAttribute(0,i);//"LabelX"
@@ -175,11 +208,26 @@ void GraticuleCreator::generatePolygonGraticule(
175208
mFields,
176209
QGis::WKBPolygon,
177210
&mSRS);
211+
//
212+
// Order our loop so that it goes from smallest to biggest
213+
//
214+
if (theXEndPoint < theXOrigin)
215+
{
216+
double myBuffer = theXOrigin;
217+
theXOrigin = theXEndPoint;
218+
theXEndPoint = myBuffer;
219+
}
220+
if (theYEndPoint < theYOrigin)
221+
{
222+
double myBuffer = theYOrigin;
223+
theYOrigin = theYEndPoint;
224+
theYEndPoint = myBuffer;
225+
}
178226
for (double i=theXOrigin;
179227
i<=theXEndPoint;
180228
i+=theXInterval)
181229
{
182-
for (double j=-theYOrigin;
230+
for (double j=theYOrigin;
183231
j<=theYEndPoint;
184232
j+=theYInterval)
185233
{

0 commit comments

Comments
 (0)
Please sign in to comment.