Revision 32538 branches/v2_0_0_prep/libraries/org.gvsig.arcims/src/org/gvsig/remoteclient/arcims/ArcImsProtFeatureHandler.java
ArcImsProtFeatureHandler.java | ||
---|---|---|
47 | 47 |
import java.util.StringTokenizer; |
48 | 48 |
import java.util.Vector; |
49 | 49 |
|
50 |
import org.exolab.castor.xml.dtd.parser.ParseException; |
|
50 | 51 |
import org.gvsig.fmap.geom.Geometry; |
51 | 52 |
import org.gvsig.fmap.geom.GeometryLocator; |
52 | 53 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
124 | 125 |
/* |
125 | 126 |
* Parse response and add geometries to the general Array |
126 | 127 |
*/ |
127 |
String layerId = (String) status.getLayerIds().get(0);
|
|
128 |
String layerId = (String) status.getLayersIdsSelected().get(0);
|
|
128 | 129 |
|
129 | 130 |
// Deal with UTF-8 |
130 | 131 |
Reader reader = null; |
... | ... | |
257 | 258 |
tag = kxmlParser.nextTag(); |
258 | 259 |
|
259 | 260 |
while (tag != KXmlParser.END_DOCUMENT) { |
261 |
|
|
262 |
ArcImsFeature afeat = new ArcImsFeature(); |
|
263 |
|
|
260 | 264 |
switch (tag) { |
261 | 265 |
case KXmlParser.START_TAG: |
262 | 266 |
|
... | ... | |
272 | 276 |
// timeTemp = System.currentTimeMillis(); |
273 | 277 |
geom = parseEnvelopeFromFeatureTag(kxmlParser, |
274 | 278 |
delDec); |
279 |
afeat.putGeometry(geom); |
|
275 | 280 |
} |
276 | 281 |
|
277 | 282 |
// SECOND FIELDS TAG |
278 | 283 |
// timeTemp = System.currentTimeMillis(); |
279 |
values = parseValuesFromFeatureTag(kxmlParser, // the
|
|
284 |
afeat = parseValuesFromFeatureTag(kxmlParser, // the
|
|
280 | 285 |
// kxml |
281 | 286 |
// parser |
282 | 287 |
fieldsInfoA, // Hashmap with names and |
283 | 288 |
// FieldInformation objects) |
284 | 289 |
delDec, // the separators |
285 |
position // the relative positions of |
|
290 |
position, // the relative positions of
|
|
286 | 291 |
// returned values |
292 |
afeat |
|
287 | 293 |
); |
288 | 294 |
|
289 | 295 |
// timeFeat += System.currentTimeMillis() - |
... | ... | |
299 | 305 |
// parser |
300 | 306 |
delTuple, delCoords, delDec // the |
301 | 307 |
// separators |
308 |
|
|
302 | 309 |
); |
310 |
afeat.putGeometry(geom); |
|
303 | 311 |
|
304 | 312 |
// timeGeom += System.currentTimeMillis() - |
305 | 313 |
// timeTemp; |
306 | 314 |
} |
307 | 315 |
|
308 |
// If some geometry is created, we add a IFeature |
|
309 |
// into features ArrayList |
|
310 |
if (withGeometries > 0) { |
|
311 |
features.add(new ArcImsFeature(geom, values));
|
|
312 |
} |
|
313 |
// Else we only need the Value[] array |
|
314 |
else { |
|
315 |
features.add(new ArcImsFeature(values));
|
|
316 |
} |
|
316 |
// // If some geometry is created, we add a IFeature
|
|
317 |
// // into features ArrayList
|
|
318 |
// if (withGeometries > 0) {
|
|
319 |
// features.add(new ArcImsFeature(geom, values));
|
|
320 |
// }
|
|
321 |
// // Else we only need the Value[] array
|
|
322 |
// else {
|
|
323 |
// features.add(new ArcImsFeature(values));
|
|
324 |
// }
|
|
317 | 325 |
} else if (kxmlParser.getName().compareTo( |
318 | 326 |
GetFeaturesTags.FEATURECOUNT) == 0) { |
319 | 327 |
String value = new String(); |
... | ... | |
346 | 354 |
case KXmlParser.TEXT: |
347 | 355 |
break; |
348 | 356 |
} |
349 |
|
|
357 |
if(afeat != null){ |
|
358 |
features.add(afeat); |
|
359 |
} |
|
350 | 360 |
tag = kxmlParser.next(); |
351 | 361 |
} |
352 | 362 |
|
... | ... | |
454 | 464 |
* @throws ArcImsException |
455 | 465 |
* @throws ParseException |
456 | 466 |
*/ |
457 |
private Object[] parseValuesFromFeatureTag(KXmlParser parser,
|
|
458 |
List<FieldInformation> fieldsInfoA, char delDec, int[] position) |
|
467 |
private ArcImsFeature parseValuesFromFeatureTag(KXmlParser parser,
|
|
468 |
List<FieldInformation> fieldsInfoA, char delDec, int[] position, ArcImsFeature afeat )
|
|
459 | 469 |
throws XmlPullParserException, IOException, ArcImsException { |
460 | 470 |
|
461 | 471 |
int currentTag; |
... | ... | |
465 | 475 |
String text; |
466 | 476 |
int type; |
467 | 477 |
|
468 |
Object[] values = new Object[fieldsInfoA.size()]; |
|
478 |
//Object[] values = new Object[fieldsInfoA.size()];
|
|
469 | 479 |
|
470 | 480 |
currentTag = parser.next(); |
471 | 481 |
|
... | ... | |
482 | 492 |
* attribute into the ArrayList of fieldInformation objects |
483 | 493 |
*/ |
484 | 494 |
if (position[f] == -1) { |
485 |
position[f] = getPosition(fieldsInfoA.iterator(), att); |
|
495 |
position[f] = getPosition(fieldsInfoA.iterator(), att);
|
|
486 | 496 |
} |
487 | 497 |
|
488 | 498 |
if (position[f] == -1) { |
... | ... | |
505 | 515 |
|
506 | 516 |
// Add the Value into the correct position |
507 | 517 |
if (text == null) { |
508 |
values[position[f]] = null; |
|
518 |
String fieldName = fieldsInfoA.get(position[f]).getName(); |
|
519 |
afeat.put(fieldName,null); |
|
509 | 520 |
} else { |
521 |
String fieldName = fieldsInfoA.get(position[f]).getName(); |
|
510 | 522 |
switch (type) { |
511 | 523 |
case FieldInformation.BOOLEAN: |
512 |
values[position[f]] = new Boolean(text);
|
|
524 |
afeat.put(fieldName,new Boolean(text));
|
|
513 | 525 |
f++; |
514 | 526 |
break; |
515 | 527 |
case FieldInformation.SHAPE: |
516 | 528 |
case FieldInformation.STRING: |
517 |
values[position[f]] = new String(text);
|
|
529 |
afeat.put(fieldName, new String(text));
|
|
518 | 530 |
f++; |
519 | 531 |
break; |
520 | 532 |
case FieldInformation.DATE: |
521 |
values[position[f]] = new Date(Long.parseLong(text));
|
|
533 |
afeat.put(fieldName, new Date(Long.parseLong(text)));
|
|
522 | 534 |
f++; |
523 | 535 |
break; |
524 | 536 |
case FieldInformation.FLOAT: |
525 | 537 |
String textfloat = text.replace(delDec, '.'); |
526 |
values[position[f]] = new Float(textfloat);
|
|
538 |
afeat.put(fieldName, new Float(textfloat));
|
|
527 | 539 |
f++; |
528 | 540 |
break; |
529 | 541 |
case FieldInformation.DOUBLE: |
530 | 542 |
String textdouble = text.replace(delDec, '.'); |
531 |
values[position[f]] = new Double(textdouble);
|
|
543 |
afeat.put(fieldName, new Double(textdouble));
|
|
532 | 544 |
f++; |
533 | 545 |
break; |
534 | 546 |
case FieldInformation.SMALLINT: |
535 |
values[position[f]] = new Short(text);
|
|
547 |
afeat.put(fieldName, new Short(text));
|
|
536 | 548 |
f++; |
537 | 549 |
break; |
538 | 550 |
case FieldInformation.BIGINT: |
539 |
values[position[f]] = new Long(text);
|
|
551 |
afeat.put(fieldName, new Long(text));
|
|
540 | 552 |
f++; |
541 | 553 |
break; |
542 | 554 |
case FieldInformation.ID: |
543 | 555 |
case FieldInformation.INTEGER: |
544 |
values[position[f]] = new Integer(text);
|
|
556 |
afeat.put(fieldName, new Integer(text));
|
|
545 | 557 |
f++; |
546 | 558 |
break; |
547 | 559 |
default: |
548 |
values[position[f]] = new String(text);
|
|
560 |
afeat.put(fieldName, new String(text));
|
|
549 | 561 |
f++; |
550 | 562 |
} |
551 | 563 |
} |
... | ... | |
570 | 582 |
} |
571 | 583 |
} |
572 | 584 |
|
573 |
return values;
|
|
585 |
return afeat;
|
|
574 | 586 |
|
575 | 587 |
} |
576 | 588 |
|
... | ... | |
813 | 825 |
public Rectangle2D getLayerExtent(ArcImsVectStatus status) |
814 | 826 |
throws ArcImsException { |
815 | 827 |
Rectangle2D envelope = null; |
816 |
String layerId = (String) status.getLayerIds().get(0);
|
|
828 |
String layerId = (String) status.getLayersIdsSelected().get(0);
|
|
817 | 829 |
|
818 | 830 |
// logger.info("Getting Vectorial Layer Extent (" + status.getl) |
819 | 831 |
ServiceInformation si = status.getServiceInfo(); |
... | ... | |
979 | 991 |
/* |
980 | 992 |
* Parse response and return a Rectangle2D |
981 | 993 |
*/ |
982 |
String layerId = (String) statusCloned.getLayerIds().get(0);
|
|
994 |
String layerId = (String) statusCloned.getLayersIdsSelected().get(0);
|
|
983 | 995 |
logger.debug("Start attributes downloading and parsing (" |
984 | 996 |
+ featCount + ") ids retrieved"); |
985 | 997 |
features.add(getFeatures(br, statusCloned.getServiceInfo(), |
... | ... | |
1106 | 1118 |
/* |
1107 | 1119 |
* Parse response and return a Rectangle2D |
1108 | 1120 |
*/ |
1109 |
String layerId = (String) statusCloned.getLayerIds().get(0);
|
|
1121 |
String layerId = (String) statusCloned.getLayersIdsSelected().get(0);
|
|
1110 | 1122 |
logger.debug("Start attributes downloading and parsing (" |
1111 | 1123 |
+ featCount + ") ids retrieved"); |
1112 | 1124 |
features.add(getFeatures(br, statusCloned.getServiceInfo(), |
Also available in: Unified diff