protected String getSpatialIndexName(FeatureEntry entry) { String spatial_index = "rtree_" + entry.getTableName() + "_" + entry.getGeometryColumn(); return spatial_index; } /**
/** * Create a spatial index * * @param e feature entry to create spatial index for */ public void createSpatialIndex(FeatureEntry e) throws IOException { Map<String, String> properties = new HashMap<String, String>(); PrimaryKey pk = ((JDBCFeatureStore) (dataStore.getFeatureSource(e.getTableName()))).getPrimaryKey(); if (pk.getColumns().size() != 1) { throw new IOException("Spatial index only supported for primary key of single column."); } properties.put("t", e.getTableName()); properties.put("c", e.getGeometryColumn()); properties.put("i", pk.getColumns().get(0).getName()); Connection cx; try { cx = connPool.getConnection(); try { runScript(SPATIAL_INDEX + ".sql", cx, properties); } finally { cx.close(); } } catch (SQLException ex) { throw new IOException(ex); } }
/** * Returns a writer used to modify or add to the contents of a feature dataset. * * @param entry The feature entry. * @param append Flag controlling whether to modify existing contents, or append to the dataset. * @param filter Filter determining what subset of dataset to modify, only relevant when * <tt>append</tt> set to false. May be <code>null</code> to specify no filter. * @param tx Transaction object, may be <code>null</code> to specify auto commit transaction. */ public SimpleFeatureWriter writer( FeatureEntry entry, boolean append, Filter filter, Transaction tx) throws IOException { DataStore dataStore = dataStore(); FeatureWriter w = append ? dataStore.getFeatureWriterAppend(entry.getTableName(), tx) : dataStore.getFeatureWriter(entry.getTableName(), filter, tx); return Features.simple(w); }
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); } }
/** * Returns a reader for the contents of a feature dataset. * * @param entry The feature entry. * @param filter Filter Filter determining what subset of dataset to return. May be <code>null * </code> to specify no filter. * @param tx Transaction object, may be <code>null</code> to specify auto commit transaction. */ public SimpleFeatureReader reader(FeatureEntry entry, Filter filter, Transaction tx) throws IOException { Query q = new Query(entry.getTableName()); q.setFilter(filter != null ? filter : Filter.INCLUDE); return Features.simple(dataStore().getFeatureReader(q, tx)); }
PreparedStatement ps = prepare(cx, sql) .set(e.getTableName()) .set(e.getGeometryColumn()) .set(
protected String getSpatialIndexName(FeatureEntry entry) { String spatial_index = "rtree_" + entry.getTableName() + "_" + entry.getGeometryColumn(); return spatial_index; } /**
/** * Returns a writer used to modify or add to the contents of a feature dataset. * * @param entry The feature entry. * @param append Flag controlling whether to modify existing contents, or append to the dataset. * @param filter Filter determining what subset of dataset to modify, only relevant when * <tt>append</tt> set to false. May be <code>null</code> to specify no filter. * @param tx Transaction object, may be <code>null</code> to specify auto commit transaction. */ public SimpleFeatureWriter writer( FeatureEntry entry, boolean append, Filter filter, Transaction tx) throws IOException { DataStore dataStore = dataStore(); FeatureWriter w = append ? dataStore.getFeatureWriterAppend(entry.getTableName(), tx) : dataStore.getFeatureWriter(entry.getTableName(), filter, tx); return Features.simple(w); }
/** * Create a spatial index * * @param e feature entry to create spatial index for */ public void createSpatialIndex(FeatureEntry e) throws IOException { Map<String, String> properties = new HashMap<String, String>(); PrimaryKey pk = ((JDBCFeatureStore) (dataStore.getFeatureSource(e.getTableName()))).getPrimaryKey(); if (pk.getColumns().size() != 1) { throw new IOException("Spatial index only supported for primary key of single column."); } properties.put("t", e.getTableName()); properties.put("c", e.getGeometryColumn()); properties.put("i", pk.getColumns().get(0).getName()); Connection cx; try { cx = connPool.getConnection(); try { runScript(SPATIAL_INDEX + ".sql", cx, properties); } finally { cx.close(); } } catch (SQLException ex) { throw new IOException(ex); } }
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); } }
/** * Returns a reader for the contents of a feature dataset. * * @param entry The feature entry. * @param filter Filter Filter determining what subset of dataset to return. May be <code>null * </code> to specify no filter. * @param tx Transaction object, may be <code>null</code> to specify auto commit transaction. */ public SimpleFeatureReader reader(FeatureEntry entry, Filter filter, Transaction tx) throws IOException { Query q = new Query(entry.getTableName()); q.setFilter(filter != null ? filter : Filter.INCLUDE); return Features.simple(dataStore().getFeatureReader(q, tx)); }
@Then("^the result is a valid GeoPackage file$") public void gpkg_CheckResponseIsGeoPackage() throws Throwable { checkContentType(Variants.GEOPKG_MEDIA_TYPE.getType()); File tmp = File.createTempFile("gpkg_functional_test", ".gpkg", context.getTempFolder()); tmp.deleteOnExit(); try (InputStream stream = context.getLastResponseInputStream()) { try (OutputStream to = new FileOutputStream(tmp)) { ByteStreams.copy(stream, to); } } GeoPackage gpkg = new GeoPackage(tmp); try { List<FeatureEntry> features = gpkg.features(); System.err.printf("Found gpkg tables: %s\n", Lists.transform(features, (e) -> e.getTableName())); } finally { gpkg.close(); } }
PreparedStatement ps = prepare(cx, sql) .set(e.getTableName()) .set(e.getGeometryColumn()) .set(