source: subversion/applications/editors/osm-editor/qt3/LandsatManager2.h @ 16590

Last change on this file since 16590 was 1158, checked in by nick, 13 years ago

moved current version to qt3 directory in preparation for qt4

File size: 3.0 KB
Line 
1/*
2    Copyright (C) 2005 Nick Whitelegg, Hogweed Software, nick@hogweed.org
3
4    This program is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
17
18 */
19#ifndef LANDSATMANAGER_H
20#define LANDSATMANAGER_H
21
22#include "Map.h"
23#include <qpixmap.h>
24#include "functions.h"
25#include <qpainter.h>
26#include <qwidget.h>
27#include <qcstring.h>
28
29#include "HTTPHandler.h"
30
31#include <vector>
32using std::vector;
33
34namespace OpenStreetMap
35{
36
37class MainWindow2;
38
39class Tile
40{
41public:
42        int lat, lon;   
43        QPixmap pixmap;
44        bool hasData;
45
46        Tile(int lt, int ln, int w, int h) 
47                { lat=lt; lon=ln; pixmap=QPixmap(w,h); hasData=false; }
48
49        void draw(QPainter& p, int x, int y)
50        {
51                if(hasData)
52                        p.drawPixmap(x,y,pixmap);
53        }
54
55        QString getURL(double llstep)
56        {
57                QString url;
58
59                double a = ((double)lon) / 1000000;
60                double b = ((double)lat) / 1000000;
61
62                url.sprintf("/wms.cgi?request=GetMap&width=%d&height=%d&layers=global_mosaic&styles=&srs=EPSG:4326&format=image/jpeg&bbox=%lf,%lf,%lf,%lf", 
63                pixmap.width(),pixmap.height(),a,b,a+(llstep/1000000),
64                                                        b+(llstep/1000000));
65
66                return url;
67        }
68};
69
70class LandsatManager2 : public QObject
71{
72Q_OBJECT
73
74private:
75        MainWindow2 *widget;
76        QPixmap pixmap;
77        QPixmap* tiles;
78        bool dataDisplayed;
79        EarthPoint topLeft, bottomRight;
80        int nRows, nCols, tileSize;
81        HTTPHandler lshttp;
82
83        bool doNeedMoreData();
84
85        vector<Tile*> newtiles;
86
87public:
88        LandsatManager2(MainWindow2 *p): lshttp("onearth.jpl.nasa.gov") { widget=p; 
89                        dataDisplayed=false; }
90        LandsatManager2(MainWindow2*,int,int,int);
91        ~LandsatManager2() { delete[] tiles; }
92
93        bool needMoreData() { return dataDisplayed && doNeedMoreData(); }
94        bool toggleDisplay();
95        void draw(QPainter&);
96        //void grabAll() { if (dataDisplayed) grabTiles(0,0,nCols,nRows); }
97        void grabAll() { if (dataDisplayed) grabTilesNew(); }
98//      void forceGrabAll() { dataDisplayed=true; grabTiles(0,0,nCols,nRows); }
99        void forceGrabAll() { dataDisplayed=true; grabTilesNew(); }
100        //QPixmap doGrab(double w,double s,double e,double n,int width,int height);
101        void drawTiles(QPainter& p);
102        void left();
103        void right();
104        void up();
105        void down();
106        void resize(int w,int h);
107        void grabTiles(int x1,int y1,int x2,int y2);
108        int getTileSize(){ return tileSize; }
109        void drawTilesNew(QPainter& p);
110        void grabTilesNew();
111        bool tileExists(int,int);
112        void clearTiles();
113
114public slots:
115        void dataReceived(const QByteArray& response,void *dim);
116        void newDataReceived(const QByteArray& response,void *t);
117
118};
119
120}
121
122#endif
Note: See TracBrowser for help on using the repository browser.