FeaturePart class
Main class to handle feature.
Contents
Base classes
- class PointSet
Constructors, destructors, conversion operators
- FeaturePart(QgsLabelFeature* lf, const GEOSGeometry* geom)
- Creates a new generic feature.
- ~FeaturePart() override
- Delete the feature.
Public functions
- auto alwaysShow() const -> bool
- Returns true if the feature's label should always been shown, even when it collides with other labels.
- auto calculatePriority() const -> double
- Calculates the priority for the feature.
- auto createCandidates(QList<LabelPosition*>& lPos, const GEOSPreparedGeometry* mapBoundary, PointSet* mapShape, RTree<LabelPosition*, double, 2, double>* candidates) -> int
- Generic method to generate label candidates for the feature.
- auto createCandidatesAlongLine(QList<LabelPosition*>& lPos, PointSet* mapShape) -> int
- Generate candidates for line feature.
- auto createCandidatesAlongLineNearMidpoint(QList<LabelPosition*>& lPos, PointSet* mapShape, double initialCost = 0.0) -> int
- Generate candidates for line feature, by trying to place candidates as close as possible to the line's midpoint.
- auto createCandidatesAlongLineNearStraightSegments(QList<LabelPosition*>& lPos, PointSet* mapShape) -> int
- Generate candidates for line feature, by trying to place candidates towards the middle of the longest straightish segments of the line.
- auto createCandidatesAroundPoint(double x, double y, QList<LabelPosition*>& lPos, double angle) -> int
- Generate candidates for point feature, located around a specified point.
- auto createCandidatesAtOrderedPositionsOverPoint(double x, double y, QList<LabelPosition*>& lPos, double angle) -> int
- Generates candidates following a prioritized list of predefined positions around a point.
- auto createCandidatesForPolygon(QList<LabelPosition*>& lPos, PointSet* mapShape) -> int
- Generate candidates for polygon features.
- auto createCandidatesOverPoint(double x, double y, QList<LabelPosition*>& lPos, double angle) -> int
- Generate one candidate over or offset the specified point.
- auto createCurvedCandidatesAlongLine(QList<LabelPosition*>& lPos, PointSet* mapShape) -> int
- Generate curved candidates for line features.
- auto curvedPlacementAtOffset(PointSet* path_positions, double* path_distances, int& orientation, int index, double distance, bool& reversed, bool& flip) -> LabelPosition*
- Returns the label position for a curved label at a specific offset along a path.
- auto feature() -> QgsLabelFeature*
- Returns the parent feature.
- auto featureId() const -> QgsFeatureId
- Returns the unique ID of the feature.
- auto fixedAngle() const -> double
- Returns the fixed angle for the feature's label.
- auto getNumSelfObstacles() const -> int
- Gets number of holes (inner rings) - they are considered as obstacles.
- auto getSelfObstacle(int i) -> FeaturePart*
- Gets hole (inner ring) - considered as obstacle.
- auto hasFixedPosition() const -> bool
- Returns true if the feature's label has a fixed position.
- auto hasFixedRotation() const -> bool
- Returns true if the feature's label has a fixed rotation.
- auto hasSameLabelFeatureAs(FeaturePart* part) const -> bool
- Tests whether this feature part belongs to the same QgsLabelFeature as another feature part.
- auto isConnected(FeaturePart* p2) -> bool
- Check whether this part is connected with some other part.
- auto isObstacle() const -> bool
- Returns true if the feature should act as an obstacle to labels.
- auto layer() -> Layer*
- Returns the layer that feature belongs to.
- auto mergeWithFeaturePart(FeaturePart* other) -> bool
- Merge other (connected) part with this one and save the result in this part (other is unchanged).
- auto nextCharPosition(double charWidth, double segment_length, PointSet* path_positions, int& index, double& distance, double& start_x, double& start_y, double& end_x, double& end_y) const -> bool
- Returns true if the next char position is found. The referenced parameters are updated.
- auto obstacleFactor() const -> double
- Returns the feature's obstacle factor, which represents the penalty incurred for a label to overlap the feature.
- auto repeatDistance() const -> double
- Returns the distance between repeating labels for this feature.
- auto showUprightLabels() const -> bool
- Returns true if feature's label must be displayed upright.
Protected functions
- void extractCoords(const GEOSGeometry* geom)
- read coordinates from a GEOS geom
Function documentation
pal:: FeaturePart:: FeaturePart(QgsLabelFeature* lf,
const GEOSGeometry* geom)
Creates a new generic feature.
| Parameters | |
|---|---|
| lf | a pointer for a feature which contains the spatial entites |
| geom | a pointer to a GEOS geometry |
double pal:: FeaturePart:: calculatePriority() const
Calculates the priority for the feature.
This will be the feature's priority if set, otherwise the layer's default priority.
int pal:: FeaturePart:: createCandidates(QList<LabelPosition*>& lPos,
const GEOSPreparedGeometry* mapBoundary,
PointSet* mapShape,
RTree<LabelPosition*, double, 2, double>* candidates)
Generic method to generate label candidates for the feature.
| Parameters | |
|---|---|
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| mapBoundary | map boundary geometry |
| mapShape | generate candidates for this spatial entity |
| candidates | index for candidates |
| Returns | the number of candidates generated in lPos |
int pal:: FeaturePart:: createCandidatesAlongLine(QList<LabelPosition*>& lPos,
PointSet* mapShape)
Generate candidates for line feature.
| Parameters | |
|---|---|
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| mapShape | a pointer to the line |
| Returns | the number of generated candidates |
int pal:: FeaturePart:: createCandidatesAlongLineNearMidpoint(QList<LabelPosition*>& lPos,
PointSet* mapShape,
double initialCost = 0.0)
Generate candidates for line feature, by trying to place candidates as close as possible to the line's midpoint.
| Parameters | |
|---|---|
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| mapShape | a pointer to the line |
| initialCost | initial cost for candidates generated using this method. If set, cost can be increased by a preset amount. |
| Returns | the number of generated candidates |
Candidates can "cut corners" if it helps them place near this mid point.
int pal:: FeaturePart:: createCandidatesAlongLineNearStraightSegments(QList<LabelPosition*>& lPos,
PointSet* mapShape)
Generate candidates for line feature, by trying to place candidates towards the middle of the longest straightish segments of the line.
| Parameters | |
|---|---|
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| mapShape | a pointer to the line |
| Returns | the number of generated candidates |
Segments closer to horizontal are preferred over vertical segments.
int pal:: FeaturePart:: createCandidatesAroundPoint(double x,
double y,
QList<LabelPosition*>& lPos,
double angle)
Generate candidates for point feature, located around a specified point.
| Parameters | |
|---|---|
| x | x coordinate of the point |
| y | y coordinate of the point |
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| angle | orientation of the label |
| Returns | the number of generated candidates |
int pal:: FeaturePart:: createCandidatesAtOrderedPositionsOverPoint(double x,
double y,
QList<LabelPosition*>& lPos,
double angle)
Generates candidates following a prioritized list of predefined positions around a point.
| Parameters | |
|---|---|
| x | x coordinate of the point |
| y | y coordinate of the point |
| lPos | pointer to an array of candidates, will be filled by generated candidate |
| angle | orientation of the label |
| Returns | the number of generated candidates |
int pal:: FeaturePart:: createCandidatesForPolygon(QList<LabelPosition*>& lPos,
PointSet* mapShape)
Generate candidates for polygon features.
| Parameters | |
|---|---|
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| mapShape | a pointer to the polygon |
| Returns | the number of generated candidates |
int pal:: FeaturePart:: createCandidatesOverPoint(double x,
double y,
QList<LabelPosition*>& lPos,
double angle)
Generate one candidate over or offset the specified point.
| Parameters | |
|---|---|
| x | x coordinate of the point |
| y | y coordinate of the point |
| lPos | pointer to an array of candidates, will be filled by generated candidate |
| angle | orientation of the label |
| Returns | the number of generated candidates (always 1) |
int pal:: FeaturePart:: createCurvedCandidatesAlongLine(QList<LabelPosition*>& lPos,
PointSet* mapShape)
Generate curved candidates for line features.
| Parameters | |
|---|---|
| lPos | pointer to an array of candidates, will be filled by generated candidates |
| mapShape | a pointer to the line |
| Returns | the number of generated candidates |
LabelPosition* pal:: FeaturePart:: curvedPlacementAtOffset(PointSet* path_positions,
double* path_distances,
int& orientation,
int index,
double distance,
bool& reversed,
bool& flip)
Returns the label position for a curved label at a specific offset along a path.
| Parameters | |
|---|---|
| path_positions | line path to place label on |
| path_distances | array of distances to each segment on path |
| orientation | can be 0 for automatic calculation of orientation, or -1/+1 for a specific label orientation |
| index | |
| distance | distance to offset label along curve by |
| reversed | if true label is reversed from lefttoright to righttoleft |
| flip | if true label is placed on the other side of the line |
| Returns | calculated label position |
bool pal:: FeaturePart:: hasSameLabelFeatureAs(FeaturePart* part) const
Tests whether this feature part belongs to the same QgsLabelFeature as another feature part.
| Parameters | |
|---|---|
| part | part to compare to |
| Returns | true if both parts belong to same QgsLabelFeature |
bool pal:: FeaturePart:: mergeWithFeaturePart(FeaturePart* other)
Merge other (connected) part with this one and save the result in this part (other is unchanged).
Returns true on success, false if the feature wasn't modified