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

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

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

Friends

class CostCalculator
 
class PolygonCostCalculator
 

Detailed Description

LabelPositon is a candidate feature label position.

Definition at line 53 of file labelposition.h.

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

Definition at line 57 of file labelposition.cpp.

pal::LabelPosition::LabelPosition ( const LabelPosition other)

copy constructor

Definition at line 148 of file labelposition.cpp.

pal::LabelPosition::~LabelPosition ( )
inline

Definition at line 109 of file labelposition.h.

Member Function Documentation

bool pal::LabelPosition::costGrow ( void *  l,
void *  r 
)
static

Definition at line 391 of file labelposition.cpp.

bool pal::LabelPosition::costShrink ( void *  l,
void *  r 
)
static

Definition at line 386 of file labelposition.cpp.

bool pal::LabelPosition::countFullOverlapCallback ( LabelPosition lp,
void *  ctx 
)
static

Definition at line 462 of file labelposition.cpp.

bool pal::LabelPosition::countOverlapCallback ( LabelPosition lp,
void *  ctx 
)
static

Definition at line 448 of file labelposition.cpp.

double pal::LabelPosition::getAlpha ( ) const

get alpha

Returns
alpha to rotate text (in rad)

Definition at line 330 of file labelposition.cpp.

void pal::LabelPosition::getBoundingBox ( double  amin[2],
double  amax[2] 
) const

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

Definition at line 354 of file labelposition.cpp.

double pal::LabelPosition::getCost ( ) const

get the position geographical cost

Returns
geographical cost

Definition at line 335 of file labelposition.cpp.

double pal::LabelPosition::getDistanceToPoint ( double  xp,
double  yp 
)

get distance from this label to a point.

If point lies inside, returns negative number.

Definition at line 499 of file labelposition.cpp.

FeaturePart * pal::LabelPosition::getFeaturePart ( )

return the feature corresponding to this labelposition

Returns
the feature

Definition at line 349 of file labelposition.cpp.

double pal::LabelPosition::getHeight ( ) const
inline

Definition at line 208 of file labelposition.h.

int pal::LabelPosition::getId ( ) const

return id

Returns
id

Definition at line 315 of file labelposition.cpp.

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

return pointer to layer's name.

used for stats

Definition at line 381 of file labelposition.cpp.

LabelPosition* pal::LabelPosition::getNextPart ( ) const
inline

Definition at line 220 of file labelposition.h.

double pal::LabelPosition::getNumOverlaps ( ) const
inline

Definition at line 168 of file labelposition.h.

int pal::LabelPosition::getNumPointsInPolygon ( int  npol,
double *  xp,
double *  yp 
)

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

Definition at line 583 of file labelposition.cpp.

int pal::LabelPosition::getPartId ( ) const
inline

Definition at line 224 of file labelposition.h.

int pal::LabelPosition::getProblemFeatureId ( ) const
inline

Definition at line 171 of file labelposition.h.

bool pal::LabelPosition::getReversed ( ) const
inline

Definition at line 215 of file labelposition.h.

bool pal::LabelPosition::getUpsideDown ( ) const
inline

Definition at line 216 of file labelposition.h.

double pal::LabelPosition::getWidth ( ) const
inline

Definition at line 207 of file labelposition.h.

double pal::LabelPosition::getX ( int  i = 0) const

get the down-left x coordinate

Returns
x coordinate

Definition at line 320 of file labelposition.cpp.

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

get the down-left y coordinate

Returns
y coordinate

Definition at line 325 of file labelposition.cpp.

void pal::LabelPosition::insertIntoIndex ( RTree< LabelPosition *, double, 2, double > *  index)

Definition at line 422 of file labelposition.cpp.

bool pal::LabelPosition::isBorderCrossingLine ( PointSet feat)

returns true if this label crosses the specified line

Definition at line 553 of file labelposition.cpp.

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}

Definition at line 171 of file labelposition.cpp.

bool pal::LabelPosition::isInConflict ( LabelPosition ls)

Check whether or not this overlap with another labelPosition.

Parameters
lsother labelposition
Returns
true or false

Definition at line 234 of file labelposition.cpp.

bool pal::LabelPosition::isInConflictMultiPart ( LabelPosition lp)
protected

Definition at line 282 of file labelposition.cpp.

bool pal::LabelPosition::isInConflictSinglePart ( LabelPosition lp)
protected

Definition at line 245 of file labelposition.cpp.

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

Is the labelposition inside the bounding-box ?

Parameters
bboxthe bounding-box double[4] = {xmin, ymin, xmax, ymax}

Definition at line 206 of file labelposition.cpp.

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

Is the labelposition intersect the bounding-box ?

Parameters
bboxthe bounding-box double[4] = {xmin, ymin, xmax, ymax}

Definition at line 189 of file labelposition.cpp.

void pal::LabelPosition::offsetPosition ( double  xOffset,
double  yOffset 
)

shift the label by specified offset

Definition at line 302 of file labelposition.cpp.

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

Definition at line 397 of file labelposition.cpp.

void pal::LabelPosition::print ( )

Definition at line 222 of file labelposition.cpp.

bool pal::LabelPosition::pruneCallback ( LabelPosition lp,
void *  ctx 
)
static

Check whether the candidate in ctx overlap with obstacle feat.

Definition at line 433 of file labelposition.cpp.

void pal::LabelPosition::removeFromIndex ( RTree< LabelPosition *, double, 2, double > *  index)

Definition at line 413 of file labelposition.cpp.

bool pal::LabelPosition::removeOverlapCallback ( LabelPosition lp,
void *  ctx 
)
static

Definition at line 483 of file labelposition.cpp.

void pal::LabelPosition::resetNumOverlaps ( )
inline

Definition at line 169 of file labelposition.h.

void pal::LabelPosition::setCost ( double  newCost)
inline

Modify candidate's cost.

Definition at line 190 of file labelposition.h.

void pal::LabelPosition::setNextPart ( LabelPosition next)
inline

Definition at line 221 of file labelposition.h.

void pal::LabelPosition::setPartId ( int  id)
inline

Definition at line 225 of file labelposition.h.

void pal::LabelPosition::setProblemIds ( int  probFid,
int  lpId 
)
inline

set problem feature ID and assigned label candidate ID.

called from pal.cpp during extraction

Definition at line 174 of file labelposition.h.

void pal::LabelPosition::validateCost ( )

Make sure the cost is less than 1.

Definition at line 340 of file labelposition.cpp.

Friends And Related Function Documentation

friend class CostCalculator
friend

Definition at line 55 of file labelposition.h.

friend class PolygonCostCalculator
friend

Definition at line 56 of file labelposition.h.

Member Data Documentation

double pal::LabelPosition::alpha
protected

Definition at line 70 of file labelposition.h.

double pal::LabelPosition::cost
protected

Definition at line 61 of file labelposition.h.

FeaturePart* pal::LabelPosition::feature
protected

Definition at line 62 of file labelposition.h.

double pal::LabelPosition::h
protected

Definition at line 72 of file labelposition.h.

int pal::LabelPosition::id
protected

Definition at line 60 of file labelposition.h.

int pal::LabelPosition::nbOverlap
protected

Definition at line 67 of file labelposition.h.

LabelPosition* pal::LabelPosition::nextPart
protected

Definition at line 74 of file labelposition.h.

int pal::LabelPosition::partId
protected

Definition at line 75 of file labelposition.h.

int pal::LabelPosition::probFeat
protected

Definition at line 65 of file labelposition.h.

bool pal::LabelPosition::reversed
protected

Definition at line 80 of file labelposition.h.

bool pal::LabelPosition::upsideDown
protected

Definition at line 82 of file labelposition.h.

double pal::LabelPosition::w
protected

Definition at line 71 of file labelposition.h.

double pal::LabelPosition::x[4]
protected

Definition at line 69 of file labelposition.h.

double pal::LabelPosition::y[4]
protected

Definition at line 69 of file labelposition.h.


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