Java Code Examples for mil.nga.geopackage.GeoPackageManager#create()
The following examples show how to use
mil.nga.geopackage.GeoPackageManager#create() .
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: TestSetupTeardown.java From geopackage-android-map with MIT License | 4 votes |
/** * Set up the create database * * @param activity * @param testContext * @param features * @param allowEmptyFeatures * @param tiles * @return * @throws SQLException * @throws IOException */ public static GeoPackage setUpCreate(Activity activity, Context testContext, boolean features, boolean allowEmptyFeatures, boolean tiles) throws SQLException, IOException { GeoPackageManager manager = GeoPackageFactory.getManager(activity); // Delete manager.delete(TestConstants.TEST_DB_NAME); // Create manager.create(TestConstants.TEST_DB_NAME); // Open GeoPackage geoPackage = manager.open(TestConstants.TEST_DB_NAME); if (geoPackage == null) { throw new GeoPackageException("Failed to open database"); } TestCase.assertEquals("Application Id", geoPackage.getApplicationId(), GeoPackageConstants.APPLICATION_ID); TestCase.assertEquals("User Version", geoPackage.getUserVersion(), GeoPackageConstants.USER_VERSION); String userVersionString = String.valueOf(geoPackage.getUserVersion()); String majorVersion = userVersionString.substring(0, userVersionString.length() - 4); String minorVersion = userVersionString.substring(userVersionString.length() - 4, userVersionString.length() - 2); String patchVersion = userVersionString.substring(userVersionString.length() - 2); TestCase.assertEquals("Major User Version", geoPackage.getUserVersionMajor(), Integer.valueOf(majorVersion).intValue()); TestCase.assertEquals("Minor User Version", geoPackage.getUserVersionMinor(), Integer.valueOf(minorVersion).intValue()); TestCase.assertEquals("Patch User Version", geoPackage.getUserVersionPatch(), Integer.valueOf(patchVersion).intValue()); if (features) { setUpCreateFeatures(geoPackage, allowEmptyFeatures); } if (tiles) { setUpCreateTiles(testContext, geoPackage); } setUpCreateCommon(geoPackage); return geoPackage; }
Example 2
Source File: TestSetupTeardown.java From geopackage-android with MIT License | 4 votes |
/** * Set up the create database * * @param activity * @param testContext * @param features * @param allowEmptyFeatures * @param tiles * @return * @throws SQLException * @throws IOException * @parma name */ public static GeoPackage setUpCreate(Activity activity, Context testContext, String name, boolean features, boolean allowEmptyFeatures, boolean tiles) throws SQLException, IOException { GeoPackageManager manager = GeoPackageFactory.getManager(activity); // Delete manager.delete(name); // Create manager.create(name); // Open GeoPackage geoPackage = manager.open(name); if (geoPackage == null) { throw new GeoPackageException("Failed to open database"); } TestCase.assertEquals("Application Id", geoPackage.getApplicationId(), GeoPackageConstants.APPLICATION_ID); TestCase.assertEquals("User Version", geoPackage.getUserVersion(), GeoPackageConstants.USER_VERSION); String userVersionString = String.valueOf(geoPackage.getUserVersion()); String majorVersion = userVersionString.substring(0, userVersionString.length() - 4); String minorVersion = userVersionString.substring(userVersionString.length() - 4, userVersionString.length() - 2); String patchVersion = userVersionString.substring(userVersionString.length() - 2); TestCase.assertEquals("Major User Version", geoPackage.getUserVersionMajor(), Integer.valueOf(majorVersion).intValue()); TestCase.assertEquals("Minor User Version", geoPackage.getUserVersionMinor(), Integer.valueOf(minorVersion).intValue()); TestCase.assertEquals("Patch User Version", geoPackage.getUserVersionPatch(), Integer.valueOf(patchVersion).intValue()); if (features) { setUpCreateFeatures(geoPackage, allowEmptyFeatures); } if (tiles) { setUpCreateTiles(testContext, geoPackage); } setUpCreateCommon(geoPackage); return geoPackage; }
Example 3
Source File: OAPIFeatureGeneratorTest.java From geopackage-android with MIT License | 4 votes |
/** * Test a WFS server and create a GeoPackage * * @param server server url * @param collection collection name * @param name geoPackage and table name * @param limit request limit * @param totalLimit total limit * @param boundingBox bounding box * @param time time * @param period period or end time * @throws SQLException upon error */ private void testServer(String server, String collection, String name, Integer limit, Integer totalLimit, BoundingBox boundingBox, String time, String period) throws SQLException { GeoPackageManager geoPackageManager = GeoPackageFactory.getManager(activity); geoPackageManager.delete(collection); geoPackageManager.create(collection); GeoPackage geoPackage = geoPackageManager.open(collection); OAPIFeatureGenerator generator = new OAPIFeatureGenerator( geoPackage, name, server, collection); generator.setLimit(limit); generator.setTotalLimit(totalLimit); generator.setBoundingBox(boundingBox); generator.setTime(time); generator.setPeriod(period); generator.setDownloadAttempts(3); int count = generator.generateFeatures(); if (totalLimit != null) { TestCase.assertEquals(totalLimit.intValue(), count); } FeatureDao featureDao = generator.getFeatureDao(); if (totalLimit != null) { TestCase.assertEquals(totalLimit.intValue(), featureDao.count()); } FeatureIndexManager indexer = new FeatureIndexManager(activity, geoPackage, featureDao); indexer.setIndexLocation(FeatureIndexType.GEOPACKAGE); indexer.index(); indexer.close(); BoundingBox dataBounds = geoPackage .getBoundingBox(featureDao.getTableName()); Contents contents = featureDao.getContents(); contents.setBoundingBox(dataBounds); geoPackage.getContentsDao().update(contents); geoPackage.close(); }
Example 4
Source File: GeoPackageExample.java From geopackage-android with MIT License | 3 votes |
private static GeoPackage createGeoPackage(Context context) { GeoPackageManager manager = GeoPackageFactory.getManager(context); manager.delete(GEOPACKAGE_NAME); manager.create(GEOPACKAGE_NAME); GeoPackage geoPackage = manager.open(GEOPACKAGE_NAME); if (geoPackage == null) { throw new GeoPackageException("Failed to open database"); } return geoPackage; }