LabelPosition class
LabelPosition is a candidate feature label position.
Contents
Base classes
- class PointSet
Public types
- enum Quadrant { QuadrantAboveLeft, QuadrantAbove, QuadrantAboveRight, QuadrantLeft, QuadrantOver, QuadrantRight, QuadrantBelowLeft, QuadrantBelow, QuadrantBelowRight }
- Position of label candidate relative to feature.
Public static functions
- static auto pruneCallback(LabelPosition* candidatePosition, void* ctx) -> bool
- Check whether the candidate in ctx overlap with obstacle feat.
Constructors, destructors, conversion operators
- 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
- LabelPosition(const LabelPosition& other)
- Copy constructor.
Public functions
- auto conflictsWithObstacle() const -> bool
- Returns whether the position is marked as conflicting with an obstacle feature.
- auto cost() const -> double
- Returns the candidate label position's geographical cost.
- auto crossesBoundary(PointSet* polygon) const -> bool
- Returns true if this label crosses the boundary of the specified polygon.
- auto crossesLine(PointSet* line) const -> bool
- Returns true if this label crosses the specified line.
- auto getAlpha() const -> double
- Returns the angle to rotate text (in rad).
- void getBoundingBox(double amin[2], double amax[2]) const
- Returns bounding box - amin: xmin,ymin - amax: xmax,ymax.
- auto getDistanceToPoint(double xp, double yp) const -> double
- Gets distance from this label to a point. If point lies inside, returns negative number.
- auto getFeaturePart() -> FeaturePart*
- Returns the feature corresponding to this labelposition.
- auto getId() const -> int
- Returns the id.
- auto getX(int i = 0) const -> double
- Returns the down-left x coordinate.
- auto getY(int i = 0) const -> double
- Returns the down-left y coordinate.
- auto incrementUpsideDownCharCount() -> int
- Increases the count of upside down characters for this label position.
- auto intersects(const GEOSPreparedGeometry* geometry) -> bool
- Returns true if the label position intersects a geometry.
- auto intersectsWithPolygon(PointSet* polygon) const -> bool
- Returns true if any intersection between polygon and position exists.
- auto isIn(double* bbox) -> bool
- Is the labelposition in the bounding-box ? (intersect or inside????)
- auto isInConflict(LabelPosition* ls) -> bool
- Check whether or not this overlap with another labelPosition.
- auto isInside(double* bbox) -> bool
- Is the labelposition inside the bounding-box ?
- auto isIntersect(double* bbox) -> bool
- Is the labelposition intersect the bounding-box ?
- void offsetPosition(double xOffset, double yOffset)
- Shift the label by specified offset.
- auto polygonIntersectionCost(PointSet* polygon) const -> int
- Returns cost of position intersection with polygon (testing area of intersection and center).
- void setConflictsWithObstacle(bool conflicts)
- Sets whether the position is marked as conflicting with an obstacle feature.
- void setCost(double newCost)
- Sets the candidate label position's geographical cost.
- void setProblemIds(int probFid, int lpId)
- Set problem feature ID and assigned label candidate ID.
- auto upsideDownCharCount() const -> int
- Returns the number of upside down characters for this label position.
- void validateCost()
- Make sure the cost is less than 1.
- auto within(const GEOSPreparedGeometry* geometry) -> bool
- Returns true if the label position is within a geometry.
Function 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 | |
|---|---|
| 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 |
bool pal:: LabelPosition:: conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
double pal:: LabelPosition:: cost() const
Returns the candidate label position's geographical cost.
double pal:: LabelPosition:: getX(int i = 0) const
Returns the down-left x coordinate.
double pal:: LabelPosition:: getY(int i = 0) const
Returns the down-left y coordinate.
bool pal:: LabelPosition:: isIn(double* bbox)
Is the labelposition in the bounding-box ? (intersect or inside????)
| Parameters | |
|---|---|
| bbox | the bounding-box double[4] = {xmin, ymin, xmax, ymax} |
bool pal:: LabelPosition:: isInConflict(LabelPosition* ls)
Check whether or not this overlap with another labelPosition.
| Parameters | |
|---|---|
| ls | other labelposition |
| Returns | true or false |
bool pal:: LabelPosition:: isInside(double* bbox)
Is the labelposition inside the bounding-box ?
| Parameters | |
|---|---|
| bbox | the bounding-box double[4] = {xmin, ymin, xmax, ymax} |
bool pal:: LabelPosition:: isIntersect(double* bbox)
Is the labelposition intersect the bounding-box ?
| Parameters | |
|---|---|
| bbox | the bounding-box double[4] = {xmin, ymin, xmax, ymax} |
int pal:: 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.
void pal:: LabelPosition:: setConflictsWithObstacle(bool conflicts)
Sets whether the position is marked as conflicting with an obstacle feature.
| Parameters | |
|---|---|
| conflicts | set to true to mark candidate as being in conflict |
void pal:: LabelPosition:: setCost(double newCost)
Sets the candidate label position's geographical cost.
| Parameters | |
|---|---|
| newCost | new cost for position |
void pal:: LabelPosition:: setProblemIds(int probFid,
int lpId)
Set problem feature ID and assigned label candidate ID.
called from pal.cpp during extraction