QGIS API Documentation
3.0.2-Girona (307d082)
|
LabelPosition is a candidate feature label position. More...
#include <labelposition.h>
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 () override | |
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. If point lies inside, returns negative number. More... | |
FeaturePart * | getFeaturePart () |
return the feature corresponding to this labelposition More... | |
double | getHeight () const |
int | getId () const |
return id More... | |
LabelPosition * | getNextPart () const |
int | getNumOverlaps () const |
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... | |
int | incrementUpsideDownCharCount () |
Increases the count of upside down characters for this label position. More... | |
void | insertIntoIndex (RTree< LabelPosition *, double, 2, double > *index) |
bool | intersects (const GEOSPreparedGeometry *geometry) |
Returns true if the label position intersects a geometry. More... | |
bool | intersectsWithPolygon (PointSet *polygon) const |
Returns true if any intersection between polygon and position exists. 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... | |
int | polygonIntersectionCost (PointSet *polygon) const |
Returns cost of position intersection with polygon (testing area of intersection and center). More... | |
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... | |
int | upsideDownCharCount () const |
Returns the number of upside down characters for this label position. More... | |
void | validateCost () |
Make sure the cost is less than 1. More... | |
bool | within (const GEOSPreparedGeometry *geometry) |
Returns true if the label position is within a geometry. More... | |
Public Member Functions inherited from pal::PointSet | |
PointSet () | |
PointSet (int nbPoints, double *x, double *y) | |
virtual | ~PointSet () |
CHullBox * | compute_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... | |
PointSet * | extractShape (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 |
PointSet * | getHoleOf () |
Returns NULL if this isn't a hole. Otherwise returns pointer to parent pointset. 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... | |
bool | isClosed () const |
Returns true if pointset is closed. More... | |
double | length () const |
Returns length of line geometry. More... | |
double | minDistanceToPoint (double px, double py, double *rx=nullptr, double *ry=nullptr) 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 | countFullOverlapCallback (LabelPosition *lp, void *ctx) |
static bool | countOverlapCallback (LabelPosition *lp, void *ctx) |
static bool | polygonObstacleCallback (pal::FeaturePart *obstacle, void *ctx) |
static bool | pruneCallback (LabelPosition *candidatePosition, 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) |
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 |
FeaturePart * | feature = nullptr |
double | h |
int | id |
int | nbOverlap |
LabelPosition * | nextPart = nullptr |
int | partId |
int | probFeat |
LabelPosition::Quadrant | quadrant |
bool | reversed |
bool | upsideDown |
double | w |
Protected Attributes inherited from pal::PointSet | |
int * | cHull = nullptr |
int | cHullSize |
PointSet * | holeOf = nullptr |
GEOSGeometry * | mGeos = nullptr |
bool | mOwnsGeom = false |
int | nbPoints |
PointSet * | parent = nullptr |
int | type |
double * | x = nullptr |
double | xmax = -DBL_MAX |
double | xmin = DBL_MAX |
double * | y = nullptr |
double | ymax = -DBL_MAX |
double | ymin = DBL_MAX |
Friends | |
class | CostCalculator |
class | PolygonCostCalculator |
LabelPosition is a candidate feature label position.
Definition at line 55 of file labelposition.h.
Position of label candidate relative to feature.
Enumerator | |
---|---|
QuadrantAboveLeft | |
QuadrantAbove | |
QuadrantAboveRight | |
QuadrantLeft | |
QuadrantOver | |
QuadrantRight | |
QuadrantBelowLeft | |
QuadrantBelow | |
QuadrantBelowRight |
Definition at line 65 of file labelposition.h.
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
id | id of this labelposition |
x1 | down-left x coordinate |
y1 | down-left y coordinate |
w | label width |
h | label height |
alpha | rotation in rad |
cost | geographic cost |
feature | labelpos owners |
isReversed | label is reversed |
quadrant | relative position of label to feature |
Definition at line 43 of file labelposition.cpp.
LabelPosition::LabelPosition | ( | const LabelPosition & | other | ) |
Copy constructor.
Definition at line 140 of file labelposition.cpp.
|
inlineoverride |
Definition at line 100 of file labelposition.h.
|
inline |
Returns whether the position is marked as conflicting with an obstacle feature.
Definition at line 220 of file labelposition.h.
|
inline |
Returns the candidate label position's geographical cost.
Definition at line 199 of file labelposition.h.
|
static |
Definition at line 467 of file labelposition.cpp.
|
static |
Definition at line 455 of file labelposition.cpp.
bool LabelPosition::crossesBoundary | ( | PointSet * | polygon | ) | const |
Returns true if this label crosses the boundary of the specified polygon.
Definition at line 537 of file labelposition.cpp.
bool LabelPosition::crossesLine | ( | PointSet * | line | ) | const |
Returns true if this label crosses the specified line.
Definition at line 508 of file labelposition.cpp.
double LabelPosition::getAlpha | ( | ) | const |
void LabelPosition::getBoundingBox | ( | double | amin[2], |
double | amax[2] | ||
) | const |
Return bounding box - amin: xmin,ymin - amax: xmax,ymax.
Definition at line 371 of file labelposition.cpp.
double 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 496 of file labelposition.cpp.
FeaturePart * LabelPosition::getFeaturePart | ( | ) |
return the feature corresponding to this labelposition
Definition at line 366 of file labelposition.cpp.
|
inline |
Definition at line 238 of file labelposition.h.
int LabelPosition::getId | ( | ) | const |
|
inline |
Definition at line 249 of file labelposition.h.
|
inline |
Definition at line 180 of file labelposition.h.
|
inline |
Definition at line 253 of file labelposition.h.
|
inline |
Definition at line 183 of file labelposition.h.
|
inline |
Definition at line 248 of file labelposition.h.
|
inline |
Definition at line 245 of file labelposition.h.
|
inline |
Definition at line 246 of file labelposition.h.
|
inline |
Definition at line 237 of file labelposition.h.
double LabelPosition::getX | ( | int | i = 0 | ) | const |
get the down-left x coordinate
Definition at line 343 of file labelposition.cpp.
double LabelPosition::getY | ( | int | i = 0 | ) | const |
get the down-left y coordinate
Definition at line 348 of file labelposition.cpp.
|
inline |
Increases the count of upside down characters for this label position.
Definition at line 257 of file labelposition.h.
void LabelPosition::insertIntoIndex | ( | RTree< LabelPosition *, double, 2, double > * | index | ) |
Definition at line 427 of file labelposition.cpp.
bool LabelPosition::intersects | ( | const GEOSPreparedGeometry * | geometry | ) |
Returns true if the label position intersects a geometry.
Definition at line 199 of file labelposition.cpp.
bool LabelPosition::intersectsWithPolygon | ( | PointSet * | polygon | ) | const |
Returns true if any intersection between polygon and position exists.
Definition at line 575 of file labelposition.cpp.
bool LabelPosition::isIn | ( | double * | bbox | ) |
Is the labelposition in the bounding-box ? (intersect or inside????)
bbox | the bounding-box double[4] = {xmin, ymin, xmax, ymax} |
Definition at line 165 of file labelposition.cpp.
bool LabelPosition::isInConflict | ( | LabelPosition * | ls | ) |
Check whether or not this overlap with another labelPosition.
ls | other labelposition |
Definition at line 264 of file labelposition.cpp.
|
protected |
Definition at line 296 of file labelposition.cpp.
|
protected |
Definition at line 275 of file labelposition.cpp.
bool LabelPosition::isInside | ( | double * | bbox | ) |
Is the labelposition inside the bounding-box ?
bbox | the bounding-box double[4] = {xmin, ymin, xmax, ymax} |
Definition at line 249 of file labelposition.cpp.
bool LabelPosition::isIntersect | ( | double * | bbox | ) |
Is the labelposition intersect the bounding-box ?
bbox | the bounding-box double[4] = {xmin, ymin, xmax, ymax} |
Definition at line 182 of file labelposition.cpp.
void LabelPosition::offsetPosition | ( | double | xOffset, |
double | yOffset | ||
) |
Shift the label by specified offset.
Definition at line 324 of file labelposition.cpp.
int LabelPosition::polygonIntersectionCost | ( | PointSet * | polygon | ) | const |
Returns cost of position intersection with polygon (testing area of intersection and center).
Cost ranges between 0 and 12, with extra cost if center of label position is covered.
Definition at line 567 of file labelposition.cpp.
|
static |
Definition at line 404 of file labelposition.cpp.
|
static |
Check whether the candidate in ctx overlap with obstacle feat.
Definition at line 435 of file labelposition.cpp.
void LabelPosition::removeFromIndex | ( | RTree< LabelPosition *, double, 2, double > * | index | ) |
Definition at line 419 of file labelposition.cpp.
|
static |
Definition at line 483 of file labelposition.cpp.
|
inline |
Definition at line 181 of file labelposition.h.
void LabelPosition::setConflictsWithObstacle | ( | bool | conflicts | ) |
Sets whether the position is marked as conflicting with an obstacle feature.
conflicts | set to true to mark candidate as being in conflict |
Definition at line 397 of file labelposition.cpp.
|
inline |
Sets the candidate label position's geographical cost.
newCost | new cost for position |
Definition at line 206 of file labelposition.h.
|
inline |
Definition at line 250 of file labelposition.h.
|
inline |
Definition at line 254 of file labelposition.h.
|
inline |
Set problem feature ID and assigned label candidate ID.
called from pal.cpp during extraction
Definition at line 188 of file labelposition.h.
|
inline |
Returns the number of upside down characters for this label position.
Definition at line 260 of file labelposition.h.
void LabelPosition::validateCost | ( | ) |
Make sure the cost is less than 1.
Definition at line 358 of file labelposition.cpp.
bool LabelPosition::within | ( | const GEOSPreparedGeometry * | geometry | ) |
Returns true if the label position is within a geometry.
Definition at line 224 of file labelposition.cpp.
|
friend |
Definition at line 57 of file labelposition.h.
|
friend |
Definition at line 58 of file labelposition.h.
|
protected |
Definition at line 307 of file labelposition.h.
|
protected |
Definition at line 300 of file labelposition.h.
|
protected |
Definition at line 309 of file labelposition.h.
|
protected |
Definition at line 298 of file labelposition.h.
|
protected |
Definition at line 305 of file labelposition.h.
|
protected |
Definition at line 311 of file labelposition.h.
|
protected |
Definition at line 312 of file labelposition.h.
|
protected |
Definition at line 303 of file labelposition.h.
|
protected |
Definition at line 321 of file labelposition.h.
|
protected |
Definition at line 317 of file labelposition.h.
|
protected |
Definition at line 319 of file labelposition.h.
|
protected |
Definition at line 308 of file labelposition.h.