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