3 #include <QImageReader>
7 #include "geotiffmap.h"
10 GeoTIFFMap::GeoTIFFMap(const QString
&fileName
, QObject
*parent
)
11 : Map(parent
), _fileName(fileName
), _img(0), _ratio(1.0), _valid(false)
13 QImageReader
ir(fileName
);
15 _errorString
= "Unsupported/invalid image file";
22 _errorString
= gt
.errorString();
25 _projection
= gt
.projection();
26 _transform
= gt
.transform();
32 GeoTIFFMap::~GeoTIFFMap()
37 QString
GeoTIFFMap::name() const
39 QFileInfo
fi(_fileName
);
43 QPointF
GeoTIFFMap::ll2xy(const Coordinates
&c
)
45 return QPointF(_transform
.proj2img(_projection
.ll2xy(c
))) / _ratio
;
48 Coordinates
GeoTIFFMap::xy2ll(const QPointF
&p
)
50 return _projection
.xy2ll(_transform
.img2proj(p
* _ratio
));
53 QRectF
GeoTIFFMap::bounds()
55 return QRectF(QPointF(0, 0), _size
/ _ratio
);
58 void GeoTIFFMap::draw(QPainter
*painter
, const QRectF
&rect
, Flags flags
)
61 _img
->draw(painter
, rect
, flags
);
64 void GeoTIFFMap::setDevicePixelRatio(qreal ratio
)
68 _img
->setDevicePixelRatio(_ratio
);
71 void GeoTIFFMap::load()
74 _img
= new Image(_fileName
);
77 void GeoTIFFMap::unload()