Statistics
| Revision:

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

History | View | Annotate | Download (2.67 KB)

1
/*
2
 * Created on 13-dic-2004
3
 */
4
package org.cresques.io;
5

    
6
import java.awt.Image;
7
import java.net.URL;
8

    
9
import javax.imageio.ImageIO;
10

    
11
import org.cresques.cts.ICoordTrans;
12
import org.cresques.cts.IProjection;
13
import org.cresques.px.Extent;
14

    
15
/**
16
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
17
 */
18
public class MapServerInputStream extends GeoRasterFile {
19
        int width, height;
20
        protected MapServerClient mapServer = null;
21
        public MapServerInputStream(IProjection proj, String name) {
22
                super(proj, name);
23
        }
24
        public MapServerInputStream(IProjection proj, MapServerClient server) {
25
                super(proj, server.getName());
26
                mapServer = server;
27
                extent = mapServer.getViewExtent();
28
        }
29
        
30
        public GeoFile load() {
31
                System.out.println("mapServer size = ("+width+","+height+")"/*+
32
                                "\n inc=("+file.cellIncrementX+","+file.cellIncrementY+")\n"+
33
                                " datum='"+file.datum+"', proyeccion='"+file.projection+"'"*/);
34
                return this;
35
        }
36

    
37
        /* (non-Javadoc)
38
         * @see org.cresques.io.GeoRasterFile#close()
39
         */
40
        public void close() {
41
                // TODO Auto-generated method stub
42
                
43
        }
44

    
45
        public void setExtent(Extent e) {
46
                extent = e;
47
        }
48
        
49
        public void setSize(int w, int h) {
50
                width = w; height = h;
51
        }
52

    
53
        public int getWidth() { return width; }
54

    
55
        public int getHeight() { return height; }
56

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

    
64
        public void setView(Extent e) {
65
/**/        mapServer.setView((long) e.getMin().getX(), (long) e.getMax().getY(),
66
/**/                (long) e.getMax().getX(), (long)e.getMin().getY());
67
        }
68

    
69
        public Extent getView() {
70
                return mapServer.getViewExtent();
71
        }
72

    
73
        /* (non-Javadoc)
74
         * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans)
75
         */
76
        public Image updateImage(int width, int height, ICoordTrans rp) {
77
                Image image = null;
78
                int line, pRGBArray[] = null;
79
                if (mapServer == null) return image;
80
                
81
                try {
82
/**/                mapServer.setViewSize(width, height);
83
                    System.out.println("Querying mapServer: "+mapServer.getUrl());
84
                        image = ImageIO.read(new URL(mapServer.getUrl()));
85
                } catch (Exception e) {
86
                        e.printStackTrace();
87
                }
88

    
89
                return image; //.getScaledInstance(width, height, Image.SCALE_FAST);
90
        }
91

    
92
        /* (non-Javadoc)
93
         * @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
94
         */
95
        public Image updateImage(int width, int height, ICoordTrans rp, Image img, int flags) {
96
                // TODO Auto-generated method stub
97
                return null;
98
        }
99
        /* (non-Javadoc)
100
         * @see org.cresques.io.GeoRasterFile#getData(int, int, int)
101
         */
102
        public Object getData(int x, int y, int band) {
103
                // TODO Auto-generated method stub
104
                return null;
105
        }
106
        
107
}