svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / grid / ArcGridDriver.java @ 569
History | View | Annotate | Download (3.67 KB)
1 |
/*
|
---|---|
2 |
* Created on 17-dic-2004
|
3 |
*/
|
4 |
package com.iver.cit.gvsig.fmap.drivers.grid; |
5 |
|
6 |
import java.awt.geom.Rectangle2D; |
7 |
import java.io.File; |
8 |
import java.io.IOException; |
9 |
|
10 |
import org.cresques.cts.IProjection; |
11 |
import org.cresques.io.AscArcGridFile; |
12 |
|
13 |
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver; |
14 |
|
15 |
/**
|
16 |
* Driver de raster (tal y como los abre CMS.
|
17 |
* Primera aproximaci?n al raster. Borrador para revisar.
|
18 |
*
|
19 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
20 |
*/
|
21 |
public class ArcGridDriver implements GeorreferencedRasterDriver { |
22 |
private File rasterFile = null; |
23 |
private IProjection proj = null; |
24 |
private AscArcGridFile gridFile = null; |
25 |
/**
|
26 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#open(java.io.File)
|
27 |
*/
|
28 |
public void open(File f) throws IOException { |
29 |
rasterFile = f; |
30 |
} |
31 |
|
32 |
/* (non-Javadoc)
|
33 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#close()
|
34 |
*/
|
35 |
public void close() throws IOException { |
36 |
// TODO Auto-generated method stub
|
37 |
} |
38 |
|
39 |
/* (non-Javadoc)
|
40 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#initialize()
|
41 |
*/
|
42 |
public void initialize() throws IOException { |
43 |
if (proj != null){ |
44 |
gridFile = new AscArcGridFile(proj, rasterFile.getAbsolutePath());
|
45 |
gridFile.load(); |
46 |
} else
|
47 |
throw new IOException("Proyecci?n no asignada"); |
48 |
} |
49 |
|
50 |
/**
|
51 |
* @see com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver#initialize(org.cresques.cts.IProjection)
|
52 |
*/
|
53 |
public void initialize(IProjection proj) throws IOException { |
54 |
setProjection(proj); |
55 |
gridFile = new AscArcGridFile(proj, rasterFile.getAbsolutePath());
|
56 |
} |
57 |
|
58 |
/*
|
59 |
* @see com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver#getProjection()
|
60 |
*/
|
61 |
public IProjection getProjection() {
|
62 |
return proj;
|
63 |
} |
64 |
|
65 |
|
66 |
/* (non-Javadoc)
|
67 |
* @see com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver#setProjection(org.cresques.cts.IProjection)
|
68 |
*/
|
69 |
public void setProjection(IProjection proj) { |
70 |
this.proj = proj;
|
71 |
} |
72 |
|
73 |
/*
|
74 |
* @see com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver#getFullExtent()
|
75 |
*/
|
76 |
public Rectangle2D getFullExtent() { |
77 |
return gridFile.getExtent().toRectangle2D();
|
78 |
} |
79 |
|
80 |
/*
|
81 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getNumBands()
|
82 |
*/
|
83 |
public int getNumBands() { |
84 |
return gridFile.getBandCount();
|
85 |
} |
86 |
|
87 |
/* (non-Javadoc)
|
88 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getRasterDataType()
|
89 |
*/
|
90 |
public int getRasterDataType() { |
91 |
return gridFile.getDataType();
|
92 |
} |
93 |
|
94 |
/* (non-Javadoc)
|
95 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getData(int, int, int)
|
96 |
*/
|
97 |
public Object getData(int x, int y, int band) { |
98 |
return gridFile.getElem(x, y, band);
|
99 |
} |
100 |
|
101 |
/* (non-Javadoc)
|
102 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getDataAsByte(int, int, int)
|
103 |
*/
|
104 |
public byte getDataAsByte(int x, int y, int band) { |
105 |
return (byte) gridFile.getElemInt(x, y, band); |
106 |
} |
107 |
|
108 |
/* (non-Javadoc)
|
109 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getDataAsFloat(int, int, int)
|
110 |
*/
|
111 |
public float getDataAsFloat(int x, int y, int band) { |
112 |
return gridFile.getElemFloat(x, y, band);
|
113 |
} |
114 |
|
115 |
/* (non-Javadoc)
|
116 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getDataAsDouble(int, int, int)
|
117 |
*/
|
118 |
public double getDataAsDouble(int x, int y, int band) { |
119 |
return gridFile.getElemDouble(x, y, band);
|
120 |
} |
121 |
|
122 |
/* (non-Javadoc)
|
123 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#getDataAsInt(int, int, int)
|
124 |
*/
|
125 |
public int getDataAsInt(int x, int y, int band) { |
126 |
return gridFile.getElemInt(x, y, band);
|
127 |
} |
128 |
/* (non-Javadoc)
|
129 |
* @see com.hardcode.driverManager.Driver#getName()
|
130 |
*/
|
131 |
public String getName() { |
132 |
return "gvSIG ArcGrid (ascii) Driver"; |
133 |
} |
134 |
|
135 |
/* (non-Javadoc)
|
136 |
* @see com.iver.cit.gvsig.fmap.drivers.RasterDriver#fileAccepted(java.io.File)
|
137 |
*/
|
138 |
public boolean fileAccepted(File fName) { |
139 |
return true; |
140 |
} |
141 |
} |