Revision 1717
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrRaster.java | ||
---|---|---|
165 | 165 |
String data = "<"+getName()+">\n"; |
166 | 166 |
|
167 | 167 |
ArrayList attr = source.getAttributes(); |
168 |
data += "<raster>\n";
|
|
169 |
data += " <File>"+((RasterFileAdapter) source).getFile()+"</File>\n";
|
|
168 |
data += " <raster\n";
|
|
169 |
data += " File=\""+((RasterFileAdapter) source).getFile()+"\"\n";
|
|
170 | 170 |
for (int i=0; i<attr.size(); i++) { |
171 | 171 |
Object [] a = (Object []) attr.get(i); |
172 | 172 |
|
173 |
data += " <"+a[0].toString()+">\""+ |
|
174 |
a[1].toString()+"\"</"+a[0].toString()+">\n"; |
|
173 |
data += " "+a[0].toString()+"="; |
|
174 |
if (a[1].toString() instanceof String) |
|
175 |
data += "\""+a[1].toString()+"\"\n"; |
|
176 |
else |
|
177 |
data += a[1].toString()+"\n"; |
|
175 | 178 |
} |
176 |
data += "</raster>";
|
|
179 |
data += " />\n";
|
|
177 | 180 |
|
178 |
return data+"</"+getName()+">\n"; |
|
181 |
data += "</"+getName()+">\n"; |
|
182 |
System.out.println(data); |
|
183 |
return data; |
|
179 | 184 |
} |
180 | 185 |
|
181 | 186 |
/** |
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/MapServerClient.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-dic-2004 |
|
3 |
*/ |
|
4 |
package org.cresques.io; |
|
5 |
|
|
6 |
import java.io.BufferedInputStream; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStream; |
|
9 |
import java.net.MalformedURLException; |
|
10 |
import java.net.URL; |
|
11 |
|
|
12 |
import org.cresques.px.Extent; |
|
13 |
|
|
14 |
/** |
|
15 |
* Consulta para un servidor de mapas. |
|
16 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
|
17 |
*/ |
|
18 |
public abstract class MapServerClient implements Extent.Has { |
|
19 |
public static final int MAXBUFSIZE = 1024*1024; |
|
20 |
BufferedInputStream bufIn = null; |
|
21 |
byte [] buffer; |
|
22 |
int bufPos; |
|
23 |
String serverName; |
|
24 |
protected String urlBase = null; |
|
25 |
protected long xMin, xMax, yMin, yMax; |
|
26 |
protected int ancho, alto; |
|
27 |
public boolean echo = false; |
|
28 |
private Extent extent = null; |
|
29 |
private int maxViewWidth = 1500; |
|
30 |
private int maxViewHeight = 1500; |
|
31 |
private float minTimeBetweenQuerys = 0; |
|
32 |
|
|
33 |
public MapServerClient(String serverName) { |
|
34 |
this.serverName = serverName; |
|
35 |
} |
|
36 |
|
|
37 |
public String getName() { return serverName; } |
|
38 |
|
|
39 |
public byte [] getBuffer() { return buffer; } |
|
40 |
|
|
41 |
public void setView(long xMin, long yMin, long xMax, long yMax) { |
|
42 |
this.xMin = xMin; this.xMax = xMax; |
|
43 |
this.yMax = yMax; this.yMin = yMin; |
|
44 |
} |
|
45 |
|
|
46 |
public void setViewSize( int w, int h) { |
|
47 |
ancho = w; alto = h; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* Pone el tama?o m?ximo de la vista. Solicitando una vista m?s |
|
52 |
* grande que esta al servidor dar? error (y no im?genes) :-( |
|
53 |
* @param w ancho |
|
54 |
* @param h alto |
|
55 |
*/ |
|
56 |
public void setMaxViewSize( int w, int h) { |
|
57 |
maxViewWidth = w; maxViewHeight = h; |
|
58 |
} |
|
59 |
|
|
60 |
public Extent getViewExtent() { |
|
61 |
return new Extent(xMin, yMax, xMax, yMin); |
|
62 |
} |
|
63 |
|
|
64 |
public void setExtent(Extent e) { extent = e; } |
|
65 |
|
|
66 |
public Extent getExtent() { return extent; } |
|
67 |
|
|
68 |
abstract public String getUrl(); |
|
69 |
|
|
70 |
public void get() throws Exception { |
|
71 |
get(getUrl()); |
|
72 |
} |
|
73 |
public void get(String address) throws Exception { |
|
74 |
bufPos = 0; |
|
75 |
buffer = new byte[MAXBUFSIZE]; |
|
76 |
try { |
|
77 |
// Check to see that a command parameter was entered |
|
78 |
|
|
79 |
// Create an URL instance |
|
80 |
URL url = new URL(address); |
|
81 |
|
|
82 |
// Get an input stream for reading |
|
83 |
InputStream in = url.openStream(); |
|
84 |
|
|
85 |
// Create a buffered input stream for efficency |
|
86 |
bufIn = new BufferedInputStream(in); |
|
87 |
// Repeat until end of file |
|
88 |
int data; |
|
89 |
for (bufPos = 0; (data = bufIn.read()) != -1; bufPos++) { |
|
90 |
buffer[bufPos] = (byte) data; |
|
91 |
if ( echo ) System.out.println (data); |
|
92 |
} |
|
93 |
|
|
94 |
byte [] buf = new byte[bufPos]; |
|
95 |
for (int i=0; i<bufPos; i++) buf[i] = buffer[i]; |
|
96 |
buffer = buf; |
|
97 |
System.out.println(bufPos+" bytes leidos."); |
|
98 |
|
|
99 |
bufIn.close(); |
|
100 |
in.close(); |
|
101 |
} catch (MalformedURLException mue) { |
|
102 |
System.err.println ("Invalid URL"); |
|
103 |
} catch (IOException ioe) { |
|
104 |
System.err.println ("I/O Error - " + ioe); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
0 | 109 |
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/io/MapServerInputStream.java | ||
---|---|---|
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 |
} |
|
0 | 108 |
branches/v02_desarrollo/libraries/libCq CMS for java.old/src/org/cresques/px/PxRaster.java | ||
---|---|---|
11 | 11 |
import java.awt.geom.Point2D; |
12 | 12 |
import java.awt.image.DataBuffer; |
13 | 13 |
import java.awt.image.ImageObserver; |
14 |
import java.lang.reflect.InvocationTargetException; |
|
14 | 15 |
import java.util.Date; |
15 | 16 |
import java.util.Vector; |
16 | 17 |
|
... | ... | |
338 | 339 |
/* */ |
339 | 340 |
|
340 | 341 |
public Image renderizeRaster(RasterBuf raster) { |
341 |
if (true) { |
|
342 |
Class [] filtros = { |
|
343 |
ComputeMinMaxFilter.class, |
|
344 |
LinearEnhancementFilter.class |
|
345 |
}; |
|
346 |
|
|
347 |
try { |
|
348 |
Class [] args = {RasterBuf.class, RasterStats.class}; |
|
349 |
for (int i=0; i<filtros.length; i++) { |
|
350 |
Object [] params = {raster, stats}; |
|
351 |
filtros[i].getConstructor(args).newInstance(params); |
|
352 |
} |
|
353 |
} catch (IllegalArgumentException e) { |
|
354 |
// TODO Auto-generated catch block |
|
355 |
e.printStackTrace(); |
|
356 |
} catch (SecurityException e) { |
|
357 |
// TODO Auto-generated catch block |
|
358 |
e.printStackTrace(); |
|
359 |
} catch (InstantiationException e) { |
|
360 |
// TODO Auto-generated catch block |
|
361 |
e.printStackTrace(); |
|
362 |
} catch (IllegalAccessException e) { |
|
363 |
// TODO Auto-generated catch block |
|
364 |
e.printStackTrace(); |
|
365 |
} catch (InvocationTargetException e) { |
|
366 |
// TODO Auto-generated catch block |
|
367 |
e.printStackTrace(); |
|
368 |
} catch (NoSuchMethodException e) { |
|
369 |
// TODO Auto-generated catch block |
|
370 |
e.printStackTrace(); |
|
371 |
} |
|
372 |
|
|
373 |
/* if (true) { |
|
342 | 374 |
ComputeMinMaxFilter filter = |
343 | 375 |
new ComputeMinMaxFilter(raster, stats); |
344 | 376 |
filter = null; |
... | ... | |
348 | 380 |
LinearEnhancementFilter lEFilter = |
349 | 381 |
new LinearEnhancementFilter(raster, stats); |
350 | 382 |
lEFilter = null; |
351 |
} |
|
383 |
}*/
|
|
352 | 384 |
|
353 | 385 |
Image image = new RasterToImageFilter(raster, getAlpha()).getImage(); |
354 | 386 |
raster = null; |
355 |
if (true)
|
|
387 |
if (filtros.length > 0)
|
|
356 | 388 |
stats.pinta(); |
357 | 389 |
return image; |
358 | 390 |
} |
359 | 391 |
|
360 | 392 |
public Image renderizeRaster(Image image) { |
361 |
if (true) { |
|
393 |
/* */ if (true) {
|
|
362 | 394 |
ComputeMinMaxFilter filter = |
363 | 395 |
new ComputeMinMaxImageFilter(image, stats); |
364 | 396 |
filter = null; |
... | ... | |
368 | 400 |
LinearEnhancementFilter lEFilter = |
369 | 401 |
new LinearEnhancementImageFilter(image, stats); |
370 | 402 |
lEFilter = null; |
371 |
} |
|
403 |
} /* */
|
|
372 | 404 |
if (true) |
373 | 405 |
stats.pinta(); |
374 | 406 |
return image; |
branches/v02_desarrollo/libraries/libCq CMS for java.old/src-dvp/org/cresques/io/MapServerInputStream.java | ||
---|---|---|
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 |
} |
branches/v02_desarrollo/libraries/libCq CMS for java.old/src-dvp/org/cresques/io/MapServerClient.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 12-dic-2004 |
|
3 |
*/ |
|
4 |
package org.cresques.io; |
|
5 |
|
|
6 |
import java.io.BufferedInputStream; |
|
7 |
import java.io.IOException; |
|
8 |
import java.io.InputStream; |
|
9 |
import java.net.MalformedURLException; |
|
10 |
import java.net.URL; |
|
11 |
|
|
12 |
import org.cresques.px.Extent; |
|
13 |
|
|
14 |
/** |
|
15 |
* Consulta para un servidor de mapas. |
|
16 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
|
17 |
*/ |
|
18 |
public abstract class MapServerClient implements Extent.Has { |
|
19 |
public static final int MAXBUFSIZE = 1024*1024; |
|
20 |
BufferedInputStream bufIn = null; |
|
21 |
byte [] buffer; |
|
22 |
int bufPos; |
|
23 |
String serverName; |
|
24 |
protected String urlBase = null; |
|
25 |
protected long xMin, xMax, yMin, yMax; |
|
26 |
protected int ancho, alto; |
|
27 |
public boolean echo = false; |
|
28 |
private Extent extent = null; |
|
29 |
private int maxViewWidth = 1500; |
|
30 |
private int maxViewHeight = 1500; |
|
31 |
private float minTimeBetweenQuerys = 0; |
|
32 |
|
|
33 |
public MapServerClient(String serverName) { |
|
34 |
this.serverName = serverName; |
|
35 |
} |
|
36 |
|
|
37 |
public String getName() { return serverName; } |
|
38 |
|
|
39 |
public byte [] getBuffer() { return buffer; } |
|
40 |
|
|
41 |
public void setView(long xMin, long yMin, long xMax, long yMax) { |
|
42 |
this.xMin = xMin; this.xMax = xMax; |
|
43 |
this.yMax = yMax; this.yMin = yMin; |
|
44 |
} |
|
45 |
|
|
46 |
public void setViewSize( int w, int h) { |
|
47 |
ancho = w; alto = h; |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* Pone el tama?o m?ximo de la vista. Solicitando una vista m?s |
|
52 |
* grande que esta al servidor dar? error (y no im?genes) :-( |
|
53 |
* @param w ancho |
|
54 |
* @param h alto |
|
55 |
*/ |
|
56 |
public void setMaxViewSize( int w, int h) { |
|
57 |
maxViewWidth = w; maxViewHeight = h; |
|
58 |
} |
|
59 |
|
|
60 |
public Extent getViewExtent() { |
|
61 |
return new Extent(xMin, yMax, xMax, yMin); |
|
62 |
} |
|
63 |
|
|
64 |
public void setExtent(Extent e) { extent = e; } |
|
65 |
|
|
66 |
public Extent getExtent() { return extent; } |
|
67 |
|
|
68 |
abstract public String getUrl(); |
|
69 |
|
|
70 |
public void get() throws Exception { |
|
71 |
get(getUrl()); |
|
72 |
} |
|
73 |
public void get(String address) throws Exception { |
|
74 |
bufPos = 0; |
|
75 |
buffer = new byte[MAXBUFSIZE]; |
|
76 |
try { |
|
77 |
// Check to see that a command parameter was entered |
|
78 |
|
|
79 |
// Create an URL instance |
|
80 |
URL url = new URL(address); |
|
81 |
|
|
82 |
// Get an input stream for reading |
|
83 |
InputStream in = url.openStream(); |
|
84 |
|
|
85 |
// Create a buffered input stream for efficency |
|
86 |
bufIn = new BufferedInputStream(in); |
|
87 |
// Repeat until end of file |
|
88 |
int data; |
|
89 |
for (bufPos = 0; (data = bufIn.read()) != -1; bufPos++) { |
|
90 |
buffer[bufPos] = (byte) data; |
|
91 |
if ( echo ) System.out.println (data); |
|
92 |
} |
|
93 |
|
|
94 |
byte [] buf = new byte[bufPos]; |
|
95 |
for (int i=0; i<bufPos; i++) buf[i] = buffer[i]; |
|
96 |
buffer = buf; |
|
97 |
System.out.println(bufPos+" bytes leidos."); |
|
98 |
|
|
99 |
bufIn.close(); |
|
100 |
in.close(); |
|
101 |
} catch (MalformedURLException mue) { |
|
102 |
System.err.println ("Invalid URL"); |
|
103 |
} catch (IOException ioe) { |
|
104 |
System.err.println ("I/O Error - " + ioe); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
|
Also available in: Unified diff