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

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

#include <labelposition.h>

Inheritance diagram for pal::LabelPosition:
Inheritance graph
[legend]

Classes

struct  CountContext
 
struct  PruneCtx
 

Public Types

enum  Quadrant {
  QuadrantAboveLeft, QuadrantAbove, QuadrantAboveRight, QuadrantLeft,
  QuadrantOver, QuadrantRight, QuadrantBelowLeft, QuadrantBelow,
  QuadrantBelowRight
}
 Position of label candidate relative to feature. More...
 

Public Member Functions

 LabelPosition (int id, double x1, double y1, double w, double h, double alpha, double cost, FeaturePart *feature, bool isReversed=false, Quadrant quadrant=QuadrantOver)
 create a new LabelPosition More...
 
 LabelPosition (const LabelPosition &other)
 Copy constructor. More...
 
 ~LabelPosition ()
 
bool conflictsWithObstacle () const
 Returns whether the position is marked as conflicting with an obstacle feature. More...
 
double cost () const
 Returns the candidate label position's geographical cost. More...
 
bool crossesBoundary (PointSet *polygon) const
 Returns true if this label crosses the boundary of the specified polygon. More...
 
bool crossesLine (PointSet *line) const
 Returns true if this label crosses the specified line. More...
 
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 getDistanceToPoint (double xp, double yp) const
 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...
 
QString getLayerName () const
 Return pointer to layer's name. More...
 
LabelPositiongetNextPart () const
 
double getNumOverlaps () const
 
int getNumPointsInPolygon (PointSet *polygon) const
 Returns number of intersections with polygon (testing border and center) More...
 
int getPartId () const
 
int getProblemFeatureId () const
 
Quadrant getQuadrant () 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 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 setConflictsWithObstacle (bool conflicts)
 Sets whether the position is marked as conflicting with an obstacle feature. More...
 
void setCost (double newCost)
 Sets the candidate label position's geographical 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...
 
- Public Member Functions inherited from pal::PointSet
 PointSet ()
 
 PointSet (int nbPoints, double *x, double *y)
 
virtual ~PointSet ()
 
CHullBoxcompute_chull_bbox ()
 
bool containsLabelCandidate (double x, double y, double width, double height, double alpha=0) const
 Tests whether a possible label candidate will fit completely within the shape. More...
 
bool containsPoint (double x, double y) const
 Tests whether point set contains a specified point. More...
 
PointSetextractShape (int nbPtSh, int imin, int imax, int fps, int fpe, double fptx, double fpty)
 
const GEOSGeometry * geos () const
 Returns the point set's GEOS geometry. More...
 
void getBoundingBox (double min[2], double max[2]) const
 
void getCentroid (double &px, double &py, bool forceInside=false) const
 
int getGeosType () const
 
PointSetgetHoleOf ()
 Returns NULL if this isn't a hole. More...
 
int getNumPoints () const
 
void getPointByDistance (double *d, double *ad, double dl, double *px, double *py)
 Get a point a set distance along a line geometry. More...
 
double length () const
 Returns length of line geometry. More...
 
double minDistanceToPoint (double px, double py, double *rx=0, double *ry=0) const
 Returns the squared minimum distance between the point set geometry and the point (px,py) Optionally, the nearest point is stored in (rx,ry). 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 (pal::FeaturePart *obstacle, 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)
 
- Static Public Member Functions inherited from pal::PointSet
static void splitPolygons (QLinkedList< PointSet * > &shapes_toProcess, QLinkedList< PointSet * > &shapes_final, double xrm, double yrm, const QString &uid)
 Split a concave shape into several convex shapes. More...
 

Protected Member Functions

bool isInConflictMultiPart (LabelPosition *lp)
 
bool isInConflictSinglePart (LabelPosition *lp)
 
- Protected Member Functions inherited from pal::PointSet
 PointSet (double x, double y)
 
 PointSet (const PointSet &ps)
 
void createGeosGeom () const
 
void deleteCoords ()
 
void invalidateGeos ()
 
const GEOSPreparedGeometry * preparedGeom () const
 

Protected Attributes

double alpha
 
FeaturePartfeature
 
double h
 
int id
 
int nbOverlap
 
LabelPositionnextPart
 
int partId
 
int probFeat
 
LabelPosition::Quadrant quadrant
 
bool reversed
 
bool upsideDown
 
double w
 
- Protected Attributes inherited from pal::PointSet
int * cHull
 
int cHullSize
 
PointSetholeOf
 
GEOSGeometry * mGeos
 
bool mOwnsGeom
 
int nbPoints
 
PointSetparent
 
int type
 
double * x
 
double xmax
 
double xmin
 
double * y
 
double ymax
 
double ymin
 

Friends

class CostCalculator
 
class PolygonCostCalculator
 

Detailed Description

LabelPosition is a candidate feature label position.

Definition at line 48 of file labelposition.h.

Member Enumeration Documentation

Position of label candidate relative to feature.

Enumerator
QuadrantAboveLeft 
QuadrantAbove 
QuadrantAboveRight 
QuadrantLeft 
QuadrantOver 
QuadrantRight 
QuadrantBelowLeft 
QuadrantBelow 
QuadrantBelowRight 

Definition at line 58 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,
Quadrant  quadrant = QuadrantOver 
)

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
quadrantrelative position of label to feature

Definition at line 52 of file labelposition.cpp.

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

Copy constructor.

Definition at line 169 of file labelposition.cpp.

pal::LabelPosition::~LabelPosition ( )
inline

Definition at line 93 of file labelposition.h.

Member Function Documentation

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

Returns whether the position is marked as conflicting with an obstacle feature.

See also
setConflictsWithObstacle

Definition at line 189 of file labelposition.h.

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

Returns the candidate label position's geographical cost.

See also
setCost

Definition at line 171 of file labelposition.h.

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

Definition at line 400 of file labelposition.cpp.

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

Definition at line 395 of file labelposition.cpp.

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

Definition at line 471 of file labelposition.cpp.

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

Definition at line 457 of file labelposition.cpp.

bool pal::LabelPosition::crossesBoundary ( PointSet polygon) const

Returns true if this label crosses the boundary of the specified polygon.

Definition at line 547 of file labelposition.cpp.

bool pal::LabelPosition::crossesLine ( PointSet line) const

Returns true if this label crosses the specified line.

Definition at line 518 of file labelposition.cpp.

double pal::LabelPosition::getAlpha ( ) const

get alpha

Returns
alpha to rotate text (in rad)

Definition at line 337 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 356 of file labelposition.cpp.

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

Get distance from this label to a point.

If point lies inside, returns negative number.

Definition at line 506 of file labelposition.cpp.

FeaturePart * pal::LabelPosition::getFeaturePart ( )

return the feature corresponding to this labelposition

Returns
the feature

Definition at line 351 of file labelposition.cpp.

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

Definition at line 206 of file labelposition.h.

int pal::LabelPosition::getId ( ) const

return id

Returns
id

Definition at line 322 of file labelposition.cpp.

QString pal::LabelPosition::getLayerName ( ) const

Return pointer to layer's name.

used for stats

Definition at line 383 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 153 of file labelposition.h.

int pal::LabelPosition::getNumPointsInPolygon ( PointSet polygon) const

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

Definition at line 577 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 156 of file labelposition.h.

Quadrant pal::LabelPosition::getQuadrant ( ) const
inline

Definition at line 216 of file labelposition.h.

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

Definition at line 213 of file labelposition.h.

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

Definition at line 214 of file labelposition.h.

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

Definition at line 205 of file labelposition.h.

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

get the down-left x coordinate

Returns
x coordinate

Definition at line 327 of file labelposition.cpp.

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

get the down-left y coordinate

Returns
y coordinate

Definition at line 332 of file labelposition.cpp.

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

Definition at line 431 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 193 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 256 of file labelposition.cpp.

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

Definition at line 288 of file labelposition.cpp.

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

Definition at line 267 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 228 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 211 of file labelposition.cpp.

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

Shift the label by specified offset.

Definition at line 308 of file labelposition.cpp.

bool pal::LabelPosition::polygonObstacleCallback ( pal::FeaturePart obstacle,
void *  ctx 
)
static

Definition at line 406 of file labelposition.cpp.

void pal::LabelPosition::print ( )

Definition at line 244 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 442 of file labelposition.cpp.

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

Definition at line 422 of file labelposition.cpp.

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

Definition at line 492 of file labelposition.cpp.

void pal::LabelPosition::resetNumOverlaps ( )
inline

Definition at line 154 of file labelposition.h.

void pal::LabelPosition::setConflictsWithObstacle ( bool  conflicts)

Sets whether the position is marked as conflicting with an obstacle feature.

Parameters
conflictsset to true to mark candidate as being in conflict
Note
This method applies to all label parts for the candidate position.
See also
conflictsWithObstacle

Definition at line 388 of file labelposition.cpp.

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

Sets the candidate label position's geographical cost.

Parameters
newCostnew cost for position
See also
cost

Definition at line 177 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 159 of file labelposition.h.

void pal::LabelPosition::validateCost ( )

Make sure the cost is less than 1.

Definition at line 342 of file labelposition.cpp.

Friends And Related Function Documentation

friend class CostCalculator
friend

Definition at line 50 of file labelposition.h.

friend class PolygonCostCalculator
friend

Definition at line 51 of file labelposition.h.

Member Data Documentation

double pal::LabelPosition::alpha
protected

Definition at line 277 of file labelposition.h.

FeaturePart* pal::LabelPosition::feature
protected

Definition at line 270 of file labelposition.h.

double pal::LabelPosition::h
protected

Definition at line 279 of file labelposition.h.

int pal::LabelPosition::id
protected

Definition at line 268 of file labelposition.h.

int pal::LabelPosition::nbOverlap
protected

Definition at line 275 of file labelposition.h.

LabelPosition* pal::LabelPosition::nextPart
protected

Definition at line 281 of file labelposition.h.

int pal::LabelPosition::partId
protected

Definition at line 282 of file labelposition.h.

int pal::LabelPosition::probFeat
protected

Definition at line 273 of file labelposition.h.

LabelPosition::Quadrant pal::LabelPosition::quadrant
protected

Definition at line 291 of file labelposition.h.

bool pal::LabelPosition::reversed
protected

Definition at line 287 of file labelposition.h.

bool pal::LabelPosition::upsideDown
protected

Definition at line 289 of file labelposition.h.

double pal::LabelPosition::w
protected

Definition at line 278 of file labelposition.h.


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