svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / gml / GMLFeaturesParser.java @ 6433
History | View | Annotate | Download (3.09 KB)
1 |
package com.iver.cit.gvsig.fmap.drivers.gml; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
import java.io.FileInputStream; |
5 |
import java.io.InputStream; |
6 |
import java.util.Vector; |
7 |
|
8 |
import org.geotools.data.FeatureReader; |
9 |
import org.geotools.data.wfs.WFSFeatureReader; |
10 |
import org.geotools.data.wfs.WFSTransactionState; |
11 |
import org.geotools.factory.FactoryConfigurationError; |
12 |
import org.geotools.feature.AttributeType; |
13 |
import org.geotools.feature.AttributeTypeFactory; |
14 |
import org.geotools.feature.FeatureType; |
15 |
import org.geotools.feature.FeatureTypeBuilder; |
16 |
import org.geotools.feature.SchemaException; |
17 |
import org.geotools.xml.gml.GMLFeatureCollection; |
18 |
import org.xml.sax.SAXException; |
19 |
|
20 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
21 |
*
|
22 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
23 |
*
|
24 |
* This program is free software; you can redistribute it and/or
|
25 |
* modify it under the terms of the GNU General Public License
|
26 |
* as published by the Free Software Foundation; either version 2
|
27 |
* of the License, or (at your option) any later version.
|
28 |
*
|
29 |
* This program is distributed in the hope that it will be useful,
|
30 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
31 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
32 |
* GNU General Public License for more details.
|
33 |
*
|
34 |
* You should have received a copy of the GNU General Public License
|
35 |
* along with this program; if not, write to the Free Software
|
36 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
37 |
*
|
38 |
* For more information, contact:
|
39 |
*
|
40 |
* Generalitat Valenciana
|
41 |
* Conselleria d'Infraestructures i Transport
|
42 |
* Av. Blasco Ib??ez, 50
|
43 |
* 46010 VALENCIA
|
44 |
* SPAIN
|
45 |
*
|
46 |
* +34 963862235
|
47 |
* gvsig@gva.es
|
48 |
* www.gvsig.gva.es
|
49 |
*
|
50 |
* or
|
51 |
*
|
52 |
* IVER T.I. S.A
|
53 |
* Salamanca 50
|
54 |
* 46005 Valencia
|
55 |
* Spain
|
56 |
*
|
57 |
* +34 963163400
|
58 |
* dac@iver.es
|
59 |
*/
|
60 |
/* CVS MESSAGES:
|
61 |
*
|
62 |
* $Id: GMLFeaturesParser.java 6433 2006-07-19 12:30:09Z jorpiell $
|
63 |
* $Log$
|
64 |
* Revision 1.1 2006-07-19 12:29:39 jorpiell
|
65 |
* A?adido el driver de GML
|
66 |
*
|
67 |
*
|
68 |
*/
|
69 |
/**
|
70 |
* It parses a getFeature request file
|
71 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
72 |
*/
|
73 |
public class GMLFeaturesParser{ |
74 |
private static int buffer = 100000000; |
75 |
private static int timeout = 100000000; |
76 |
/**
|
77 |
* Return an iterrator of features
|
78 |
* @param file
|
79 |
* File to parse
|
80 |
* @param currentSRS
|
81 |
* Curerent SRS (to reproject)
|
82 |
* @return
|
83 |
* Iterator
|
84 |
* @throws Exception
|
85 |
*/
|
86 |
public static GMLFeaturesIterator getFeatureReader(File file) throws Exception{ |
87 |
FileInputStream is = new FileInputStream(file); |
88 |
|
89 |
FeatureReader featureReader = getFeatureReader(is, |
90 |
buffer, |
91 |
timeout, |
92 |
null,
|
93 |
null);
|
94 |
|
95 |
return new GMLFeaturesIterator(featureReader); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* Gets a feature reader
|
100 |
* @param is
|
101 |
* WFS getFeature XML File
|
102 |
* @param bufferSize
|
103 |
* buffer size
|
104 |
* @param timeout
|
105 |
* Request timeout
|
106 |
* @param transaction
|
107 |
* @param ft
|
108 |
* Feature schema
|
109 |
* @return
|
110 |
* @throws SAXException
|
111 |
*/
|
112 |
private static FeatureReader getFeatureReader(InputStream is, |
113 |
int bufferSize, int timeout, WFSTransactionState transaction, FeatureType ft) throws SAXException{ |
114 |
return WFSFeatureReader.getFeatureReader(is, bufferSize,
|
115 |
timeout, transaction, ft); |
116 |
} |
117 |
|
118 |
|
119 |
} |