35 , mSize(
QSize( 0, 0 ) )
38 , mMagnificationFactor( 1.0 )
39 , mProjectionsEnabled( false )
41 , mDatumTransformStore( mDestCRS )
42 , mBackgroundColor(
Qt::white )
43 , mSelectionColor(
Qt::yellow )
44 , mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling | DrawSelection )
45 , mImageFormat(
QImage::Format_ARGB32_Premultiplied )
46 , mSegmentationTolerance(
M_PI_2 / 90 )
50 , mMapUnitsPerPixel( 1 )
75 QgsDebugMsg(
QString(
"Magnification factor: %1 dpi: %2 ratio: %3" ).arg( factor ).arg(
mDpi ).arg( ratio ) );
139 if ( extent.
width() > 0 &&
141 extent.
width() < 1 &&
146 double xMean = ( qAbs( extent.
xMinimum() ) + qAbs( extent.
xMaximum() ) ) * 0.5;
147 double yMean = ( qAbs( extent.
yMinimum() ) + qAbs( extent.
yMaximum() ) ) * 0.5;
149 double xRange = extent.
width() / xMean;
150 double yRange = extent.
height() / yMean;
152 static const double minProportion = 1e-12;
153 if ( xRange < minProportion || yRange < minProportion )
163 if ( !myWidth || !myHeight )
172 mMapUnitsPerPixel = mapUnitsPerPixelY > mapUnitsPerPixelX ? mapUnitsPerPixelY : mapUnitsPerPixelX;
178 if ( mapUnitsPerPixelY > mapUnitsPerPixelX )
204 #if 1 // set visible extent taking rotation in consideration 328 return mFlags.testFlag( flag );
384 double distLayerUnits = std::sqrt( l1.sqrDist( l2 ) );
387 double distMapUnits = std::sqrt( m1.sqrDist( m2 ) );
388 return distMapUnits / distLayerUnits;
403 extent = ct->transformBoundingBox( extent );
548 QgsDebugMsg(
QString(
"WARNING: layer '%1' not found in map layer registry!" ).arg( *it ) );
572 if ( fullExtent.
width() == 0.0 || fullExtent.
height() == 0.0 )
581 fullExtent.
set( -1.0, -1.0, 1.0, 1.0 );
585 const double padFactor = 1e-8;
586 double widthPad = fullExtent.
xMinimum() * padFactor;
587 double heightPad = fullExtent.
yMinimum() * padFactor;
588 double xmin = fullExtent.
xMinimum() - widthPad;
589 double xmax = fullExtent.
xMaximum() + widthPad;
590 double ymin = fullExtent.
yMinimum() - heightPad;
591 double ymax = fullExtent.
yMaximum() + heightPad;
592 fullExtent.
set( xmin, ymin, xmax, ymax );
615 srs.readXML( srsNode );
628 double rot = rotationVal.
toDouble();
634 if ( !renderMapTileElem.
isNull() )
672 renderMapTileElem.
appendChild( renderMapTileText );
void setMapUnits(QGis::UnitType mapUnits)
Set the map units.
void unionRect(const QgsRectangle &rect)
Updates rectangle to include passed argument.
double mMagnificationFactor
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
void setExtent(const QgsRectangle &rect, bool magnified=true)
Set coordinates of the rectangle which should be rendered.
QgsRectangle mVisibleExtent
extent with some additional white space that matches the output aspect ratio
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
QgsMapToPixel mMapToPixel
double magnificationFactor() const
Return the magnification factor.
QPointF toQPointF() const
Converts a point to a QPointF.
QDomNode appendChild(const QDomNode &newChild)
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
void readXML(QDomNode &theNode)
QgsCoordinateReferenceSystem mDestCRS
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsRectangle layerExtentToOutputExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
QMap< QString, QString > mLayerStyleOverrides
void scale(double scaleFactor, const QgsPoint *c=nullptr)
Scale the rectangle around its center point.
void setOutputDpi(double dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
void setDpi(double dpi)
Set the dpi to be used in scale calculations.
static QDomElement writeRectangle(const QgsRectangle &rect, QDomDocument &doc)
Q_DECL_DEPRECATED void setParameters(double mapUnitsPerPixel, double xmin, double ymin, double height)
Set parameters for use in transforming coordinates.
Abstract base class for all geometries.
QGis::UnitType mapUnits() const
Get units of map's geographical coordinates - used for scale calculation.
QgsPoint toMapCoordinates(int x, int y) const
void setLayerStyleOverrides(const QMap< QString, QString > &overrides)
Set map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
void setLayers(const QStringList &layers)
Set list of layer IDs for map rendering.
double toDouble(bool *ok) const
Q_GUI_EXPORT int qt_defaultDpiX()
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
double y() const
Get the y value of the point.
void setFlag(Flag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
QDomElement toElement() const
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
Perform transforms between map coordinates and device coordinates.
bool mValid
whether the actual settings are valid (set in updateDerived())
QString number(int n, int base)
int count(const T &value) const
QgsRectangle extent() const
Return geographical coordinates of the rectangle that should be rendered.
void setOutputSize(QSize size)
Set the size of the resulting map image.
double calculate(const QgsRectangle &mapExtent, int canvasWidth)
Calculate the scale denominator.
double layerToMapUnits(QgsMapLayer *theLayer, const QgsRectangle &referenceExtent=QgsRectangle()) const
Computes an estimated conversion factor between layer and map units: layerUnits * layerToMapUnits = m...
Flag
Enumeration of flags that adjust the way the map is rendered.
void setMagnificationFactor(double factor)
Set the magnification factor.
bool isEmpty() const
test if rectangle is empty.
void setRotation(double degrees)
Set the rotation of the resulting map image Units are clockwise degrees.
double scale() const
Return the calculated scale of the map.
void setMapUnits(QGis::UnitType u)
Set units of map's geographical coordinates - used for scale calculation.
double width() const
Width of the rectangle.
int toInt(bool *ok, int base) const
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
double mapUnitsPerPixel() const
Return the distance in geographical coordinates that equals to one pixel in the map.
const long GEOCRS_ID
Magic number for a geographic coord sys in QGIS srs.db tbl_srs.srs_id.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
bool hasValidSettings() const
Check whether the map settings are valid and can be used for rendering.
const QgsCoordinateTransform * layerTransform(QgsMapLayer *layer) const
Return coordinate transform from layer's CRS to destination CRS.
QgsScaleCalculator mScaleCalculator
A class to represent a point.
const QgsMapToPixel & mapToPixel() const
Caches QgsCoordinateReferenceSystem construction, which may be expensive.
static QGis::UnitType readMapUnits(const QDomElement &element)
This class tracks map layers that are currently loaded and provides various methods to retrieve match...
QDomText createTextNode(const QString &value)
bool isFinite() const
Returns true if the rectangle has finite boundaries.
QGis::UnitType mapUnits() const
Returns current map units.
QDomNode namedItem(const QString &name) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
Draw map such that there are no problems between adjacent tiles.
double outputDpi() const
Return DPI used for conversion between real world units (e.g.
QMap< QString, QString > layerStyleOverrides() const
Get map of map layer style overrides (key: layer ID, value: style name) where a different style shoul...
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsPoint layerToMapCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from layer's CRS to output CRS
void setFlags(const QgsMapSettings::Flags &flags)
Set combination of flags that will be used for rendering.
QgsPoint mapToLayerCoordinates(QgsMapLayer *theLayer, QgsPoint point) const
transform point coordinates from output CRS to layer's CRS
QgsRectangle fullExtent() const
returns current extent of layer set
QDomElement firstChildElement(const QString &tagName) const
Class for storing a coordinate reference system (CRS)
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Flags flags() const
Return combination of flags used for rendering.
UnitType
Map units that qgis supports.
double xMinimum() const
Get the x minimum value (left side of rectangle)
double yMaximum() const
Get the y maximum value (top side of rectangle)
QString name
Read property of QString layerName.
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
Custom exception class for Coordinate Reference System related exceptions.
QPolygonF visiblePolygon() const
Return the visible area as a polygon (may be rotated)
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
bool writeXML(QDomNode &theNode, QDomDocument &theDoc) const
Stores state to the given Dom node in the given document.
QDomElement createElement(const QString &tagName)
QStringList layers() const
Get list of layer IDs for map rendering The layers are stored in the reverse order of how they are re...
QgsPoint toMapCoordinatesF(double x, double y) const
Transform device coordinates to map (world) coordinates.
QgsDatumTransformStore mDatumTransformStore
virtual QgsRectangle extent()
Return the extent of the layer.
static QgsRectangle readRectangle(const QDomElement &element)
QSize outputSize() const
Return the size of the resulting map image.
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
QgsRectangle outputExtentToLayerExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from output CRS to layer's CRS
double x() const
Get the x value of the point.
double height() const
Height of the rectangle.
static QDomElement writeMapUnits(QGis::UnitType units, QDomDocument &doc)
void setCrsTransformEnabled(bool enabled)
sets whether to use projections for this layer set
void writeXML(QDomNode &theNode, QDomDocument &theDoc)