本文整理汇总了Java中mil.nga.geopackage.GeoPackage.close方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPackage.close方法的具体用法?Java GeoPackage.close怎么用?Java GeoPackage.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mil.nga.geopackage.GeoPackage
的用法示例。
在下文中一共展示了GeoPackage.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: infoFeatureClick
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Info feature click
*
* @param marker
* @param markerFeature
*/
private void infoFeatureClick(final Marker marker, MarkerFeature markerFeature) {
final GeoPackage geoPackage = manager.open(markerFeature.database);
final FeatureDao featureDao = geoPackage
.getFeatureDao(markerFeature.tableName);
final FeatureRow featureRow = featureDao.queryForIdRow(markerFeature.featureId);
if (featureRow != null) {
final GeoPackageGeometryData geomData = featureRow.getGeometry();
final GeometryType geometryType = geomData.getGeometry()
.getGeometryType();
String title = getTitle(geometryType, marker);
infoExistingFeatureOption(geoPackage, featureRow, title, geomData);
} else {
geoPackage.close();
}
}
示例2: open
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Open a GeoPackage
*
* @param file
* @return GeoPackage
*/
public static GeoPackage open(File file) {
// Validate the file extension
GeoPackageValidate.validateGeoPackageExtension(file);
// Create the GeoPackage Connection and table creator
GeoPackageConnection connection = connect(file);
GeoPackageTableCreator tableCreator = new GeoPackageTableCreator(
connection);
// Create a GeoPackage
GeoPackage geoPackage = new GeoPackageImpl(file, connection,
tableCreator);
// Validate the GeoPackage has the minimum required tables
try {
GeoPackageValidate.validateMinimumTables(geoPackage);
} catch (RuntimeException e) {
geoPackage.close();
throw e;
}
return geoPackage;
}
示例3: readTiles
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* 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
* @throws SQLException
*/
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();
}
}
示例4: testCreateOpen
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test creating and opening a database
*
* @throws IOException
*/
@Test
public void testCreateOpen() throws IOException {
File testFolder = folder.newFolder();
File dbFile = new File(testFolder, TestConstants.TEST_DB_FILE_NAME);
// Create
assertTrue("Database failed to create",
GeoPackageManager.create(dbFile));
assertTrue("Database does not exist", dbFile.exists());
// Open
GeoPackage geoPackage = GeoPackageManager.open(dbFile);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
}
示例5: tearDownCreate
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Tear down the create database
*
* @param activity
* @param geoPackage
*/
public static void tearDownCreate(Activity activity, GeoPackage geoPackage) {
// Close
if (geoPackage != null) {
geoPackage.close();
}
// Delete
GeoPackageManager manager = GeoPackageFactory.getManager(activity);
manager.delete(TestConstants.TEST_DB_NAME);
}
示例6: tearDownImport
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Tear down the import database
*
* @param activity
* @param geoPackage
*/
public static void tearDownImport(Activity activity, GeoPackage geoPackage) {
// Close
if (geoPackage != null) {
geoPackage.close();
}
// Delete
GeoPackageManager manager = GeoPackageFactory.getManager(activity);
manager.delete(TestConstants.IMPORT_DB_NAME);
}
示例7: testCreateOpenDelete
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test creating and deleting a database
*/
public void testCreateOpenDelete() {
GeoPackageManager manager = GeoPackageFactory.getManager(activity);
// Verify does not exist
assertFalse("Database already exists",
manager.exists(TestConstants.TEST_DB_NAME));
assertFalse("Database already returned in the set", manager
.databaseSet().contains(TestConstants.TEST_DB_NAME));
// Create
assertTrue("Database failed to create",
manager.create(TestConstants.TEST_DB_NAME));
assertTrue("Database does not exist",
manager.exists(TestConstants.TEST_DB_NAME));
assertTrue("Database not returned in the set", manager.databaseSet()
.contains(TestConstants.TEST_DB_NAME));
// Open
GeoPackage geoPackage = manager.open(TestConstants.TEST_DB_NAME);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
// Open with inverse validation
manager.setOpenHeaderValidation(!manager.isOpenHeaderValidation());
manager.setOpenIntegrityValidation(!manager.isOpenIntegrityValidation());
geoPackage = manager.open(TestConstants.TEST_DB_NAME);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
// Delete
assertTrue("Database not deleted",
manager.delete(TestConstants.TEST_DB_NAME));
assertFalse("Database exists after delete",
manager.exists(TestConstants.TEST_DB_NAME));
assertFalse("Database returned in the set after delete", manager
.databaseSet().contains(TestConstants.TEST_DB_NAME));
}
示例8: addEditableShapeBack
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Add editable shape back after editing is complete
*/
private void addEditableShapeBack() {
Long featureId = editFeatureIds.get(editFeatureMarker.getId());
final GeoPackage geoPackage = manager.open(editFeaturesDatabase);
try {
final FeatureDao featureDao = geoPackage
.getFeatureDao(editFeaturesTable);
final FeatureRow featureRow = featureDao.queryForIdRow(featureId);
GeoPackageGeometryData geomData = featureRow.getGeometry();
if (geomData != null) {
Geometry geometry = geomData.getGeometry();
if (geometry != null) {
GoogleMapShapeConverter converter = new GoogleMapShapeConverter(
featureDao.getProjection());
GoogleMapShape shape = converter.toShape(geometry);
prepareShapeOptions(shape, true, true);
GoogleMapShape mapShape = GoogleMapShapeConverter
.addShapeToMap(map, shape);
addEditableShape(featureId, mapShape);
}
}
} finally {
if (geoPackage != null) {
geoPackage.close();
}
}
}
示例9: tearDownCreate
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Tear down the create database
*
* @param geoPackage
*/
public static void tearDownCreate(GeoPackage geoPackage) {
// Close
if (geoPackage != null) {
geoPackage.close();
}
}
示例10: tearDownImport
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Tear down the import database
*
* @param geoPackage
*/
public static void tearDownImport(GeoPackage geoPackage) {
// Close
if (geoPackage != null) {
geoPackage.close();
}
}
示例11: testOpen
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test opening a database
*
* @throws IOException
*/
@Test
public void testOpen() throws IOException {
File dbFile = TestUtils.getImportDbFile();
assertTrue("Database does not exist", dbFile.exists());
// Open
GeoPackage geoPackage = GeoPackageManager.open(dbFile);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
}
示例12: testImportUrl
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test importing a database from a GeoPackage file
*
* @throws MalformedURLException
*/
public void testImportUrl() throws MalformedURLException {
GeoPackageManager manager = GeoPackageFactory.getManager(activity);
// Verify does not exist
assertFalse("Database already exists",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertFalse("Database already returned in the set", manager
.databaseSet().contains(TestConstants.IMPORT_DB_NAME));
// Import
URL importUrl = new URL(TestConstants.IMPORT_URL);
assertTrue("Database not imported", manager.importGeoPackage(
TestConstants.IMPORT_DB_NAME, importUrl));
assertTrue("Database does not exist",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertTrue("Database not returned in the set", manager.databaseSet()
.contains(TestConstants.IMPORT_DB_NAME));
// Open
GeoPackage geoPackage = manager.open(TestConstants.IMPORT_DB_NAME);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
// Delete
assertTrue("Database not deleted",
manager.delete(TestConstants.IMPORT_DB_NAME));
assertFalse("Database exists after delete",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertFalse("Database returned in the set after delete", manager
.databaseSet().contains(TestConstants.IMPORT_DB_NAME));
// Import a fake url
importUrl = new URL("http://doesnotexist/geopackage.gpkg");
try {
manager.importGeoPackage(TestConstants.IMPORT_DB_NAME, importUrl);
fail("Successully imported a fake geopackage url");
} catch (GeoPackageException e) {
// expected
}
// Import and Open with inverse validation
manager.setImportHeaderValidation(!manager.isImportHeaderValidation());
manager.setImportIntegrityValidation(!manager.isImportIntegrityValidation());
manager.setOpenHeaderValidation(!manager.isOpenHeaderValidation());
manager.setOpenIntegrityValidation(!manager.isOpenIntegrityValidation());
// Import
importUrl = new URL(TestConstants.IMPORT_URL);
assertTrue("Database not imported", manager.importGeoPackage(
TestConstants.IMPORT_DB_NAME, importUrl));
assertTrue("Database does not exist",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertTrue("Database not returned in the set", manager.databaseSet()
.contains(TestConstants.IMPORT_DB_NAME));
// Open
geoPackage = manager.open(TestConstants.IMPORT_DB_NAME);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
// Delete
assertTrue("Database not deleted",
manager.delete(TestConstants.IMPORT_DB_NAME));
assertFalse("Database exists after delete",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertFalse("Database returned in the set after delete", manager
.databaseSet().contains(TestConstants.IMPORT_DB_NAME));
}
示例13: createExternal
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Test creating a database GeoPackage file as an external link
*/
private void createExternal(int testCase) {
GeoPackageManager manager = GeoPackageFactory.getManager(activity);
// Verify does not exist
assertFalse("Database already exists",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertFalse("Database already returned in the set", manager
.databaseSet().contains(TestConstants.IMPORT_DB_NAME));
// Create
File externalDirectory = activity.getExternalCacheDir();
File createFile = new File(externalDirectory, TestConstants.IMPORT_DB_FILE_NAME);
createFile.delete();
createExternal(manager, externalDirectory, createFile, testCase);
assertTrue("Database does not exist",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertTrue("Database not returned in the set", manager.databaseSet()
.contains(TestConstants.IMPORT_DB_NAME));
assertTrue(manager.validate(TestConstants.IMPORT_DB_NAME));
assertTrue(manager.validateHeader(TestConstants.IMPORT_DB_NAME));
assertTrue(manager.validateIntegrity(TestConstants.IMPORT_DB_NAME));
// Open
GeoPackage geoPackage = manager.open(TestConstants.IMPORT_DB_NAME);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
// Attempt to create again
try {
createExternal(manager, externalDirectory, createFile, testCase);
fail("Creating database again did not cause exception");
} catch (GeoPackageException e) {
// expected
}
// Delete
assertTrue("Database not deleted",
manager.delete(TestConstants.IMPORT_DB_NAME));
assertFalse("Database exists after delete",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertFalse("Database returned in the set after delete", manager
.databaseSet().contains(TestConstants.IMPORT_DB_NAME));
assertTrue("Create file could not be deleted", createFile.delete());
// Import and Open with inverse validation
manager.setImportHeaderValidation(!manager.isImportHeaderValidation());
manager.setImportIntegrityValidation(!manager.isImportIntegrityValidation());
manager.setOpenHeaderValidation(!manager.isOpenHeaderValidation());
manager.setOpenIntegrityValidation(!manager.isOpenIntegrityValidation());
// Create
createExternal(manager, externalDirectory, createFile, testCase);
assertTrue("Database does not exist",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertTrue("Database not returned in the set", manager.databaseSet()
.contains(TestConstants.IMPORT_DB_NAME));
assertTrue(manager.validate(TestConstants.IMPORT_DB_NAME));
assertTrue(manager.validateHeader(TestConstants.IMPORT_DB_NAME));
assertTrue(manager.validateIntegrity(TestConstants.IMPORT_DB_NAME));
// Open
geoPackage = manager.open(TestConstants.IMPORT_DB_NAME);
assertNotNull("Failed to open database", geoPackage);
geoPackage.close();
// Delete
assertTrue("Database not deleted",
manager.delete(TestConstants.IMPORT_DB_NAME));
assertFalse("Database exists after delete",
manager.exists(TestConstants.IMPORT_DB_NAME));
assertFalse("Database returned in the set after delete", manager
.databaseSet().contains(TestConstants.IMPORT_DB_NAME));
// Delete the file
assertTrue("Create file could not be deleted", createFile.delete());
}
示例14: viewDatabaseOption
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* View database information
*
* @param database
*/
private void viewDatabaseOption(final String database) {
StringBuilder databaseInfo = new StringBuilder();
GeoPackage geoPackage = manager.open(database);
try {
SpatialReferenceSystemDao srsDao = geoPackage
.getSpatialReferenceSystemDao();
List<SpatialReferenceSystem> srsList = srsDao.queryForAll();
databaseInfo.append("Size: ")
.append(manager.readableSize(database));
databaseInfo.append("\n\nLocation: ").append(
manager.isExternal(database) ? "External" : "Local");
databaseInfo.append("\nPath: ").append(manager.getPath(database));
databaseInfo.append("\n\nFeature Tables: ").append(
geoPackage.getFeatureTables().size());
databaseInfo.append("\nTile Tables: ").append(
geoPackage.getTileTables().size());
databaseInfo.append("\n\nSpatial Reference Systems: ").append(
srsList.size());
for (SpatialReferenceSystem srs : srsList) {
databaseInfo.append("\n");
addSrs(databaseInfo, srs);
}
} catch (Exception e) {
databaseInfo.append(e.getMessage());
} finally {
geoPackage.close();
}
AlertDialog viewDialog = new AlertDialog.Builder(getActivity(), R.style.AppCompatAlertDialogStyle)
.setTitle(database)
.setPositiveButton(getString(R.string.button_ok_label),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).setMessage(databaseInfo.toString()).create();
viewDialog.show();
}
示例15: setEditType
import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
* Set the edit type
*
* @param editType
*/
private void setEditType(EditType previousType, EditType editType) {
if (editType != null && previousType != editType) {
editFeatureType = editType;
switch (editType) {
case POINT:
editPointButton
.setImageResource(R.drawable.ic_edit_point_active);
break;
case LINESTRING:
editLinestringButton
.setImageResource(R.drawable.ic_edit_linestring_active);
break;
case POLYGON_HOLE:
editFeatureType = EditType.POLYGON;
case POLYGON:
editPolygonButton
.setImageResource(R.drawable.ic_edit_polygon_active);
editFeaturesPolygonHoleView.setVisibility(View.VISIBLE);
break;
case EDIT_FEATURE:
editFeatureMarker = tempEditFeatureMarker;
tempEditFeatureMarker = null;
Long featureId = editFeatureIds.get(editFeatureMarker.getId());
final GeoPackage geoPackage = manager
.open(editFeaturesDatabase);
try {
final FeatureDao featureDao = geoPackage
.getFeatureDao(editFeaturesTable);
final FeatureRow featureRow = featureDao
.queryForIdRow(featureId);
Geometry geometry = featureRow.getGeometry().getGeometry();
GoogleMapShapeConverter converter = new GoogleMapShapeConverter(
featureDao.getProjection());
GoogleMapShape shape = converter.toShape(geometry);
editFeatureMarker.remove();
GoogleMapShape featureObject = editFeatureObjects
.remove(editFeatureMarker.getId());
if (featureObject != null) {
featureObject.remove();
}
MarkerOptions editFeatureShapeMarker = getEditFeatureShapeMarker();
editFeatureShape = converter.addShapeToMapAsMarkers(map,
shape, getEditFeatureMarker(),
editFeatureShapeMarker, editFeatureShapeMarker,
getEditFeatureShapeHoleMarker(),
getDrawPolylineOptions(), getDrawPolygonOptions());
updateEditState(true);
} finally {
if (geoPackage != null) {
geoPackage.close();
}
}
break;
}
}
}