Maria GDK 5.0.0.737
Documentation of native code in develop branch
Loading...
Searching...
No Matches
Maria::GeneratorUtils Namespace Reference

Functions

STK::Vector2f rotateLeft90Degrees (const STK::Vector2f &a)
 
STK::Vector2f rotateRight90Degrees (const STK::Vector2f &a)
 
void getIntermediatePositions (const std::vector< BasicGeoTypes::GeoPos > &inPos, std::vector< BasicGeoTypes::GeoPos > &outPos, bool bClosed, const CurveMode &mode, double threshold=50000.0, int max=20)
 Add intermediate positions to a geographic linestring or polygon, as required according to curve mode and threshold parameters.
 
void getIntermediatePositions (const BasicGeoTypes::GeoPos &from, const BasicGeoTypes::GeoPos &to, const CurveMode &mode, std::vector< BasicGeoTypes::GeoPos > &outPos, double threshold=50000.0, int max=20)
 Add intermediate positions to a line connecting two geographical positions, as required according to curve mode and threshold parameters.
 
bool getPixelBuffer (const std::vector< STK::Vector2f > &inPts, double d, bool bClosed, std::vector< STK::Vector2f > &bufPts)
 
bool getGeoBuffer (const std::vector< BasicGeoTypes::GeoPos > &inPos, std::vector< BasicGeoTypes::GeoPos > &bufPos, double width, bool bClosed, const CurveMode &mode, double threshold=50000.0, int max=20)
 
bool calcProjectedPoints (const RasterProjector &rp, const std::vector< BasicGeoTypes::GeoPos > &inPos, std::vector< STK::Vector2f > &projPos)
 
STK::Vector2f calcProjectedPoint (const RasterProjector &rp, const BasicGeoTypes::GeoPos &inPos)
 
bool calcProjectedPoint (const RasterProjector &rp, const BasicGeoTypes::GeoPos &inPos, STK::Vector2f &outPos)
 
bool calcGeoFromProjectedPoint (const RasterProjector &rp, const STK::Vector2f &projectedPos, BasicGeoTypes::GeoPos &outGeoPos)
 Calculate the GeoPos from an projected point, it's the reverse of \cref calcProjectedPoints.
 
std::shared_ptr< STK::PolylineRender2DcreateLineRenderItem (const Maria::DrawObjectData &drawObject, const std::shared_ptr< Maria::CompositeStyleItem > &style, const STK::Screen &screen, const std::vector< STK::Vector2f > &projPos, int lineWidth, int baseDepth, bool closed)
 
std::shared_ptr< STK::PolylineRender2DcreateOutlineRenderItem (const Maria::DrawObjectData &drawObject, const std::shared_ptr< Maria::CompositeStyleItem > &style, const STK::Screen &screen, const std::vector< STK::Vector2f > &projPos, int depth, bool closed, bool fixed, std::optional< STK::Vector2f > pos=std::nullopt)
 
std::shared_ptr< STK::PolylineRender2DcreateOffsetLineRenderItem (const STK::Screen &screen, int lineWidth, int offset, STK::PolylineRender2D::TextureAlignment alignment)
 
std::shared_ptr< STK::PolygonRender2DcreatePolygonRenderItem (const Maria::DrawObjectData &drawObject, const DrawObjectResources &drawObjectResources, const std::shared_ptr< Maria::CompositeStyleItem > &style, const std::shared_ptr< STK::Screen > &screen, const std::vector< STK::Vector2f > &projPos, int depth)
 
bool calcCorridorPoints (const RasterProjector &rp, const std::vector< BasicGeoTypes::GeoPos > &inPos, double width, bool twistLast, std::vector< std::vector< STK::Vector2f > > &projUpperPos, std::vector< std::vector< STK::Vector2f > > &projLowerPos)
 
std::shared_ptr< STK::TextRenderItemcreateTextItem (const std::string &text, const std::shared_ptr< STK::FontManager > &fontManager, const STK::Vector2f &pos, float angle, HorizontalAnchor horizAnchor, VerticalAnchor vertAnchor, const DrawObjectData &drawObjectData, const std::shared_ptr< Maria::CompositeStyleItem > &style, const std::shared_ptr< STK::Screen > &screen, const int fontSizeScaleFactor=0)
 
void calcBounds (const std::vector< STK::Vector2f > &projPos, float &minX, float &minY, float &maxX, float &maxY)
 
STK::OrientedBoundingBox2f calcOrientedBoundingBox (const std::vector< STK::Vector2f > &projPos, float angle, const STK::Vector2f &rotCenter=STK::Vector2f(0, 0))
 
void createLatLonCircle (std::vector< BasicGeoTypes::GeoPos > &geoPos, const BasicGeoTypes::GeoPos &origin, double a0, double a1, double range, int numSlices=36)
 
std::vector< STK::Vector2fcreateArc (const STK::Vector2f &center, float startAngle, float endAngle, float radius, int numSlices)
 Create an arc in screenspace that is centered around the center. The angles are clockwise from 0, which is straight north.
 
std::shared_ptr< STK::TextRenderItemcreateTextLabel (const DrawObjectRenderGenerator &generator, const std::shared_ptr< Maria::CompositeStyleItem > &style, const std::shared_ptr< STK::FontManager > &fontManager, const std::shared_ptr< STK::Screen > &screen, const DrawObjectData &drawObjectData, const RasterProjector &rp, const std::shared_ptr< GeoUnitsSetting > &geoUnitsSetting, const STK::OrientedBoundingBox2f &bbox, const std::string &parameterName, const STK::Vector2f &centroid)
 
std::vector< STK::Vector2fcreateEllipsePoints (const STK::Vector2f &center, float r1, float r2, int numSlices)
 Creates an ellipse as a set of projected points. Used for items hat needs dash styling, for solid ellipses, use createEllipseItem.
 
std::optional< std::string > getSubstitutedText (const DrawObjectRenderGenerator &generator, const DrawObjectData &drawObjectData, const std::string &parameterName, const std::shared_ptr< GeoUnitsSetting > geoUnitsSetting)
 Get the substituted text from drawObjectData, based on the parameters in the generator XML.
 
float ScreenBearing (const STK::Vector2f &p0, const STK::Vector2f &p1)
 
template<typename T >
STK::Vector2< T > LatLonToXY (const std::shared_ptr< RasterProjector > &pj, const BasicGeoTypes::GeoPos &gp)
 
template<typename T >
std::vector< STK::Vector2< T > > LatLonToXY (const std::shared_ptr< RasterProjector > &pj, const std::vector< BasicGeoTypes::GeoPos > &posGeo)
 
std::shared_ptr< GeometrygetInnerGeometry (std::shared_ptr< Geometry > geo)
 Function to find the innermost geometry. This will unwrap containers such as SurfaceVolumeGeometry. Returns the input geometry if it's not a container.
 
std::pair< STK::Vector2f, STK::Vector2fcalcEllipseBoundingBox (const STK::Vector2f &center, const STK::Vector2f &v1, const STK::Vector2f &v2, const float angle)
 Calculate the extreme points that define the bounding box of a rotated ellipse.
 
void calcOrbitAreaCenterPoints (const Maria::OrbitAreaGeometry &orbitArea, BasicGeoTypes::GeoPos &c0, BasicGeoTypes::GeoPos &c1)
 
std::optional< STK::OrientedBoundingBox2fcalculateLegBoundingBox (const RasterProjector &rp, double widthInMeters, const BasicGeoTypes::GeoPos &startPos, const BasicGeoTypes::GeoPos &endPos)
 
STK::OrientedBoundingBox2f calculateLegBoundingBox (const STK::Vector2f &upperLeft, const STK::Vector2f &upperRight, const STK::Vector2f &lowerLeft, const STK::Vector2f &lowerRight)
 Calculate the bounding box for a corridor leg.
 
std::vector< STK::Vector2fcreateArc (const STK::Vector2f &center, double width, double height, double ellipseRotation, double startAngle, double arcSize, int numSlices)
 Create an arc of an ellipse.
 
std::vector< STK::Vector2fsmoothLine (const std::vector< STK::Vector2f > &line, bool closed=false)
 
STK::Box2< float > measureTextSize (STK::FontManager &fontManager, const STK::Screen &screen, const std::string &text, const std::string &fontName, float fontSize)
 
void setLineTexture (std::shared_ptr< STK::PolylineRender2D > &lineRender, const DrawObjectRenderGenerator &generator, const std::shared_ptr< DrawObjectResources > &drawObjectResources, const std::shared_ptr< STK::Screen > &screen, const std::string &rootParam, const bool fixToText=false, bool snapTexCoords=true, const float scale=1)
 
std::shared_ptr< STK::IconRenderItemcreateIconRenderItem (const DrawObjectResources &resources, const STK::Screen &screen, const STK::Vector2f &position, const IconStyle &iconStyle, const float scaleTexture=1.0f)
 
std::shared_ptr< STK::IconRenderItemcreateSymbolIconRenderItem (const std::shared_ptr< Maria::SymbolCache > &symbolCache, const std::string &symbolType, const std::string &symbolCode, const STK::Screen &screen, const STK::Vector2f &position, const float scaleTexture=1.0f)
 
bool calculateOffset (const std::string &offsetFlagValue, const DrawObjectData &drawObject, const Maria::RasterProjector &rp, const STK::Vector2f &input, STK::Vector2f &output)
 

Variables

constexpr int SimplifyPolyCountLimit = 1000
 Simplify polygons with more than this number of vertices.
 
constexpr double SimplifyPolyTolerance = 1e-3
 

Detailed Description

GeneratorUtils - Short description

Function Documentation

◆ calcEllipseBoundingBox()

std::pair< STK::Vector2f, STK::Vector2f > Maria::GeneratorUtils::calcEllipseBoundingBox ( const STK::Vector2f center,
const STK::Vector2f v1,
const STK::Vector2f v2,
const float  angle 
)
inline

Calculate the extreme points that define the bounding box of a rotated ellipse.

Parameters
centerThe center of the ellipse
v1Vector in upwards direction
v2Vector in right direction
angleThe angle of the whole ellipse, in clockwise degrees.
Returns
The two extreme points that define the bounding box.

◆ calcGeoFromProjectedPoint()

bool Maria::GeneratorUtils::calcGeoFromProjectedPoint ( const RasterProjector rp,
const STK::Vector2f projectedPos,
BasicGeoTypes::GeoPos outGeoPos 
)

Calculate the GeoPos from an projected point, it's the reverse of \cref calcProjectedPoints.

Parameters
rpThe projection used to calculate the projected position
projectedPosThe projected position
outGeoPosThe geo position that was output
Returns
true on successful conversion, false on error

◆ createArc() [1/2]

std::vector< STK::Vector2f > Maria::GeneratorUtils::createArc ( const STK::Vector2f center,
double  width,
double  height,
double  ellipseRotation,
double  startAngle,
double  arcSize,
int  numSlices 
)

Create an arc of an ellipse.

Parameters
centerthe center of the ellipse
widthThe width of the ellipse
heightthe height of the ellipse
ellipseRotationThe rotation of the ellipse, in clockwise direction in degrees
startAngleThe start angle of the arc, where 0 is the semi-minor axis, and it goes in clockwise direction
arcSizeThe length of the arc in degrees, relative to the centre. It goes clockwise
numSlicesNumber of slices to create
Returns
The list of points from the StartAngle to StartAngle+arcSize

◆ createArc() [2/2]

std::vector< STK::Vector2f > Maria::GeneratorUtils::createArc ( const STK::Vector2f center,
float  startAngle,
float  endAngle,
float  radius,
int  numSlices 
)

Create an arc in screenspace that is centered around the center. The angles are clockwise from 0, which is straight north.

Parameters
centerThe center of the arc
startAngleThe starting angle of the arc.
endAngleThe ending angle of the arc.
radiusThe radius in
numSlices
Returns

◆ createEllipsePoints()

std::vector< STK::Vector2f > Maria::GeneratorUtils::createEllipsePoints ( const STK::Vector2f center,
float  r1,
float  r2,
int  numSlices 
)

Creates an ellipse as a set of projected points. Used for items hat needs dash styling, for solid ellipses, use createEllipseItem.

Parameters
centerCenter of the circle
r1Radius in dimension 1
r2Radius in dimension 2
numSlicesResolution
Returns
En ellipse as a set of points.

◆ createOffsetLineRenderItem()

std::shared_ptr< STK::PolylineRender2D > Maria::GeneratorUtils::createOffsetLineRenderItem ( const STK::Screen screen,
int  lineWidth,
int  offset,
STK::PolylineRender2D::TextureAlignment  alignment 
)

Create a texture line item with an offset in pixels relative to the center. Note that this method does not fill in any styling parameters or actual vertex data.

Parameters
screenScreen resolution object.
lineWidthLine width in pixels
offsetOffset in pixels from line center.
alignmentAbove of below the line center.
Returns
A LineRenderItem which can be modified before adding to the scene.

◆ createOutlineRenderItem()

std::shared_ptr< STK::PolylineRender2D > Maria::GeneratorUtils::createOutlineRenderItem ( const Maria::DrawObjectData drawObject,
const std::shared_ptr< Maria::CompositeStyleItem > &  style,
const STK::Screen screen,
const std::vector< STK::Vector2f > &  projPos,
int  depth,
bool  closed,
bool  fixed,
std::optional< STK::Vector2f pos = std::nullopt 
)
Parameters
drawObject
style
screen
projPos
depth
closed
fixed
posOptional position to fix object

◆ getInnerGeometry()

std::shared_ptr< Geometry > Maria::GeneratorUtils::getInnerGeometry ( std::shared_ptr< Geometry geo)
inline

Function to find the innermost geometry. This will unwrap containers such as SurfaceVolumeGeometry. Returns the input geometry if it's not a container.

Parameters
geoThe geometry to unwrap
Returns
Innermost geometry

◆ getIntermediatePositions() [1/2]

void Maria::GeneratorUtils::getIntermediatePositions ( const BasicGeoTypes::GeoPos from,
const BasicGeoTypes::GeoPos to,
const CurveMode &  mode,
std::vector< BasicGeoTypes::GeoPos > &  outPos,
double  threshold = 50000.0,
int  max = 20 
)

Add intermediate positions to a line connecting two geographical positions, as required according to curve mode and threshold parameters.

Parameters
fromstart position
toend position
modecurve mode
outPosoutput linestring of positions, including start end end positions
thresholdminimum distance between consecutive positions for intermediate positions to be added. Default = 50000m
maxmax number of intermediate positions per leg

◆ getIntermediatePositions() [2/2]

void Maria::GeneratorUtils::getIntermediatePositions ( const std::vector< BasicGeoTypes::GeoPos > &  inPos,
std::vector< BasicGeoTypes::GeoPos > &  outPos,
bool  bClosed,
const CurveMode &  mode,
double  threshold = 50000.0,
int  max = 20 
)

Add intermediate positions to a geographic linestring or polygon, as required according to curve mode and threshold parameters.

Parameters
inPosoriginal linestring or polygon
outPosoutput linestring or polygon
bClosedtrue if there should be a line connecting last and first point
modecurve mode
thresholdminimum distance between consecutive positions for intermediate positions to be added. Default = 50000m
maxmax number of intermediate positions per leg

◆ getSubstitutedText()

std::optional< std::string > Maria::GeneratorUtils::getSubstitutedText ( const DrawObjectRenderGenerator generator,
const DrawObjectData drawObjectData,
const std::string &  parameterName,
const std::shared_ptr< GeoUnitsSetting geoUnitsSetting 
)

Get the substituted text from drawObjectData, based on the parameters in the generator XML.

Parameters
generatorThe generator to get the controlling parameters from
drawObjectDataThe draw object data to use for the substitution
parameterNameThe prefix to use for all parameter queries
geoUnitsSettingThe GeoUnitsSetting used for parsing data to the right format
Returns

Variable Documentation

◆ SimplifyPolyTolerance

constexpr double Maria::GeneratorUtils::SimplifyPolyTolerance = 1e-3
inlineconstexpr

Tolerance for polygon/polyline simplification. This value is relative to the object size in pixels, so an object of 1000 pixels with a tolerance factor of 1e-3 will have a maximum error of 1 pixel relative to the original data.