use of org.codice.ddf.spatial.ogc.csw.catalog.common.BoundingBoxReader in project ddf by codice.
the class CswUnmarshallHelper method convertRecordPropertyToMetacardAttribute.
/**
* Converts the CSW record property {@code reader} is currently at to the specified Metacard
* attribute format.
*
* @param reader the reader at the element whose value you want to convert
* @param cswAxisOrder the order of the coordinates in the XML being read by {@code reader}
* @return the value that was extracted from {@code reader} and is of the type described by
* {@code attributeFormat}
*/
public static Serializable convertRecordPropertyToMetacardAttribute(AttributeType.AttributeFormat attributeFormat, HierarchicalStreamReader reader, CswAxisOrder cswAxisOrder) {
LOGGER.debug("converting csw record property {}", reader.getValue());
Serializable ser = null;
switch(attributeFormat) {
case BOOLEAN:
ser = Boolean.valueOf(reader.getValue());
break;
case DOUBLE:
ser = Double.valueOf(reader.getValue());
break;
case FLOAT:
ser = Float.valueOf(reader.getValue());
break;
case INTEGER:
ser = Integer.valueOf(reader.getValue());
break;
case LONG:
ser = Long.valueOf(reader.getValue());
break;
case SHORT:
ser = Short.valueOf(reader.getValue());
break;
case XML:
case STRING:
ser = reader.getValue();
break;
case DATE:
ser = CswUnmarshallHelper.convertStringValueToMetacardValue(attributeFormat, reader.getValue());
break;
case GEOMETRY:
// We pass in cswAxisOrder, so we can determine coord order (LAT/LON vs
// LON/LAT).
BoundingBoxReader bboxReader = new BoundingBoxReader(reader, cswAxisOrder);
try {
ser = bboxReader.getWkt();
} catch (CswException cswException) {
LOGGER.debug("CswUnmarshallHelper.convertRecordPropertyToMetacardAttribute(): could not read BoundingBox.", cswException);
}
LOGGER.debug("WKT = {}", ser);
break;
case BINARY:
ser = reader.getValue().getBytes(StandardCharsets.UTF_8);
break;
default:
break;
}
return ser;
}
Aggregations