root / trunk / libraries / libGPE-GML / src / org / gvsig / gpe / gml / parser / sfp0 / coordinates / PosTypeIterator.java @ 19954
History | View | Annotate | Download (3.32 KB)
1 |
package org.gvsig.gpe.gml.parser.sfp0.coordinates; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.util.StringTokenizer; |
5 |
|
6 |
import javax.xml.namespace.QName; |
7 |
|
8 |
import org.gvsig.gpe.gml.parser.GPEDefaultGmlParser; |
9 |
import org.gvsig.gpe.gml.parser.v2.coordinates.GmlCoodinatesIterator; |
10 |
import org.gvsig.gpe.gml.parser.v2.geometries.DoubleTypeBinding; |
11 |
import org.gvsig.gpe.gml.utils.GMLTags; |
12 |
import org.gvsig.gpe.xml.stream.IXmlStreamReader; |
13 |
import org.gvsig.gpe.xml.stream.XmlStreamException; |
14 |
import org.gvsig.gpe.xml.utils.CompareUtils; |
15 |
|
16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
17 |
*
|
18 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
19 |
*
|
20 |
* This program is free software; you can redistribute it and/or
|
21 |
* modify it under the terms of the GNU General Public License
|
22 |
* as published by the Free Software Foundation; either version 2
|
23 |
* of the License, or (at your option) any later version.
|
24 |
*
|
25 |
* This program is distributed in the hope that it will be useful,
|
26 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
* GNU General Public License for more details.
|
29 |
*
|
30 |
* You should have received a copy of the GNU General Public License
|
31 |
* along with this program; if not, write to the Free Software
|
32 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
33 |
*
|
34 |
* For more information, contact:
|
35 |
*
|
36 |
* Generalitat Valenciana
|
37 |
* Conselleria d'Infraestructures i Transport
|
38 |
* Av. Blasco Ib??ez, 50
|
39 |
* 46010 VALENCIA
|
40 |
* SPAIN
|
41 |
*
|
42 |
* +34 963862235
|
43 |
* gvsig@gva.es
|
44 |
* www.gvsig.gva.es
|
45 |
*
|
46 |
* or
|
47 |
*
|
48 |
* IVER T.I. S.A
|
49 |
* Salamanca 50
|
50 |
* 46005 Valencia
|
51 |
* Spain
|
52 |
*
|
53 |
* +34 963163400
|
54 |
* dac@iver.es
|
55 |
*/
|
56 |
|
57 |
public class PosTypeIterator extends GmlCoodinatesIterator{ |
58 |
|
59 |
/* (non-Javadoc)
|
60 |
* @see org.gvsig.gpe.gml.parser.v2.coordinates.GmlCoodinatesIterator#initialize(org.gvsig.gpe.xml.stream.IXmlStreamReader, org.gvsig.gpe.gml.parser.GPEDefaultGmlParser, java.lang.String)
|
61 |
*/
|
62 |
public void initialize(IXmlStreamReader parser, |
63 |
GPEDefaultGmlParser handler, QName lastTag)
|
64 |
throws XmlStreamException, IOException { |
65 |
// TODO Auto-generated method stub
|
66 |
super.initialize(parser, handler, lastTag);
|
67 |
} |
68 |
|
69 |
/*
|
70 |
* (non-Javadoc)
|
71 |
* @see org.gvsig.gpe.parser.ICoordinateIterator#hasNext()
|
72 |
*/
|
73 |
public boolean hasNext() throws IOException { |
74 |
QName tag = parser.getName();
|
75 |
|
76 |
if (CompareUtils.compareWithNamespace(tag,GMLTags.GML_POS)){
|
77 |
return true; |
78 |
} |
79 |
parseAll(); |
80 |
return false; |
81 |
} |
82 |
|
83 |
/*
|
84 |
* (non-Javadoc)
|
85 |
* @see org.gvsig.gpe.parser.ICoordinateIterator#next(double[])
|
86 |
*/
|
87 |
public void next(double[] buffer) throws IOException { |
88 |
parser.next(); |
89 |
|
90 |
StringTokenizer coordinatesString = new StringTokenizer(parser.getText().trim(),TUPLES_SEPARATOR); |
91 |
int i=0; |
92 |
|
93 |
while(coordinatesString.hasMoreTokens() && i<buffer.length){
|
94 |
buffer[i] = DoubleTypeBinding.parse(coordinatesString.nextToken(),COORDINATES_DECIMAL); |
95 |
i++; |
96 |
} |
97 |
//Advance until the end pos label
|
98 |
while ((parser.getName() != GMLTags.GML_POS) && (parser.getEventType() != IXmlStreamReader.END_ELEMENT)){
|
99 |
parser.next(); |
100 |
} |
101 |
} |
102 |
|
103 |
/* (non-Javadoc)
|
104 |
* @see org.gvsig.gpe.gml.parser.v2.coordinates.GmlCoodinatesIterator#getDimension()
|
105 |
*/
|
106 |
public int getDimension() { |
107 |
//TODO Calculate the dimension
|
108 |
if (dimension == -1){ |
109 |
dimension = 3;
|
110 |
} |
111 |
return dimension;
|
112 |
} |
113 |
|
114 |
|
115 |
} |