@Test public void testBooleanWrite() throws Exception { ShapefileDataStore shp = new ShapefileDataStore(setUpBoolShapefile()); SimpleFeatureCollection coll = shp.getFeatureSource().getFeatures(); FeatureEntry entry = new FeatureEntry(); entry.setBounds(coll.getBounds()); try { geopkg.add(entry, coll); } catch (Exception e) { fail(e.getMessage()); } }
public void add(FeatureEntry entry, SimpleFeatureCollection collection) throws IOException { FeatureEntry e = new FeatureEntry(); e.init(entry); if (e.getBounds() == null) { e.setBounds(collection.getBounds()); } create(e, collection.getSchema()); Transaction tx = new DefaultTransaction(); try { SimpleFeatureWriter w = writer(e, true, null, tx); SimpleFeatureIterator it = collection.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); SimpleFeature g = w.next(); g.setAttributes(f.getAttributes()); for (PropertyDescriptor pd : collection.getSchema().getDescriptors()) { String name = pd.getName().getLocalPart(); if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) { bool = (Boolean) (f.getAttribute(name)) ? 1 : 0; } g.setAttribute(name, bool); } } w.write(); } } finally { w.close(); it.close(); } tx.commit(); } catch (Exception ex) { tx.rollback(); throw new IOException(ex); } finally { tx.close(); } entry.init(e); }
GeoPackage implements Closeable { public void add(FeatureEntry entry, SimpleFeatureCollection collection) throws IOException { FeatureEntry e = new FeatureEntry(); e.init(entry); if (e.getBounds() == null) { e.setBounds(collection.getBounds()); } create(e, collection.getSchema()); Transaction tx = new DefaultTransaction(); try { SimpleFeatureWriter w = writer(e, true, null, tx); SimpleFeatureIterator it = collection.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); SimpleFeature g = w.next(); g.setAttributes(f.getAttributes()); for (PropertyDescriptor pd : collection.getSchema().getDescriptors()) { String name = pd.getName().getLocalPart(); if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) { bool = (Boolean) (f.getAttribute(name)) ? 1 : 0; } g.setAttribute(name, bool); } } w.write(); } } finally { w.close(); it.close(); } tx.commit(); } catch (Exception ex) { tx.rollback(); throw new IOException(ex); } finally { tx.close(); } entry.init(e); } }
GeoPackage implements Closeable { public void add(FeatureEntry entry, SimpleFeatureCollection collection) throws IOException { FeatureEntry e = new FeatureEntry(); e.init(entry); if (e.getBounds() == null) { e.setBounds(collection.getBounds()); } create(e, collection.getSchema()); Transaction tx = new DefaultTransaction(); try { SimpleFeatureWriter w = writer(e, true, null, tx); SimpleFeatureIterator it = collection.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); SimpleFeature g = w.next(); g.setAttributes(f.getAttributes()); for (PropertyDescriptor pd : collection.getSchema().getDescriptors()) { String name = pd.getName().getLocalPart(); if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) { bool = (Boolean) (f.getAttribute(name)) ? 1 : 0; } g.setAttribute(name, bool); } } w.write(); } } finally { w.close(); it.close(); } tx.commit(); } catch (Exception ex) { tx.rollback(); throw new IOException(ex); } finally { tx.close(); } entry.init(e); } GeoPackage();  GeoPackage(File file);  GeoPackage(File file, String user, String passwd);  GeoPackage(File file, String user, String passwd, boolean readOnly);   GeoPackage(DataSource dataSource);  GeoPackage(JDBCDataStore dataStore);  GeoPackage(File file, SQLiteConfig config, Map<String, Object> storeParams); }
GeoPackage implements Closeable { public void add(FeatureEntry entry, SimpleFeatureCollection collection) throws IOException { FeatureEntry e = new FeatureEntry(); e.init(entry); if (e.getBounds() == null) { e.setBounds(collection.getBounds()); } create(e, collection.getSchema()); Transaction tx = new DefaultTransaction(); try { SimpleFeatureWriter w = writer(e, true, null, tx); SimpleFeatureIterator it = collection.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); SimpleFeature g = w.next(); g.setAttributes(f.getAttributes()); for (PropertyDescriptor pd : collection.getSchema().getDescriptors()) { String name = pd.getName().getLocalPart(); if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) { bool = (Boolean) (f.getAttribute(name)) ? 1 : 0; } g.setAttribute(name, bool); } } w.write(); } } finally { w.close(); it.close(); } tx.commit(); } catch (Exception ex) { tx.rollback(); throw new IOException(ex); } finally { tx.close(); } entry.init(e); } GeoPackage();  GeoPackage(File file);  GeoPackage(File file, String user, String passwd);  GeoPackage(File file, String user, String passwd, boolean readOnly);   GeoPackage(DataSource dataSource);  GeoPackage(JDBCDataStore dataStore);  GeoPackage(File file, SQLiteConfig config, Map<String, Object> storeParams); GeoPkgGeomWriter.Configuration getWriterConfiguration(); File getFile(); DataSource getDataSource(); void init(); void close(); void addCRS(int srid); static void addCRS(
            Connection cx,
            int srid,
            String srsName,
            String organization,
            int organizationCoordSysId,
            String definition,
            String description); void addCRS(CoordinateReferenceSystem crs, String auth, int srid); List<Entry> contents(); List<FeatureEntry> features(); FeatureEntry feature(String name); GeoPkgExtension getExtension(String name); T getExtension(Class<T> extensionClass); void create(FeatureEntry entry, SimpleFeatureType schema); void add(FeatureEntry entry, SimpleFeatureCollection collection); void add(FeatureEntry entry, SimpleFeatureSource source, Filter filter); SimpleFeatureWriter writer(
            FeatureEntry entry, boolean append, Filter filter, Transaction tx); SimpleFeatureReader reader(FeatureEntry entry, Filter filter, Transaction tx); static SimpleDateFormat getDateFormat(); void createSpatialIndex(FeatureEntry e); List<TileEntry> tiles(); TileEntry tile(String name); void create(TileEntry entry); void add(TileEntry entry, Tile tile); @SuppressWarnings("PMD.CloseResource") // cx and st get into the TileReader TileReader reader(
            TileEntry entry,
            Integer lowZoom,
            Integer highZoom,
            Integer lowCol,
            Integer highCol,
            Integer lowRow,
            Integer highRow); void addRange(String attribute, Integer low, Integer high, List<String> q); boolean hasSpatialIndex(FeatureEntry entry); Set<Identifier> searchSpatialIndex(
            FeatureEntry entry, Double minX, Double minY, Double maxX, Double maxY); int getTileBound(TileEntry entry, int zoom, boolean isMax, boolean isRow); }
GeoPackage implements Closeable { public void add(FeatureEntry entry, SimpleFeatureCollection collection) throws IOException { FeatureEntry e = new FeatureEntry(); e.init(entry); if (e.getBounds() == null) { e.setBounds(collection.getBounds()); } create(e, collection.getSchema()); Transaction tx = new DefaultTransaction(); try { SimpleFeatureWriter w = writer(e, true, null, tx); SimpleFeatureIterator it = collection.features(); try { while (it.hasNext()) { SimpleFeature f = it.next(); SimpleFeature g = w.next(); g.setAttributes(f.getAttributes()); for (PropertyDescriptor pd : collection.getSchema().getDescriptors()) { String name = pd.getName().getLocalPart(); if (pd.getType().getBinding() == Boolean.class) { int bool = 0; if (f.getAttribute(name) != null) { bool = (Boolean) (f.getAttribute(name)) ? 1 : 0; } g.setAttribute(name, bool); } } w.write(); } } finally { w.close(); it.close(); } tx.commit(); } catch (Exception ex) { tx.rollback(); throw new IOException(ex); } finally { tx.close(); } entry.init(e); } GeoPackage();  GeoPackage(File file);  GeoPackage(File file, String user, String passwd);  GeoPackage(File file, String user, String passwd, boolean readOnly);   GeoPackage(DataSource dataSource);  GeoPackage(JDBCDataStore dataStore);  GeoPackage(File file, SQLiteConfig config, Map<String, Object> storeParams); GeoPkgGeomWriter.Configuration getWriterConfiguration(); File getFile(); DataSource getDataSource(); void init(); void close(); void addCRS(int srid); static void addCRS(
            Connection cx,
            int srid,
            String srsName,
            String organization,
            int organizationCoordSysId,
            String definition,
            String description); void addCRS(CoordinateReferenceSystem crs, String auth, int srid); List<Entry> contents(); List<FeatureEntry> features(); FeatureEntry feature(String name); GeoPkgExtension getExtension(String name); T getExtension(Class<T> extensionClass); void create(FeatureEntry entry, SimpleFeatureType schema); void add(FeatureEntry entry, SimpleFeatureCollection collection); void add(FeatureEntry entry, SimpleFeatureSource source, Filter filter); SimpleFeatureWriter writer(
            FeatureEntry entry, boolean append, Filter filter, Transaction tx); SimpleFeatureReader reader(FeatureEntry entry, Filter filter, Transaction tx); static SimpleDateFormat getDateFormat(); void createSpatialIndex(FeatureEntry e); List<TileEntry> tiles(); TileEntry tile(String name); void create(TileEntry entry); void add(TileEntry entry, Tile tile); @SuppressWarnings("PMD.CloseResource") // cx and st get into the TileReader TileReader reader(
            TileEntry entry,
            Integer lowZoom,
            Integer highZoom,
            Integer lowCol,
            Integer highCol,
            Integer lowRow,
            Integer highRow); void addRange(String attribute, Integer low, Integer high, List<String> q); boolean hasSpatialIndex(FeatureEntry entry); Set<Identifier> searchSpatialIndex(
            FeatureEntry entry, Double minX, Double minY, Double maxX, Double maxY); int getTileBound(TileEntry entry, int zoom, boolean isMax, boolean isRow); static final String GEOPACKAGE_CONTENTS; static final String GEOMETRY_COLUMNS; static final String SPATIAL_REF_SYS; static final String DATA_COLUMNS; static final String TILE_MATRIX_METADATA; static final String METADATA; static final String METADATA_REFERENCE; static final String TILE_MATRIX_SET; static final String DATA_COLUMN_CONSTRAINTS; static final String EXTENSIONS; static final String SPATIAL_INDEX; static final String SCHEMA; static final String SKIP_REGISTRATION; static final String DATA_COLUMN; }