public int numberOfTiles(long zoomLevel) throws SQLException { int size; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare(cx, format("SELECT COUNT(*) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (!rs.next()) { throw new SQLException("Zoom level count did not return any row"); } size = rs.getInt(1); rs.close(); ps.close(); } finally { cx.close(); } return size; }
private void disableJournal(Connection cx) throws SQLException { PreparedStatement prepared = prepare(cx, PRAGMA_JOURNAL_MODE_OFF).statement(); try { prepared.execute(); } catch (Exception e) { throw new SQLException(e); } finally { if (prepared != null) { prepared.close(); } } } }
public long maxColumn(long zoomLevel) throws SQLException { long size = Long.MAX_VALUE; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT MAX(tile_column) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { size = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return size; }
.set(tableName) .log(Level.FINE) .statement();
.set(e.isM()) .log(Level.FINE) .statement(); try { ps.execute();
.set(tile.getData()) .log(Level.FINE) .statement(); try { ps.execute();
.set(entry.getTileRow()) .log(Level.FINE) .statement(); ResultSet rs = ps.executeQuery();
public long maxRow(long zoomLevel) throws SQLException { long size = Long.MAX_VALUE; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT MAX(tile_row) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { size = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return size; }
public long closestZoom(long zoomLevel) throws SQLException { long zoom = 0; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT zoom_level FROM %s ORDER BY abs(zoom_level - ?)", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { zoom = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return zoom; }
private CoordinateReferenceSystem getCRS(int srid) { try { try (Connection cx = connPool.getConnection()) { try (PreparedStatement ps = cx.prepareStatement( String.format( "SELECT definition FROM %s WHERE srs_id = ?", SPATIAL_REF_SYS))) { try (ResultSet rs = prepare(ps).set(srid).log(Level.FINE).statement().executeQuery()) { if (rs.next()) { try { return CRS.parseWKT(rs.getString("definition")); } catch (FactoryException e) { LOGGER.log(Level.FINE, "Error parsing CRS definitions!", e); } } } } } } catch (SQLException e) { throw new RuntimeException(e); } return null; }
public long minRow(long zoomLevel) throws SQLException { long size = 0; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT MIN(tile_row) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { size = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return size; }
protected void saveMetaDataEntry(String name, String value, Connection cx) throws SQLException { PreparedStatement ps; if (disableJournal) { disableJournal(cx); } if (value != null) { ps = prepare(cx, format("INSERT OR REPLACE INTO %s VALUES (?,?)", TABLE_METADATA)) .set(name) .set(value) .log(Level.FINE) .statement(); } else { ps = prepare(cx, format("DELETE FROM %s WHERE NAME = ?", TABLE_METADATA)) .set(name) .log(Level.FINE) .statement(); } ps.execute(); ps.close(); }
public long minColumn(long zoomLevel) throws SQLException { long size = 0; Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare( cx, format( "SELECT MIN(tile_column) FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); ResultSet rs = ps.executeQuery(); if (rs.next()) { size = rs.getLong(1); } rs.close(); ps.close(); } finally { cx.close(); } return size; }
void deleteGeometryColumnsEntry(FeatureEntry e) throws IOException { String sql = format("DELETE FROM %s WHERE table_name = ?", GEOMETRY_COLUMNS); try { Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare(cx, sql).set(e.getTableName()).log(Level.FINE).statement(); try { ps.execute(); } finally { close(ps); } } finally { close(cx); } } catch (SQLException ex) { throw new IOException(ex); } }
protected String loadMetaDataEntry(String name, Connection cx) throws SQLException { PreparedStatement ps; ps = prepare(cx, format("SELECT VALUE FROM %s WHERE NAME = ?", TABLE_METADATA)) .set(name) .log(Level.FINE) .statement(); ResultSet rs = ps.executeQuery(); String result = null; if (rs.next()) { result = rs.getString(1); } rs.close(); ps.close(); return result; }
void deleteGeoPackageContentsEntry(Entry e) throws IOException { String sql = format("DELETE FROM %s WHERE table_name = ?", GEOPACKAGE_CONTENTS); try { Connection cx = connPool.getConnection(); try { PreparedStatement ps = prepare(cx, sql).set(e.getTableName()).log(Level.FINE).statement(); try { ps.execute(); } finally { close(ps); } } finally { close(cx); } } catch (SQLException ex) { throw new IOException(ex); } }
public TileIterator tiles( long zoomLevel, long leftTile, long bottomTile, long rightTile, long topTile) throws SQLException { Connection cx = connPool.getConnection(); PreparedStatement ps = prepare( cx, format( "SELECT * FROM %s WHERE zoom_level=? AND tile_column >= ? AND tile_row >= ? AND tile_column <= ? AND tile_row <= ?", TABLE_TILES)) .set(zoomLevel) .set(leftTile) .set(bottomTile) .set(rightTile) .set(topTile) .statement(); return new TileIterator(ps.executeQuery()); }
public static enum DataType { Feature("features"), Raster("rasters"), Tile("tiles"), FeatureWithRaster("featuresWithRasters"); String value; DataType(String value) { this.value = value; } public String value() { return value; } }
public TileIterator tiles(long zoomLevel) throws SQLException { Connection cx = connPool.getConnection(); PreparedStatement ps = prepare(cx, format("SELECT * FROM %s WHERE zoom_level=?", TABLE_TILES)) .set(zoomLevel) .statement(); return new TileIterator(ps.executeQuery()); }