30#ifndef LABELPOSITION_H
31#define LABELPOSITION_H
58 friend class PolygonCostCalculator;
94 double alpha,
double cost,
95 FeaturePart *feature,
bool isReversed =
false, Quadrant quadrant = QuadrantOver );
107 bool intersects(
const GEOSPreparedGeometry *geometry );
114 bool within(
const GEOSPreparedGeometry *geometry );
131 void getBoundingBox(
double amin[2],
double amax[2] )
const;
137 bool outerBoundingBoxIntersects(
const LabelPosition *other )
const;
146 double getDistanceToPoint(
double xp,
double yp,
bool useOuterBounds )
const;
153 bool crossesLine(
PointSet *line )
const;
160 bool crossesBoundary(
PointSet *polygon )
const;
166 int polygonIntersectionCost(
PointSet *polygon )
const;
173 bool intersectsWithPolygon(
PointSet *polygon )
const;
208 if ( mNextPart ) mNextPart->setProblemIds( probFid, lpId );
215 double cost()
const {
return mCost; }
222 void setCost(
double newCost ) { mCost = newCost; }
230 void setConflictsWithObstacle(
bool conflicts );
244 void setHasHardObstacleConflict(
bool conflicts );
261 double getX(
int i = 0 )
const;
267 double getY(
int i = 0 )
const;
275 double getAlpha()
const;
293 void setNextPart( std::unique_ptr< LabelPosition > next ) { mNextPart = std::move( next ); }
328 const GEOSPreparedGeometry *preparedMultiPartGeom()
const;
335 const GEOSPreparedGeometry *preparedOuterBoundsGeom()
const;
345 unsigned int globalId()
const {
return mGlobalId; }
358 double angleDifferential();
388 unsigned int mGlobalId = 0;
389 std::unique_ptr< LabelPosition > mNextPart;
391 std::vector< double > mOuterBoundsX;
392 std::vector< double > mOuterBoundsY;
394 double mOuterBoundsXMin = std::numeric_limits<double>::max();
395 double mOuterBoundsXMax = std::numeric_limits<double>::lowest();
396 double mOuterBoundsYMin = std::numeric_limits<double>::max();
397 double mOuterBoundsYMax = std::numeric_limits<double>::lowest();
400 const GEOSPreparedGeometry *mPreparedOuterBoundsGeos =
nullptr;
403 bool mHasObstacleConflict;
404 bool mHasHardConflict =
false;
405 int mUpsideDownCharCount;
410 int partCount()
const;
416 double polygonIntersectionCostForParts(
PointSet *polygon )
const;
421 void createMultiPartGeosGeom()
const;
425 void createOuterBoundsGeom();
A rtree spatial index for use in the pal labeling engine.
Calculates label candidate costs considering different factors.
Main class to handle feature.
LabelPosition is a candidate feature label position.
Quadrant
Position of label candidate relative to feature.
void incrementNumOverlaps()
Increases the number of overlaps recorded against this position by 1.
LabelPosition::Quadrant quadrant
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.
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.
Quadrant getQuadrant() const
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.
unsigned int globalId() const
Returns the global ID for the candidate, which is unique for a single run of the pal labelling engine...
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.