mil.nga.geopackage.extension.Extensions Java Examples
The following examples show how to use
mil.nga.geopackage.extension.Extensions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebPExtensionTest.java From geopackage-java with MIT License | 6 votes |
/** * Test the WebP Extension creation */ @Test public void testWebPExtension() throws Exception { WebPExtension webpExtension = new WebPExtension(geoPackage); String tableName = "table"; Extensions extension = webpExtension.getOrCreate(tableName); assertNotNull(extension); assertTrue(webpExtension.has(tableName)); assertEquals(extension.getExtensionName(), WebPExtension.EXTENSION_NAME); assertEquals(extension.getAuthor(), GeoPackageConstants.EXTENSION_AUTHOR); assertEquals(extension.getExtensionNameNoAuthor(), WebPExtension.NAME); assertEquals(extension.getTableName(), tableName); assertEquals(extension.getColumnName(), TileTable.COLUMN_TILE_DATA); assertEquals(extension.getScope(), ExtensionScopeType.READ_WRITE); assertEquals(extension.getDefinition(), WebPExtension.DEFINITION); GeoPackageExtensions.deleteTableExtensions(geoPackage, tableName); assertFalse(webpExtension.has(tableName)); }
Example #2
Source File: WebPExtensionTest.java From geopackage-android with MIT License | 6 votes |
/** * Test the WebP Extension creation */ @Test public void testWebPExtension() throws Exception { WebPExtension webpExtension = new WebPExtension(geoPackage); String tableName = "table"; Extensions extension = webpExtension.getOrCreate(tableName); assertNotNull(extension); assertTrue(webpExtension.has(tableName)); assertEquals(extension.getExtensionName(), WebPExtension.EXTENSION_NAME); assertEquals(extension.getAuthor(), GeoPackageConstants.EXTENSION_AUTHOR); assertEquals(extension.getExtensionNameNoAuthor(), WebPExtension.NAME); assertEquals(extension.getTableName(), tableName); assertEquals(extension.getColumnName(), TileTable.COLUMN_TILE_DATA); assertEquals(extension.getScope(), ExtensionScopeType.READ_WRITE); assertEquals(extension.getDefinition(), WebPExtension.DEFINITION); GeoPackageExtensions.deleteTableExtensions(geoPackage, tableName); assertFalse(webpExtension.has(tableName)); }
Example #3
Source File: GeoPackageDaoManager.java From geopackage-core-java with MIT License | 6 votes |
/** * Unregister all GeoPackage DAO with the connection source * * @param connectionSource * connection source */ public static void unregisterDaos(ConnectionSource connectionSource) { // TODO when ormlite-core version > 5.1 is released, replace with: // "DaoManager.unregisterDaos(connectionSource);" // See https://github.com/j256/ormlite-core/pull/149 unregisterDao(connectionSource, Contents.class, SpatialReferenceSystem.class, SpatialReferenceSystemSfSql.class, SpatialReferenceSystemSqlMm.class, Extensions.class, GriddedCoverage.class, GriddedTile.class, GeometryIndex.class, TableIndex.class, FeatureTileLink.class, ExtendedRelation.class, TileScaling.class, GeometryColumns.class, GeometryColumnsSfSql.class, GeometryColumnsSqlMm.class, Metadata.class, MetadataReference.class, DataColumns.class, DataColumnConstraints.class, TileMatrix.class, TileMatrixSet.class, ContentsId.class); }
Example #4
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public boolean createExtensionsTable() { verifyWritable(); boolean created = false; ExtensionsDao dao = getExtensionsDao(); try { if (!dao.isTableExists()) { created = tableCreator.createExtensions() > 0; } } catch (SQLException e) { throw new GeoPackageException( "Failed to check if " + Extensions.class.getSimpleName() + " table exists and create it", e); } return created; }
Example #5
Source File: CoverageDataCore.java From geopackage-core-java with MIT License | 6 votes |
/** * Get or create the extension * * @return extensions list */ public List<Extensions> getOrCreate() { // Create tables geoPackage.createGriddedCoverageTable(); geoPackage.createGriddedTileTable(); List<Extensions> extensionList = new ArrayList<>(); Extensions coverage = getOrCreate(EXTENSION_NAME, GriddedCoverage.TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); Extensions tile = getOrCreate(EXTENSION_NAME, GriddedTile.TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); Extensions table = getOrCreate(EXTENSION_NAME, tileMatrixSet.getTableName(), TileTable.COLUMN_TILE_DATA, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); extensionList.add(coverage); extensionList.add(tile); extensionList.add(table); return extensionList; }
Example #6
Source File: PropertiesCoreExtension.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create the extension * * @return extension */ public Extensions getOrCreate() { // Create the attributes table if (!geoPackage.isTable(TABLE_NAME)) { AttributesColumn propertyColumn = AttributesColumn.createColumn( COLUMN_PROPERTY, GeoPackageDataType.TEXT, true, null); AttributesColumn valueColumn = AttributesColumn .createColumn(COLUMN_VALUE, GeoPackageDataType.TEXT); List<AttributesColumn> additionalColumns = new ArrayList<>(); additionalColumns.add(propertyColumn); additionalColumns.add(valueColumn); List<Constraint> constraints = new ArrayList<>(); constraints.add(new UniqueConstraint(propertyColumn, valueColumn)); geoPackage.createAttributesTableWithId(TABLE_NAME, additionalColumns, constraints); } Extensions extension = getOrCreate(EXTENSION_NAME, TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #7
Source File: ZoomOtherExtensionTest.java From geopackage-java with MIT License | 5 votes |
/** * Test the Zoom Other Extension creation */ @Test public void testZoomOtherExtension() throws Exception { ZoomOtherExtension zoomOtherExtension = new ZoomOtherExtension( geoPackage); String tableName = "table"; Extensions extension = zoomOtherExtension.getOrCreate(tableName); assertNotNull(extension); assertTrue(zoomOtherExtension.has(tableName)); assertEquals(extension.getExtensionName(), ZoomOtherExtension.EXTENSION_NAME); assertEquals(extension.getAuthor(), GeoPackageConstants.EXTENSION_AUTHOR); assertEquals(extension.getExtensionNameNoAuthor(), ZoomOtherExtension.NAME); assertEquals(extension.getTableName(), tableName); assertEquals(extension.getColumnName(), TileTable.COLUMN_TILE_DATA); assertEquals(extension.getScope(), ExtensionScopeType.READ_WRITE); assertEquals(extension.getDefinition(), ZoomOtherExtension.DEFINITION); GeoPackageExtensions.deleteTableExtensions(geoPackage, tableName); assertFalse(zoomOtherExtension.has(tableName)); }
Example #8
Source File: ExtensionsUtils.java From geopackage-java with MIT License | 5 votes |
/** * Compare the two extensions by their unique columns * * @param first * @param second * @return */ private static boolean compare(Extensions first, Extensions second) { return first.getExtensionName().equals(second.getExtensionName()) && (first.getTableName() == null ? second.getTableName() == null : first.getTableName().equals(second.getTableName())) && (first.getColumnName() == null ? second.getColumnName() == null : first.getColumnName().equals(second.getColumnName())); }
Example #9
Source File: TileTableScaling.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create if needed the extension * * @return extensions object */ private Extensions getOrCreateExtension() { Extensions extension = getOrCreate(EXTENSION_NAME, tableName, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #10
Source File: RelatedTablesCoreExtension.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create the extension * * @return extension */ private Extensions getOrCreate() { // Create table geoPackage.createExtendedRelationsTable(); Extensions extension = getOrCreate(EXTENSION_NAME, ExtendedRelation.TABLE_NAME, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #11
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create if needed the extension * * @return extensions object */ private Extensions getOrCreateExtension() { Extensions extension = getOrCreate(EXTENSION_NAME, tableName, columnName, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #12
Source File: FeatureCoreStyleExtension.java From geopackage-core-java with MIT License | 5 votes |
/** * Get the feature tables registered with the extension * * @return list of feature table names */ public List<String> getTables() { List<String> tables = new ArrayList<>(); List<Extensions> extensions = getExtensions(EXTENSION_NAME); if (extensions != null) { for (Extensions extension : extensions) { tables.add(extension.getTableName()); } } return tables; }
Example #13
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 5 votes |
/** * Determine if the feature table is indexed * * @return true if indexed */ public boolean isIndexed() { boolean indexed = false; Extensions extension = getExtension(); if (extension != null) { ContentsDao contentsDao = geoPackage.getContentsDao(); try { Contents contents = contentsDao.queryForId(tableName); if (contents != null) { Date lastChange = contents.getLastChange(); TableIndexDao tableIndexDao = geoPackage.getTableIndexDao(); TableIndex tableIndex = tableIndexDao.queryForId(tableName); if (tableIndex != null) { Date lastIndexed = tableIndex.getLastIndexed(); indexed = lastIndexed != null && lastIndexed .getTime() >= lastChange.getTime(); } } } catch (SQLException e) { throw new GeoPackageException( "Failed to check if table is indexed, GeoPackage: " + geoPackage.getName() + ", Table Name: " + tableName, e); } } return indexed; }
Example #14
Source File: ExtensionsUtils.java From geopackage-android with MIT License | 5 votes |
/** * Compare the two extensions by their unique columns * * @param first * @param second * @return */ private static boolean compare(Extensions first, Extensions second) { return first.getExtensionName().equals(second.getExtensionName()) && (first.getTableName() == null ? second.getTableName() == null : first.getTableName().equals(second.getTableName())) && (first.getColumnName() == null ? second.getColumnName() == null : first.getColumnName().equals(second.getColumnName())); }
Example #15
Source File: FeatureCoreStyleExtension.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create the extension * * @param featureTable * feature table * @return extension */ private Extensions getOrCreate(String featureTable) { Extensions extension = getOrCreate(EXTENSION_NAME, featureTable, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #16
Source File: ZoomOtherExtensionTest.java From geopackage-android with MIT License | 5 votes |
/** * Test the Zoom Other Extension creation */ @Test public void testZoomOtherExtension() throws Exception { ZoomOtherExtension zoomOtherExtension = new ZoomOtherExtension( geoPackage); String tableName = "table"; Extensions extension = zoomOtherExtension.getOrCreate(tableName); assertNotNull(extension); assertTrue(zoomOtherExtension.has(tableName)); assertEquals(extension.getExtensionName(), ZoomOtherExtension.EXTENSION_NAME); assertEquals(extension.getAuthor(), GeoPackageConstants.EXTENSION_AUTHOR); assertEquals(extension.getExtensionNameNoAuthor(), ZoomOtherExtension.NAME); assertEquals(extension.getTableName(), tableName); assertEquals(extension.getColumnName(), TileTable.COLUMN_TILE_DATA); assertEquals(extension.getScope(), ExtensionScopeType.READ_WRITE); assertEquals(extension.getDefinition(), ZoomOtherExtension.DEFINITION); GeoPackageExtensions.deleteTableExtensions(geoPackage, tableName); assertFalse(zoomOtherExtension.has(tableName)); }
Example #17
Source File: ContentsIdExtension.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create if needed the extension * * @return extensions object */ public Extensions getOrCreateExtension() { // Create table geoPackage.createContentsIdTable(); Extensions extension = getOrCreate(EXTENSION_NAME, null, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); ContentsDao contentsDao = geoPackage.getContentsDao(); try { if (contentsDao.queryForId(ContentsId.TABLE_NAME) == null) { Contents contents = new Contents(); contents.setTableName(ContentsId.TABLE_NAME); contents.setDataTypeString(Extensions.TABLE_NAME); contents.setIdentifier(ContentsId.TABLE_NAME); contentsDao.create(contents); } } catch (SQLException e) { throw new GeoPackageException( "Failed to create contents entry for contents id. GeoPackage: " + geoPackage.getName(), e); } return extension; }
Example #18
Source File: FeatureTileTableCoreLinker.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create if needed the extension * * @return extensions object */ private Extensions getOrCreateExtension() { Extensions extension = getOrCreate(EXTENSION_NAME, null, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #19
Source File: ExtensionsUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { List<Extensions> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata int random = (int) (Math.random() * results.size()); Extensions extensions = results.get(random); // Delete the extensions dao.delete(extensions); // Verify deleted Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNull(queryExtensions); // Choose prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata random = (int) (Math.random() * results.size()); extensions = results.get(random); // Find which metadata to delete QueryBuilder<Extensions, Void> qb = dao.queryBuilder(); qb.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedQuery<Extensions> query = qb.prepare(); List<Extensions> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<Extensions, Void> db = dao.deleteBuilder(); db.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedDelete<Extensions> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }
Example #20
Source File: ExtensionsUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test delete * * @param geoPackage * @throws SQLException */ public static void testDelete(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { List<Extensions> results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata int random = (int) (Math.random() * results.size()); Extensions extensions = results.get(random); // Delete the extensions dao.delete(extensions); // Verify deleted Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNull(queryExtensions); // Choose prepared deleted results = dao.queryForAll(); if (!results.isEmpty()) { // Choose random metadata random = (int) (Math.random() * results.size()); extensions = results.get(random); // Find which metadata to delete QueryBuilder<Extensions, Void> qb = dao.queryBuilder(); qb.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedQuery<Extensions> query = qb.prepare(); List<Extensions> queryResults = dao.query(query); int count = queryResults.size(); // Delete DeleteBuilder<Extensions, Void> db = dao.deleteBuilder(); db.where().eq(Extensions.COLUMN_EXTENSION_NAME, extensions.getExtensionName()); PreparedDelete<Extensions> deleteQuery = db.prepare(); int deleted = dao.delete(deleteQuery); TestCase.assertEquals(count, deleted); } } } }
Example #21
Source File: ExtensionsUtils.java From geopackage-java with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); // Create new extensions String tableName = "CREATE_TABLE_NAME"; String columnName = "CREATE_COLUMN_NAME"; String author = "nga"; String extension = "create_extension"; String definition = "definition"; ExtensionScopeType scopeType = ExtensionScopeType.READ_WRITE; Extensions extensions = new Extensions(); extensions.setTableName(tableName); extensions.setColumnName(columnName); extensions.setExtensionName(author, extension); extensions.setDefinition(definition); extensions.setScope(scopeType); dao.create(extensions); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); // Verify saved extensions Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNotNull(queryExtensions); TestCase.assertEquals(tableName, queryExtensions.getTableName()); TestCase.assertEquals(columnName, queryExtensions.getColumnName()); TestCase.assertEquals(author + Extensions.EXTENSION_NAME_DIVIDER + extension, queryExtensions.getExtensionName()); TestCase.assertEquals(author, queryExtensions.getAuthor()); TestCase.assertEquals(extension, queryExtensions.getExtensionNameNoAuthor()); TestCase.assertEquals(definition, queryExtensions.getDefinition()); TestCase.assertEquals(scopeType, queryExtensions.getScope()); } }
Example #22
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 4 votes |
/** * {@inheritDoc} */ @Override public ExtensionsDao getExtensionsDao() { return createDao(Extensions.class); }
Example #23
Source File: ExtensionsUtils.java From geopackage-android with MIT License | 4 votes |
/** * Test create * * @param geoPackage * @throws SQLException */ public static void testCreate(GeoPackage geoPackage) throws SQLException { ExtensionsDao dao = geoPackage.getExtensionsDao(); if (dao.isTableExists()) { // Get current count long count = dao.countOf(); // Create new extensions String tableName = "CREATE_TABLE_NAME"; String columnName = "CREATE_COLUMN_NAME"; String author = "nga"; String extension = "create_extension"; String definition = "definition"; ExtensionScopeType scopeType = ExtensionScopeType.READ_WRITE; Extensions extensions = new Extensions(); extensions.setTableName(tableName); extensions.setColumnName(columnName); extensions.setExtensionName(author, extension); extensions.setDefinition(definition); extensions.setScope(scopeType); dao.create(extensions); // Verify count long newCount = dao.countOf(); TestCase.assertEquals(count + 1, newCount); // Verify saved extensions Extensions queryExtensions = dao.queryByExtension( extensions.getExtensionName(), extensions.getTableName(), extensions.getColumnName()); TestCase.assertNotNull(queryExtensions); TestCase.assertEquals(tableName, queryExtensions.getTableName()); TestCase.assertEquals(columnName, queryExtensions.getColumnName()); TestCase.assertEquals(author + Extensions.EXTENSION_NAME_DIVIDER + extension, queryExtensions.getExtensionName()); TestCase.assertEquals(author, queryExtensions.getAuthor()); TestCase.assertEquals(extension, queryExtensions.getExtensionNameNoAuthor()); TestCase.assertEquals(definition, queryExtensions.getDefinition()); TestCase.assertEquals(scopeType, queryExtensions.getScope()); } }
Example #24
Source File: FeatureTileTableCoreLinker.java From geopackage-core-java with MIT License | 3 votes |
/** * Get the extension * * @return extensions object or null if one does not exist */ public Extensions getExtension() { Extensions extension = get(EXTENSION_NAME, null, null); return extension; }
Example #25
Source File: TileTableScaling.java From geopackage-core-java with MIT License | 3 votes |
/** * Get the extension * * @return extensions object or null if one does not exist */ public Extensions getExtension() { Extensions extension = get(EXTENSION_NAME, tableName, null); return extension; }
Example #26
Source File: ContentsIdExtension.java From geopackage-core-java with MIT License | 3 votes |
/** * Get the extension * * @return extensions object or null if one does not exist */ public Extensions getExtension() { Extensions extension = get(EXTENSION_NAME, null, null); return extension; }
Example #27
Source File: RelatedTablesCoreExtension.java From geopackage-core-java with MIT License | 3 votes |
/** * Get or create the extension * * @param mappingTable * mapping table name * @return extension */ private Extensions getOrCreate(String mappingTable) { getOrCreate(); Extensions extension = getOrCreate(EXTENSION_NAME, mappingTable, null, EXTENSION_DEFINITION, ExtensionScopeType.READ_WRITE); return extension; }
Example #28
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 3 votes |
/** * Get the extension * * @return extensions object or null if one does not exist */ public Extensions getExtension() { Extensions extension = get(EXTENSION_NAME, tableName, columnName); return extension; }