root / tags / v1_1_Build_1006 / libraries / libCq CMS for java.old / src / org / cresques / io / ShpFile.java @ 12458
History | View | Annotate | Download (3.43 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.cresques.io; |
25 |
|
26 |
import org.cresques.cts.ICoordTrans; |
27 |
import org.cresques.cts.IProjection; |
28 |
|
29 |
import org.cresques.px.IObjList; |
30 |
import org.cresques.px.gml.*; |
31 |
|
32 |
import java.io.FileInputStream; |
33 |
import java.io.FileNotFoundException; |
34 |
import java.io.IOException; |
35 |
import java.io.InputStream; |
36 |
|
37 |
import java.nio.MappedByteBuffer; |
38 |
import java.nio.channels.FileChannel; |
39 |
|
40 |
|
41 |
/**
|
42 |
* Clase de soporte para ficheros .shp de ArcView
|
43 |
*
|
44 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
|
45 |
* TODO extension .shp sin implementar
|
46 |
*/
|
47 |
public class ShpFile extends GeoFile { |
48 |
private String name; |
49 |
int l = 0; |
50 |
FeatureCollection collection = null;
|
51 |
|
52 |
/**
|
53 |
* Constructor de la clase Shp
|
54 |
*
|
55 |
*/
|
56 |
public ShpFile(IProjection proj, String name) { |
57 |
super(proj, name);
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* Carga un .gml
|
62 |
* @param name nombre del fichero
|
63 |
*/
|
64 |
public GeoFile load() {
|
65 |
System.out.println("Cargando " + name + " ..."); |
66 |
|
67 |
try {
|
68 |
if (FileFolder.isUrl(name)) {
|
69 |
ZipFileFolder zFolder = new ZipFileFolder(name);
|
70 |
|
71 |
return load(zFolder.getInputStream(name));
|
72 |
} else {
|
73 |
return load(new FileInputStream(name)); |
74 |
} |
75 |
} catch (FileNotFoundException e) { |
76 |
e.printStackTrace(); |
77 |
} catch (IOException ie) { |
78 |
System.err.println("ERROR." + l + "lineas leidas"); |
79 |
ie.printStackTrace(); |
80 |
} |
81 |
|
82 |
return this; |
83 |
} |
84 |
|
85 |
public int openLayer() { |
86 |
String m_Path = null; |
87 |
|
88 |
try {
|
89 |
FileInputStream fin = new FileInputStream(m_Path); |
90 |
|
91 |
// Open the file and then get a channel from the stream
|
92 |
FileChannel fc = fin.getChannel();
|
93 |
long sz = fc.size();
|
94 |
|
95 |
// Get the file's size and then map it into memory
|
96 |
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz); |
97 |
} catch (Exception e) { |
98 |
System.err.notify();
|
99 |
} |
100 |
|
101 |
return 0; |
102 |
} |
103 |
|
104 |
public GeoFile load(InputStream is) { |
105 |
// create a new header.
|
106 |
ShpFileHeader myHeader = new ShpFileHeader();
|
107 |
|
108 |
// read the header
|
109 |
//myHeader.readHeader(fr);
|
110 |
return this; |
111 |
} |
112 |
|
113 |
/**
|
114 |
* Obtiene la lista de features.
|
115 |
*/
|
116 |
public IObjList getObjects() {
|
117 |
return collection;
|
118 |
} |
119 |
|
120 |
public void reProject(ICoordTrans rp) { |
121 |
// TODO metodo reProject pendiente de implementar
|
122 |
} |
123 |
|
124 |
/* (non-Javadoc)
|
125 |
* @see org.cresques.io.GeoFile#close()
|
126 |
*/
|
127 |
public void close() { |
128 |
// TODO Auto-generated method stub
|
129 |
} |
130 |
} |