Statistics
| Revision:

svn-gvsig-desktop / tags / Root_CqCMSGisPlanet / libraries / libCq CMS for java.old / src / org / cresques / io / ShpFile.java @ 1933

History | View | Annotate | Download (2.29 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.IOException;
12
import java.io.InputStream;
13
import java.nio.MappedByteBuffer;
14
import java.nio.channels.FileChannel;
15

    
16
import org.cresques.cts.ICoordTrans;
17
import org.cresques.cts.IProjection;
18
import org.cresques.px.IObjList;
19
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
        private String name;        
30
        int l = 0;
31
        FeatureCollection collection = null;
32

    
33
        /**
34
         * Constructor de la clase Shp
35
         *
36
         */
37
        
38
        public ShpFile(IProjection proj, String name) {
39
                super(proj, name);
40
        }
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
                                return load(zFolder.getInputStream(name));
53
                        } else 
54
                                return load(new FileInputStream(name));
55
                } 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
        public int openLayer() {
65
                String m_Path = null;
66
                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
        
81
        public GeoFile load(InputStream is) {
82
                // create a new header.
83
                ShpFileHeader myHeader = new ShpFileHeader();
84
        
85
                // read the header
86
                //myHeader.readHeader(fr);
87
                return this;
88
        }
89
        
90
        /**
91
         * Obtiene la lista de features.
92
         */
93
        
94
        public IObjList getObjects() {
95
                return collection;
96
        }
97
        
98
        public void reProject(ICoordTrans rp) {
99
                // TODO metodo reProject pendiente de implementar
100
        }
101

    
102
        /* (non-Javadoc)
103
         * @see org.cresques.io.GeoFile#close()
104
         */
105
        public void close() {
106
                // TODO Auto-generated method stub
107
                
108
        }
109
}