svn-gvsig-desktop / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / kml / KmlDriver.java @ 18333
History | View | Annotate | Download (4.07 KB)
1 | 10269 | jorpiell | package org.gvsig.remoteClient.kml; |
---|---|---|---|
2 | |||
3 | import java.awt.geom.Rectangle2D; |
||
4 | import java.io.InputStream; |
||
5 | |||
6 | import org.gvsig.remoteClient.gml.engine.AbstractDriver; |
||
7 | import org.gvsig.remoteClient.gml.engine.IFeaturesIterator; |
||
8 | import org.gvsig.remoteClient.gml.engine.readers.XmlReaderFile; |
||
9 | 18333 | jpiera | import org.gvsig.remoteClient.gml.exceptions.GMLException; |
10 | import org.gvsig.remoteClient.gml.exceptions.GMLExceptionList; |
||
11 | 10269 | jorpiell | import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
12 | import org.gvsig.remoteClient.kml.exceptions.KmlException; |
||
13 | import org.xmlpull.v1.XmlPullParserException; |
||
14 | |||
15 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
16 | *
|
||
17 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
18 | *
|
||
19 | * This program is free software; you can redistribute it and/or
|
||
20 | * modify it under the terms of the GNU General Public License
|
||
21 | * as published by the Free Software Foundation; either version 2
|
||
22 | * of the License, or (at your option) any later version.
|
||
23 | *
|
||
24 | * This program is distributed in the hope that it will be useful,
|
||
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
27 | * GNU General Public License for more details.
|
||
28 | *
|
||
29 | * You should have received a copy of the GNU General Public License
|
||
30 | * along with this program; if not, write to the Free Software
|
||
31 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
32 | *
|
||
33 | * For more information, contact:
|
||
34 | *
|
||
35 | * Generalitat Valenciana
|
||
36 | * Conselleria d'Infraestructures i Transport
|
||
37 | * Av. Blasco Ib??ez, 50
|
||
38 | * 46010 VALENCIA
|
||
39 | * SPAIN
|
||
40 | *
|
||
41 | * +34 963862235
|
||
42 | * gvsig@gva.es
|
||
43 | * www.gvsig.gva.es
|
||
44 | *
|
||
45 | * or
|
||
46 | *
|
||
47 | * IVER T.I. S.A
|
||
48 | * Salamanca 50
|
||
49 | * 46005 Valencia
|
||
50 | * Spain
|
||
51 | *
|
||
52 | * +34 963163400
|
||
53 | * dac@iver.es
|
||
54 | */
|
||
55 | /* CVS MESSAGES:
|
||
56 | *
|
||
57 | * $Id$
|
||
58 | * $Log$
|
||
59 | * Revision 1.1 2007-02-12 13:49:18 jorpiell
|
||
60 | * A?adido el driver de KML
|
||
61 | *
|
||
62 | *
|
||
63 | */
|
||
64 | /**
|
||
65 | * @author Jorge Piera Llodr? (piera_jor@gva.es)
|
||
66 | */
|
||
67 | public class KmlDriver extends AbstractDriver{ |
||
68 | private KmlHeaderParser headerParser = null; |
||
69 | |||
70 | 18333 | jpiera | public KmlDriver(InputStream file,IGeometriesFactory factory) throws GMLException { |
71 | 10269 | jorpiell | super(file, factory);
|
72 | } |
||
73 | |||
74 | /*
|
||
75 | * (non-Javadoc)
|
||
76 | * @see org.gvsig.remoteClient.gmlEngine.IDriver#getFeaturesIterator()
|
||
77 | */
|
||
78 | 18333 | jpiera | public IFeaturesIterator getFeaturesIterator() throws GMLException { |
79 | 10269 | jorpiell | return featuresParser.getFeaturesIterator();
|
80 | } |
||
81 | |||
82 | /*
|
||
83 | * (non-Javadoc)
|
||
84 | * @see org.gvsig.remoteClient.gmlEngine.IDriver#getExtent()
|
||
85 | */
|
||
86 | public Rectangle2D getExtent() { |
||
87 | // TODO Auto-generated method stub
|
||
88 | return null; |
||
89 | } |
||
90 | |||
91 | /*
|
||
92 | * (non-Javadoc)
|
||
93 | * @see org.gvsig.remoteClient.gmlEngine.IDriver#getSRS()
|
||
94 | */
|
||
95 | public String getSRS() { |
||
96 | // TODO Auto-generated method stub
|
||
97 | return null; |
||
98 | } |
||
99 | |||
100 | /*
|
||
101 | * (non-Javadoc)
|
||
102 | * @see org.gvsig.remoteClient.gmlEngine.IDriver#getVersion()
|
||
103 | */
|
||
104 | public String getVersion() { |
||
105 | // TODO Auto-generated method stub
|
||
106 | return null; |
||
107 | } |
||
108 | |||
109 | /*
|
||
110 | * (non-Javadoc)
|
||
111 | * @see org.gvsig.remoteClient.gmlEngine.IDriver#getWarnings()
|
||
112 | */
|
||
113 | 18333 | jpiera | public GMLExceptionList getWarnings() {
|
114 | 10269 | jorpiell | // TODO Auto-generated method stub
|
115 | return null; |
||
116 | } |
||
117 | |||
118 | /*
|
||
119 | * (non-Javadoc)
|
||
120 | * @see org.gvsig.remoteClient.gmlEngine.AbstractDriver#initialize(org.gvsig.remoteClient.gml.factories.IGeometriesFactory)
|
||
121 | */
|
||
122 | 18333 | jpiera | protected void initialize(IGeometriesFactory factory) throws KmlException { |
123 | 10269 | jorpiell | headerParser = new KmlHeaderParser(getReader());
|
124 | |||
125 | KmlParsersFactory parsersFactory = new KmlParsersFactory();
|
||
126 | featuresParser = (KmlFeaturesParser)parsersFactory.createParser(headerParser.getNameSpace(),factory,getReader()); |
||
127 | } |
||
128 | |||
129 | /*
|
||
130 | * (non-Javadoc)
|
||
131 | * @see org.gvsig.remoteClient.gmlEngine.AbstractDriver#initializeReader()
|
||
132 | */
|
||
133 | 18333 | jpiera | protected void initializeReader() throws KmlException { |
134 | 10269 | jorpiell | // make GML parser with the good enconding
|
135 | XmlReaderFile xmlReader = new XmlReaderFile();
|
||
136 | |||
137 | // setInput(file,encoding): it sets the encoding to read with the KXML parser
|
||
138 | //It is necessary to close the file before
|
||
139 | try {
|
||
140 | xmlReader.setInput(getInputStream(), getEncoding()); |
||
141 | 18333 | jpiera | } catch (Exception e) { |
142 | 10269 | jorpiell | // TODO Auto-generated catch block
|
143 | 18333 | jpiera | throw new KmlException(e); |
144 | 10269 | jorpiell | } |
145 | setReader(xmlReader); |
||
146 | } |
||
147 | |||
148 | |||
149 | |||
150 | } |