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