QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
pal::LabelPosition Class Reference

LabelPositon is a candidate feature label position. More...

#include <labelposition.h>

Classes

struct  CountContext
 
struct  PruneCtx
 

Public Member Functions

 LabelPosition (int id, double x1, double y1, double w, double h, double alpha, double cost, FeaturePart *feature, bool isReversed=false)
 create a new LabelPosition More...
 
 LabelPosition (const LabelPosition &other)
 copy constructor More...
 
 ~LabelPosition ()
 
bool isIn (double *bbox)
 Is the labelposition in the bounding-box ? (intersect or inside????) More...
 
bool isIntersect (double *bbox)
 Is the labelposition intersect the bounding-box ? More...
 
bool isInside (double *bbox)
 Is the labelposition inside the bounding-box ? More...
 
bool isInConflict (LabelPosition *ls)
 Check whether or not this overlap with another labelPosition. More...
 
void getBoundingBox (double amin[2], double amax[2]) const
 return bounding box - amin: xmin,ymin - amax: xmax,ymax More...
 
double getDistanceToPoint (double xp, double yp)
 get distance from this label to a point. More...
 
bool isBorderCrossingLine (PointSet *feat)
 returns true if this label crosses the specified line More...
 
int getNumPointsInPolygon (int npol, double *xp, double *yp)
 returns number of intersections with polygon (testing border and center) More...
 
void offsetPosition (double xOffset, double yOffset)
 shift the label by specified offset More...
 
int getId () const
 return id More...
 
FeaturePartgetFeaturePart ()
 return the feature corresponding to this labelposition More...
 
double getNumOverlaps () const
 
void resetNumOverlaps ()
 
int getProblemFeatureId () const
 
void setProblemIds (int probFid, int lpId)
 set problem feature ID and assigned label candidate ID. More...
 
char * getLayerName () const
 return pointer to layer's name. More...
 
double getCost () const
 get the position geographical cost More...
 
void setCost (double newCost)
 Modify candidate's cost. More...
 
void validateCost ()
 Make sure the cost is less than 1. More...
 
double getX (int i=0) const
 get the down-left x coordinate More...
 
double getY (int i=0) const
 get the down-left y coordinate More...
 
double getWidth () const
 
double getHeight () const
 
double getAlpha () const
 get alpha More...
 
bool getReversed () const
 
bool getUpsideDown () const
 
void print ()
 
LabelPositiongetNextPart () const
 
void setNextPart (LabelPosition *next)
 
int getPartId () const
 
void setPartId (int id)
 
void removeFromIndex (RTree< LabelPosition *, double, 2, double > *index)
 
void insertIntoIndex (RTree< LabelPosition *, double, 2, double > *index)
 

Static Public Member Functions

static bool pruneCallback (LabelPosition *lp, void *ctx)
 Check whether the candidate in ctx overlap with obstacle feat. More...
 
static bool costShrink (void *l, void *r)
 
static bool costGrow (void *l, void *r)
 
static bool countOverlapCallback (LabelPosition *lp, void *ctx)
 
static bool countFullOverlapCallback (LabelPosition *lp, void *ctx)
 
static bool removeOverlapCallback (LabelPosition *lp, void *ctx)
 
static bool polygonObstacleCallback (PointSet *feat, void *ctx)
 

Protected Member Functions

bool isInConflictSinglePart (LabelPosition *lp)
 
bool isInConflictMultiPart (LabelPosition *lp)
 

Protected Attributes

int id
 
double cost
 
FeaturePartfeature
 
int probFeat
 
int nbOverlap
 
double x [4]
 
double y [4]
 
double alpha
 
double w
 
double h
 
LabelPositionnextPart
 
int partId
 
bool reversed
 
bool upsideDown
 

Friends

class CostCalculator
 
class PolygonCostCalculator
 

Detailed Description

LabelPositon is a candidate feature label position.

Constructor & Destructor Documentation

pal::LabelPosition::LabelPosition ( int  id,
double  x1,
double  y1,
double  w,
double  h,
double  alpha,
double  cost,
FeaturePart feature,
bool  isReversed = false 
)

create a new LabelPosition

Parameters
idid of this labelposition
x1down-left x coordinate
y1down-left y coordinate
wlabel width
hlabel height
alpharotation in rad
costgeographic cost
featurelabelpos owners
isReversedlabel is reversed
pal::LabelPosition::LabelPosition ( const LabelPosition other)

copy constructor

pal::LabelPosition::~LabelPosition ( )
inline

Member Function Documentation

bool pal::LabelPosition::costGrow ( void *  l,
void *  r 
)
static
bool pal::LabelPosition::costShrink ( void *  l,
void *  r 
)
static
bool pal::LabelPosition::countFullOverlapCallback ( LabelPosition lp,
void *  ctx 
)
static
bool pal::LabelPosition::countOverlapCallback ( LabelPosition lp,
void *  ctx 
)
static
double pal::LabelPosition::getAlpha ( ) const

get alpha

Returns
alpha to rotate text (in rad)
void pal::LabelPosition::getBoundingBox ( double  amin[2],
double  amax[2] 
) const

return bounding box - amin: xmin,ymin - amax: xmax,ymax

double pal::LabelPosition::getCost ( ) const

get the position geographical cost

Returns
geographical cost
double pal::LabelPosition::getDistanceToPoint ( double  xp,
double  yp 
)

get distance from this label to a point.

If point lies inside, returns negative number.

FeaturePart * pal::LabelPosition::getFeaturePart ( )

return the feature corresponding to this labelposition

Returns
the feature
double pal::LabelPosition::getHeight ( ) const
inline
int pal::LabelPosition::getId ( ) const

return id

Returns
id
char * pal::LabelPosition::getLayerName ( ) const

return pointer to layer's name.

used for stats

LabelPosition* pal::LabelPosition::getNextPart ( ) const
inline
double pal::LabelPosition::getNumOverlaps ( ) const
inline
int pal::LabelPosition::getNumPointsInPolygon ( int  npol,
double *  xp,
double *  yp 
)

returns number of intersections with polygon (testing border and center)

int pal::LabelPosition::getPartId ( ) const
inline
int pal::LabelPosition::getProblemFeatureId ( ) const
inline
bool pal::LabelPosition::getReversed ( ) const
inline
bool pal::LabelPosition::getUpsideDown ( ) const
inline
double pal::LabelPosition::getWidth ( ) const
inline
double pal::LabelPosition::getX ( int  i = 0) const

get the down-left x coordinate

Returns
x coordinate
double pal::LabelPosition::getY ( int  i = 0) const

get the down-left y coordinate

Returns
y coordinate
void pal::LabelPosition::insertIntoIndex ( RTree< LabelPosition *, double, 2, double > *  index)
bool pal::LabelPosition::isBorderCrossingLine ( PointSet feat)

returns true if this label crosses the specified line

bool pal::LabelPosition::isIn ( double *  bbox)

Is the labelposition in the bounding-box ? (intersect or inside????)

Parameters
bboxthe bounding-box double[4] = {xmin, ymin, xmax, ymax}
bool pal::LabelPosition::isInConflict ( LabelPosition ls)

Check whether or not this overlap with another labelPosition.

Parameters
lsother labelposition
Returns
true or false
bool pal::LabelPosition::isInConflictMultiPart ( LabelPosition lp)
protected
bool pal::LabelPosition::isInConflictSinglePart ( LabelPosition lp)
protected
bool pal::LabelPosition::isInside ( double *  bbox)

Is the labelposition inside the bounding-box ?

Parameters
bboxthe bounding-box double[4] = {xmin, ymin, xmax, ymax}
bool pal::LabelPosition::isIntersect ( double *  bbox)

Is the labelposition intersect the bounding-box ?

Parameters
bboxthe bounding-box double[4] = {xmin, ymin, xmax, ymax}
void pal::LabelPosition::offsetPosition ( double  xOffset,
double  yOffset 
)

shift the label by specified offset

bool pal::LabelPosition::polygonObstacleCallback ( PointSet feat,
void *  ctx 
)
static
void pal::LabelPosition::print ( )
bool pal::LabelPosition::pruneCallback ( LabelPosition lp,
void *  ctx 
)
static

Check whether the candidate in ctx overlap with obstacle feat.

void pal::LabelPosition::removeFromIndex ( RTree< LabelPosition *, double, 2, double > *  index)
bool pal::LabelPosition::removeOverlapCallback ( LabelPosition lp,
void *  ctx 
)
static
void pal::LabelPosition::resetNumOverlaps ( )
inline
void pal::LabelPosition::setCost ( double  newCost)
inline

Modify candidate's cost.

void pal::LabelPosition::setNextPart ( LabelPosition next)
inline
void pal::LabelPosition::setPartId ( int  id)
inline
void pal::LabelPosition::setProblemIds ( int  probFid,
int  lpId 
)
inline

set problem feature ID and assigned label candidate ID.

called from pal.cpp during extraction

void pal::LabelPosition::validateCost ( )

Make sure the cost is less than 1.

Friends And Related Function Documentation

friend class CostCalculator
friend
friend class PolygonCostCalculator
friend

Member Data Documentation

double pal::LabelPosition::alpha
protected
double pal::LabelPosition::cost
protected
FeaturePart* pal::LabelPosition::feature
protected
double pal::LabelPosition::h
protected
int pal::LabelPosition::id
protected
int pal::LabelPosition::nbOverlap
protected
LabelPosition* pal::LabelPosition::nextPart
protected
int pal::LabelPosition::partId
protected
int pal::LabelPosition::probFeat
protected
bool pal::LabelPosition::reversed
protected
bool pal::LabelPosition::upsideDown
protected
double pal::LabelPosition::w
protected
double pal::LabelPosition::x[4]
protected
double pal::LabelPosition::y[4]
protected

The documentation for this class was generated from the following files: