2 #include <QImageReader>
5 #include "geotiffmap.h"
8 GeoTIFFMap::GeoTIFFMap(const QString
&fileName
, QObject
*parent
)
9 : Map(fileName
, parent
), _img(0), _ratio(1.0), _valid(false)
11 QImageReader
ir(fileName
);
13 _errorString
= "Unsupported/invalid image file";
20 _errorString
= gt
.errorString();
23 _projection
= gt
.projection();
24 _transform
= gt
.transform();
30 GeoTIFFMap::~GeoTIFFMap()
35 QPointF
GeoTIFFMap::ll2xy(const Coordinates
&c
)
37 return QPointF(_transform
.proj2img(_projection
.ll2xy(c
))) / _ratio
;
40 Coordinates
GeoTIFFMap::xy2ll(const QPointF
&p
)
42 return _projection
.xy2ll(_transform
.img2proj(p
* _ratio
));
45 QRectF
GeoTIFFMap::bounds()
47 return QRectF(QPointF(0, 0), _size
/ _ratio
);
50 void GeoTIFFMap::draw(QPainter
*painter
, const QRectF
&rect
, Flags flags
)
53 _img
->draw(painter
, rect
, flags
);
56 void GeoTIFFMap::load(const Projection
&in
, const Projection
&out
,
57 qreal deviceRatio
, bool hidpi
)
62 _ratio
= hidpi
? deviceRatio
: 1.0;
64 _img
= new Image(path());
66 _img
->setDevicePixelRatio(_ratio
);
69 void GeoTIFFMap::unload()
75 Map
*GeoTIFFMap::create(const QString
&path
, const Projection
&proj
, bool *isDir
)
82 return new GeoTIFFMap(path
);