svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / io / ShpFile.java @ 9
History | View | Annotate | Download (2.2 KB)
1 |
/*
|
---|---|
2 |
* Created on 03-may-2004
|
3 |
*
|
4 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
5 |
*/
|
6 |
|
7 |
package org.cresques.io; |
8 |
|
9 |
import java.io.FileInputStream; |
10 |
import java.io.FileNotFoundException; |
11 |
import java.io.FileReader; |
12 |
import java.io.IOException; |
13 |
import java.io.InputStream; |
14 |
import java.io.InputStreamReader; |
15 |
import java.io.Reader; |
16 |
import java.nio.MappedByteBuffer; |
17 |
import java.nio.channels.FileChannel; |
18 |
|
19 |
import org.cresques.geo.Projection; |
20 |
import org.cresques.geo.ReProjection; |
21 |
import org.cresques.px.gml.*; |
22 |
|
23 |
/**
|
24 |
* Clase de soporte para ficheros .shp de ArcView
|
25 |
*
|
26 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
|
27 |
* TODO extension .shp sin implementar
|
28 |
*/
|
29 |
|
30 |
public class ShpFile extends GeoFile { |
31 |
private String name; |
32 |
int l = 0; |
33 |
|
34 |
FeatureCollection collection = null;
|
35 |
|
36 |
/**
|
37 |
* Constructor de la clase Shp
|
38 |
*
|
39 |
*/
|
40 |
|
41 |
public ShpFile(Projection proj, String name) { |
42 |
super(proj);
|
43 |
this.name = name;
|
44 |
} |
45 |
|
46 |
/**
|
47 |
* Carga un .gml
|
48 |
* @param name nombre del fichero
|
49 |
*/
|
50 |
|
51 |
public GeoFile load() {
|
52 |
System.out.println("Cargando "+name+" ..."); |
53 |
try {
|
54 |
if (FileFolder.isUrl(name)) {
|
55 |
ZipFileFolder zFolder = new ZipFileFolder(name);
|
56 |
return load(zFolder.getInputStream(name));
|
57 |
} else
|
58 |
return load(new FileInputStream(name)); |
59 |
} catch (FileNotFoundException e) { |
60 |
e.printStackTrace(); |
61 |
} catch (IOException ie) { |
62 |
System.err.println("ERROR."+l+"lineas leidas"); |
63 |
ie.printStackTrace(); |
64 |
} |
65 |
return this; |
66 |
} |
67 |
|
68 |
public int openLayer() { |
69 |
try {
|
70 |
FileInputStream fin = new FileInputStream(m_Path); |
71 |
// Open the file and then get a channel from the stream
|
72 |
FileChannel fc = fin.getChannel();
|
73 |
long sz = fc.size();
|
74 |
// Get the file's size and then map it into memory
|
75 |
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz); |
76 |
} |
77 |
catch(Exception e) |
78 |
{ |
79 |
System.err.notify();
|
80 |
} |
81 |
return 0; |
82 |
} |
83 |
public GeoFile load(InputStream is) { |
84 |
// create a new header.
|
85 |
ShpFileHeader myHeader = new ShpFileHeader();
|
86 |
|
87 |
// read the header
|
88 |
myHeader.readHeader(fr); |
89 |
return this; |
90 |
} |
91 |
|
92 |
/**
|
93 |
* Obtiene la lista de features.
|
94 |
*/
|
95 |
|
96 |
public FeatureCollection getObjects() {
|
97 |
return collection;
|
98 |
} |
99 |
|
100 |
public void reProject(ReProjection rp) { |
101 |
// TODO metodo reProject pendiente de implementar
|
102 |
} |
103 |
} |