svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / TifGeoRefFile.java @ 1928
History | View | Annotate | Download (4.47 KB)
1 |
/*
|
---|---|
2 |
* Created on 16-jun-2004
|
3 |
*/
|
4 |
package org.cresques.io; |
5 |
|
6 |
import java.awt.Dimension; |
7 |
import java.awt.Image; |
8 |
import java.awt.Point; |
9 |
import java.io.IOException; |
10 |
|
11 |
import org.cresques.cts.ICoordTrans; |
12 |
import org.cresques.cts.IProjection; |
13 |
import org.cresques.geo.GeoPoint; |
14 |
import org.cresques.geo.Geodetic; |
15 |
import org.cresques.geo.ProjPoint; |
16 |
import org.cresques.geo.Projection; |
17 |
import org.cresques.px.Extent; |
18 |
|
19 |
/**
|
20 |
* Soporte para ficheros georeferenciados con World File (.tfw)
|
21 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
22 |
* @author "Jos? Morell Rama" <morell_josram@gva.es>
|
23 |
*/
|
24 |
public class TifGeoRefFile extends GeoRasterFile { |
25 |
geo.raster.GeoRasterFile geoRasterFile = null;
|
26 |
Extent v = null;
|
27 |
|
28 |
/**
|
29 |
* @param name
|
30 |
*/
|
31 |
public TifGeoRefFile(IProjection proj, String fName) { |
32 |
super(proj, null); // TODO aqui van las proyecciones |
33 |
fName = DataSource.normalize(fName);
|
34 |
super.setName(fName);
|
35 |
System.out.println("jmGeoRaster: "+fName); |
36 |
|
37 |
geoRasterFile = geo.raster.GeoRasterFile.createFile(fName); |
38 |
|
39 |
load(); |
40 |
} |
41 |
|
42 |
/* (non-Javadoc)
|
43 |
* @see org.cresques.io.GeoRasterFile#load()
|
44 |
*/
|
45 |
public GeoFile load() {
|
46 |
try {
|
47 |
geoRasterFile.open(); |
48 |
if (!(proj instanceof Geodetic) && (proj instanceof Projection) && |
49 |
geoRasterFile.getOriginX() >= -180.0 && geoRasterFile.getOriginX() <= 180.0) { |
50 |
GeoPoint gPt = new GeoPoint(geoRasterFile.getOriginX(), geoRasterFile.getOriginY());
|
51 |
ProjPoint pt = (ProjPoint) getProjection().createPoint(0.0, 0.0); |
52 |
pt = (ProjPoint) ((Geodetic)getProjection()).fromGeo(gPt, pt); |
53 |
GeoPoint gPt2 = new GeoPoint(geoRasterFile.getOriginX()+geoRasterFile.getCellIncrementX(), geoRasterFile.getOriginY()+geoRasterFile.getCellIncrementY());
|
54 |
ProjPoint pt2 = (ProjPoint) ((Geodetic)getProjection()).createPoint(0.0, 0.0); |
55 |
pt2 = (ProjPoint) ((Geodetic)getProjection()).fromGeo(gPt2, pt2); |
56 |
geoRasterFile.setOriginX(pt.getX()); |
57 |
geoRasterFile.setOriginY(pt.getY()); |
58 |
geoRasterFile.setCellIncrementX(pt2.getX()-pt.getX()); |
59 |
geoRasterFile.setCellIncrementY(pt2.getY()-pt.getY()); |
60 |
|
61 |
//geoRasterFile.computeExtent();
|
62 |
} |
63 |
extent = new Extent(geoRasterFile.getExtent());
|
64 |
System.out.println("jmGeoRaster: Extent="+extent); |
65 |
geoRasterFile.setOriginRaster(new Point(0, 0)); |
66 |
geoRasterFile.setGraphics2Doffset(new Point(0, 0)); |
67 |
|
68 |
} catch (IOException e) { |
69 |
e.printStackTrace(); |
70 |
geoRasterFile = null;
|
71 |
} |
72 |
return this; |
73 |
} |
74 |
|
75 |
public int getWidth() { return geoRasterFile.getWidth(); } |
76 |
public int getHeight() { return geoRasterFile.getHeight(); } |
77 |
|
78 |
/* (non-Javadoc)
|
79 |
* @see org.cresques.io.GeoRasterFile#setView(org.cresques.px.Extent)
|
80 |
*/
|
81 |
public void setView(Extent e) { v = new Extent(e); } |
82 |
public Extent getView() { return v; } |
83 |
|
84 |
/* (non-Javadoc)
|
85 |
* @see org.cresques.io.GeoRasterFile#setTransparency(boolean)
|
86 |
*/
|
87 |
public void setTransparency(boolean t) { |
88 |
//transparency = t;
|
89 |
} |
90 |
|
91 |
public void setTransparency(int t) { |
92 |
//transparency = t;
|
93 |
} |
94 |
/* (non-Javadoc)
|
95 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.geo.ReProjection)
|
96 |
*/
|
97 |
public Image updateImage(int width, int height, ICoordTrans rp) { |
98 |
double viewportScale = (double) width/v.width(); |
99 |
Dimension sz = new Dimension(width, height); |
100 |
|
101 |
//return geoRasterFile.window(v.toRectangle2D(), viewportScale);
|
102 |
return ((geo.raster.GeoRasterFile) geoRasterFile).updateImage(sz, v.toRectangle2D(), viewportScale);
|
103 |
} |
104 |
|
105 |
|
106 |
/* (non-Javadoc)
|
107 |
* @see org.cresques.io.GeoRasterFile#reProject(org.cresques.geo.ReProjection)
|
108 |
*/
|
109 |
public void reProject(ICoordTrans rp) { |
110 |
// TODO Auto-generated method stub
|
111 |
|
112 |
} |
113 |
|
114 |
/* (non-Javadoc)
|
115 |
* @see org.cresques.io.GeoRasterFile#close()
|
116 |
*/
|
117 |
public void close() { |
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 flags) { |
124 |
// TODO Auto-generated method stub
|
125 |
return null; |
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, int origBand, int destBand) { |
132 |
// TODO Auto-generated method stub
|
133 |
return null; |
134 |
} |
135 |
/* (non-Javadoc)
|
136 |
* @see org.cresques.io.GeoRasterFile#getData(int, int)
|
137 |
*/
|
138 |
public Object getData(int x, int y, int band) { |
139 |
// TODO Auto-generated method stub
|
140 |
return null; |
141 |
} |
142 |
|
143 |
public int getBlockSize(){ |
144 |
return 0; |
145 |
} |
146 |
|
147 |
public byte[] getWindow(int ulX, int ulY, int sizeX, int sizeY, int band){ |
148 |
return null; |
149 |
} |
150 |
} |