public ObjectMatch tryUnmarshall(SerializerState state, Class clazz, Object o) throws UnmarshallException {
JSONObject jso = (JSONObject) o;
String type = jso.getString(ATTRIBUTE_TYPE);
if (type == null) {
throw new UnmarshallException("no type hint");
}
int srid = jso.getInt(ATTRIBUTE_SRID);
if (srid <= 0) {
throw new UnmarshallException("no srid");
}
int precision = jso.getInt(ATTRIBUTE_PRECISION);
if (precision <= 0) {
throw new UnmarshallException("no precision");
}
if (!(type.equals(org.geomajas.geometry.Geometry.POINT) ||
type.equals(org.geomajas.geometry.Geometry.LINE_STRING) ||
type.equals(org.geomajas.geometry.Geometry.POLYGON) ||
type.equals(org.geomajas.geometry.Geometry.LINEAR_RING) ||
type.equals(org.geomajas.geometry.Geometry.MULTI_LINE_STRING) ||
type.equals(org.geomajas.geometry.Geometry.MULTI_POLYGON))) {
throw new UnmarshallException(type + " is not a supported geometry");
}
JSONArray coordinates = jso.getJSONArray(ATTRIBUTE_COORDINATES);
if (coordinates == null) {
throw new UnmarshallException("coordinates missing");
}
return ObjectMatch.OKAY;
}