30#ifndef LABELPOSITION_H
31#define LABELPOSITION_H
58 friend class PolygonCostCalculator;
87 double alpha,
double cost,
89 LabelDirectionToLine directionToLine = LabelDirectionToLine::SameDirection,
101 bool intersects(
const GEOSPreparedGeometry *geometry );
108 bool within(
const GEOSPreparedGeometry *geometry );
126 void getBoundingBox(
double amin[2],
double amax[2] )
const;
146 bool outerBoundingBoxIntersects(
const LabelPosition *other )
const;
155 double getDistanceToPoint(
double xp,
double yp,
bool useOuterBounds )
const;
162 bool crossesLine(
PointSet *line )
const;
169 bool crossesBoundary(
PointSet *polygon )
const;
175 int polygonIntersectionCost(
PointSet *polygon )
const;
182 bool intersectsWithPolygon(
PointSet *polygon )
const;
217 if ( mNextPart ) mNextPart->setProblemIds( probFid, lpId );
224 double cost()
const {
return mCost; }
231 void setCost(
double newCost ) { mCost = newCost; }
239 void setConflictsWithObstacle(
bool conflicts );
253 void setHasHardObstacleConflict(
bool conflicts );
270 double getX(
int i = 0 )
const;
276 double getY(
int i = 0 )
const;
284 double getAlpha()
const;
310 void setNextPart( std::unique_ptr< LabelPosition > next ) { mNextPart = std::move( next ); }
352 const GEOSPreparedGeometry *preparedMultiPartGeom()
const;
359 const GEOSPreparedGeometry *preparedOuterBoundsGeom()
const;
369 unsigned int globalId()
const {
return mGlobalId; }
382 double angleDifferential();
412 unsigned int mGlobalId = 0;
413 std::unique_ptr< LabelPosition > mNextPart;
415 std::vector< double > mOuterBoundsX;
416 std::vector< double > mOuterBoundsY;
418 double mOuterBoundsXMin = std::numeric_limits<double>::max();
419 double mOuterBoundsXMax = std::numeric_limits<double>::lowest();
420 double mOuterBoundsYMin = std::numeric_limits<double>::max();
421 double mOuterBoundsYMax = std::numeric_limits<double>::lowest();
423 geos::unique_ptr mOuterBoundsGeos;
424 const GEOSPreparedGeometry *mPreparedOuterBoundsGeos =
nullptr;
427 bool mHasObstacleConflict;
428 bool mHasHardConflict =
false;
429 int mUpsideDownCharCount;
434 int partCount()
const;
440 double polygonIntersectionCostForParts(
PointSet *polygon )
const;
445 void createMultiPartGeosGeom()
const;
449 void createOuterBoundsGeom();
A rtree spatial index for use in the pal labeling engine.
LabelQuadrantPosition
Label quadrant positions.
A rectangle specified with double values.
Calculates label candidate costs considering different factors.
Main class to handle feature.
LabelPosition is a candidate feature label position.
void incrementNumOverlaps()
Increases the number of overlaps recorded against this position by 1.
bool hasHardObstacleConflict() const
Returns whether the position is marked as having a hard conflict with an obstacle feature.
void setNextPart(std::unique_ptr< LabelPosition > next)
Sets the next part of this label position (i.e.
void setCost(double newCost)
Sets the candidate label position's geographical cost.
double alpha
Rotation in radians.
int upsideDownCharCount() const
Returns the number of upside down characters for this label position.
void setGlobalId(unsigned int id)
Sets the global id for the candidate, which is unique for a single run of the pal labelling engine.
void decrementNumOverlaps()
Decreases the number of overlaps recorded against this position by 1.
double cost() const
Returns the candidate label position's geographical cost.
bool conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
int getNumOverlaps() const
void setProblemIds(int probFid, int lpId)
Set problem feature ID and assigned label candidate ID.
void setUpsideDownCharCount(int count)
Sets the count of upside down characters for this label position.
LabelDirectionToLine
Label directions in relation to line or polygon ring directions.
bool isReversedFromLineDirection() const
Returns true if the label direction is the reversed from the line or polygon ring direction.
unsigned int globalId() const
Returns the global ID for the candidate, which is unique for a single run of the pal labelling engine...
Qgis::LabelQuadrantPosition quadrant() const
Returns the quadrant associated with this label position.
int getProblemFeatureId() const
bool getUpsideDown() const
LabelPosition * nextPart() const
Returns the next part of this label position (i.e.
The underlying raw pal geometry class.
struct GEOSGeom_t GEOSGeometry