30#ifndef LABELPOSITION_H
31#define LABELPOSITION_H
88 double alpha,
double cost,
90 LabelDirectionToLine directionToLine = LabelDirectionToLine::SameDirection,
102 bool intersects(
const GEOSPreparedGeometry *geometry );
109 bool within(
const GEOSPreparedGeometry *geometry );
127 void getBoundingBox(
double amin[2],
double amax[2] )
const;
147 bool outerBoundingBoxIntersects(
const LabelPosition *other )
const;
156 double getDistanceToPoint(
double xp,
double yp,
bool useOuterBounds )
const;
163 bool crossesLine(
PointSet *line )
const;
170 bool crossesBoundary(
PointSet *polygon )
const;
176 int polygonIntersectionCost(
PointSet *polygon )
const;
183 bool intersectsWithPolygon(
PointSet *polygon )
const;
218 if ( mNextPart ) mNextPart->setProblemIds( probFid, lpId );
225 double cost()
const {
return mCost; }
232 void setCost(
double newCost ) { mCost = newCost; }
240 void setConflictsWithObstacle(
bool conflicts );
254 void setHasHardObstacleConflict(
bool conflicts );
271 double getX(
int i = 0 )
const;
277 double getY(
int i = 0 )
const;
285 double getAlpha()
const;
311 void setNextPart( std::unique_ptr< LabelPosition > next ) { mNextPart = std::move( next ); }
353 const GEOSPreparedGeometry *preparedMultiPartGeom()
const;
360 const GEOSPreparedGeometry *preparedOuterBoundsGeom()
const;
370 unsigned int globalId()
const {
return mGlobalId; }
383 double angleDifferential();
413 unsigned int mGlobalId = 0;
414 std::unique_ptr< LabelPosition > mNextPart;
416 std::vector< double > mOuterBoundsX;
417 std::vector< double > mOuterBoundsY;
419 double mOuterBoundsXMin = std::numeric_limits<double>::max();
420 double mOuterBoundsXMax = std::numeric_limits<double>::lowest();
421 double mOuterBoundsYMin = std::numeric_limits<double>::max();
422 double mOuterBoundsYMax = std::numeric_limits<double>::lowest();
425 const GEOSPreparedGeometry *mPreparedOuterBoundsGeos =
nullptr;
430 bool mHasObstacleConflict;
431 bool mHasHardConflict =
false;
432 int mUpsideDownCharCount;
437 int partCount()
const;
443 double polygonIntersectionCostForParts(
PointSet *polygon )
const;
448 void createMultiPartGeosGeom()
const;
452 void createOuterBoundsGeom();
A rtree spatial index for use in the pal labeling engine.
LabelQuadrantPosition
Label quadrant positions.
A rectangle specified with double values.
Represents a part of a label 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.
LabelPosition(int id, double x1, double y1, double w, double h, double alpha, double cost, FeaturePart *feature, LabelDirectionToLine directionToLine=LabelDirectionToLine::SameDirection, Qgis::LabelQuadrantPosition quadrant=Qgis::LabelQuadrantPosition::Over)
create a new LabelPosition
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.
friend class CostCalculator
friend class PolygonCostCalculator
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.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
struct GEOSGeom_t GEOSGeometry