On 29 May 2015 at 18:16, Lukas Eder <[email protected]> wrote:

> Could you please provide the DDL of the table that contains this position 
> column? It will be helpful in trying to reproduce this issue. Also, the 
> source code of PositionConverter and Position (if you wrote that yourself) 
> would be needed.

public class PositionConverter implements Converter<Object, Position> {

    @Override
    public Position from(Object object) {
        if (object == null) {
            return null;
        }

        Geometry geometry = ((PGgeometry) object).getGeometry();

        if (!(geometry instanceof Point)) {
            throw new IllegalArgumentException("Geometry is not a
org.postgis.Point.");
        }

        Point point = (Point)geometry;

        return new Position(BigDecimal.valueOf(point.getX()),
BigDecimal.valueOf(point.getY()));
    }

    @Override
    public Object to(Position position) {
        if (position == null) {
            return null;
        }

        Point p = new Point(position.getLatitude().doubleValue(),
position.getLongitude().doubleValue());
        p.setSrid(Position.SPATIAL_REF_SYS);
        return new PGgeometry(p);
    }

    @Override
    public Class<Object> fromType() {
        return Object.class;
    }

    @Override
    public Class<Position> toType() {
        return Position.class;
    }
}

public class Position {

    public static final int SPATIAL_REF_SYS = 4326;

    private BigDecimal latitude;

    private BigDecimal longitude;

    // getters, setters omitted
}

create table data_point (
  id serial primary key,
  survey_id integer not null,
  probe_id integer not null,
  position geography(point,4326) null,
  date_recorded timestamp with time zone not null,
  date_arrived timestamp with time zone not null,
  data json null
);

Regards,
Andreas

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to