Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added settings to PAL for enable/disable partial shown labels
  • Loading branch information
yellow-sky committed Sep 15, 2013
1 parent a1a95c1 commit 983edc9
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -1361,7 +1361,12 @@ namespace pal
// purge candidates that are outside the bbox
for ( i = 0; i < nbp; i++ )
{
if ( !( *lPos )[i]->isIn( bbox ) )
bool outside = false;
if ( f->layer->pal->getShowPartial() )
outside = !( *lPos )[i]->isIntersect( bbox );
else
outside = !( *lPos )[i]->isInside( bbox );
if ( outside )
{
rnbp--;
( *lPos )[i]->setCost( DBL_MAX ); // infinite cost => do not use
Expand Down
33 changes: 33 additions & 0 deletions src/core/pal/labelposition.cpp
Expand Up @@ -184,6 +184,39 @@ namespace pal
return false;

}

bool LabelPosition::isIntersect( double *bbox )
{
int i;

for ( i = 0; i < 4; i++ )
{
if ( x[i] >= bbox[0] && x[i] <= bbox[2] &&
y[i] >= bbox[1] && y[i] <= bbox[3] )
return true;
}

if ( nextPart )
return nextPart->isIntersect( bbox );
else
return false;
}

bool LabelPosition::isInside( double *bbox )
{
for (int i = 0; i < 4; i++ )
{
if ( !( x[i] >= bbox[0] && x[i] <= bbox[2] &&
y[i] >= bbox[1] && y[i] <= bbox[3] ) )
return false;
}

if ( nextPart )
return nextPart->isInside( bbox );
else
return true;

}

void LabelPosition::print()
{
Expand Down
16 changes: 15 additions & 1 deletion src/core/pal/labelposition.h
Expand Up @@ -109,12 +109,26 @@ namespace pal


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

/**
* \brief Is the labelposition intersect the bounding-box ?
*
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
*/
bool isIntersect( double *bbox );

/**
* \brief Is the labelposition inside the bounding-box ?
*
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
*/
bool isInside( double *bbox );

/**
* \brief Check whether or not this overlap with another labelPosition
*
Expand Down
14 changes: 13 additions & 1 deletion src/core/pal/pal.cpp
Expand Up @@ -106,7 +106,9 @@ namespace pal
point_p = 8;
line_p = 8;
poly_p = 8;


showPartial = true;

this->map_unit = pal::METER;

std::cout.precision( 12 );
Expand Down Expand Up @@ -899,6 +901,11 @@ namespace pal
if ( dpi > 0 )
this->dpi = dpi;
}

void Pal::setShowPartial(bool show)
{
this->showPartial = show;
}

int Pal::getPointP()
{
Expand Down Expand Up @@ -929,6 +936,11 @@ namespace pal
{
return dpi;
}

bool Pal::getShowPartial()
{
return showPartial;
}

SearchMethod Pal::getSearch()
{
Expand Down
21 changes: 19 additions & 2 deletions src/core/pal/pal.h
Expand Up @@ -166,6 +166,11 @@ namespace pal
int ejChainDeg;
int tenure;
double candListSize;

/**
* \brief show partial labels (cut-off by the map canvas) or not
*/
bool showPartial;

/**
* \brief Problem factory
Expand Down Expand Up @@ -352,8 +357,20 @@ namespace pal
* @return map resolution (dot per inch)
*/
int getDpi();



/**
*\brief Set flag show partial label
*
* @param show flag value
*/
void setShowPartial(bool show);

/**
* \brief Get flag show partial label
*
* @return value of flag
*/
bool getShowPartial();

/**
* \brief set # candidates to generate for points features
Expand Down

0 comments on commit 983edc9

Please sign in to comment.