svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / GeoTiffFile.java @ 130
History | View | Annotate | Download (4.03 KB)
1 |
/*
|
---|---|
2 |
* Created on 06-jul-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
6 |
*/
|
7 |
package org.cresques.io; |
8 |
|
9 |
import java.awt.Dimension; |
10 |
import java.awt.Image; |
11 |
import java.awt.Point; |
12 |
import java.io.IOException; |
13 |
|
14 |
import org.cresques.cts.ICoordTrans; |
15 |
import org.cresques.cts.IProjection; |
16 |
//import org.cresques.geo.Projection;
|
17 |
//import org.cresques.geo.ReProjection;
|
18 |
import org.cresques.px.Extent; |
19 |
|
20 |
/**
|
21 |
* @author jmorell
|
22 |
*
|
23 |
* To change the template for this generated type comment go to
|
24 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
25 |
*/
|
26 |
public class GeoTiffFile extends GeoRasterFile { |
27 |
geo.raster.GeoRasterFile geoRasterFile = null;
|
28 |
Extent v = null;
|
29 |
|
30 |
//boolean doTransparency = false;
|
31 |
//PixelFilter tFilter = null;
|
32 |
|
33 |
public GeoTiffFile(IProjection proj, String fName) { |
34 |
super(proj, null); |
35 |
fName = DataSource.normalize(fName);
|
36 |
super.setName(fName);
|
37 |
//extent = new Extent();
|
38 |
System.out.println("GjmTiffRaster: " + fName); |
39 |
if (fName.endsWith("tif") || fName.endsWith("tiff") ) { |
40 |
geoRasterFile = new geo.raster.GeoTiffFile(fName);
|
41 |
} |
42 |
load(); |
43 |
} |
44 |
|
45 |
/* (non-Javadoc)
|
46 |
* @see org.cresques.io.GeoFile#load()
|
47 |
*/
|
48 |
public GeoFile load() {
|
49 |
try {
|
50 |
geoRasterFile.open(); |
51 |
// Comentarizado porque se produce un error
|
52 |
//if (!(proj instanceof Geodetic) &&
|
53 |
// geoRasterFile.getOriginX() >= -180.0 && geoRasterFile.getOriginX() <= 180.0) {
|
54 |
/*if (false) {
|
55 |
GeoPoint gPt = new GeoPoint(geoRasterFile.getOriginX(), geoRasterFile.getOriginY());
|
56 |
ProjPoint pt = (ProjPoint) getProjection().createPoint(0.0, 0.0);
|
57 |
System.out.println("geoRasterFile.getOriginX() = " + geoRasterFile.getOriginX());
|
58 |
System.out.println("gPt = " + gPt);
|
59 |
System.out.println("pt = " + pt);
|
60 |
pt = (ProjPoint) getProjection().fromGeo(gPt, pt);
|
61 |
GeoPoint gPt2 = new GeoPoint(geoRasterFile.getOriginX()+geoRasterFile.getCellIncrementX(), geoRasterFile.getOriginY()+geoRasterFile.getCellIncrementY());
|
62 |
ProjPoint pt2 = (ProjPoint) getProjection().createPoint(0.0, 0.0);
|
63 |
pt2 = (ProjPoint) getProjection().fromGeo(gPt2, pt2);
|
64 |
geoRasterFile.setOriginX(pt.getX());
|
65 |
geoRasterFile.setOriginY(pt.getY());
|
66 |
geoRasterFile.setCellIncrementX(pt2.getX()-pt.getX());
|
67 |
geoRasterFile.setCellIncrementY(pt2.getY()-pt.getY());
|
68 |
|
69 |
//geoRasterFile.computeExtent();
|
70 |
}*/
|
71 |
extent = new Extent(geoRasterFile.getExtent());
|
72 |
System.out.println("GjmTiffRaster: Extent="+extent); |
73 |
geoRasterFile.setOriginRaster(new Point(0, 0)); |
74 |
geoRasterFile.setGraphics2Doffset(new Point(0, 0)); |
75 |
|
76 |
} catch (IOException e) { |
77 |
e.printStackTrace(); |
78 |
geoRasterFile = null;
|
79 |
} |
80 |
return this; |
81 |
} |
82 |
|
83 |
public int getWidth() { return geoRasterFile.getWidth(); } |
84 |
public int getHeight() { return geoRasterFile.getHeight(); } |
85 |
|
86 |
/* (non-Javadoc)
|
87 |
* @see org.cresques.geo.Projected#reProject(org.cresques.geo.ReProjection)
|
88 |
*/
|
89 |
public void reProject(ICoordTrans rp) { |
90 |
// TODO Auto-generated method stub
|
91 |
} |
92 |
|
93 |
/* (non-Javadoc)
|
94 |
* @see org.cresques.io.GeoRasterFile#setView(org.cresques.px.Extent)
|
95 |
*/
|
96 |
public void setView(Extent e) { |
97 |
v = new Extent(e);
|
98 |
} |
99 |
|
100 |
/* (non-Javadoc)
|
101 |
* @see org.cresques.io.GeoRasterFile#getView()
|
102 |
*/
|
103 |
public Extent getView() {
|
104 |
return v;
|
105 |
} |
106 |
|
107 |
/* (non-Javadoc)
|
108 |
* @see org.cresques.io.GeoRasterFile#setTransparency(boolean)
|
109 |
*/
|
110 |
public void setTransparency(boolean t) { |
111 |
//transparency = t;
|
112 |
|
113 |
//doTransparency = t;
|
114 |
//tFilter = new PixelFilter();
|
115 |
} |
116 |
|
117 |
/*public boolean getTransparency() {
|
118 |
return doTransparency;
|
119 |
}*/
|
120 |
|
121 |
/* (non-Javadoc)
|
122 |
* @see org.cresques.io.GeoRasterFile#updateImage(int, int, org.cresques.geo.ReProjection)
|
123 |
*/
|
124 |
public Image updateImage(int width, int height, ICoordTrans rp) { |
125 |
double viewportScale = (double) width/v.width(); |
126 |
Dimension sz = new Dimension(width, height); |
127 |
|
128 |
//return geoRasterFile.window(v.toRectangle2D(), viewportScale);
|
129 |
//return ((geo.raster.WorldFile) geoRasterFile).updateImage(sz, v.toRectangle2D(), viewportScale);
|
130 |
return ((geo.raster.GeoTiffFile) geoRasterFile).updateImage(sz, v.toRectangle2D(), viewportScale);
|
131 |
} |
132 |
|
133 |
} |