mil.nga.geopackage.GeoPackageException Java Examples

The following examples show how to use mil.nga.geopackage.GeoPackageException. 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: ImportCoverageDataTiffGeoPackageTestCase.java    From geopackage-android with MIT License 6 votes vote down vote up
@Override
protected GeoPackage getGeoPackage() throws Exception {

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);

    // Delete
    manager.delete(TestConstants.IMPORT_COVERAGE_DATA_TIFF_DB_NAME);

    // Copy the test db file from assets to the internal storage
    TestUtils.copyAssetFileToInternalStorage(activity, testContext,
            TestConstants.IMPORT_COVERAGE_DATA_TIFF_DB_FILE_NAME);

    // Import
    String importLocation = TestUtils.getAssetFileInternalStorageLocation(
            activity, TestConstants.IMPORT_COVERAGE_DATA_TIFF_DB_FILE_NAME);
    manager.importGeoPackage(new File(importLocation));

    // Open
    GeoPackage geoPackage = manager.open(TestConstants.IMPORT_COVERAGE_DATA_TIFF_DB_NAME);
    if (geoPackage == null) {
        throw new GeoPackageException("Failed to open database");
    }

    return geoPackage;
}
 
Example #2
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean createGeometryIndexTable() {
	verifyWritable();

	boolean created = false;
	GeometryIndexDao dao = getGeometryIndexDao();
	try {
		if (!dao.isTableExists()) {
			created = tableCreator.createGeometryIndex() > 0;
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to check if " + GeometryIndex.class.getSimpleName()
						+ " table exists and create it",
				e);
	}
	return created;
}
 
Example #3
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Copy the user table
 * 
 * @param tableName
 *            table name
 * @param newTableName
 *            new table name
 * @param transferContent
 *            transfer user table content flag
 * @param validateContents
 *            true to validate a contents was copied
 * @return copied contents
 * @since 3.3.0
 */
protected Contents copyUserTable(String tableName, String newTableName,
		boolean transferContent, boolean validateContents) {

	AlterTable.copyTable(database, tableName, newTableName,
			transferContent);

	Contents contents = copyContents(tableName, newTableName);

	if (contents == null && validateContents) {
		throw new GeoPackageException(
				"No table contents found for table: " + tableName);
	}

	return contents;
}
 
Example #4
Source File: UserColumns.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Get the column index of the column name
 * 
 * @param columnName
 *            column name
 * @param required
 *            column existence is required
 * @return column index
 */
public Integer getColumnIndex(String columnName, boolean required) {
	Integer index = nameToIndex.get(columnName.toLowerCase());
	if (required && index == null) {
		StringBuilder error = new StringBuilder(
				"Column does not exist in ");
		if (custom) {
			error.append("custom specified table columns");
		} else {
			error.append("table");
		}
		error.append(". table: " + tableName + ", column: " + columnName);
		if (custom) {
			error.append(", columns: " + columnNames);
		}
		throw new GeoPackageException(error.toString());
	}
	return index;
}
 
Example #5
Source File: NGAExtensions.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Delete the Feature Tile Link extensions for the table
 * 
 * @param geoPackage
 *            GeoPackage
 * @param table
 *            table name
 * @since 1.1.5
 */
public static void deleteFeatureTileLink(GeoPackageCore geoPackage,
		String table) {

	FeatureTileLinkDao featureTileLinkDao = geoPackage
			.getFeatureTileLinkDao();
	try {
		if (featureTileLinkDao.isTableExists()) {
			featureTileLinkDao.deleteByTableName(table);
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to delete Feature Tile Link. GeoPackage: "
						+ geoPackage.getName() + ", Table: " + table,
				e);
	}
}
 
Example #6
Source File: GeoPackageImpl.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AttributesDao getAttributesDao(String tableName) {

	ContentsDao dao = getContentsDao();
	Contents contents = null;
	try {
		contents = dao.queryForId(tableName);
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to retrieve " + Contents.class.getSimpleName()
						+ " for table name: " + tableName,
				e);
	}
	if (contents == null) {
		throw new GeoPackageException(
				"No Contents Table exists for table name: " + tableName);
	}
	return getAttributesDao(contents);
}
 
Example #7
Source File: GeoPackageTableCreator.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Create the minimum required GeoPackage tables
 */
public void createRequired() {

	// Create the Spatial Reference System table (spec Requirement 10)
	createSpatialReferenceSystem();

	// Create the Contents table (spec Requirement 13)
	createContents();

	// Create the required Spatial Reference Systems (spec Requirement
	// 11)
	try {
		SpatialReferenceSystemDao dao = DaoManager.createDao(
				db.getConnectionSource(), SpatialReferenceSystem.class);
		dao.createWgs84();
		dao.createUndefinedCartesian();
		dao.createUndefinedGeographic();
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Error creating default required Spatial Reference Systems",
				e);
	}
}
 
Example #8
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Delete all RTree Index extensions. Drops the triggers, RTree tables, and
 * deletes the extensions.
 * 
 * @since 3.2.0
 */
public void deleteAll() {
	try {
		if (extensionsDao.isTableExists()) {
			List<Extensions> extensions = extensionsDao
					.queryByExtension(EXTENSION_NAME);
			for (Extensions extension : extensions) {
				delete(extension.getTableName(), extension.getColumnName());
			}
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to delete all RTree Index extensions. GeoPackage: "
						+ geoPackage.getName(),
				e);
	}

}
 
Example #9
Source File: FeatureIndexManager.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Is the feature table indexed in the provided type location
 *
 * @param type
 *            index location type
 * @return true if indexed
 */
public boolean isIndexed(FeatureIndexType type) {
	boolean indexed = false;
	if (type == null) {
		indexed = isIndexed();
	} else {
		switch (type) {
		case GEOPACKAGE:
			indexed = featureTableIndex.isIndexed();
			break;
		case RTREE:
			indexed = rTreeIndexTableDao.has();
			break;
		default:
			throw new GeoPackageException(
					"Unsupported FeatureIndexType: " + type);
		}
	}
	return indexed;
}
 
Example #10
Source File: CoverageDataCore.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Get the Y encoded location from the base provided y
 * 
 * @param y
 *            y location
 * @param encodingType
 *            pixel encoding type
 * @return encoded y location
 */
private float getYEncodedLocation(float y,
		GriddedCoverageEncodingType encodingType) {

	float yLocation = y;

	switch (encodingType) {
	case CENTER:
	case AREA:
		yLocation += 0.5f;
		break;
	case CORNER:
		yLocation += 1.0f;
		break;
	default:
		throw new GeoPackageException("Unsupported Encoding Type: "
				+ encodingType);
	}

	return yLocation;
}
 
Example #11
Source File: FeatureDao.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Constructor
 *
 * @param database        database name
 * @param db              connection
 * @param geometryColumns geometry columns
 * @param table           feature table
 */
public FeatureDao(String database, GeoPackageConnection db, GeometryColumns geometryColumns,
                  FeatureTable table) {
    super(database, db, new FeatureConnection(db), table);

    this.featureDb = (FeatureConnection) getUserDb();
    this.geometryColumns = geometryColumns;
    if (geometryColumns.getContents() == null) {
        throw new GeoPackageException(GeometryColumns.class.getSimpleName()
                + " " + geometryColumns.getId() + " has null "
                + Contents.class.getSimpleName());
    }
    if (geometryColumns.getSrs() == null) {
        throw new GeoPackageException(GeometryColumns.class.getSimpleName()
                + " " + geometryColumns.getId() + " has null "
                + SpatialReferenceSystem.class.getSimpleName());
    }

    projection = geometryColumns.getProjection();
}
 
Example #12
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean createContentsIdTable() {
	verifyWritable();

	boolean created = false;
	ContentsIdDao dao = getContentsIdDao();
	try {
		if (!dao.isTableExists()) {
			created = tableCreator.createContentsId() > 0;
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to check if " + ContentsId.class.getSimpleName()
						+ " table exists and create it",
				e);
	}
	return created;
}
 
Example #13
Source File: FeatureIndexManager.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Delete the feature index for the geometry id
 *
 * @param type   feature index type
 * @param geomId geometry id
 * @return true if deleted
 */
public boolean deleteIndex(FeatureIndexType type, long geomId) {
    if (type == null) {
        throw new GeoPackageException("FeatureIndexType is required to delete index");
    }
    boolean deleted = false;
    switch (type) {
        case GEOPACKAGE:
            deleted = featureTableIndex.deleteIndex(geomId) > 0;
            break;
        case METADATA:
            deleted = featureIndexer.deleteIndex(geomId);
            break;
        case RTREE:
            // Updated by triggers, ignore for RTree
            deleted = true;
            break;
        default:
            throw new GeoPackageException("Unsupported FeatureIndexType: " + type);
    }
    return deleted;
}
 
Example #14
Source File: StyleRow.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Validate and adjust the color value
 * 
 * @param color
 *            color
 */
private String validateColor(String color) {
	String validated = color;
	if (color != null) {
		if (!color.startsWith("#")) {
			validated = "#" + color;
		}
		if (!colorPattern.matcher(validated).matches()) {
			throw new GeoPackageException(
					"Color must be in hex format #RRGGBB or #RGB, invalid value: "
							+ color);
		}
		validated = validated.toUpperCase();
	}
	return validated;
}
 
Example #15
Source File: FeatureCoreStyleExtension.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Check if the style extension relationship between a feature table and
 * style extension table exists
 * 
 * @param mappingTableName
 *            mapping table name
 * @param featureTable
 *            feature table name
 * @param baseTable
 *            base table name
 * @param relatedTable
 *            related table name
 * @return true if relationship exists
 */
private boolean hasStyleRelationship(String mappingTableName,
		String baseTable, String relatedTable) {

	boolean has = false;

	try {
		has = relatedTables.hasRelations(baseTable, relatedTable,
				mappingTableName);
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to check if Feature Style Relationship exists. Base Table: "
						+ baseTable + ", Related Table: " + relatedTable
						+ ", Mapping Table: " + mappingTableName, e);
	}

	return has;
}
 
Example #16
Source File: TileMatrix.java    From geopackage-core-java with MIT License 6 votes vote down vote up
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a tiles data type (Spec Requirement 42)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null
				|| (dataType != ContentsDataType.TILES && dataType != ContentsDataType.GRIDDED_COVERAGE)) {
			throw new GeoPackageException("The "
					+ Contents.class.getSimpleName() + " of a "
					+ TileMatrix.class.getSimpleName()
					+ " must have a data type of "
					+ ContentsDataType.TILES.getName() + " or "
					+ ContentsDataType.GRIDDED_COVERAGE.getName());
		}
		tableName = contents.getId();
	} else {
		tableName = null;
	}
}
 
Example #17
Source File: GeometryColumnsSfSql.java    From geopackage-core-java with MIT License 6 votes vote down vote up
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a features data type (Spec Requirement
		// 23)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null || dataType != ContentsDataType.FEATURES) {
			throw new GeoPackageException("The "
					+ Contents.class.getSimpleName() + " of a "
					+ GeometryColumnsSfSql.class.getSimpleName()
					+ " must have a data type of "
					+ ContentsDataType.FEATURES.getName());
		}
		fTableName = contents.getId();
	}
}
 
Example #18
Source File: FeatureCoreStyleExtension.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Completely remove and delete the extension and all styles and icons
 */
public void removeExtension() {

	deleteRelationships();

	geoPackage.deleteTable(StyleTable.TABLE_NAME);

	geoPackage.deleteTable(IconTable.TABLE_NAME);

	try {
		if (extensionsDao.isTableExists()) {
			extensionsDao.deleteByExtension(EXTENSION_NAME);
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to delete Feature Style extension. GeoPackage: "
						+ geoPackage.getName(), e);
	}

}
 
Example #19
Source File: LoadGeoPackageTestCase.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws IOException
 * @throws SQLException
 */
@Override
protected GeoPackage getGeoPackage() throws Exception {
	File testFolder = folder.newFolder();

	File testFile = TestUtils.getTestFile(file);

	File newFile = new File(testFolder, testFile.getName());
	try {
		GeoPackageIOUtils.copyFile(testFile, newFile);
	} catch (IOException e) {
		throw new GeoPackageException(
				"Failed to copy GeoPackage to test directory. File: "
						+ testFile.getAbsolutePath() + ", Test Directory: "
						+ testFolder.getAbsolutePath(), e);
	}

	// Open
	GeoPackage geoPackage = GeoPackageManager.open(newFile);
	if (geoPackage == null) {
		throw new GeoPackageException("Failed to open database");
	}

	return geoPackage;
}
 
Example #20
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public TileDao getTileDao(Contents contents) {

    if (contents == null) {
        throw new GeoPackageException("Non null "
                + Contents.class.getSimpleName()
                + " is required to create " + TileDao.class.getSimpleName());
    }

    TileMatrixSet tileMatrixSet = contents.getTileMatrixSet();
    if (tileMatrixSet == null) {
        throw new GeoPackageException("No "
                + TileMatrixSet.class.getSimpleName() + " exists for "
                + Contents.class.getSimpleName() + " " + contents.getId());
    }

    return getTileDao(tileMatrixSet);
}
 
Example #21
Source File: TileTableScaling.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Create or update the tile scaling
 * 
 * @param tileScaling
 *            tile scaling
 * @return true upon success
 */
public boolean createOrUpdate(TileScaling tileScaling) {

	boolean success = false;
	tileScaling.setTableName(tableName);

	getOrCreateExtension();
	try {
		if (!tileScalingDao.isTableExists()) {
			geoPackage.createTileScalingTable();
		}

		CreateOrUpdateStatus status = tileScalingDao
				.createOrUpdate(tileScaling);
		success = status.isCreated() || status.isUpdated();

	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to create or update tile scaling for GeoPackage: "
						+ geoPackage.getName() + ", Tile Table: "
						+ tableName, e);
	}

	return success;
}
 
Example #22
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Delete all RTree Index extensions for the table. Drops the triggers,
 * RTree tables, and deletes the extensions.
 * 
 * @param tableName
 *            table name
 * 
 * @since 3.2.0
 */
public void delete(String tableName) {
	try {
		if (extensionsDao.isTableExists()) {
			List<Extensions> extensions = extensionsDao
					.queryByExtension(EXTENSION_NAME, tableName);
			for (Extensions extension : extensions) {
				delete(extension.getTableName(), extension.getColumnName());
			}
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to delete RTree Index extensions for table. GeoPackage: "
						+ geoPackage.getName() + ", Table: " + tableName,
				e);
	}

}
 
Example #23
Source File: UrlTileGenerator.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Set the tile format
 * 
 * @param tileFormat
 *            tile format
 */
public void setTileFormat(TileFormatType tileFormat) {
	if (tileFormat == null) {
		this.tileFormat = TileFormatType.XYZ;
	} else {
		switch (tileFormat) {
		case XYZ:
		case TMS:
			this.tileFormat = tileFormat;
			break;
		default:
			throw new GeoPackageException(
					"Unsupported Tile Format Type for URL Tile Generation: "
							+ tileFormat);
		}
	}
}
 
Example #24
Source File: FeatureTableCoreIndex.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Clear the Geometry Indices for the table name
 * 
 * @return number of rows deleted
 */
private int clearGeometryIndices() {
	int deleted = 0;
	DeleteBuilder<GeometryIndex, GeometryIndexKey> db = geometryIndexDao
			.deleteBuilder();
	try {
		db.where().eq(GeometryIndex.COLUMN_TABLE_NAME, tableName);
		PreparedDelete<GeometryIndex> deleteQuery = db.prepare();
		deleted = geometryIndexDao.delete(deleteQuery);
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to clear Geometry Index rows for GeoPackage: "
						+ geoPackage.getName() + ", Table Name: "
						+ tableName + ", Column Name: " + columnName,
				e);
	}

	return deleted;
}
 
Example #25
Source File: GeoPackageMetadataDataSource.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Create a new GeoPackage metadata
 *
 * @param metadata GeoPackage metadata
 */
public void create(GeoPackageMetadata metadata) {
    ContentValues values = new ContentValues();
    values.put(GeoPackageMetadata.COLUMN_NAME, metadata.getName());
    values.put(GeoPackageMetadata.COLUMN_EXTERNAL_PATH, metadata.getExternalPath());
    long insertId = db.insert(
            GeoPackageMetadata.TABLE_NAME, null,
            values);
    if (insertId == -1) {
        throw new GeoPackageException(
                "Failed to insert GeoPackage metadata. Name: "
                        + metadata.getName() + ", External Path: "
                        + metadata.getExternalPath());
    }
    metadata.setId(insertId);
}
 
Example #26
Source File: FeatureTableCoreIndex.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Delete the feature table index
 * 
 * @return true if index deleted
 */
public boolean deleteIndex() {

	boolean deleted = false;

	ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
	TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();
	try {
		// Delete geometry indices and table index
		if (tableIndexDao.isTableExists()) {
			deleted = tableIndexDao.deleteByIdCascade(tableName) > 0;
		}
		// Delete the extensions entry
		if (extensionsDao.isTableExists()) {
			deleted = extensionsDao.deleteByExtension(EXTENSION_NAME,
					tableName) > 0 || deleted;
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to delete Table Index. GeoPackage: "
						+ geoPackage.getName() + ", Table: " + tableName,
				e);
	}

	return deleted;
}
 
Example #27
Source File: TileReader.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * Read the tiles in the directory into the GeoPackage file table
 * 
 * @param geoPackageFile
 *            GeoPackage file
 * @param tileTable
 *            tile table
 * @param directory
 *            input directory
 * @param imageFormat
 *            image format
 * @param tileType
 *            tile type
 * @param rawImage
 *            use raw image flag
 * @throws IOException
 *             upon failure
 * @throws SQLException
 *             upon failure
 */
public static void readTiles(File geoPackageFile, String tileTable,
		File directory, String imageFormat, TileFormatType tileType,
		boolean rawImage) throws IOException, SQLException {

	// If the GeoPackage does not exist create it
	if (!geoPackageFile.exists()) {
		if (!GeoPackageManager.create(geoPackageFile)) {
			throw new GeoPackageException(
					"Failed to create GeoPackage file: "
							+ geoPackageFile.getAbsolutePath());
		}
	}

	// Open the GeoPackage
	GeoPackage geoPackage = GeoPackageManager.open(geoPackageFile);
	try {
		readTiles(geoPackage, tileTable, directory, imageFormat, tileType,
				rawImage);
	} finally {
		geoPackage.close();
	}
}
 
Example #28
Source File: UrlTileGenerator.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * Constructor
 *
 * @param context     app context
 * @param geoPackage  GeoPackage
 * @param tableName   table name
 * @param tileUrl     tile url
 * @param minZoom     min zoom
 * @param maxZoom     max zoom
 * @param boundingBox tiles bounding box
 * @param projection  tiles projection
 * @since 1.3.0
 */
public UrlTileGenerator(Context context, GeoPackage geoPackage,
                        String tableName, String tileUrl, int minZoom, int maxZoom, BoundingBox boundingBox, Projection projection) {
    super(context, geoPackage, tableName, minZoom, maxZoom, boundingBox, projection);

    try {
        this.tileUrl = URLDecoder.decode(tileUrl, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new GeoPackageException("Failed to decode tile url: "
                + tileUrl, e);
    }

    this.urlHasXYZ = hasXYZ(tileUrl);
    this.urlHasBoundingBox = hasBoundingBox(tileUrl);

    if (!this.urlHasXYZ && !this.urlHasBoundingBox) {
        throw new GeoPackageException(
                "URL does not contain x,y,z or bounding box variables: "
                        + tileUrl);
    }
}
 
Example #29
Source File: LoadGeoPackageTestCase.java    From geopackage-android with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @throws IOException
 * @throws SQLException
 */
@Override
protected GeoPackage getGeoPackage() throws Exception {
    GeoPackageManager manager = GeoPackageFactory.getManager(activity);

    // Delete
    manager.delete(name);

    // Copy the test db file from assets to the internal storage
    TestUtils.copyAssetFileToInternalStorage(activity, testContext,
            file);

    // Import
    String importLocation = TestUtils.getAssetFileInternalStorageLocation(
            activity, file);
    manager.importGeoPackage(new File(importLocation));

    // Open
    GeoPackage geoPackage = manager.open(name);
    if (geoPackage == null) {
        throw new GeoPackageException("Failed to open database");
    }

    return geoPackage;
}
 
Example #30
Source File: ImportCoverageDataGeoPackageTestCase.java    From geopackage-android with MIT License 6 votes vote down vote up
@Override
protected GeoPackage getGeoPackage() throws Exception {

    GeoPackageManager manager = GeoPackageFactory.getManager(activity);

    // Delete
    manager.delete(TestConstants.IMPORT_COVERAGE_DATA_DB_NAME);

    // Copy the test db file from assets to the internal storage
    TestUtils.copyAssetFileToInternalStorage(activity, testContext,
            TestConstants.IMPORT_COVERAGE_DATA_DB_FILE_NAME);

    // Import
    String importLocation = TestUtils.getAssetFileInternalStorageLocation(
            activity, TestConstants.IMPORT_COVERAGE_DATA_DB_FILE_NAME);
    manager.importGeoPackage(new File(importLocation));

    // Open
    GeoPackage geoPackage = manager.open(TestConstants.IMPORT_COVERAGE_DATA_DB_NAME);
    if (geoPackage == null) {
        throw new GeoPackageException("Failed to open database");
    }

    return geoPackage;
}