@Override
 public void visitElement(int row, Envelope env) {
   fired = true;
   try {
     assertTrue(env.contains(ds.getGeometry(row).getEnvelopeInternal()));
   } catch (DriverException ex) {
     fail();
   }
 }
  @Test
  public void testIndexVisitor() throws Exception {
    DiskRTree tree = new DiskRTree(16, 1024, false);
    tree.newIndex(indexFile);
    DataSource ds = dsf.getDataSource("points");
    String fieldName = "the_geom";

    ds.open();
    int fieldIndex = ds.getFieldIndexByName(fieldName);
    for (int i = 0; i < ds.getRowCount(); i++) {
      Envelope value = ds.getFieldValue(i, fieldIndex).getAsGeometry().getEnvelopeInternal();
      tree.insert(value, i);
    }
    Envelope e = ds.getGeometry((ds.getRowCount() - 1) / 2).getEnvelopeInternal();

    IV iV = new IV(ds);
    tree.query(e, iV);

    assertTrue(iV.fired);
  }
  @Test
  public void testST_Transform() throws Exception {
    dsf.executeSQL(
        "CREATE TABLE init AS SELECT 'POINT(584173.736059813 2594514.82833411)'::GEOMETRY as the_geom;");
    DataSource ds = dsf.getDataSourceFromSQL("SELECT * from init;");
    // EPSG:27572;584173.736059813;2594514.82833411;EPSG:4326;;0.01

    WKTReader wKTReader = new WKTReader();
    Geometry targetGeom = wKTReader.read("POINT(2.114551393 50.345609791)");
    ds.open();
    assertTrue(!ds.isNull(0, 0));
    ds.close();

    ds =
        dsf.getDataSourceFromSQL(
            "SELECT ST_TRANSFORM(the_geom, 'EPSG:27572', 'EPSG:4326') from init;");

    ds.open();

    assertTrue(ds.getGeometry(0).equalsExact(targetGeom, 0.01));

    ds.close();
  }