35 , mSize(
QSize( 0, 0 ) )
38 , mProjectionsEnabled( false )
40 , mDatumTransformStore( mDestCRS )
41 , mBackgroundColor(
Qt::white )
42 , mSelectionColor(
Qt::yellow )
43 , mFlags( Antialiasing | UseAdvancedEffects | DrawLabeling | DrawSelection )
44 , mImageFormat(
QImage::Format_ARGB32_Premultiplied )
47 , mMapUnitsPerPixel( 1 )
106 if ( extent.
width() > 0 &&
108 extent.
width() < 1 &&
113 double xMean = ( qAbs( extent.
xMinimum() ) + qAbs( extent.
xMaximum() ) ) * 0.5;
114 double yMean = ( qAbs( extent.
yMinimum() ) + qAbs( extent.
yMaximum() ) ) * 0.5;
116 double xRange = extent.
width() / xMean;
117 double yRange = extent.
height() / yMean;
119 static const double minProportion = 1e-12;
120 if ( xRange < minProportion || yRange < minProportion )
130 if ( !myWidth || !myHeight )
139 mMapUnitsPerPixel = mapUnitsPerPixelY > mapUnitsPerPixelX ? mapUnitsPerPixelY : mapUnitsPerPixelX;
145 if ( mapUnitsPerPixelY > mapUnitsPerPixelX )
171 #if 1 // set visible extent taking rotation in consideration 295 return mFlags.testFlag( flag );
351 double distLayerUnits = std::sqrt( l1.sqrDist( l2 ) );
354 double distMapUnits = std::sqrt( m1.sqrDist( m2 ) );
355 return distMapUnits / distLayerUnits;
370 extent = ct->transformBoundingBox( extent );
515 QgsDebugMsg(
QString(
"WARNING: layer '%1' not found in map layer registry!" ).arg( *it ) );
539 if ( fullExtent.
width() == 0.0 || fullExtent.
height() == 0.0 )
548 fullExtent.
set( -1.0, -1.0, 1.0, 1.0 );
552 const double padFactor = 1e-8;
553 double widthPad = fullExtent.
xMinimum() * padFactor;
554 double heightPad = fullExtent.
yMinimum() * padFactor;
555 double xmin = fullExtent.
xMinimum() - widthPad;
556 double xmax = fullExtent.
xMaximum() + widthPad;
557 double ymin = fullExtent.
yMinimum() - heightPad;
558 double ymax = fullExtent.
yMaximum() + heightPad;
559 fullExtent.
set( xmin, ymin, xmax, ymax );
582 srs.readXML( srsNode );
595 double rot = rotationVal.
toDouble();
601 if ( !renderMapTileElem.
isNull() )
639 renderMapTileElem.
appendChild( renderMapTileText );
void setMapUnits(QGis::UnitType mapUnits)
Set the map units.
void unionRect(const QgsRectangle &rect)
Updates rectangle to include passed argument.
void setDestinationCrs(const QgsCoordinateReferenceSystem &crs)
sets destination coordinate reference system
A rectangle specified with double values.
Base class for all map layer types.
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
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)
void setOutputDpi(int dpi)
Set DPI used for conversion between real world units (e.g. mm) and pixels.
QgsCoordinateReferenceSystem mDestCRS
QgsRectangle layerExtentToOutputExtent(QgsMapLayer *theLayer, QgsRectangle extent) const
transform bounding box from layer's CRS to output CRS
QMap< QString, QString > mLayerStyleOverrides
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.
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)
double y() const
Get the y value of the point.
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
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.
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)
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
static QGis::UnitType readMapUnits(const QDomElement &element)
This class tracks map layers that are currently loaded and provides a means to fetch a pointer to a m...
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.
QString name() const
Get the display name of the layer.
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)
void setExtent(const QgsRectangle &rect)
Set coordinates of the rectangle which should be rendered.
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)
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
int outputDpi() const
Return DPI used for conversion between real world units (e.g.
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)