QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Main class to handle feature. More...
#include <feature.h>
Public Member Functions | |
FeaturePart (const FeaturePart &other) | |
FeaturePart (QgsLabelFeature *lf, const GEOSGeometry *geom) | |
Creates a new generic feature. More... | |
~FeaturePart () override | |
Delete the feature. More... | |
void | addSizePenalty (std::vector< std::unique_ptr< LabelPosition > > &lPos, double bbx[4], double bby[4]) |
Increases the cost of the label candidates for this feature, based on the size of the feature. More... | |
bool | alwaysShow () const |
Returns true if the feature's label should always been shown, even when it collides with other labels. More... | |
double | calculatePriority () const |
Calculates the priority for the feature. More... | |
std::size_t | createCandidateCenteredOverPoint (double x, double y, std::vector< std::unique_ptr< LabelPosition > > &lPos, double angle) |
Generate one candidate centered over the specified point. More... | |
std::unique_ptr< LabelPosition > | createCandidatePointOnSurface (PointSet *mapShape) |
Creates a single candidate using the "point on sruface" algorithm. More... | |
std::vector< std::unique_ptr< LabelPosition > > | createCandidates (Pal *pal) |
Generates a list of candidate positions for labels for this feature. More... | |
std::size_t | createCandidatesAlongLine (std::vector< std::unique_ptr< LabelPosition > > &lPos, PointSet *mapShape, bool allowOverrun, Pal *pal) |
Generate candidates for line feature. More... | |
std::size_t | createCandidatesAlongLineNearMidpoint (std::vector< std::unique_ptr< LabelPosition > > &lPos, PointSet *mapShape, double initialCost=0.0, Pal *pal=nullptr) |
Generate candidates for line feature, by trying to place candidates as close as possible to the line's midpoint. More... | |
std::size_t | createCandidatesAlongLineNearStraightSegments (std::vector< std::unique_ptr< LabelPosition > > &lPos, PointSet *mapShape, Pal *pal) |
Generate candidates for line feature, by trying to place candidates towards the middle of the longest straightish segments of the line. More... | |
std::size_t | createCandidatesAroundPoint (double x, double y, std::vector< std::unique_ptr< LabelPosition > > &lPos, double angle) |
Generate candidates for point feature, located around a specified point. More... | |
std::size_t | createCandidatesAtOrderedPositionsOverPoint (double x, double y, std::vector< std::unique_ptr< LabelPosition > > &lPos, double angle) |
Generates candidates following a prioritized list of predefined positions around a point. More... | |
std::size_t | createCandidatesForPolygon (std::vector< std::unique_ptr< LabelPosition > > &lPos, PointSet *mapShape, Pal *pal) |
Generate candidates for polygon features. More... | |
std::size_t | createCandidatesOutsidePolygon (std::vector< std::unique_ptr< LabelPosition > > &lPos, Pal *pal) |
Generate candidates outside of polygon features. More... | |
std::size_t | createCandidatesOverPoint (double x, double y, std::vector< std::unique_ptr< LabelPosition > > &lPos, double angle) |
Generate one candidate over or offset the specified point. More... | |
std::size_t | createCurvedCandidatesAlongLine (std::vector< std::unique_ptr< LabelPosition > > &lPos, PointSet *mapShape, bool allowOverrun, Pal *pal) |
Generate curved candidates for line features. More... | |
std::size_t | createHorizontalCandidatesAlongLine (std::vector< std::unique_ptr< LabelPosition > > &lPos, PointSet *mapShape, Pal *pal) |
Generate horizontal candidates for line feature. More... | |
std::unique_ptr< LabelPosition > | curvedPlacementAtOffset (PointSet *path_positions, double *path_distances, int &orientation, double distance, bool &reversed, bool &flip) |
Returns the label position for a curved label at a specific offset along a path. More... | |
QgsLabelFeature * | feature () |
Returns the parent feature. More... | |
QgsFeatureId | featureId () const |
Returns the unique ID of the feature. More... | |
double | fixedAngle () const |
Returns the fixed angle for the feature's label. More... | |
double | getLabelDistance () const |
Returns the distance from the anchor point to the label. More... | |
double | getLabelHeight (double angle=0.0) const |
Returns the height of the label, optionally taking an angle into account. More... | |
double | getLabelWidth (double angle=0.0) const |
Returns the width of the label, optionally taking an angle into account. More... | |
int | getNumSelfObstacles () const |
Gets number of holes (inner rings) - they are considered as obstacles. More... | |
FeaturePart * | getSelfObstacle (int i) |
Gets hole (inner ring) - considered as obstacle. More... | |
bool | hasFixedPosition () const |
Returns true if the feature's label has a fixed position. More... | |
bool | hasFixedRotation () const |
Returns true if the feature's label has a fixed rotation. More... | |
bool | hasSameLabelFeatureAs (FeaturePart *part) const |
Tests whether this feature part belongs to the same QgsLabelFeature as another feature part. More... | |
bool | isConnected (FeaturePart *p2) |
Check whether this part is connected with some other part. More... | |
Layer * | layer () |
Returns the layer that feature belongs to. More... | |
std::size_t | maximumLineCandidates () const |
Returns the maximum number of line candidates to generate for this feature. More... | |
std::size_t | maximumPointCandidates () const |
Returns the maximum number of point candidates to generate for this feature. More... | |
std::size_t | maximumPolygonCandidates () const |
Returns the maximum number of polygon candidates to generate for this feature. More... | |
bool | mergeWithFeaturePart (FeaturePart *other) |
Merge other (connected) part with this one and save the result in this part (other is unchanged). More... | |
bool | nextCharPosition (double charWidth, double segmentLength, PointSet *path_positions, int &index, double ¤tDistanceAlongSegment, double &characterStartX, double &characterStartY, double &characterEndX, double &characterEndY) const |
Returns true if the next char position is found. The referenced parameters are updated. More... | |
const QgsLabelObstacleSettings & | obstacleSettings () const |
Returns the feature's obstacle settings. More... | |
double | repeatDistance () const |
Returns the distance between repeating labels for this feature. More... | |
void | setTotalRepeats (int repeats) |
Returns the total number of repeating labels associated with this label. More... | |
bool | showUprightLabels () const |
Returns true if feature's label must be displayed upright. More... | |
int | totalRepeats () const |
Returns the total number of repeating labels associated with this label. More... | |
Public Member Functions inherited from pal::PointSet | |
PointSet () | |
PointSet (int nbPoints, double *x, double *y) | |
virtual | ~PointSet () |
double | area () const |
Returns area of polygon geometry. More... | |
QgsRectangle | boundingBox () const |
Returns the point set bounding box. More... | |
bool | boundingBoxIntersects (const PointSet *other) const |
Returns true if the bounding box of this pointset intersects the bounding box of another pointset. More... | |
std::unique_ptr< PointSet > | clone () const |
Returns a copy of the point set. More... | |
CHullBox | compute_chull_bbox () |
Computes a con???? hull. More... | |
bool | containsLabelCandidate (double x, double y, double width, double height, double alpha=0) const |
Tests whether a possible label candidate will fit completely within the shape. More... | |
bool | containsPoint (double x, double y) const |
Tests whether point set contains a specified point. More... | |
void | extendLineByDistance (double startDistance, double endDistance, double smoothDistance) |
Extends linestrings by the specified amount at the start and end of the line, by extending the existing lines following the same direction as the original line start or end. More... | |
std::unique_ptr< PointSet > | extractShape (int nbPtSh, int imin, int imax, int fps, int fpe, double fptx, double fpty) |
Does... More... | |
const GEOSGeometry * | geos () const |
Returns the point set's GEOS geometry. More... | |
void | getCentroid (double &px, double &py, bool forceInside=false) const |
int | getGeosType () const |
PointSet * | getHoleOf () const |
Returns nullptr if this isn't a hole. Otherwise returns pointer to parent pointset. More... | |
int | getNumPoints () const |
void | getPointByDistance (double *d, double *ad, double dl, double *px, double *py) |
Gets a point a set distance along a line geometry. More... | |
bool | isClosed () const |
Returns true if pointset is closed. More... | |
double | length () const |
Returns length of line geometry. More... | |
double | minDistanceToPoint (double px, double py, double *rx=nullptr, double *ry=nullptr) const |
Returns the squared minimum distance between the point set geometry and the point (px,py) Optionally, the nearest point is stored in (rx,ry). More... | |
Protected Member Functions | |
void | extractCoords (const GEOSGeometry *geom) |
read coordinates from a GEOS geom More... | |
Protected Member Functions inherited from pal::PointSet | |
PointSet (const PointSet &ps) | |
PointSet (double x, double y) | |
void | createGeosGeom () const |
void | deleteCoords () |
void | invalidateGeos () |
const GEOSPreparedGeometry * | preparedGeom () const |
Protected Attributes | |
QList< FeaturePart * > | mHoles |
QgsLabelFeature * | mLF = nullptr |
Protected Attributes inherited from pal::PointSet | |
int * | cHull = nullptr |
int | cHullSize = 0 |
PointSet * | holeOf = nullptr |
double | mArea = -1 |
GEOSGeometry * | mGeos = nullptr |
double | mLength = -1 |
bool | mOwnsGeom = false |
PointSet * | parent = nullptr |
int | type |
double | xmax = std::numeric_limits<double>::lowest() |
double | xmin = std::numeric_limits<double>::max() |
double | ymax = std::numeric_limits<double>::lowest() |
double | ymin = std::numeric_limits<double>::max() |
Additional Inherited Members | |
Static Public Member Functions inherited from pal::PointSet | |
static void | splitPolygons (QLinkedList< PointSet * > &inputShapes, QLinkedList< PointSet * > &outputShapes, double xrm, double yrm) |
Split a concave shape into several convex shapes. More... | |
Public Attributes inherited from pal::PointSet | |
int | nbPoints |
std::vector< double > | x |
std::vector< double > | y |
Main class to handle feature.
FeaturePart::FeaturePart | ( | QgsLabelFeature * | lf, |
const GEOSGeometry * | geom | ||
) |
Creates a new generic feature.
lf | a pointer for a feature which contains the spatial entites |
geom | a pointer to a GEOS geometry |
Definition at line 51 of file feature.cpp.
FeaturePart::FeaturePart | ( | const FeaturePart & | other | ) |
Definition at line 68 of file feature.cpp.
|
override |
Delete the feature.
Definition at line 79 of file feature.cpp.
void FeaturePart::addSizePenalty | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
double | bbx[4], | ||
double | bby[4] | ||
) |
Increases the cost of the label candidates for this feature, based on the size of the feature.
E.g. small lines or polygons get higher cost so that larger features are more likely to be labeled.
Definition at line 2109 of file feature.cpp.
|
inline |
double FeaturePart::calculatePriority | ( | ) | const |
Calculates the priority for the feature.
This will be the feature's priority if set, otherwise the layer's default priority.
Definition at line 2206 of file feature.cpp.
std::size_t FeaturePart::createCandidateCenteredOverPoint | ( | double | x, |
double | y, | ||
std::vector< std::unique_ptr< LabelPosition > > & | lPos, | ||
double | angle | ||
) |
Generate one candidate centered over the specified point.
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 |
Definition at line 289 of file feature.cpp.
std::unique_ptr< LabelPosition > FeaturePart::createCandidatePointOnSurface | ( | PointSet * | mapShape | ) |
Creates a single candidate using the "point on sruface" algorithm.
Definition at line 397 of file feature.cpp.
std::vector< std::unique_ptr< LabelPosition > > FeaturePart::createCandidates | ( | Pal * | pal | ) |
Generates a list of candidate positions for labels for this feature.
Definition at line 2004 of file feature.cpp.
std::size_t FeaturePart::createCandidatesAlongLine | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
PointSet * | mapShape, | ||
bool | allowOverrun, | ||
Pal * | pal | ||
) |
Generate candidates for line feature.
lPos | pointer to an array of candidates, will be filled by generated candidates |
mapShape | a pointer to the line |
allowOverrun | set to true to allow labels to overrun features |
pal | point to pal settings object, for cancellation support |
Definition at line 716 of file feature.cpp.
std::size_t FeaturePart::createCandidatesAlongLineNearMidpoint | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
PointSet * | mapShape, | ||
double | initialCost = 0.0 , |
||
Pal * | pal = nullptr |
||
) |
Generate candidates for line feature, by trying to place candidates as close as possible to the line's midpoint.
Candidates can "cut corners" if it helps them place near this mid point.
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. |
pal | point to pal settings object, for cancellation support |
Definition at line 1026 of file feature.cpp.
std::size_t FeaturePart::createCandidatesAlongLineNearStraightSegments | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
PointSet * | mapShape, | ||
Pal * | pal | ||
) |
Generate candidates for line feature, by trying to place candidates towards the middle of the longest straightish segments of the line.
Segments closer to horizontal are preferred over vertical segments.
lPos | pointer to an array of candidates, will be filled by generated candidates |
mapShape | a pointer to the line |
pal | point to pal settings object, for cancellation support |
Definition at line 800 of file feature.cpp.
std::size_t FeaturePart::createCandidatesAroundPoint | ( | double | x, |
double | y, | ||
std::vector< std::unique_ptr< LabelPosition > > & | lPos, | ||
double | angle | ||
) |
Generate candidates for point feature, located around a specified point.
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 |
Definition at line 567 of file feature.cpp.
std::size_t FeaturePart::createCandidatesAtOrderedPositionsOverPoint | ( | double | x, |
double | y, | ||
std::vector< std::unique_ptr< LabelPosition > > & | lPos, | ||
double | angle | ||
) |
Generates candidates following a prioritized list of predefined positions around a point.
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 |
Definition at line 528 of file feature.cpp.
std::size_t FeaturePart::createCandidatesForPolygon | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
PointSet * | mapShape, | ||
Pal * | pal | ||
) |
Generate candidates for polygon features.
lPos | pointer to an array of candidates, will be filled by generated candidates |
mapShape | a pointer to the polygon |
pal | point to pal settings object, for cancellation support |
Definition at line 1564 of file feature.cpp.
std::size_t FeaturePart::createCandidatesOutsidePolygon | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
Pal * | pal | ||
) |
Generate candidates outside of polygon features.
lPos | pointer to an array of candidates, will be filled by generated candidates |
pal | point to pal settings object, for cancellation support |
Definition at line 1801 of file feature.cpp.
std::size_t FeaturePart::createCandidatesOverPoint | ( | double | x, |
double | y, | ||
std::vector< std::unique_ptr< LabelPosition > > & | lPos, | ||
double | angle | ||
) |
Generate one candidate over or offset the specified point.
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 |
Definition at line 318 of file feature.cpp.
std::size_t FeaturePart::createCurvedCandidatesAlongLine | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
PointSet * | mapShape, | ||
bool | allowOverrun, | ||
Pal * | pal | ||
) |
Generate curved candidates for line features.
lPos | pointer to an array of candidates, will be filled by generated candidates |
mapShape | a pointer to the line |
allowOverrun | set to true to allow labels to overrun features |
pal | point to pal settings object, for cancellation support |
Definition at line 1363 of file feature.cpp.
std::size_t FeaturePart::createHorizontalCandidatesAlongLine | ( | std::vector< std::unique_ptr< LabelPosition > > & | lPos, |
PointSet * | mapShape, | ||
Pal * | pal | ||
) |
Generate horizontal candidates for line feature.
lPos | pointer to an array of candidates, will be filled by generated candidates |
mapShape | a pointer to the line |
pal | point to pal settings object, for cancellation support |
Definition at line 742 of file feature.cpp.
std::unique_ptr< LabelPosition > FeaturePart::curvedPlacementAtOffset | ( | PointSet * | path_positions, |
double * | path_distances, | ||
int & | orientation, | ||
double | distance, | ||
bool & | reversed, | ||
bool & | flip | ||
) |
Returns the label position for a curved label at a specific offset along a path.
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 |
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 |
Definition at line 1188 of file feature.cpp.
|
protected |
read coordinates from a GEOS geom
Definition at line 87 of file feature.cpp.
|
inline |
QgsFeatureId FeaturePart::featureId | ( | ) | const |
Returns the unique ID of the feature.
Definition at line 157 of file feature.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
bool FeaturePart::hasSameLabelFeatureAs | ( | FeaturePart * | part | ) | const |
Tests whether this feature part belongs to the same QgsLabelFeature as another feature part.
part | part to compare to |
true
if both parts belong to same QgsLabelFeature Definition at line 211 of file feature.cpp.
bool FeaturePart::isConnected | ( | FeaturePart * | p2 | ) |
Check whether this part is connected with some other part.
Definition at line 2150 of file feature.cpp.
Layer * FeaturePart::layer | ( | ) |
Returns the layer that feature belongs to.
Definition at line 152 of file feature.cpp.
std::size_t FeaturePart::maximumLineCandidates | ( | ) | const |
Returns the maximum number of line candidates to generate for this feature.
Definition at line 167 of file feature.cpp.
std::size_t FeaturePart::maximumPointCandidates | ( | ) | const |
Returns the maximum number of point candidates to generate for this feature.
Definition at line 162 of file feature.cpp.
std::size_t FeaturePart::maximumPolygonCandidates | ( | ) | const |
Returns the maximum number of polygon candidates to generate for this feature.
Definition at line 189 of file feature.cpp.
bool 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
Definition at line 2166 of file feature.cpp.
bool FeaturePart::nextCharPosition | ( | double | charWidth, |
double | segmentLength, | ||
PointSet * | path_positions, | ||
int & | index, | ||
double & | currentDistanceAlongSegment, | ||
double & | characterStartX, | ||
double & | characterStartY, | ||
double & | characterEndX, | ||
double & | characterEndY | ||
) | const |
Returns true
if the next char position is found. The referenced parameters are updated.
Definition at line 2243 of file feature.cpp.
|
inline |
|
inline |
void FeaturePart::setTotalRepeats | ( | int | repeats | ) |
Returns the total number of repeating labels associated with this label.
Definition at line 284 of file feature.cpp.
bool FeaturePart::showUprightLabels | ( | ) | const |
Returns true
if feature's label must be displayed upright.
Definition at line 2219 of file feature.cpp.
int FeaturePart::totalRepeats | ( | ) | const |
Returns the total number of repeating labels associated with this label.
Definition at line 279 of file feature.cpp.
|
protected |
|
protected |