mil.nga.geopackage.extension.GeoPackageExtensions Java Examples

The following examples show how to use mil.nga.geopackage.extension.GeoPackageExtensions. 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-android with MIT License 6 votes vote down vote up
/**
 * 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-java with MIT License 6 votes vote down vote up
/**
 * 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: ZoomOtherExtensionTest.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * 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 #4
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void deleteTable(String table) {
	verifyWritable();

	GeoPackageExtensions.deleteTableExtensions(this, table);

	ContentsDao contentsDao = getContentsDao();
	contentsDao.deleteTable(table);
}
 
Example #5
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * Copy the table
 * 
 * @param tableName
 *            table name
 * @param newTableName
 *            new table name
 * @param transferContent
 *            transfer content flag
 * @param extensions
 *            extensions copy flag
 */
protected void copyTable(String tableName, String newTableName,
		boolean transferContent, boolean extensions) {

	ContentsDataType dataType = getTableDataType(tableName);
	if (dataType != null) {
		switch (dataType) {

		case ATTRIBUTES:
			copyAttributeTable(tableName, newTableName, transferContent);
			break;

		case FEATURES:
			copyFeatureTable(tableName, newTableName, transferContent);
			break;

		case TILES:
		case GRIDDED_COVERAGE:
			copyTileTable(tableName, newTableName, transferContent);
			break;

		default:
			throw new GeoPackageException(
					"Unsupported data type: " + dataType);
		}
	} else {
		copyUserTable(tableName, newTableName, transferContent, false);
	}

	// Copy extensions
	if (extensions) {
		GeoPackageExtensions.copyTableExtensions(this, tableName,
				newTableName);
	}
}
 
Example #6
Source File: ZoomOtherExtensionTest.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * 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 #7
Source File: GeoPackageExample.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test the GeoPackage example extensions
 *
 * @throws SQLException upon error
 * @throws IOException  upon error
 */
@Test
public void testExampleExtensions() throws SQLException, IOException, NameNotFoundException {

    create();

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);
    GeoPackage geoPackage = manager.open(GEOPACKAGE_NAME);

    validateExtensions(geoPackage, true);
    validateNGAExtensions(geoPackage, true);

    GeoPackageExtensions.deleteExtensions(geoPackage);

    validateExtensions(geoPackage, false);
    validateNGAExtensions(geoPackage, false);

    geoPackage.close();

    TestCase.assertTrue(manager.delete(GEOPACKAGE_NAME));
}
 
Example #8
Source File: GeoPackageExample.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test the GeoPackage example extensions
 * 
 * @throws SQLException
 *             upon error
 * @throws IOException
 *             upon error
 */
@Test
public void testExampleExtensions() throws SQLException, IOException {

	create();

	File file = new File(GEOPACKAGE_FILE);

	GeoPackage geoPackage = GeoPackageManager.open(file);

	validateExtensions(geoPackage, true);
	validateNGAExtensions(geoPackage, true);

	GeoPackageExtensions.deleteExtensions(geoPackage);

	validateExtensions(geoPackage, false);
	validateNGAExtensions(geoPackage, false);

	geoPackage.close();

	TestCase.assertTrue(file.delete());
}