svn-gvsig-desktop / trunk / libraries / libGPE / src-test / org / gvsig / gpe / parser / GPEContentHandlerTest.java @ 37959
History | View | Annotate | Download (19.6 KB)
1 |
package org.gvsig.gpe.parser; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.util.ArrayList; |
5 |
|
6 |
import javax.xml.namespace.QName; |
7 |
|
8 |
import org.gvsig.gpe.containers.Bbox; |
9 |
import org.gvsig.gpe.containers.Curve; |
10 |
import org.gvsig.gpe.containers.Element; |
11 |
import org.gvsig.gpe.containers.Feature; |
12 |
import org.gvsig.gpe.containers.Geometry; |
13 |
import org.gvsig.gpe.containers.Layer; |
14 |
import org.gvsig.gpe.containers.LineString; |
15 |
import org.gvsig.gpe.containers.LinearRing; |
16 |
import org.gvsig.gpe.containers.MetaData; |
17 |
import org.gvsig.gpe.containers.MultiCurve; |
18 |
import org.gvsig.gpe.containers.MultiGeometry; |
19 |
import org.gvsig.gpe.containers.MultiLineString; |
20 |
import org.gvsig.gpe.containers.MultiPoint; |
21 |
import org.gvsig.gpe.containers.MultiPolygon; |
22 |
import org.gvsig.gpe.containers.Point; |
23 |
import org.gvsig.gpe.containers.Polygon; |
24 |
import org.gvsig.gpe.containers.Time; |
25 |
|
26 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
27 |
*
|
28 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
29 |
*
|
30 |
* This program is free software; you can redistribute it and/or
|
31 |
* modify it under the terms of the GNU General Public License
|
32 |
* as published by the Free Software Foundation; either version 2
|
33 |
* of the License, or (at your option) any later version.
|
34 |
*
|
35 |
* This program is distributed in the hope that it will be useful,
|
36 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
37 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
38 |
* GNU General Public License for more details.
|
39 |
*
|
40 |
* You should have received a copy of the GNU General Public License
|
41 |
* along with this program; if not, write to the Free Software
|
42 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
43 |
*
|
44 |
* For more information, contact:
|
45 |
*
|
46 |
* Generalitat Valenciana
|
47 |
* Conselleria d'Infraestructures i Transport
|
48 |
* Av. Blasco Ib??ez, 50
|
49 |
* 46010 VALENCIA
|
50 |
* SPAIN
|
51 |
*
|
52 |
* +34 963862235
|
53 |
* gvsig@gva.es
|
54 |
* www.gvsig.gva.es
|
55 |
*
|
56 |
* or
|
57 |
*
|
58 |
* IVER T.I. S.A
|
59 |
* Salamanca 50
|
60 |
* 46005 Valencia
|
61 |
* Spain
|
62 |
*
|
63 |
* +34 963163400
|
64 |
* dac@iver.es
|
65 |
*/
|
66 |
/* CVS MESSAGES:
|
67 |
*
|
68 |
* $Id: GPEContentHandlerTest.java 202 2007-11-27 12:00:11Z jpiera $
|
69 |
* $Log$
|
70 |
* Revision 1.14 2007/06/07 14:52:28 jorpiell
|
71 |
* Add the schema support
|
72 |
*
|
73 |
* Revision 1.13 2007/05/15 12:09:41 jorpiell
|
74 |
* The bbox is linked to the feature
|
75 |
*
|
76 |
* Revision 1.12 2007/05/15 11:54:35 jorpiell
|
77 |
* A wrong label fixed
|
78 |
*
|
79 |
* Revision 1.11 2007/05/15 07:28:34 jorpiell
|
80 |
* Children Element printed
|
81 |
*
|
82 |
* Revision 1.10 2007/05/14 09:29:34 jorpiell
|
83 |
* Add some comments when an element is added
|
84 |
*
|
85 |
* Revision 1.9 2007/05/09 10:25:45 jorpiell
|
86 |
* Add the multiGeometries
|
87 |
*
|
88 |
* Revision 1.8 2007/05/09 08:35:58 jorpiell
|
89 |
* fixed an exception
|
90 |
*
|
91 |
* Revision 1.7 2007/05/02 11:46:07 jorpiell
|
92 |
* Writing tests updated
|
93 |
*
|
94 |
* Revision 1.6 2007/04/26 14:39:12 jorpiell
|
95 |
* Add some tests
|
96 |
*
|
97 |
* Revision 1.5 2007/04/19 07:23:20 jorpiell
|
98 |
* Add the add methods to teh contenhandler and change the register mode
|
99 |
*
|
100 |
* Revision 1.4 2007/04/17 07:53:55 jorpiell
|
101 |
* Before to start a new parsing process, the initialize method of the content handlers is throwed
|
102 |
*
|
103 |
* Revision 1.3 2007/04/14 16:06:35 jorpiell
|
104 |
* Add the container classes
|
105 |
*
|
106 |
* Revision 1.2 2007/04/13 13:14:55 jorpiell
|
107 |
* Created the base tests and add some methods to the content handler
|
108 |
*
|
109 |
* Revision 1.1 2007/04/12 17:06:42 jorpiell
|
110 |
* First GML writing tests
|
111 |
*
|
112 |
*
|
113 |
*/
|
114 |
/**
|
115 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es)
|
116 |
*/
|
117 |
public class GPEContentHandlerTest extends GPEContentHandler{ |
118 |
private String tab = ""; |
119 |
private ArrayList layers = new ArrayList(); |
120 |
|
121 |
/**
|
122 |
* @return the layers without parent layer
|
123 |
*/
|
124 |
public ArrayList getLayers() { |
125 |
ArrayList newLayers = new ArrayList(); |
126 |
for (int i=0 ; i<layers.size() ; i++){ |
127 |
if (((Layer)layers.get(i)).getParentLayer() == null){ |
128 |
newLayers.add(layers.get(i)); |
129 |
} |
130 |
} |
131 |
return newLayers;
|
132 |
} |
133 |
|
134 |
public void addNameToFeature(Object feature, String name){ |
135 |
System.out.print(tab + "Feature name changed: " + name + "\n"); |
136 |
((Feature)feature).setName(name); |
137 |
} |
138 |
|
139 |
public void endFeature(Object feature) { |
140 |
System.out.print(tab + "End Feature\n"); |
141 |
} |
142 |
|
143 |
public void initialize(){ |
144 |
layers = new ArrayList(); |
145 |
} |
146 |
|
147 |
public void addBboxToFeature(Object bbox, Object feature) { |
148 |
((Feature)feature).setBbox(bbox); |
149 |
|
150 |
} |
151 |
|
152 |
public void addBboxToLayer(Object bbox, Object layer) { |
153 |
Bbox box = (Bbox)bbox; |
154 |
System.out.print(tab + "Layer bbox Added:\n"); |
155 |
tab = tab + "\t";
|
156 |
System.out.print(tab + "MINX: " + box.getMinX() + "\n"); |
157 |
System.out.print(tab + "MINY: " + box.getMinY() + "\n"); |
158 |
System.out.print(tab + "MINZ: " + box.getMinZ() + "\n"); |
159 |
System.out.print(tab + "MAXX: " + box.getMaxX() + "\n"); |
160 |
System.out.print(tab + "MAXY: " + box.getMaxY() + "\n"); |
161 |
System.out.print(tab + "MAXZ: " + box.getMaxZ() + "\n"); |
162 |
System.out.print(tab + "SRS: " + box.getSrs() + "\n"); |
163 |
tab = tab.substring(0, tab.length()-1); |
164 |
((Layer)layer).setBbox(bbox); |
165 |
} |
166 |
|
167 |
public void addDescriptionToLayer(String description, Object layer) { |
168 |
System.out.print(tab + "Layer description changed: " + description + "\n"); |
169 |
((Layer)layer).setDescription(description); |
170 |
} |
171 |
|
172 |
public void addElementToFeature(Object element, Object feature) { |
173 |
Element elem = (Element)element; |
174 |
tab = tab + "\t";
|
175 |
System.out.print(tab + "Add Element " + elem.getName() + "=" + |
176 |
elem.getValue() + " to Feature\n");
|
177 |
printChildElements(elem); |
178 |
tab = tab.substring(0, tab.length()-1); |
179 |
((Feature)feature).addElement(element); |
180 |
} |
181 |
|
182 |
/**
|
183 |
* Print the element children
|
184 |
* @param element to print
|
185 |
*/
|
186 |
private void printChildElements(Element element){ |
187 |
tab = tab + "\t";
|
188 |
for (int i=0 ; i< element.getElements().size() ; i++){ |
189 |
Element child = element.getElementAt(i);
|
190 |
System.out.print(tab + "- Element " + child.getName() + "=" + |
191 |
child.getValue() + "\n");
|
192 |
printChildElements(child); |
193 |
} |
194 |
tab = tab.substring(0, tab.length()-1); |
195 |
} |
196 |
|
197 |
public void addFeatureToLayer(Object feature, Object layer) { |
198 |
((Layer)layer).addFeature(feature); |
199 |
|
200 |
} |
201 |
|
202 |
public void addGeometryToFeature(Object geometry, Object feature) { |
203 |
((Feature)feature).setGeometry(geometry); |
204 |
|
205 |
} |
206 |
|
207 |
public void addInnerPolygonToPolygon(Object innerPolygon, Object polygon) { |
208 |
((Polygon)polygon).addInnerBoundary(innerPolygon);
|
209 |
|
210 |
} |
211 |
|
212 |
public void addNameToFeature(String name, Object feature) { |
213 |
((Feature)feature).setName(name); |
214 |
|
215 |
} |
216 |
|
217 |
public void addNameToLayer(String name, Object layer) { |
218 |
System.out.print(tab + "Layer name changed: " + name + "\n"); |
219 |
((Layer)layer).setName(name); |
220 |
} |
221 |
|
222 |
public void addParentElementToElement(Object parent, Object element) { |
223 |
((Element)element).setParentElement(parent);
|
224 |
|
225 |
} |
226 |
|
227 |
public void addParentLayerToLayer(Object parent, Object layer) { |
228 |
((Layer)layer).setParentLayer(parent); |
229 |
|
230 |
} |
231 |
|
232 |
public void addSrsToLayer(String srs, Object layer) { |
233 |
((Layer)layer).setSrs(srs); |
234 |
|
235 |
} |
236 |
|
237 |
|
238 |
public Object startBbox(String id, ICoordinateIterator coords, String srs) { |
239 |
Bbox bbox = new Bbox(coords.getDimension());
|
240 |
double[] min = new double[coords.getDimension()]; |
241 |
double[] max = new double[coords.getDimension()]; |
242 |
try {
|
243 |
if (coords.hasNext()){
|
244 |
coords.next(min); |
245 |
bbox.addCoordinate(min); |
246 |
if (coords.hasNext()){
|
247 |
coords.next(max); |
248 |
bbox.addCoordinate(max); |
249 |
} |
250 |
} |
251 |
} catch (IOException e) { |
252 |
e.printStackTrace(); |
253 |
} |
254 |
bbox.setId(id); |
255 |
bbox.setSrs(srs); |
256 |
return bbox;
|
257 |
} |
258 |
|
259 |
public void endBbox(Object bbox) { |
260 |
// TODO Ap?ndice de m?todo generado autom?ticamente
|
261 |
} |
262 |
|
263 |
public Object startElement(String namespace, String name, Object value, IAttributesIterator iterator, Object parentElement) { |
264 |
Element element = new Element(); |
265 |
element.setParentElement(parentElement); |
266 |
element.setName(name); |
267 |
element.setValue(value); |
268 |
return element;
|
269 |
} |
270 |
|
271 |
public void endElement(Object element) { |
272 |
// TODO Ap?ndice de m?todo generado autom?ticamente
|
273 |
|
274 |
} |
275 |
|
276 |
public Object startFeature(String id, String namspace, String name, IAttributesIterator iterator, Object layer) { |
277 |
System.out.print(tab + "Start Feature, ID: " + id + " NAME: " + name + "\n"); |
278 |
Feature feature = new Feature();
|
279 |
feature.setName(name); |
280 |
feature.setId(id); |
281 |
if (layer != null){ |
282 |
addFeatureToLayer(feature, layer); |
283 |
} |
284 |
return feature;
|
285 |
} |
286 |
|
287 |
public Object startInnerPolygon(String id, ICoordinateIterator coords, String srs) { |
288 |
tab = tab + "\t";
|
289 |
System.out.print(tab + "Start InnerPolygon, SRS:" + srs + "\n"); |
290 |
tab = tab + "\t";
|
291 |
Polygon inner = new Polygon(); |
292 |
try {
|
293 |
while(coords.hasNext()){
|
294 |
double[] buffer = new double[coords.getDimension()]; |
295 |
coords.next(buffer); |
296 |
inner.addCoordinate(buffer); |
297 |
System.out.print(tab);
|
298 |
for (int i=0 ; i<buffer.length ; i++){ |
299 |
System.out.print(buffer[i]);
|
300 |
if (i<buffer.length-1){ |
301 |
System.out.print(","); |
302 |
} |
303 |
} |
304 |
System.out.print("\n"); |
305 |
} |
306 |
} catch (IOException e) { |
307 |
e.printStackTrace(); |
308 |
} |
309 |
inner.setId(id); |
310 |
inner.setSrs(srs); |
311 |
tab = tab.substring(0, tab.length()-2); |
312 |
return inner;
|
313 |
} |
314 |
|
315 |
/*
|
316 |
* (non-Javadoc)
|
317 |
* @see org.gvsig.gpe.IGPEContentHandler#endInnerPolygon(java.lang.Object)
|
318 |
*/
|
319 |
public void endInnerPolygon(Object polygon){ |
320 |
tab = tab + "\t";
|
321 |
System.out.print(tab + "End InnerPolygon\n"); |
322 |
tab = tab.substring(0, tab.length()-1); |
323 |
} |
324 |
|
325 |
|
326 |
public Object startLayer(String id, String namespace, String name, String description, String srs, IAttributesIterator iterator, Object parentLayer, Object bBox) { |
327 |
System.out.print(tab + "Start Layer, ID: " + id + " NAME: " + name + "\n"); |
328 |
tab = tab + "\t";
|
329 |
Layer layer = new Layer();
|
330 |
layer.setId(id); |
331 |
layer.setName(name); |
332 |
layer.setDescription(description); |
333 |
layer.setSrs(srs); |
334 |
layer.setBbox(bBox); |
335 |
layer.setParentLayer(parentLayer); |
336 |
if (parentLayer != null){ |
337 |
((Layer)parentLayer).addLayer(layer); |
338 |
} |
339 |
layers.add(layer); |
340 |
return layer;
|
341 |
} |
342 |
|
343 |
public void endLayer(Object layer) { |
344 |
tab = tab.substring(0, tab.length()-1); |
345 |
System.out.print(tab + "End Layer\n"); |
346 |
} |
347 |
|
348 |
public Object startLineString(String id, ICoordinateIterator coords, String srs) { |
349 |
tab = tab + "\t";
|
350 |
System.out.print(tab + "Start LineString, SRS:" + srs + "\n"); |
351 |
tab = tab + "\t";
|
352 |
LineString lineString = new LineString();
|
353 |
try {
|
354 |
while(coords.hasNext()){
|
355 |
double[] buffer = new double[coords.getDimension()]; |
356 |
coords.next(buffer); |
357 |
lineString.addCoordinate(buffer); |
358 |
System.out.print(tab);
|
359 |
for (int i=0 ; i<buffer.length ; i++){ |
360 |
System.out.print(buffer[i]);
|
361 |
if (i<buffer.length-1){ |
362 |
System.out.print(","); |
363 |
} |
364 |
} |
365 |
System.out.print("\n"); |
366 |
} |
367 |
} catch (IOException e) { |
368 |
e.printStackTrace(); |
369 |
} |
370 |
lineString.setId(id); |
371 |
lineString.setSrs(srs); |
372 |
tab = tab.substring(0, tab.length()-2); |
373 |
return lineString;
|
374 |
} |
375 |
|
376 |
public void endLineString(Object line) { |
377 |
System.out.print(tab + "\t"+ "End LineString:\n"); |
378 |
} |
379 |
|
380 |
public Object startPoint(String id, ICoordinateIterator coords, String srs) { |
381 |
tab = tab + "\t";
|
382 |
System.out.print(tab + "Start Point, SRS:" + srs + "\n"); |
383 |
tab = tab + "\t";
|
384 |
Point point = new Point(); |
385 |
double[] buffer = new double[coords.getDimension()]; |
386 |
try {
|
387 |
if (coords.hasNext()){
|
388 |
coords.next(buffer); |
389 |
point.setCoordinates(buffer); |
390 |
System.out.print(tab);
|
391 |
for (int i=0 ; i<buffer.length ; i++){ |
392 |
System.out.print(buffer[i]);
|
393 |
if (i<buffer.length-1){ |
394 |
System.out.print(","); |
395 |
} |
396 |
} |
397 |
System.out.print("\n"); |
398 |
} |
399 |
} catch (IOException e) { |
400 |
e.printStackTrace(); |
401 |
} |
402 |
|
403 |
point.setId(id); |
404 |
point.setSrs(srs); |
405 |
tab = tab.substring(0, tab.length()-2); |
406 |
return point;
|
407 |
} |
408 |
|
409 |
public void endPoint(Object point) { |
410 |
System.out.print(tab + "\t" + "End Point\n"); |
411 |
} |
412 |
|
413 |
public Object startPolygon(String id, ICoordinateIterator coords, String srs) { |
414 |
tab = tab + "\t";
|
415 |
System.out.print(tab + "Start Polygon, SRS:" + srs + "\n"); |
416 |
tab = tab + "\t";
|
417 |
Polygon polygon = new Polygon(); |
418 |
try {
|
419 |
while(coords.hasNext()){
|
420 |
double[] buffer = new double[coords.getDimension()]; |
421 |
coords.next(buffer); |
422 |
polygon.addCoordinate(buffer); |
423 |
System.out.print(tab);
|
424 |
for (int i=0 ; i<buffer.length ; i++){ |
425 |
System.out.print(buffer[i]);
|
426 |
if (i<buffer.length-1){ |
427 |
System.out.print(","); |
428 |
} |
429 |
} |
430 |
System.out.print("\n"); |
431 |
} |
432 |
} catch (IOException e) { |
433 |
e.printStackTrace(); |
434 |
} |
435 |
polygon.setId(id); |
436 |
polygon.setSrs(srs); |
437 |
tab = tab.substring(0, tab.length()-2); |
438 |
return polygon;
|
439 |
} |
440 |
|
441 |
|
442 |
public void endPolygon(Object polygon) { |
443 |
System.out.print(tab + "\t"+ "End Polygon\n"); |
444 |
} |
445 |
|
446 |
|
447 |
public Object startLinearRing(String id, ICoordinateIterator coords, String srs) { |
448 |
System.out.print(tab + "Start LinearRing, SRS:" + srs + "\n"); |
449 |
tab = tab + "\t";
|
450 |
LinearRing linearRing = new LinearRing();
|
451 |
try {
|
452 |
while(coords.hasNext()){
|
453 |
double[] buffer = new double[coords.getDimension()]; |
454 |
coords.next(buffer); |
455 |
linearRing.addCoordinate(buffer); |
456 |
System.out.print(tab);
|
457 |
for (int i=0 ; i<buffer.length ; i++){ |
458 |
System.out.print(buffer[i]);
|
459 |
if (i<buffer.length-1){ |
460 |
System.out.print(","); |
461 |
} |
462 |
} |
463 |
System.out.print("\n"); |
464 |
} |
465 |
} catch (IOException e) { |
466 |
e.printStackTrace(); |
467 |
} |
468 |
linearRing.setId(id); |
469 |
linearRing.setSrs(srs); |
470 |
tab = tab.substring(0, tab.length()-1); |
471 |
return linearRing;
|
472 |
} |
473 |
|
474 |
|
475 |
public void endLinearRing(Object linearRing) { |
476 |
System.out.print(tab + "End LinearRing\n"); |
477 |
} |
478 |
|
479 |
|
480 |
public Object startMultiPoint(String id, String srs) { |
481 |
System.out.print(tab + "Start MultiPoint, ID: " + id + ", SRS:" + srs + "\n"); |
482 |
tab = tab + "\t";
|
483 |
MultiPoint multiPoint = new MultiPoint();
|
484 |
multiPoint.setId(id); |
485 |
multiPoint.setSrs(srs); |
486 |
return multiPoint;
|
487 |
} |
488 |
|
489 |
public void endMultiPoint(Object multiPoint) { |
490 |
tab = tab.substring(0, tab.length()-1); |
491 |
System.out.print(tab + "End MultiPoint\n"); |
492 |
} |
493 |
|
494 |
public void addPointToMultiPoint(Object point, Object multiPoint) { |
495 |
System.out.print(tab + "Add Point to MultiPoint"); |
496 |
((MultiPoint)multiPoint).addPoint((Point)point);
|
497 |
} |
498 |
|
499 |
public Object startMultiLineString(String id, String srs) { |
500 |
System.out.print(tab + "Start MultiLineString, ID: " + id + ", SRS:" + srs + "\n"); |
501 |
tab = tab + "\t";
|
502 |
MultiLineString multiLineString = new MultiLineString();
|
503 |
multiLineString.setId(id); |
504 |
multiLineString.setSrs(srs); |
505 |
return multiLineString;
|
506 |
} |
507 |
|
508 |
public void endMultiLineString(Object multiLineString) { |
509 |
tab = tab.substring(0, tab.length()-1); |
510 |
System.out.print(tab + "End MultiLineString\n"); |
511 |
} |
512 |
|
513 |
public void addLineStringToMultiLineString(Object lineString, Object multiLineString) { |
514 |
System.out.print(tab + "Add LineString to MultiLineString"); |
515 |
((MultiLineString)multiLineString).addLineString((LineString)lineString); |
516 |
} |
517 |
|
518 |
public Object startMultiPolygon(String id, String srs) { |
519 |
System.out.print(tab + "Start MultiPolygon, ID: " + id + ", SRS:" + srs + "\n"); |
520 |
tab = tab + "\t";
|
521 |
MultiPolygon multiPolygon = new MultiPolygon();
|
522 |
multiPolygon.setId(id); |
523 |
multiPolygon.setSrs(srs); |
524 |
return multiPolygon;
|
525 |
} |
526 |
|
527 |
public void endMultiPolygon(Object multiPolygon) { |
528 |
tab = tab.substring(0, tab.length()-1); |
529 |
System.out.print(tab + "End MultiPolygon\n"); |
530 |
} |
531 |
|
532 |
public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) { |
533 |
System.out.print(tab + "Add Polygon to MultiPolygon"); |
534 |
((MultiPolygon)multiPolygon).addPolygon((Polygon)polygon);
|
535 |
} |
536 |
|
537 |
public Object startMultiGeometry(String id, String srs) { |
538 |
System.out.print(tab + "Start MultiGeometry, ID: " + id + ", SRS:" + srs + "\n"); |
539 |
tab = tab + "\t";
|
540 |
MultiGeometry multiGeometry = new MultiGeometry();
|
541 |
multiGeometry.setId(id); |
542 |
multiGeometry.setSrs(srs); |
543 |
return multiGeometry;
|
544 |
} |
545 |
|
546 |
public void endMultiGeometry(Object multiGeometry) { |
547 |
tab = tab.substring(0, tab.length()-1); |
548 |
System.out.print(tab + "End MultiGeometry\n"); |
549 |
} |
550 |
|
551 |
public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) { |
552 |
if (geometry instanceof Point){ |
553 |
System.out.print(tab + "Add Point to MultiGeometry"); |
554 |
}else if (geometry instanceof LineString){ |
555 |
System.out.print(tab + "Add LineString to MultiGeometry"); |
556 |
}else if (geometry instanceof Polygon){ |
557 |
System.out.print(tab + "Add Polygon to MultiGeometry"); |
558 |
}else if (geometry instanceof Curve){ |
559 |
System.out.print(tab + "Add LineString to Curve"); |
560 |
}else {
|
561 |
System.out.print(tab + "Add Geometry to MultiGeometry"); |
562 |
} |
563 |
((MultiGeometry)multiGeometry).addGeometry((Geometry)geometry); |
564 |
} |
565 |
|
566 |
|
567 |
public Object startCurve(String id, ICoordinateIterator coords, String srs){ |
568 |
tab = tab + "\t";
|
569 |
System.out.print(tab + "Start Curve, ID: " + id + ", SRS:" + srs + "\n"); |
570 |
tab = tab + "\t";
|
571 |
Curve curve = new Curve();
|
572 |
try {
|
573 |
while(coords.hasNext()){
|
574 |
double[] buffer = new double[coords.getDimension()]; |
575 |
coords.next(buffer); |
576 |
curve.addCoordinate(buffer); |
577 |
System.out.print(tab);
|
578 |
for (int i=0 ; i<buffer.length ; i++){ |
579 |
System.out.print(buffer[i]);
|
580 |
if (i<buffer.length-1){ |
581 |
System.out.print(","); |
582 |
} |
583 |
} |
584 |
System.out.print("\n"); |
585 |
} |
586 |
} catch (IOException e) { |
587 |
e.printStackTrace(); |
588 |
} |
589 |
curve.setId(id); |
590 |
curve.setSrs(srs); |
591 |
tab = tab.substring(0, tab.length()-2); |
592 |
return curve;
|
593 |
} |
594 |
|
595 |
public void endCurve(Object curve) { |
596 |
System.out.print(tab + "\t"+ "End Curve:\n"); |
597 |
} |
598 |
|
599 |
public Object startMultiCurve(String id, String srs) { |
600 |
System.out.print(tab + "Start MultiCurve, ID: " + id + ", SRS:" + srs + "\n"); |
601 |
tab = tab + "\t";
|
602 |
MultiCurve multiCurve = new MultiCurve();
|
603 |
multiCurve.setId(id); |
604 |
multiCurve.setSrs(srs); |
605 |
return multiCurve;
|
606 |
} |
607 |
|
608 |
public void endMultiCurve(Object multiCurve) { |
609 |
tab = tab.substring(0, tab.length()-1); |
610 |
System.out.print(tab + "End MultiCurve\n"); |
611 |
} |
612 |
|
613 |
public void addCurveToMultiCurve(Object curve, Object multiCurve) { |
614 |
System.out.print(tab + "Add Curve to MultiCurve"); |
615 |
((MultiCurve)multiCurve).addCurve((Curve)curve); |
616 |
} |
617 |
|
618 |
public Object startMetadata(String type, String data, IAttributesIterator attributes){ |
619 |
tab = tab + "\t";
|
620 |
MetaData meta=null;
|
621 |
System.out.print(tab + "Start Metadata, META: " + type + ", DATA:" + data + "\n"); |
622 |
try {
|
623 |
|
624 |
for(int i = 0; i<attributes.getNumAttributes();i++) |
625 |
{ |
626 |
//String[] buffer = new String[2];
|
627 |
QName name = attributes.nextAttributeName();
|
628 |
Object value = attributes.nextAttribute();
|
629 |
System.out.print(tab + name + " : " + value + "\n"); |
630 |
} |
631 |
} catch (IOException e) { |
632 |
// TODO Auto-generated catch block
|
633 |
e.printStackTrace(); |
634 |
} |
635 |
meta = new MetaData();
|
636 |
meta.setTagType(type); |
637 |
meta.setTagData(data); |
638 |
return meta;
|
639 |
} |
640 |
|
641 |
public void endMetadata(Object metadata) { |
642 |
tab = tab.substring(0, tab.length()-1); |
643 |
System.out.print(tab + "\t"+ "End Metadata:\n"); |
644 |
} |
645 |
|
646 |
public void addMetadataToFeature(Object metadata, Object feature){ |
647 |
System.out.print(tab+tab + "Add Metadata to Feature \n"); |
648 |
((Feature)feature).addMetadata((MetaData)metadata); |
649 |
} |
650 |
|
651 |
public void addMetadataToLayer(Object metadata, Object layer){ |
652 |
System.out.print(tab+tab + "Add Metadata to Layer \n"); |
653 |
((Layer)layer).addMetadata((MetaData)metadata); |
654 |
} |
655 |
|
656 |
|
657 |
public void addMetadataToMetadata(Object metadata, Object parent){ |
658 |
System.out.print(tab + "Add Metadata to Complex Metadata\n"); |
659 |
((MetaData)parent).addChildData((MetaData)metadata); |
660 |
} |
661 |
|
662 |
public void addTimeToFeature(Object time, Object feature) { |
663 |
System.out.print(tab + "Add Time to feature\n"); |
664 |
((Feature)feature).addTime(time); |
665 |
} |
666 |
|
667 |
public void endTime(Object time) { |
668 |
tab = tab.substring(0, tab.length()-1); |
669 |
System.out.print(tab + "\t"+ "End Time:\n"); |
670 |
} |
671 |
|
672 |
public Object startTime(String type, String time) { |
673 |
tab = tab + "\t";
|
674 |
System.out.print(tab + "Start Time, TYPE: " + type + ", DATA:" + time + "\n"); |
675 |
Time t = new Time(); |
676 |
t.setType(type); |
677 |
t.setValue(time); |
678 |
return t;
|
679 |
} |
680 |
|
681 |
public Object startTime(String name, String description, String type, |
682 |
String time, Time previous, Time next) |
683 |
{ |
684 |
tab = tab + "\t";
|
685 |
System.out.print(tab + "Start Time, NAME: " + name + ", DATA:" + time + "\n"); |
686 |
Time t = new Time(); |
687 |
t.setType(type); |
688 |
t.setValue(time); |
689 |
t.setDescription(description); |
690 |
t.setName(name); |
691 |
t.setPrevious(previous); |
692 |
t.setNext(next); |
693 |
return t;
|
694 |
} |
695 |
} |
696 |
|