Coord Projection::projInverse(const QPointF & pProj) const { qreal x = pProj.x(); qreal y = pProj.y(); projTransformToWGS84(1, 0, &x, &y, NULL); return Coord(radToAng(x), radToAng(y)); }
Coord mercatorInverse(const QPointF& point) const { qreal longitude = point.x()*180.0/EQUATORIALMETERHALFCIRCUMFERENCE; qreal latitude = radToAng(atan(sinh(point.y()/EQUATORIALMETERHALFCIRCUMFERENCE*M_PI))); return Coord(longitude, latitude); }
QPixmap GdalAdapter::getPixmap(const QRectF& /*wgs84Bbox*/, const QRectF& theProjBbox, const QRect& src) const { QPixmap pix(src.size()); pix.fill(Qt::transparent); QPainter p(&pix); QRectF projBbox = theProjBbox; if (isLatLon) projBbox = QRectF(radToAng(theProjBbox.left()), radToAng(theProjBbox.top()), radToAng(theProjBbox.width()), radToAng(theProjBbox.height())); for (int i=0; i<theImages.size(); ++i) { QPixmap theImg = theImages[i].theImg; QSizeF sz(projBbox.width() / theImages[i].adfGeoTransform[1], projBbox.height() / theImages[i].adfGeoTransform[5]); if (sz.isNull()) return QPixmap(); QPointF s((projBbox.left() - theImages[i].adfGeoTransform[0]) / theImages[i].adfGeoTransform[1], (projBbox.top() - theImages[i].adfGeoTransform[3]) / theImages[i].adfGeoTransform[5]); qDebug() << "Pixmap Origin: " << s.x() << "," << s.y(); qDebug() << "Pixmap size: " << sz.width() << "," << sz.height(); double rtx = src.width() / (double)sz.width(); double rty = src.height() / (double)sz.height(); QRect mRect = QRect(s.toPoint(), sz.toSize()); QRect iRect = theImg.rect().intersected(mRect); QRect sRect = QRect(iRect.topLeft() - mRect.topLeft(), iRect.size()); QRect fRect = QRect(sRect.x() * rtx, sRect.y() * rty, sRect.width() * rtx, sRect.height() * rty); qDebug() << "mrect: " << mRect; qDebug() << "iRect: " << iRect; qDebug() << "sRect: " << sRect; // QImage img2 = theImg.copy(iRect).scaled(fRect.size()); // p.drawImage(fRect.topLeft(), img2); QPixmap img2 = theImg.copy(iRect).scaled(fRect.size()); p.drawPixmap(fRect.topLeft(), img2); } p.end(); return pix; }