2 #include <QImageReader>
3 #include "common/util.h"
6 #include "geotiffmap.h"
9 GeoTIFFMap::GeoTIFFMap(const QString
&fileName
, QObject
*parent
)
10 : Map(fileName
, parent
), _img(0), _ratio(1.0), _valid(false)
12 QImageReader
ir(fileName
);
14 _errorString
= "Unsupported/invalid image file";
21 _errorString
= gt
.errorString();
24 _projection
= gt
.projection();
25 _transform
= gt
.transform();
31 GeoTIFFMap::~GeoTIFFMap()
36 QPointF
GeoTIFFMap::ll2xy(const Coordinates
&c
)
38 return QPointF(_transform
.proj2img(_projection
.ll2xy(c
))) / _ratio
;
41 Coordinates
GeoTIFFMap::xy2ll(const QPointF
&p
)
43 return _projection
.xy2ll(_transform
.img2proj(p
* _ratio
));
46 QRectF
GeoTIFFMap::bounds()
48 return QRectF(QPointF(0, 0), _size
/ _ratio
);
51 void GeoTIFFMap::draw(QPainter
*painter
, const QRectF
&rect
, Flags flags
)
54 _img
->draw(painter
, rect
, flags
);
57 void GeoTIFFMap::load(const Projection
&in
, const Projection
&out
,
58 qreal deviceRatio
, bool hidpi
)
63 _ratio
= hidpi
? deviceRatio
: 1.0;
65 _img
= new Image(path());
67 _img
->setDevicePixelRatio(_ratio
);
70 void GeoTIFFMap::unload()
76 Map
*GeoTIFFMap::create(const QString
&path
, bool *isDir
)
81 return new GeoTIFFMap(path
);