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