Statistics
| Revision:

root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / io / ShpFile.java @ 2249

History | View | Annotate | Download (3.55 KB)

1
/*
2
 * Created on 21-jun-2005
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
 
48
package org.cresques.io;
49

    
50
import java.io.FileInputStream;
51
import java.io.FileNotFoundException;
52
import java.io.IOException;
53
import java.io.InputStream;
54
import java.nio.MappedByteBuffer;
55
import java.nio.channels.FileChannel;
56

    
57
import org.cresques.cts.ICoordTrans;
58
import org.cresques.cts.IProjection;
59
import org.cresques.px.IObjList;
60
import org.cresques.px.gml.*;
61

    
62
/**
63
 * Clase de soporte para ficheros .shp de ArcView
64
 * 
65
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
66
 * TODO extension .shp sin implementar
67
 */
68

    
69
public class ShpFile extends GeoFile {
70
        private String name;        
71
        int l = 0;
72
        FeatureCollection collection = null;
73

    
74
        /**
75
         * Constructor de la clase Shp
76
         *
77
         */
78
        
79
        public ShpFile(IProjection proj, String name) {
80
                super(proj, name);
81
        }
82

    
83
        /**
84
         * Carga un .gml
85
         * @param name nombre del fichero
86
         */
87
        
88
        public GeoFile load() {
89
                System.out.println("Cargando "+name+" ...");
90
                try {
91
                        if (FileFolder.isUrl(name)) {
92
                                ZipFileFolder zFolder = new ZipFileFolder(name);
93
                                return load(zFolder.getInputStream(name));
94
                        } else 
95
                                return load(new FileInputStream(name));
96
                } catch (FileNotFoundException e) {
97
                        e.printStackTrace();
98
                } catch (IOException ie) {
99
                        System.err.println("ERROR."+l+"lineas leidas");
100
                        ie.printStackTrace();
101
                }
102
                return this;
103
        }
104
        
105
        public int openLayer() {
106
                String m_Path = null;
107
                try {                
108
                        FileInputStream fin = new FileInputStream(m_Path);
109
                        // Open the file and then get a channel from the stream
110
                        FileChannel fc = fin.getChannel();                        
111
                        long sz = fc.size();
112
                        // Get the file's size and then map it into memory
113
                        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
114
                }
115
                catch(Exception e)
116
                {
117
                        System.err.notify();
118
                }
119
                return 0;
120
        }
121
        
122
        public GeoFile load(InputStream is) {
123
                // create a new header.
124
                ShpFileHeader myHeader = new ShpFileHeader();
125
        
126
                // read the header
127
                //myHeader.readHeader(fr);
128
                return this;
129
        }
130
        
131
        /**
132
         * Obtiene la lista de features.
133
         */
134
        
135
        public IObjList getObjects() {
136
                return collection;
137
        }
138
        
139
        public void reProject(ICoordTrans rp) {
140
                // TODO metodo reProject pendiente de implementar
141
        }
142

    
143
        /* (non-Javadoc)
144
         * @see org.cresques.io.GeoFile#close()
145
         */
146
        public void close() {
147
                // TODO Auto-generated method stub
148
                
149
        }
150
}