Search in sources :

Example 1 with GeoArea

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));
}
Also used : GeoArea(org.activityinfo.model.type.geo.GeoArea) Quantity(org.activityinfo.model.type.number.Quantity)

Example 2 with GeoArea

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());
        }
    }));
}
Also used : GeoArea(org.activityinfo.model.type.geo.GeoArea) ResultSet(java.sql.ResultSet) FieldValue(org.activityinfo.model.type.FieldValue) Extents(org.activityinfo.model.type.geo.Extents)

Aggregations

GeoArea (org.activityinfo.model.type.geo.GeoArea)2 ResultSet (java.sql.ResultSet)1 FieldValue (org.activityinfo.model.type.FieldValue)1 Extents (org.activityinfo.model.type.geo.Extents)1 Quantity (org.activityinfo.model.type.number.Quantity)1