Revision 11475
trunk/libraries/libGPE/src/org/gvsig/gpe/IGPEContentHandler.java | ||
---|---|---|
67 | 67 |
|
68 | 68 |
public void endInnerPolygon(Object innerPolygon); |
69 | 69 |
|
70 |
public void startMultiPoint(String id, String srs); |
|
71 |
|
|
72 |
public void endMultiPoint(Object multiPoint); |
|
73 |
|
|
74 |
public void addPointToMultiPoint(Object point,Object multiPoint); |
|
75 |
|
|
76 |
public void startMultiLineString(String id, String srs); |
|
77 |
|
|
78 |
public void endMultiLineString(Object multiLineString); |
|
79 |
|
|
80 |
public void addLineStringToMultiLineString(Object lineString,Object multiLineString); |
|
81 |
|
|
82 |
public void startMultiPolygon(String id, String srs); |
|
83 |
|
|
84 |
public void endMultiPolygon(Object multiPolygon); |
|
85 |
|
|
86 |
public void addPolygonToMultiPolygon(Object polygon,Object multiPolygon); |
|
87 |
|
|
88 |
public void startMultiGeometry(String id, String srs); |
|
89 |
|
|
90 |
public void endMultiGeometry(Object multiGeometry); |
|
91 |
|
|
92 |
public void addGeometryToMultiGeometry(Object geometry,Object multiGeometry); |
|
93 |
|
|
70 | 94 |
public void addBboxToGeometry(Object bbox, Object geometry); |
71 | 95 |
|
72 | 96 |
public void addGeometryToFeature(Object geometry, Object feature); |
trunk/libraries/libGPE/src/org/gvsig/gpe/writers/IGPEWriterHandler.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.3 2007-04-26 14:29:15 jorpiell |
|
46 |
* Revision 1.4 2007-05-07 12:57:55 jorpiell |
|
47 |
* Add some methods to manage the multigeometries |
|
48 |
* |
|
49 |
* Revision 1.3 2007/04/26 14:29:15 jorpiell |
|
47 | 50 |
* Add a getStringProperty method to the GEPDeafults |
48 | 51 |
* |
49 | 52 |
* Revision 1.2 2007/04/13 13:14:55 jorpiell |
... | ... | |
113 | 116 |
|
114 | 117 |
public void endMultiPolygon(); |
115 | 118 |
|
119 |
public void startMultiGeometry(String id, String srs); |
|
120 |
|
|
121 |
public void endMultiGeometry(); |
|
122 |
|
|
116 | 123 |
public void startInnerBoundary(String id,double[] x, double[] y, double[] z, String srs); |
117 | 124 |
|
118 | 125 |
public void endInnerBoundary(); |
trunk/libraries/libGPE/src/org/gvsig/gpe/writers/GPEWriterHandler.java | ||
---|---|---|
49 | 49 |
* |
50 | 50 |
* $Id$ |
51 | 51 |
* $Log$ |
52 |
* Revision 1.7 2007-05-07 07:06:26 jorpiell |
|
52 |
* Revision 1.8 2007-05-07 12:57:55 jorpiell |
|
53 |
* Add some methods to manage the multigeometries |
|
54 |
* |
|
55 |
* Revision 1.7 2007/05/07 07:06:26 jorpiell |
|
53 | 56 |
* Add a constructor with the name and the description fields |
54 | 57 |
* |
55 | 58 |
* Revision 1.6 2007/04/26 14:29:15 jorpiell |
... | ... | |
101 | 104 |
public GPEWriterHandler(String name, String description){ |
102 | 105 |
this.name = name; |
103 | 106 |
this.description = description; |
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* @return the description |
|
111 |
*/ |
|
112 |
public String getDescription() { |
|
113 |
return description; |
|
104 | 114 |
} |
115 |
|
|
116 |
/** |
|
117 |
* @return the name |
|
118 |
*/ |
|
119 |
public String getName() { |
|
120 |
return name; |
|
121 |
} |
|
105 | 122 |
|
106 | 123 |
/** |
107 | 124 |
* Gets the deafult writting version |
... | ... | |
324 | 341 |
|
325 | 342 |
} |
326 | 343 |
|
327 |
/** |
|
328 |
* @return the description |
|
329 |
*/ |
|
330 |
public String getDescription() { |
|
331 |
return description; |
|
344 |
public void endMultiGeometry() { |
|
345 |
// TODO Auto-generated method stub |
|
346 |
|
|
332 | 347 |
} |
333 | 348 |
|
334 |
/** |
|
335 |
* @return the name |
|
336 |
*/ |
|
337 |
public String getName() { |
|
338 |
return name; |
|
349 |
public void startMultiGeometry(String id, String srs) { |
|
350 |
// TODO Auto-generated method stub |
|
351 |
|
|
339 | 352 |
} |
340 | 353 |
} |
trunk/libraries/libGPE/src/org/gvsig/gpe/GPEContentHandler.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.10 2007-04-19 07:23:20 jorpiell |
|
46 |
* Revision 1.11 2007-05-07 12:57:55 jorpiell |
|
47 |
* Add some methods to manage the multigeometries |
|
48 |
* |
|
49 |
* Revision 1.10 2007/04/19 07:23:20 jorpiell |
|
47 | 50 |
* Add the add methods to teh contenhandler and change the register mode |
48 | 51 |
* |
49 | 52 |
* Revision 1.9 2007/04/18 12:48:16 jorpiell |
... | ... | |
230 | 233 |
return null; |
231 | 234 |
} |
232 | 235 |
|
236 |
public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) { |
|
237 |
// TODO Auto-generated method stub |
|
238 |
|
|
239 |
} |
|
233 | 240 |
|
241 |
public void addLineStringToMultiLineString(Object lineString, Object multiLineString) { |
|
242 |
// TODO Auto-generated method stub |
|
243 |
|
|
244 |
} |
|
245 |
|
|
246 |
public void addPointToMultiPoint(Object point, Object multiPoint) { |
|
247 |
// TODO Auto-generated method stub |
|
248 |
|
|
249 |
} |
|
250 |
|
|
251 |
public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) { |
|
252 |
// TODO Auto-generated method stub |
|
253 |
|
|
254 |
} |
|
255 |
|
|
256 |
public void endMultiGeometry(Object multiGeometry) { |
|
257 |
// TODO Auto-generated method stub |
|
258 |
|
|
259 |
} |
|
260 |
|
|
261 |
public void endMultiLineString(Object multiLineString) { |
|
262 |
// TODO Auto-generated method stub |
|
263 |
|
|
264 |
} |
|
265 |
|
|
266 |
public void endMultiPoint(Object multiPoint) { |
|
267 |
// TODO Auto-generated method stub |
|
268 |
|
|
269 |
} |
|
270 |
|
|
271 |
public void endMultiPolygon(Object multiPolygon) { |
|
272 |
// TODO Auto-generated method stub |
|
273 |
|
|
274 |
} |
|
275 |
|
|
276 |
public void startMultiGeometry(String id, String srs) { |
|
277 |
// TODO Auto-generated method stub |
|
278 |
|
|
279 |
} |
|
280 |
|
|
281 |
public void startMultiLineString(String id, String srs) { |
|
282 |
// TODO Auto-generated method stub |
|
283 |
|
|
284 |
} |
|
285 |
|
|
286 |
public void startMultiPoint(String id, String srs) { |
|
287 |
// TODO Auto-generated method stub |
|
288 |
|
|
289 |
} |
|
290 |
|
|
291 |
public void startMultiPolygon(String id, String srs) { |
|
292 |
// TODO Auto-generated method stub |
|
293 |
|
|
294 |
} |
|
295 |
|
|
296 |
|
|
234 | 297 |
|
235 | 298 |
|
236 | 299 |
|
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/utils/CoordsContainer.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.utils; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
6 |
* |
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
8 |
* |
|
9 |
* This program is free software; you can redistribute it and/or |
|
10 |
* modify it under the terms of the GNU General Public License |
|
11 |
* as published by the Free Software Foundation; either version 2 |
|
12 |
* of the License, or (at your option) any later version. |
|
13 |
* |
|
14 |
* This program is distributed in the hope that it will be useful, |
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with this program; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
22 |
* |
|
23 |
* For more information, contact: |
|
24 |
* |
|
25 |
* Generalitat Valenciana |
|
26 |
* Conselleria d'Infraestructures i Transport |
|
27 |
* Av. Blasco Ib??ez, 50 |
|
28 |
* 46010 VALENCIA |
|
29 |
* SPAIN |
|
30 |
* |
|
31 |
* +34 963862235 |
|
32 |
* gvsig@gva.es |
|
33 |
* www.gvsig.gva.es |
|
34 |
* |
|
35 |
* or |
|
36 |
* |
|
37 |
* IVER T.I. S.A |
|
38 |
* Salamanca 50 |
|
39 |
* 46005 Valencia |
|
40 |
* Spain |
|
41 |
* |
|
42 |
* +34 963163400 |
|
43 |
* dac@iver.es |
|
44 |
*/ |
|
45 |
/* CVS MESSAGES: |
|
46 |
* |
|
47 |
* $Id$ |
|
48 |
* $Log$ |
|
49 |
* Revision 1.1 2007-05-07 12:58:42 jorpiell |
|
50 |
* Add some methods to manage the multigeometries |
|
51 |
* |
|
52 |
* |
|
53 |
*/ |
|
54 |
/** |
|
55 |
* This class is used like a coordinates container. It is |
|
56 |
* used when the COORD gml tag appears and the parser |
|
57 |
* needs to have a list of the previous parsed coordinates. |
|
58 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
59 |
*/ |
|
60 |
public class CoordsContainer { |
|
61 |
private ArrayList coordinates = null; |
|
62 |
|
|
63 |
public CoordsContainer(){ |
|
64 |
//TODO Hacer lo mismo con 3 arraylists |
|
65 |
coordinates = new ArrayList(); |
|
66 |
} |
|
67 |
|
|
68 |
public void addCoordinates(double[] xyz){ |
|
69 |
coordinates.add(xyz); |
|
70 |
} |
|
71 |
|
|
72 |
/** |
|
73 |
* It retuns a matrix of doubles with 3 columns (x,y,z) and |
|
74 |
* one row for each coordinate. |
|
75 |
*/ |
|
76 |
public double[][] getCoordinates(){ |
|
77 |
double[][] coords = new double[3][coordinates.size()]; |
|
78 |
for (int i=0 ; i<coordinates.size() ; i++){ |
|
79 |
coords[0][i] = ((double[])coordinates.get(i))[0]; |
|
80 |
coords[1][i] = ((double[])coordinates.get(i))[1]; |
|
81 |
coords[2][i] = ((double[])coordinates.get(i))[2]; |
|
82 |
} |
|
83 |
return coords; |
|
84 |
} |
|
85 |
} |
|
0 | 86 |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/utils/GMLUtilsParser.java | ||
---|---|---|
3 | 3 |
import java.awt.geom.Point2D; |
4 | 4 |
import java.awt.geom.Rectangle2D; |
5 | 5 |
import java.io.IOException; |
6 |
import java.util.Hashtable; |
|
6 | 7 |
|
7 | 8 |
import org.gvsig.exceptions.BaseException; |
8 | 9 |
import org.gvsig.gpe.gml.GMLTags; |
10 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
9 | 11 |
import org.gvsig.gpe.gml.GMLFeaturesParser.Extent; |
10 | 12 |
import org.gvsig.gpe.gml.exceptions.GMLFileReadException; |
11 | 13 |
import org.gvsig.gpe.gml.exceptions.GMLNoGeometryException; |
... | ... | |
13 | 15 |
import org.gvsig.gpe.gml.factories.IGeometriesFactory; |
14 | 16 |
import org.gvsig.gpe.gml.schemas.XMLSchemaParser; |
15 | 17 |
import org.kxml2.io.KXmlParser; |
18 |
import org.xmlpull.v1.XmlPullParser; |
|
16 | 19 |
import org.xmlpull.v1.XmlPullParserException; |
17 | 20 |
|
18 | 21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
... | ... | |
59 | 62 |
* |
60 | 63 |
* $Id$ |
61 | 64 |
* $Log$ |
62 |
* Revision 1.1 2007-02-28 11:48:31 csanchez |
|
65 |
* Revision 1.2 2007-05-07 12:58:42 jorpiell |
|
66 |
* Add some methods to manage the multigeometries |
|
67 |
* |
|
68 |
* Revision 1.1 2007/02/28 11:48:31 csanchez |
|
63 | 69 |
* *** empty log message *** |
64 | 70 |
* |
65 | 71 |
* Revision 1.1 2007/02/20 10:53:20 jorpiell |
... | ... | |
83 | 89 |
public class GMLUtilsParser { |
84 | 90 |
|
85 | 91 |
/** |
92 |
* It returns a HashTable with the XML attributes. It has been |
|
93 |
* created because the parser doesn't has a getAttribiute(AttributeName) |
|
94 |
* method. |
|
95 |
|
|
96 |
* @param parser |
|
97 |
* @return |
|
98 |
*/ |
|
99 |
public static Hashtable getAttributes(XmlPullParser parser){ |
|
100 |
Hashtable hash = new Hashtable(); |
|
101 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
102 |
hash.put(parser.getAttributeName(i), |
|
103 |
parser.getAttributeValue(i)); |
|
104 |
} |
|
105 |
return hash; |
|
106 |
} |
|
107 |
|
|
108 |
|
|
109 |
/** |
|
86 | 110 |
* Parses the boundedBy GML tag |
87 | 111 |
* @throws IOException |
88 | 112 |
* @throws XmlPullParserException |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/GMLTags.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.5 2007-04-13 13:16:00 jorpiell |
|
46 |
* Revision 1.6 2007-05-07 12:58:42 jorpiell |
|
47 |
* Add some methods to manage the multigeometries |
|
48 |
* |
|
49 |
* Revision 1.5 2007/04/13 13:16:00 jorpiell |
|
47 | 50 |
* Add the multiple geometries |
48 | 51 |
* |
49 | 52 |
* Revision 1.4 2007/04/12 17:06:44 jorpiell |
... | ... | |
100 | 103 |
public static final String GML_COORD = "coord"; |
101 | 104 |
public static final String GML_X = "X"; |
102 | 105 |
public static final String GML_Y = "Y"; |
106 |
public static final String GML_Z = "Z"; |
|
103 | 107 |
public static final String GML_COORDINATES_DECIMAL = "decimal"; |
104 | 108 |
public static final String GML_COORDINATES_CS = "cs"; |
105 | 109 |
public static final String GML_COORDINATES_TS = "ts"; |
... | ... | |
123 | 127 |
public static final String GML_MULTIPOINT = "MultiPoint"; |
124 | 128 |
public static final String GML_MULTILINESTRING = "MultiLineString"; |
125 | 129 |
public static final String GML_MULTIPOLYGON = "MultiPolygon"; |
130 |
public static final String GML_MULTIGEOMETRY = "MultiGeometry"; |
|
126 | 131 |
|
132 |
public static final String GML_DEFAULT_TUPLES_SEPARATOR = " "; |
|
133 |
public static final String GML_DEFAULT_COORDINATES_SEPARATOR = ","; |
|
134 |
public static final String GML_DEFAULT_COORDINATES_DECIMAL = "."; |
|
135 |
|
|
127 | 136 |
public static final String GML_OUTERBOUNDARYIS = "outerBoundaryIs"; |
128 | 137 |
public static final String GML_INNERBOUNDARYIS = "innerBoundaryIs"; |
129 | 138 |
public static final String GML_POINTMEMBER = "pointMember"; |
130 | 139 |
public static final String GML_LINESTRINGMEMBER = "lineStringMember"; |
131 | 140 |
public static final String GML_POLYGONMEMBER = "polygonMember"; |
141 |
public static final String GML_GEOMETRYMEMBER = "geometryMember"; |
|
142 |
|
|
132 | 143 |
} |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/PolygonBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.gpe.gml.GMLTags; |
|
6 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
7 |
import org.kxml2.io.KXmlParser; |
|
8 |
import org.xmlpull.v1.XmlPullParser; |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id$ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1 2007-05-07 07:06:46 jorpiell |
|
56 |
* Add a constructor with the name and the description fields |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
62 |
*/ |
|
63 |
public class PolygonBinding { |
|
64 |
public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
65 |
boolean endFeature = false; |
|
66 |
int currentTag; |
|
67 |
Object polygon = null; |
|
68 |
|
|
69 |
String srsName = AGeometryBinding.getSrsName(parser, handler); |
|
70 |
String id = AGeometryBinding.getID(parser, handler); |
|
71 |
|
|
72 |
|
|
73 |
String tag = parser.getName(); |
|
74 |
currentTag = parser.getEventType(); |
|
75 |
|
|
76 |
while (!endFeature){ |
|
77 |
switch(currentTag){ |
|
78 |
case KXmlParser.START_TAG: |
|
79 |
// if (tag.compareTo(KmlTags.OUTERBOUNDARYIS) == 0){ |
|
80 |
// double[][] coordinates = OuterBoundaryIsBinding.parse(parser, handler); |
|
81 |
// polygon = handler.getContentHandler().startPolygon(id, |
|
82 |
// coordinates[0], |
|
83 |
// coordinates[1], |
|
84 |
// coordinates[2], |
|
85 |
// KmlTags.DEFAULT_SRS); |
|
86 |
// }else if (tag.compareTo(KmlTags.INNERBOUNDARYIS) == 0){ |
|
87 |
// double[][] coordinates = InnerBoundaryIsBinding.parse(parser, handler); |
|
88 |
// Object innerPolygon = handler.getContentHandler().startInnerPolygon(null, |
|
89 |
// coordinates[0], |
|
90 |
// coordinates[1], |
|
91 |
// coordinates[2], |
|
92 |
// KmlTags.DEFAULT_SRS); |
|
93 |
// handler.getContentHandler().endInnerPolygon(innerPolygon); |
|
94 |
// handler.getContentHandler().addInnerPolygonToPolygon(innerPolygon,polygon); |
|
95 |
// } |
|
96 |
break; |
|
97 |
case KXmlParser.END_TAG: |
|
98 |
if (tag.compareTo(GMLTags.GML_POLYGON) == 0){ |
|
99 |
endFeature = true; |
|
100 |
handler.getContentHandler().endPolygon(polygon); |
|
101 |
} |
|
102 |
break; |
|
103 |
case KXmlParser.TEXT: |
|
104 |
|
|
105 |
break; |
|
106 |
} |
|
107 |
if (!endFeature){ |
|
108 |
currentTag = parser.next(); |
|
109 |
tag = parser.getName(); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
return polygon; |
|
114 |
} |
|
115 |
} |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/PointBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.gpe.gml.GMLTags; |
|
6 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
7 |
import org.kxml2.io.KXmlParser; |
|
8 |
import org.xmlpull.v1.XmlPullParser; |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id$ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1 2007-05-07 07:06:46 jorpiell |
|
56 |
* Add a constructor with the name and the description fields |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
62 |
*/ |
|
63 |
public class PointBinding { |
|
64 |
|
|
65 |
public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
66 |
boolean endFeature = false; |
|
67 |
int currentTag; |
|
68 |
Object point = null; |
|
69 |
|
|
70 |
String srsName = AGeometryBinding.getSrsName(parser, handler); |
|
71 |
String id = AGeometryBinding.getID(parser, handler); |
|
72 |
|
|
73 |
String tag = parser.getName(); |
|
74 |
currentTag = parser.getEventType(); |
|
75 |
|
|
76 |
while (!endFeature){ |
|
77 |
switch(currentTag){ |
|
78 |
case KXmlParser.START_TAG: |
|
79 |
if (tag.compareTo(GMLTags.GML_COORDINATES) == 0){ |
|
80 |
double[][] coordinates = CoordinatesBinding.parse(parser, handler); |
|
81 |
point = handler.getContentHandler().startPoint(id, |
|
82 |
coordinates[0][0], |
|
83 |
coordinates[1][0], |
|
84 |
coordinates[2][0], |
|
85 |
srsName); |
|
86 |
} |
|
87 |
break; |
|
88 |
case KXmlParser.END_TAG: |
|
89 |
if (tag.compareTo(GMLTags.GML_POINT) == 0){ |
|
90 |
endFeature = true; |
|
91 |
handler.getContentHandler().endPoint(point); |
|
92 |
} |
|
93 |
break; |
|
94 |
case KXmlParser.TEXT: |
|
95 |
|
|
96 |
break; |
|
97 |
} |
|
98 |
if (!endFeature){ |
|
99 |
currentTag = parser.next(); |
|
100 |
tag = parser.getName(); |
|
101 |
} |
|
102 |
} |
|
103 |
return point; |
|
104 |
} |
|
105 |
} |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/CoordinatesBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.gpe.gml.GMLTags; |
|
6 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
7 |
import org.kxml2.io.KXmlParser; |
|
8 |
import org.xmlpull.v1.XmlPullParser; |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id$ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1 2007-05-07 07:06:46 jorpiell |
|
56 |
* Add a constructor with the name and the description fields |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
62 |
*/ |
|
63 |
public class CoordinatesBinding { |
|
64 |
|
|
65 |
/** |
|
66 |
* It retuns a matrix of doubles with 3 columns (x,y,z) and |
|
67 |
* one row for each coordinate. |
|
68 |
* @param parser |
|
69 |
* @param handler |
|
70 |
* @return |
|
71 |
* @throws XmlPullParserException |
|
72 |
* @throws IOException |
|
73 |
* @throws KmlBodyParseException |
|
74 |
*/ |
|
75 |
public static double[][] parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
76 |
boolean endFeature = false; |
|
77 |
int currentTag; |
|
78 |
|
|
79 |
double[][] aCoordinates = null; |
|
80 |
|
|
81 |
String tag = parser.getName(); |
|
82 |
currentTag = parser.getEventType(); |
|
83 |
|
|
84 |
while (!endFeature){ |
|
85 |
switch(currentTag){ |
|
86 |
case KXmlParser.START_TAG: |
|
87 |
if (tag.compareTo(GMLTags.GML_COORDINATES) == 0){ |
|
88 |
parser.next(); |
|
89 |
//Calcular los car?cteres de separaci?n |
|
90 |
String TUPLES_SEPARATOR = null; |
|
91 |
String COORDINATES_SEPARATOR = null; |
|
92 |
String DOUBLE_SEPARATOR = null; |
|
93 |
|
|
94 |
String[] coordinates = parser.getText().split(TUPLES_SEPARATOR); |
|
95 |
aCoordinates = new double[3][coordinates.length]; |
|
96 |
for (int i=0 ; i<coordinates.length ; i++){ |
|
97 |
String[] coordinate = coordinates[i].trim().split(COORDINATES_SEPARATOR); |
|
98 |
aCoordinates[0][i] = Double.valueOf(coordinate[0]).doubleValue(); |
|
99 |
aCoordinates[1][i] = Double.valueOf(coordinate[1]).doubleValue(); |
|
100 |
//Tener en cuenta que puede no haber una tercera coordenada |
|
101 |
aCoordinates[2][i] = Double.valueOf(coordinate[2]).doubleValue(); |
|
102 |
} |
|
103 |
} |
|
104 |
break; |
|
105 |
case KXmlParser.END_TAG: |
|
106 |
if (tag.compareTo(GMLTags.GML_COORDINATES) == 0){ |
|
107 |
endFeature = true; |
|
108 |
} |
|
109 |
break; |
|
110 |
case KXmlParser.TEXT: |
|
111 |
|
|
112 |
break; |
|
113 |
} |
|
114 |
if (!endFeature){ |
|
115 |
currentTag = parser.next(); |
|
116 |
tag = parser.getName(); |
|
117 |
} |
|
118 |
} |
|
119 |
|
|
120 |
return aCoordinates; |
|
121 |
} |
|
122 |
|
|
123 |
} |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/AGeometryBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import org.gvsig.gpe.gml.GMLTags; |
|
4 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
5 |
import org.xmlpull.v1.XmlPullParser; |
|
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 |
/* CVS MESSAGES: |
|
48 |
* |
|
49 |
* $Id$ |
|
50 |
* $Log$ |
|
51 |
* Revision 1.1 2007-05-07 07:06:46 jorpiell |
|
52 |
* Add a constructor with the name and the description fields |
|
53 |
* |
|
54 |
* |
|
55 |
*/ |
|
56 |
/** |
|
57 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
58 |
*/ |
|
59 |
public class AGeometryBinding { |
|
60 |
|
|
61 |
/** |
|
62 |
* It returns the GML srs attribute value |
|
63 |
* @param parser |
|
64 |
* @param handler |
|
65 |
* @return |
|
66 |
*/ |
|
67 |
public static String getSrsName(XmlPullParser parser,GPEGmlParser handler){ |
|
68 |
String srsName = null; |
|
69 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
70 |
if (parser.getAttributeName(i).compareTo(GMLTags.GML_SRS_NAME) == 0){ |
|
71 |
srsName = parser.getAttributeValue(i); |
|
72 |
} |
|
73 |
} |
|
74 |
//TODO Convertir el SRS de GML a normal |
|
75 |
return srsName; |
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* It returns the GML geometry id attribute value |
|
80 |
* @param parser |
|
81 |
* @param handler |
|
82 |
* @return |
|
83 |
*/ |
|
84 |
public static String getID(XmlPullParser parser,GPEGmlParser handler){ |
|
85 |
String id = null; |
|
86 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
87 |
if (parser.getAttributeName(i).compareTo(GMLTags.GML_ID) == 0){ |
|
88 |
id = parser.getAttributeValue(i); |
|
89 |
} |
|
90 |
} |
|
91 |
return id; |
|
92 |
} |
|
93 |
} |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/MultiPolygonTypeBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Hashtable; |
|
5 |
|
|
6 |
import org.gvsig.gpe.gml.GMLTags; |
|
7 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
8 |
import org.gvsig.gpe.gml.utils.GMLUtilsParser; |
|
9 |
import org.kxml2.io.KXmlParser; |
|
10 |
import org.xmlpull.v1.XmlPullParser; |
|
11 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 |
|
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
14 |
* |
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
16 |
* |
|
17 |
* This program is free software; you can redistribute it and/or |
|
18 |
* modify it under the terms of the GNU General Public License |
|
19 |
* as published by the Free Software Foundation; either version 2 |
|
20 |
* of the License, or (at your option) any later version. |
|
21 |
* |
|
22 |
* This program is distributed in the hope that it will be useful, |
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
* GNU General Public License for more details. |
|
26 |
* |
|
27 |
* You should have received a copy of the GNU General Public License |
|
28 |
* along with this program; if not, write to the Free Software |
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
30 |
* |
|
31 |
* For more information, contact: |
|
32 |
* |
|
33 |
* Generalitat Valenciana |
|
34 |
* Conselleria d'Infraestructures i Transport |
|
35 |
* Av. Blasco Ib??ez, 50 |
|
36 |
* 46010 VALENCIA |
|
37 |
* SPAIN |
|
38 |
* |
|
39 |
* +34 963862235 |
|
40 |
* gvsig@gva.es |
|
41 |
* www.gvsig.gva.es |
|
42 |
* |
|
43 |
* or |
|
44 |
* |
|
45 |
* IVER T.I. S.A |
|
46 |
* Salamanca 50 |
|
47 |
* 46005 Valencia |
|
48 |
* Spain |
|
49 |
* |
|
50 |
* +34 963163400 |
|
51 |
* dac@iver.es |
|
52 |
*/ |
|
53 |
/* CVS MESSAGES: |
|
54 |
* |
|
55 |
* $Id$ |
|
56 |
* $Log$ |
|
57 |
* Revision 1.1 2007-05-07 12:58:42 jorpiell |
|
58 |
* Add some methods to manage the multigeometries |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
/** |
|
63 |
* It parses a gml:MultiPolygonType object. Example: |
|
64 |
* <p> |
|
65 |
* <pre> |
|
66 |
* <code> |
|
67 |
* <MultiPolygon gid="c731" srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> |
|
68 |
* <polygonMember> |
|
69 |
* <Polygon gid="_877789"> |
|
70 |
* <outerBoundaryIs> |
|
71 |
* <LinearRing> |
|
72 |
* <coordinates>0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0</coordinates> |
|
73 |
* </LinearRing> |
|
74 |
* </outerBoundaryIs> |
|
75 |
* </Polygon> |
|
76 |
* </polygonMember> |
|
77 |
* <polygonMember> |
|
78 |
* <Polygon gid="_877790"> |
|
79 |
* <outerBoundaryIs> |
|
80 |
* <LinearRing> |
|
81 |
* <coordinates>0.0,0.0 100.0,0.0 50.0,100.0 0.0,0.0</coordinates> |
|
82 |
* </LinearRing> |
|
83 |
* </outerBoundaryIs> |
|
84 |
* </Polygon> |
|
85 |
* </polygonMember> |
|
86 |
* </MultiPolygon> |
|
87 |
* </code> |
|
88 |
* </pre> |
|
89 |
* </p> |
|
90 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
91 |
*/ |
|
92 |
public class MultiPolygonTypeBinding { |
|
93 |
|
|
94 |
/** |
|
95 |
* It parses the gml:MultiPolygon tag |
|
96 |
* @param parser |
|
97 |
* The XML parser |
|
98 |
* @param handler |
|
99 |
* The GPE parser that contains the content handler and |
|
100 |
* the error handler |
|
101 |
* @return |
|
102 |
* A multipolygon |
|
103 |
* @throws XmlPullParserException |
|
104 |
* @throws IOException |
|
105 |
*/ |
|
106 |
public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
107 |
boolean endFeature = false; |
|
108 |
int currentTag; |
|
109 |
Object multiPolygon = null; |
|
110 |
|
|
111 |
Hashtable attributes = GMLUtilsParser.getAttributes(parser); |
|
112 |
String srsName = GeometryAttributesBinding.getSrs(attributes); |
|
113 |
String id = GeometryAttributesBinding.getID(attributes); |
|
114 |
|
|
115 |
handler.getContentHandler().startMultiPolygon(id, srsName); |
|
116 |
|
|
117 |
String tag = parser.getName(); |
|
118 |
currentTag = parser.getEventType(); |
|
119 |
|
|
120 |
while (!endFeature){ |
|
121 |
switch(currentTag){ |
|
122 |
case KXmlParser.START_TAG: |
|
123 |
if (tag.compareTo(GMLTags.GML_POLYGONMEMBER) == 0){ |
|
124 |
Object polygon = PolygonMemberTypeBinding.parse(parser, handler); |
|
125 |
handler.getContentHandler().addPolygonToMultiPolygon(polygon, multiPolygon); |
|
126 |
} |
|
127 |
break; |
|
128 |
case KXmlParser.END_TAG: |
|
129 |
if (tag.compareTo(GMLTags.GML_MULTIPOLYGON) == 0){ |
|
130 |
endFeature = true; |
|
131 |
handler.getContentHandler().endMultiPolygon(multiPolygon); |
|
132 |
} |
|
133 |
break; |
|
134 |
case KXmlParser.TEXT: |
|
135 |
|
|
136 |
break; |
|
137 |
} |
|
138 |
if (!endFeature){ |
|
139 |
currentTag = parser.next(); |
|
140 |
tag = parser.getName(); |
|
141 |
} |
|
142 |
} |
|
143 |
return multiPolygon; |
|
144 |
} |
|
145 |
} |
|
0 | 146 |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/MultiLineStrinsTypeBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Hashtable; |
|
5 |
|
|
6 |
import org.gvsig.gpe.gml.GMLTags; |
|
7 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
8 |
import org.gvsig.gpe.gml.utils.GMLUtilsParser; |
|
9 |
import org.kxml2.io.KXmlParser; |
|
10 |
import org.xmlpull.v1.XmlPullParser; |
|
11 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 |
|
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
14 |
* |
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
16 |
* |
|
17 |
* This program is free software; you can redistribute it and/or |
|
18 |
* modify it under the terms of the GNU General Public License |
|
19 |
* as published by the Free Software Foundation; either version 2 |
|
20 |
* of the License, or (at your option) any later version. |
|
21 |
* |
|
22 |
* This program is distributed in the hope that it will be useful, |
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
* GNU General Public License for more details. |
|
26 |
* |
|
27 |
* You should have received a copy of the GNU General Public License |
|
28 |
* along with this program; if not, write to the Free Software |
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
30 |
* |
|
31 |
* For more information, contact: |
|
32 |
* |
|
33 |
* Generalitat Valenciana |
|
34 |
* Conselleria d'Infraestructures i Transport |
|
35 |
* Av. Blasco Ib??ez, 50 |
|
36 |
* 46010 VALENCIA |
|
37 |
* SPAIN |
|
38 |
* |
|
39 |
* +34 963862235 |
|
40 |
* gvsig@gva.es |
|
41 |
* www.gvsig.gva.es |
|
42 |
* |
|
43 |
* or |
|
44 |
* |
|
45 |
* IVER T.I. S.A |
|
46 |
* Salamanca 50 |
|
47 |
* 46005 Valencia |
|
48 |
* Spain |
|
49 |
* |
|
50 |
* +34 963163400 |
|
51 |
* dac@iver.es |
|
52 |
*/ |
|
53 |
/* CVS MESSAGES: |
|
54 |
* |
|
55 |
* $Id$ |
|
56 |
* $Log$ |
|
57 |
* Revision 1.1 2007-05-07 12:58:42 jorpiell |
|
58 |
* Add some methods to manage the multigeometries |
|
59 |
* |
|
60 |
* |
|
61 |
*/ |
|
62 |
/** |
|
63 |
* It parses a gml:MultiLineStringType object. Example: |
|
64 |
* <p> |
|
65 |
* <pre> |
|
66 |
* <code> |
|
67 |
* <MultiLineString srsName="http://www.opengis.net/gml/srs/epsg.xml#4326"> |
|
68 |
* <lineStringMember> |
|
69 |
* <LineString> |
|
70 |
* <coord><X>56.1</X><Y>0.45</Y></coord> |
|
71 |
* <coord><X>67.23</X><Y>0.98</Y></coord> |
|
72 |
* </LineString> |
|
73 |
* </lineStringMember> |
|
74 |
* <lineStringMember> |
|
75 |
* <LineString> |
|
76 |
* <coord><X>46.71</X><Y>9.25</Y></coord> |
|
77 |
* <coord><X>56.88</X><Y>10.44</Y></coord> |
|
78 |
* </LineString> |
|
79 |
* </lineStringMember> |
|
80 |
* </MultiLineString> |
|
81 |
* </code> |
|
82 |
* </pre> |
|
83 |
* </p> |
|
84 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
85 |
*/ |
|
86 |
public class MultiLineStrinsTypeBinding { |
|
87 |
|
|
88 |
/** |
|
89 |
* It parses the gml:MultiLineString tag |
|
90 |
* @param parser |
|
91 |
* The XML parser |
|
92 |
* @param handler |
|
93 |
* The GPE parser that contains the content handler and |
|
94 |
* the error handler |
|
95 |
* @return |
|
96 |
* A multilinestring |
|
97 |
* @throws XmlPullParserException |
|
98 |
*/ |
|
99 |
public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
100 |
boolean endFeature = false; |
|
101 |
int currentTag; |
|
102 |
Object multiLineString = null; |
|
103 |
|
|
104 |
Hashtable attributes = GMLUtilsParser.getAttributes(parser); |
|
105 |
String srsName = GeometryAttributesBinding.getSrs(attributes); |
|
106 |
String id = GeometryAttributesBinding.getID(attributes); |
|
107 |
|
|
108 |
handler.getContentHandler().startMultiLineString(id, srsName); |
|
109 |
|
|
110 |
String tag = parser.getName(); |
|
111 |
currentTag = parser.getEventType(); |
|
112 |
|
|
113 |
while (!endFeature){ |
|
114 |
switch(currentTag){ |
|
115 |
case KXmlParser.START_TAG: |
|
116 |
if (tag.compareTo(GMLTags.GML_LINESTRINGMEMBER) == 0){ |
|
117 |
Object lineString = LineStringMemberTypeBinding.parse(parser, handler); |
|
118 |
handler.getContentHandler().addLineStringToMultiLineString(lineString, multiLineString); |
|
119 |
} |
|
120 |
break; |
|
121 |
case KXmlParser.END_TAG: |
|
122 |
if (tag.compareTo(GMLTags.GML_MULTILINESTRING) == 0){ |
|
123 |
endFeature = true; |
|
124 |
handler.getContentHandler().endMultiLineString(multiLineString); |
|
125 |
} |
|
126 |
break; |
|
127 |
case KXmlParser.TEXT: |
|
128 |
|
|
129 |
break; |
|
130 |
} |
|
131 |
if (!endFeature){ |
|
132 |
currentTag = parser.next(); |
|
133 |
tag = parser.getName(); |
|
134 |
} |
|
135 |
} |
|
136 |
return multiLineString; |
|
137 |
} |
|
138 |
} |
|
0 | 139 |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/CoordTypeBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.gpe.gml.GMLTags; |
|
6 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
7 |
import org.xmlpull.v1.XmlPullParser; |
|
8 |
import org.xmlpull.v1.XmlPullParserException; |
|
9 |
|
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id$ |
|
53 |
* $Log$ |
|
54 |
* Revision 1.1 2007-05-07 12:58:42 jorpiell |
|
55 |
* Add some methods to manage the multigeometries |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
/** |
|
60 |
* It parses a gml:CoordType object. Example: |
|
61 |
* <p> |
|
62 |
* <pre> |
|
63 |
* <code> |
|
64 |
* <gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord> |
|
65 |
* </code> |
|
66 |
* </pre> |
|
67 |
* </p> |
|
68 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
69 |
*/ |
|
70 |
public class CoordTypeBinding { |
|
71 |
|
|
72 |
/** |
|
73 |
* It parses the gml:coord tag |
|
74 |
* @param parser |
|
75 |
* The XML parser |
|
76 |
* @param handler |
|
77 |
* The GPE parser that contains the content handler and |
|
78 |
* the error handler |
|
79 |
* @return |
|
80 |
* It retuns an array of doubles with 3 values (x,y,z) |
|
81 |
* @throws XmlPullParserException |
|
82 |
* @throws IOException |
|
83 |
*/ |
|
84 |
public static double[] parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
85 |
boolean endFeature = false; |
|
86 |
int currentTag; |
|
87 |
|
|
88 |
String COORDINATES_DECIMAL = GMLTags.GML_DEFAULT_COORDINATES_DECIMAL; |
|
89 |
|
|
90 |
double[] aCoordinates = new double[3]; |
|
91 |
|
|
92 |
String tag = parser.getName(); |
|
93 |
currentTag = parser.getEventType(); |
|
94 |
|
|
95 |
while (!endFeature){ |
|
96 |
switch(currentTag){ |
|
97 |
case XmlPullParser.START_TAG: |
|
98 |
if (tag.compareTo(GMLTags.GML_X) == 0){ |
|
99 |
parser.next(); |
|
100 |
aCoordinates[0] = DoubleTypeBinding.parse(parser.getText(),COORDINATES_DECIMAL); |
|
101 |
}else if (tag.compareTo(GMLTags.GML_Y) == 0){ |
|
102 |
parser.next(); |
|
103 |
aCoordinates[1] = DoubleTypeBinding.parse(parser.getText(),COORDINATES_DECIMAL); |
|
104 |
}else if (tag.compareTo(GMLTags.GML_Z) == 0){ |
|
105 |
parser.next(); |
|
106 |
aCoordinates[2] = DoubleTypeBinding.parse(parser.getText(),COORDINATES_DECIMAL); |
|
107 |
} |
|
108 |
break; |
|
109 |
case XmlPullParser.END_TAG: |
|
110 |
if (tag.compareTo(GMLTags.GML_COORD) == 0){ |
|
111 |
endFeature = true; |
|
112 |
} |
|
113 |
break; |
|
114 |
case XmlPullParser.TEXT: |
|
115 |
|
|
116 |
break; |
|
117 |
} |
|
118 |
if (!endFeature){ |
|
119 |
currentTag = parser.next(); |
|
120 |
tag = parser.getName(); |
|
121 |
} |
|
122 |
} |
|
123 |
|
|
124 |
return aCoordinates; |
|
125 |
} |
|
126 |
} |
|
0 | 127 |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/LineStringMemberTypeBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.gvsig.gpe.gml.GMLTags; |
|
6 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
7 |
import org.kxml2.io.KXmlParser; |
|
8 |
import org.xmlpull.v1.XmlPullParser; |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
12 |
* |
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
14 |
* |
|
15 |
* This program is free software; you can redistribute it and/or |
|
16 |
* modify it under the terms of the GNU General Public License |
|
17 |
* as published by the Free Software Foundation; either version 2 |
|
18 |
* of the License, or (at your option) any later version. |
|
19 |
* |
|
20 |
* This program is distributed in the hope that it will be useful, |
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
23 |
* GNU General Public License for more details. |
|
24 |
* |
|
25 |
* You should have received a copy of the GNU General Public License |
|
26 |
* along with this program; if not, write to the Free Software |
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
28 |
* |
|
29 |
* For more information, contact: |
|
30 |
* |
|
31 |
* Generalitat Valenciana |
|
32 |
* Conselleria d'Infraestructures i Transport |
|
33 |
* Av. Blasco Ib??ez, 50 |
|
34 |
* 46010 VALENCIA |
|
35 |
* SPAIN |
|
36 |
* |
|
37 |
* +34 963862235 |
|
38 |
* gvsig@gva.es |
|
39 |
* www.gvsig.gva.es |
|
40 |
* |
|
41 |
* or |
|
42 |
* |
|
43 |
* IVER T.I. S.A |
|
44 |
* Salamanca 50 |
|
45 |
* 46005 Valencia |
|
46 |
* Spain |
|
47 |
* |
|
48 |
* +34 963163400 |
|
49 |
* dac@iver.es |
|
50 |
*/ |
|
51 |
/* CVS MESSAGES: |
|
52 |
* |
|
53 |
* $Id$ |
|
54 |
* $Log$ |
|
55 |
* Revision 1.1 2007-05-07 12:58:42 jorpiell |
|
56 |
* Add some methods to manage the multigeometries |
|
57 |
* |
|
58 |
* |
|
59 |
*/ |
|
60 |
/** |
|
61 |
* It parses a gml:LineStringMemberType object. Example: |
|
62 |
* <p> |
|
63 |
* <pre> |
|
64 |
* <code> |
|
65 |
* <lineStringMember> |
|
66 |
* <LineString> |
|
67 |
* <coord><X>56.1</X><Y>0.45</Y></coord> |
|
68 |
* <coord><X>67.23</X><Y>0.98</Y></coord> |
|
69 |
* </LineString> |
|
70 |
* </lineStringMember> |
|
71 |
* </code> |
|
72 |
* </pre> |
|
73 |
* </p> |
|
74 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
75 |
*/ |
|
76 |
public class LineStringMemberTypeBinding { |
|
77 |
|
|
78 |
/** |
|
79 |
* It parses the gml:LineStringMember tag |
|
80 |
* @param parser |
|
81 |
* The XML parser |
|
82 |
* @param handler |
|
83 |
* The GPE parser that contains the content handler and |
|
84 |
* the error handler |
|
85 |
* @return |
|
86 |
* A line |
|
87 |
* @throws XmlPullParserException |
|
88 |
* @throws IOException |
|
89 |
*/ |
|
90 |
public static Object parse(XmlPullParser parser,GPEGmlParser handler) throws XmlPullParserException, IOException { |
|
91 |
boolean endFeature = false; |
|
92 |
int currentTag; |
|
93 |
Object lineString = null; |
|
94 |
|
|
95 |
String tag = parser.getName(); |
|
96 |
currentTag = parser.getEventType(); |
|
97 |
|
|
98 |
while (!endFeature){ |
|
99 |
switch(currentTag){ |
|
100 |
case KXmlParser.START_TAG: |
|
101 |
if (tag.compareTo(GMLTags.GML_LINESTRING) == 0){ |
|
102 |
lineString = LineStringTypeBinding.parse(parser, handler); |
|
103 |
} |
|
104 |
break; |
|
105 |
case KXmlParser.END_TAG: |
|
106 |
if (tag.compareTo(GMLTags.GML_LINESTRINGMEMBER) == 0){ |
|
107 |
endFeature = true; |
|
108 |
} |
|
109 |
break; |
|
110 |
case KXmlParser.TEXT: |
|
111 |
|
|
112 |
break; |
|
113 |
} |
|
114 |
if (!endFeature){ |
|
115 |
currentTag = parser.next(); |
|
116 |
tag = parser.getName(); |
|
117 |
} |
|
118 |
} |
|
119 |
return lineString; |
|
120 |
} |
|
121 |
} |
|
0 | 122 |
trunk/libraries/libGPE-GML/src/org/gvsig/gpe/gml/bindings/geometries/MultiGeometryTypeBinding.java | ||
---|---|---|
1 |
package org.gvsig.gpe.gml.bindings.geometries; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.util.Hashtable; |
|
5 |
|
|
6 |
import org.gvsig.gpe.gml.GMLTags; |
|
7 |
import org.gvsig.gpe.gml.GPEGmlParser; |
|
8 |
import org.gvsig.gpe.gml.utils.GMLUtilsParser; |
|
9 |
import org.kxml2.io.KXmlParser; |
|
10 |
import org.xmlpull.v1.XmlPullParser; |
|
11 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 |
|
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
14 |
* |
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
16 |
* |
|
17 |
* This program is free software; you can redistribute it and/or |
|
18 |
* modify it under the terms of the GNU General Public License |
|
19 |
* as published by the Free Software Foundation; either version 2 |
|
20 |
* of the License, or (at your option) any later version. |
|
21 |
* |
|
22 |
* This program is distributed in the hope that it will be useful, |
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
* GNU General Public License for more details. |
|
26 |
* |
|
27 |
* You should have received a copy of the GNU General Public License |
|
28 |
* along with this program; if not, write to the Free Software |
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
30 |
* |
|
31 |
* For more information, contact: |
|
32 |
* |
|
33 |
* Generalitat Valenciana |
|
34 |
* Conselleria d'Infraestructures i Transport |
|
35 |
* Av. Blasco Ib??ez, 50 |
|
36 |
* 46010 VALENCIA |
|
37 |
* SPAIN |
|
38 |
* |
|
39 |
* +34 963862235 |
|
40 |
* gvsig@gva.es |
|
41 |
* www.gvsig.gva.es |
|
42 |
* |
|
43 |
* or |
|
44 |
* |
|
45 |
* IVER T.I. S.A |
|
46 |
* Salamanca 50 |
|
47 |
* 46005 Valencia |
|
48 |
* Spain |
|
49 |
* |
Also available in: Unified diff