svn-gvsig-desktop / tags / v1_1_Build_1000 / libraries / libCq CMS for java.old / src / org / cresques / io / MapServerInputStream.java @ 11885
History | View | Annotate | Download (4.6 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 org.cresques.cts.ICoordTrans; |
27 |
import org.cresques.cts.IProjection; |
28 |
|
29 |
import org.cresques.px.Extent; |
30 |
|
31 |
import java.awt.Image; |
32 |
|
33 |
import java.net.URL; |
34 |
|
35 |
import javax.imageio.ImageIO; |
36 |
|
37 |
|
38 |
/**
|
39 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
40 |
*/
|
41 |
public class MapServerInputStream extends GeoRasterFile { |
42 |
int width;
|
43 |
int height;
|
44 |
protected MapServerClient mapServer = null; |
45 |
|
46 |
public MapServerInputStream(IProjection proj, String name) { |
47 |
super(proj, name);
|
48 |
} |
49 |
|
50 |
public MapServerInputStream(IProjection proj, MapServerClient server) {
|
51 |
super(proj, server.getName());
|
52 |
mapServer = server; |
53 |
extent = mapServer.getViewExtent(); |
54 |
} |
55 |
|
56 |
public GeoFile load() {
|
57 |
System.out.println("mapServer size = (" + width + "," + height + |
58 |
")" /*+ |
59 |
"\n inc=("+file.cellIncrementX+","+file.cellIncrementY+")\n"+
|
60 |
" datum='"+file.datum+"', proyeccion='"+file.projection+"'"*/ );
|
61 |
|
62 |
return this; |
63 |
} |
64 |
|
65 |
/* (non-Javadoc)
|
66 |
* @see org.cresques.io.GeoRasterFile#close()
|
67 |
*/
|
68 |
public void close() { |
69 |
// TODO Auto-generated method stub
|
70 |
} |
71 |
|
72 |
public void setExtent(Extent e) { |
73 |
extent = e; |
74 |
} |
75 |
|
76 |
public void setSize(int w, int h) { |
77 |
width = w; |
78 |
height = h; |
79 |
} |
80 |
|
81 |
public int getWidth() { |
82 |
return width;
|
83 |
} |
84 |
|
85 |
public int getHeight() { |
86 |
return height;
|
87 |
} |
88 |
|
89 |
/* (non-Javadoc)
|
90 |
* @see org.cresques.io.GeoRasterFile#reProject(org.cresques.cts.ICoordTrans)
|
91 |
*/
|
92 |
public void reProject(ICoordTrans rp) { |
93 |
// TODO Auto-generated method stub
|
94 |
} |
95 |
|
96 |
public void setView(Extent e) { |
97 |
/**/ mapServer.setView((long) e.getMin().getX(), (long) e.getMax().getY(), |
98 |
(long) e.getMax().getX(), (long) e.getMin().getY()); |
99 |
} |
100 |
|
101 |
public Extent getView() {
|
102 |
return mapServer.getViewExtent();
|
103 |
} |
104 |
|
105 |
/* (non-Javadoc)
|
106 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans)
|
107 |
*/
|
108 |
public Image updateImage(int width, int height, ICoordTrans rp) { |
109 |
Image image = null; |
110 |
int line;
|
111 |
int[] pRGBArray = null; |
112 |
|
113 |
if (mapServer == null) { |
114 |
return image;
|
115 |
} |
116 |
|
117 |
try {
|
118 |
/**/ mapServer.setViewSize(width, height);
|
119 |
System.out.println("Querying mapServer: " + mapServer.getUrl()); |
120 |
image = ImageIO.read(new URL(mapServer.getUrl())); |
121 |
} catch (Exception e) { |
122 |
e.printStackTrace(); |
123 |
} |
124 |
|
125 |
return image; //.getScaledInstance(width, height, Image.SCALE_FAST); |
126 |
} |
127 |
|
128 |
/* (non-Javadoc)
|
129 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
|
130 |
*/
|
131 |
public Image updateImage(int width, int height, ICoordTrans rp, Image img, |
132 |
int flags) {
|
133 |
// TODO Auto-generated method stub
|
134 |
return null; |
135 |
} |
136 |
|
137 |
/* (non-Javadoc)
|
138 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.cts.ICoordTrans, java.awt.Image, int)
|
139 |
*/
|
140 |
public Image updateImage(int width, int height, ICoordTrans rp, Image img, |
141 |
int origBand, int destBand) { |
142 |
// TODO Auto-generated method stub
|
143 |
return null; |
144 |
} |
145 |
|
146 |
/* (non-Javadoc)
|
147 |
* @see org.cresques.io.GeoRasterFile#getData(int, int, int)
|
148 |
*/
|
149 |
public Object getData(int x, int y, int band) { |
150 |
// TODO Auto-generated method stub
|
151 |
return null; |
152 |
} |
153 |
|
154 |
public int getBlockSize() { |
155 |
return 0; |
156 |
} |
157 |
|
158 |
public byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band) { |
159 |
return null; |
160 |
} |
161 |
|
162 |
public void setExtentTransform(double originX, double originY, double psX, double psY) {} |
163 |
} |