Skip to content

Commit 983edc9

Browse files
committed
Added settings to PAL for enable/disable partial shown labels
1 parent a1a95c1 commit 983edc9

File tree

5 files changed

+86
-5
lines changed

5 files changed

+86
-5
lines changed

src/core/pal/feature.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,7 +1361,12 @@ namespace pal
13611361
// purge candidates that are outside the bbox
13621362
for ( i = 0; i < nbp; i++ )
13631363
{
1364-
if ( !( *lPos )[i]->isIn( bbox ) )
1364+
bool outside = false;
1365+
if ( f->layer->pal->getShowPartial() )
1366+
outside = !( *lPos )[i]->isIntersect( bbox );
1367+
else
1368+
outside = !( *lPos )[i]->isInside( bbox );
1369+
if ( outside )
13651370
{
13661371
rnbp--;
13671372
( *lPos )[i]->setCost( DBL_MAX ); // infinite cost => do not use

src/core/pal/labelposition.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,39 @@ namespace pal
184184
return false;
185185

186186
}
187+
188+
bool LabelPosition::isIntersect( double *bbox )
189+
{
190+
int i;
191+
192+
for ( i = 0; i < 4; i++ )
193+
{
194+
if ( x[i] >= bbox[0] && x[i] <= bbox[2] &&
195+
y[i] >= bbox[1] && y[i] <= bbox[3] )
196+
return true;
197+
}
198+
199+
if ( nextPart )
200+
return nextPart->isIntersect( bbox );
201+
else
202+
return false;
203+
}
204+
205+
bool LabelPosition::isInside( double *bbox )
206+
{
207+
for (int i = 0; i < 4; i++ )
208+
{
209+
if ( !( x[i] >= bbox[0] && x[i] <= bbox[2] &&
210+
y[i] >= bbox[1] && y[i] <= bbox[3] ) )
211+
return false;
212+
}
213+
214+
if ( nextPart )
215+
return nextPart->isInside( bbox );
216+
else
217+
return true;
218+
219+
}
187220

188221
void LabelPosition::print()
189222
{

src/core/pal/labelposition.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,26 @@ namespace pal
109109

110110

111111
/**
112-
* \brief is the labelposition in the bounding-box ?
112+
* \brief Is the labelposition in the bounding-box ? (intersect or inside????)
113113
*
114114
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
115115
*/
116116
bool isIn( double *bbox );
117117

118+
/**
119+
* \brief Is the labelposition intersect the bounding-box ?
120+
*
121+
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
122+
*/
123+
bool isIntersect( double *bbox );
124+
125+
/**
126+
* \brief Is the labelposition inside the bounding-box ?
127+
*
128+
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
129+
*/
130+
bool isInside( double *bbox );
131+
118132
/**
119133
* \brief Check whether or not this overlap with another labelPosition
120134
*

src/core/pal/pal.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ namespace pal
106106
point_p = 8;
107107
line_p = 8;
108108
poly_p = 8;
109-
109+
110+
showPartial = true;
111+
110112
this->map_unit = pal::METER;
111113

112114
std::cout.precision( 12 );
@@ -899,6 +901,11 @@ namespace pal
899901
if ( dpi > 0 )
900902
this->dpi = dpi;
901903
}
904+
905+
void Pal::setShowPartial(bool show)
906+
{
907+
this->showPartial = show;
908+
}
902909

903910
int Pal::getPointP()
904911
{
@@ -929,6 +936,11 @@ namespace pal
929936
{
930937
return dpi;
931938
}
939+
940+
bool Pal::getShowPartial()
941+
{
942+
return showPartial;
943+
}
932944

933945
SearchMethod Pal::getSearch()
934946
{

src/core/pal/pal.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ namespace pal
166166
int ejChainDeg;
167167
int tenure;
168168
double candListSize;
169+
170+
/**
171+
* \brief show partial labels (cut-off by the map canvas) or not
172+
*/
173+
bool showPartial;
169174

170175
/**
171176
* \brief Problem factory
@@ -352,8 +357,20 @@ namespace pal
352357
* @return map resolution (dot per inch)
353358
*/
354359
int getDpi();
355-
356-
360+
361+
/**
362+
*\brief Set flag show partial label
363+
*
364+
* @param show flag value
365+
*/
366+
void setShowPartial(bool show);
367+
368+
/**
369+
* \brief Get flag show partial label
370+
*
371+
* @return value of flag
372+
*/
373+
bool getShowPartial();
357374

358375
/**
359376
* \brief set # candidates to generate for points features

0 commit comments

Comments
 (0)