Bbox implements Serializable { public static Pair<Pair<Double,Double>,Pair<Double,Double>> getPoints(Bbox source) { if (source != null && source.getBbox() != null) { Pattern pattern = Pattern.compile("BOX\\(\\s*([-\\d\\.]+)\\s+([-\\d\\.]+)\\s*,\\s*([-\\d\\.]+)\\s+([-\\d\\.]+)\\s*\\)"); Matcher matcher = pattern.matcher(source.getBbox()); if (matcher.matches()) { double minX = Double.parseDouble(matcher.group(1)); double minY = Double.parseDouble(matcher.group(2)); double maxX = Double.parseDouble(matcher.group(3)); double maxY = Double.parseDouble(matcher.group(4)); return new ImmutablePair<>(new ImmutablePair<>(minX,minY), new ImmutablePair<>(maxX,maxY)); } } return null; }  @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") int getId(); void setId(int id); @Column(name = "bbox", columnDefinition = "box2d") String getBbox(); void setBbox(String bbox); void setBbox(double minX, double minY, double maxX, double maxY); Envelope makeEnvelope(); static Pair<Pair<Double,Double>,Pair<Double,Double>> getPoints(Bbox source); static Bbox copyValues(Bbox from, Bbox to); static Polygon envelopeToPolygon(Envelope e); static Bbox copyToSquareBox(Bbox source); static Bbox copyToCRS(Bbox source, String targetCRS); static final int SRID; static final String BOX_FORMAT; }
@Test public void testGetPoints() { Bbox testBox = new Bbox(); testBox.setBbox(10, 11, 20, 21); Pair<Pair<Double,Double>,Pair<Double,Double>> points = Bbox.getPoints(testBox); assertEquals(new Double(10), points.getLeft().getLeft()); assertEquals(new Double(11), points.getLeft().getRight()); assertEquals(new Double(20), points.getRight().getLeft()); assertEquals(new Double(21), points.getRight().getRight()); }