use of org.activityinfo.model.type.geo.GeoArea in project activityinfo by bedatadriven.
the class BoundingBoxFunction method apply.
@Override
public FieldValue apply(List<FieldValue> arguments) {
checkArity(arguments, 1);
GeoArea value = (GeoArea) arguments.get(0);
return new Quantity(apply(value));
}
use of org.activityinfo.model.type.geo.GeoArea in project activityinfo by bedatadriven.
the class TableMappingBuilder method addGeoAreaField.
public void addGeoAreaField(FormField field) {
add(new FieldMapping(field, Arrays.asList("x1", "y1", "x2", "y2"), new FieldValueConverter() {
@Override
public FieldValue toFieldValue(ResultSet rs, int index) throws SQLException {
double x1 = rs.getDouble(index);
if (rs.wasNull()) {
return null;
}
double y1 = rs.getDouble(index + 1);
if (rs.wasNull()) {
return null;
}
double x2 = rs.getDouble(index + 2);
if (rs.wasNull()) {
return null;
}
double y2 = rs.getDouble(index + 3);
if (rs.wasNull()) {
return null;
}
return new GeoArea(Extents.create(x1, y1, x2, y2), "FIXME");
}
@Override
public Collection<? extends Object> toParameters(FieldValue value) {
GeoArea area = (GeoArea) value;
Extents bbox = area.getEnvelope();
return Arrays.asList(bbox.getX1(), bbox.getY1(), bbox.getX2(), bbox.getY2());
}
}));
}
Aggregations