Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / MapServerInputStream.java @ 2312

History | View | Annotate | Download (3.95 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io;
25

    
26
import java.awt.Image;
27
import java.net.URL;
28

    
29
import javax.imageio.ImageIO;
30

    
31
import org.cresques.cts.ICoordTrans;
32
import org.cresques.cts.IProjection;
33
import org.cresques.px.Extent;
34

    
35
/**
36
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
37
 */
38
public class MapServerInputStream extends GeoRasterFile {
39
        int width, height;
40
        protected MapServerClient mapServer = null;
41
        public MapServerInputStream(IProjection proj, String name) {
42
                super(proj, name);
43
        }
44
        public MapServerInputStream(IProjection proj, MapServerClient server) {
45
                super(proj, server.getName());
46
                mapServer = server;
47
                extent = mapServer.getViewExtent();
48
        }
49
        
50
        public GeoFile load() {
51
                System.out.println("mapServer size = ("+width+","+height+")"/*+
52
                                "\n inc=("+file.cellIncrementX+","+file.cellIncrementY+")\n"+
53
                                " datum='"+file.datum+"', proyeccion='"+file.projection+"'"*/);
54
                return this;
55
        }
56

    
57
        /* (non-Javadoc)
58
         * @see org.cresques.io.GeoRasterFile#close()
59
         */
60
        public void close() {
61
                // TODO Auto-generated method stub
62
                
63
        }
64

    
65
        public void setExtent(Extent e) {
66
                extent = e;
67
        }
68
        
69
        public void setSize(int w, int h) {
70
                width = w; height = h;
71
        }
72

    
73
        public int getWidth() { return width; }
74

    
75
        public int getHeight() { return height; }
76

    
77
        /* (non-Javadoc)
78
         * @see org.cresques.io.GeoRasterFile#reProject(org.cresques.cts.ICoordTrans)
79
         */
80
        public void reProject(ICoordTrans rp) {
81
                // TODO Auto-generated method stub
82
        }
83

    
84
        public void setView(Extent e) {
85
/**/        mapServer.setView((long) e.getMin().getX(), (long) e.getMax().getY(),
86
/**/                (long) e.getMax().getX(), (long)e.getMin().getY());
87
        }
88

    
89
        public Extent getView() {
90
                return mapServer.getViewExtent();
91
        }
92

    
93
        /* (non-Javadoc)
94
         * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans)
95
         */
96
        public Image updateImage(int width, int height, ICoordTrans rp) {
97
                Image image = null;
98
                int line, pRGBArray[] = null;
99
                if (mapServer == null) return image;
100
                
101
                try {
102
/**/                mapServer.setViewSize(width, height);
103
                    System.out.println("Querying mapServer: "+mapServer.getUrl());
104
                        image = ImageIO.read(new URL(mapServer.getUrl()));
105
                } catch (Exception e) {
106
                        e.printStackTrace();
107
                }
108

    
109
                return image; //.getScaledInstance(width, height, Image.SCALE_FAST);
110
        }
111

    
112
        /* (non-Javadoc)
113
         * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
114
         */
115
        public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags) {
116
                // TODO Auto-generated method stub
117
                return null;
118
        }
119
        
120
        /* (non-Javadoc)
121
         * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
122
         */
123
        public Image updateImage(int width, int height, ICoordTrans rp, Image img, int origBand, int destBand) {
124
                // TODO Auto-generated method stub
125
                return null;
126
        }
127
        
128
        /* (non-Javadoc)
129
         * @see org.cresques.io.GeoRasterFile#getData(int, int, int)
130
         */
131
        public Object getData(int x, int y, int band) {
132
                // TODO Auto-generated method stub
133
                return null;
134
        }
135
        
136
        
137
        public int getBlockSize(){
138
                return 0;
139
        }
140
        
141
        public byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band){
142
                return null;
143
        }
144
        
145
}