Java Code Examples for mil.nga.geopackage.GeoPackage#getFeatureTables()

The following examples show how to use mil.nga.geopackage.GeoPackage#getFeatureTables() . 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: FeatureIndexManagerUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Test large index
 *
 * @param geoPackage              GeoPackage
 * @param compareProjectionCounts compare projection counts and query counts
 * @param verbose                 verbose printing
 * @throws SQLException upon error
 */
public static void testTimedIndex(Activity activity, GeoPackage geoPackage,
                                  boolean compareProjectionCounts, boolean verbose)
        throws SQLException {
    for (String featureTable : geoPackage.getFeatureTables()) {
        testTimedIndex(activity, geoPackage, featureTable, compareProjectionCounts,
                verbose);
    }
}
 
Example 2
Source File: GeopackageFeatureTilesOverlay.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
public List<String> getFeatureTable(String database) throws Exception {
    GeoPackage open = null;
    List<String> featureTables = new ArrayList<>();
    try {
        open = manager.open(database);
        featureTables = open.getFeatureTables();
    } catch (Exception ex) {
        throw ex;
    } finally {
        if (open != null)
            open.close();
    }

    return featureTables;
}
 
Example 3
Source File: GeoPackageExample.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void insertRelatedTablesMediaPreviewExtensionRows(
		GeoPackage geoPackage, RelatedTablesExtension relatedTables)
		throws IOException {

	ContentsIdExtension contentsId = new ContentsIdExtension(geoPackage);

	MediaTable mediaTable = MediaTable.create("preview");
	UserMappingTable userMappingTable = UserMappingTable
			.create("features_" + mediaTable.getTableName());

	ExtendedRelation relation = relatedTables.addMediaRelationship(
			ContentsId.TABLE_NAME, mediaTable, userMappingTable);

	MediaDao mediaDao = relatedTables.getMediaDao(relation);
	UserMappingDao userMappingDao = relatedTables.getMappingDao(relation);

	for (String featureTable : geoPackage.getFeatureTables()) {

		long featureContentsId = contentsId.getOrCreateId(featureTable);

		FeaturePreview preview = new FeaturePreview(geoPackage,
				featureTable);
		preview.setManual(true);
		preview.setBufferPercentage(0.1);
		BufferedImage previewImage = preview.draw();
		byte[] previewBytes = ImageUtils.writeImageToBytes(previewImage,
				ImageUtils.IMAGE_FORMAT_PNG);

		MediaRow mediaRow = mediaDao.newRow();
		mediaRow.setData(previewBytes);
		mediaRow.setContentType("image/png");
		long mediaRowId = mediaDao.create(mediaRow);

		UserMappingRow userMappingRow = userMappingDao.newRow();
		userMappingRow.setBaseId(featureContentsId);
		userMappingRow.setRelatedId(mediaRowId);
		userMappingDao.create(userMappingRow);
	}

}
 
Example 4
Source File: GeoPackageExample.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void createFeatureTileLinkExtension(GeoPackage geoPackage)
		throws SQLException, IOException {

	List<String> featureTables = geoPackage.getFeatureTables();
	for (String featureTable : featureTables) {

		FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
		FeatureTiles featureTiles = new DefaultFeatureTiles(geoPackage,
				featureDao);

		BoundingBox boundingBox = featureDao.getBoundingBox();
		Projection projection = featureDao.getProjection();

		Projection requestProjection = ProjectionFactory
				.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);
		ProjectionTransform transform = projection
				.getTransformation(requestProjection);
		BoundingBox requestBoundingBox = boundingBox.transform(transform);

		int zoomLevel = TileBoundingBoxUtils
				.getZoomLevel(requestBoundingBox);
		zoomLevel = Math.max(zoomLevel, 8);
		zoomLevel = Math.min(zoomLevel, 19);

		int minZoom = zoomLevel - 8;
		int maxZoom = zoomLevel + 2;

		TileGenerator tileGenerator = new FeatureTileGenerator(geoPackage,
				featureTable + "_tiles", featureTiles, minZoom, maxZoom,
				requestBoundingBox, requestProjection);

		tileGenerator.generateTiles();
	}
}
 
Example 5
Source File: GeoPackageExample.java    From geopackage-java with MIT License 5 votes vote down vote up
private static void createGeometryIndexExtension(GeoPackage geoPackage) {

		List<String> featureTables = geoPackage.getFeatureTables();
		for (String featureTable : featureTables) {

			FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
			FeatureTableIndex featureTableIndex = new FeatureTableIndex(
					geoPackage, featureDao);
			featureTableIndex.index();
		}

	}
 
Example 6
Source File: GeoPackageRepository.java    From geopackage-mapcache-android with MIT License 5 votes vote down vote up
/**
 *  Returns the list of feature tables for a geopackage
 */
public List<String> getFeatureTables(String database){
    GeoPackage geo = manager.open(database);
    if(geo != null) {
        List<String> features = geo.getFeatureTables();
        geo.close();
        return features;
    }
    return null;
}
 
Example 7
Source File: GeoPackageExample.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void createFeatureTileLinkExtension(Context context, GeoPackage geoPackage)
        throws SQLException, IOException {

    List<String> featureTables = geoPackage.getFeatureTables();
    for (String featureTable : featureTables) {

        FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
        FeatureTiles featureTiles = new DefaultFeatureTiles(context, geoPackage, featureDao,
                context.getResources().getDisplayMetrics().density);

        BoundingBox boundingBox = featureDao.getBoundingBox();
        Projection projection = featureDao.getProjection();

        Projection requestProjection = ProjectionFactory
                .getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);
        ProjectionTransform transform = projection
                .getTransformation(requestProjection);
        BoundingBox requestBoundingBox = boundingBox.transform(transform);

        int zoomLevel = TileBoundingBoxUtils
                .getZoomLevel(requestBoundingBox);
        zoomLevel = Math.max(zoomLevel, 8);
        zoomLevel = Math.min(zoomLevel, 19);

        int minZoom = zoomLevel - 8;
        int maxZoom = zoomLevel + 2;

        TileGenerator tileGenerator = new FeatureTileGenerator(context, geoPackage,
                featureTable + "_tiles", featureTiles, minZoom, maxZoom,
                requestBoundingBox, requestProjection);

        tileGenerator.generateTiles();
        featureTiles.close();
    }
}
 
Example 8
Source File: GeoPackageExample.java    From geopackage-android with MIT License 5 votes vote down vote up
private static void createGeometryIndexExtension(Context context, GeoPackage geoPackage) {

        List<String> featureTables = geoPackage.getFeatureTables();
        for (String featureTable : featureTables) {

            FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
            FeatureIndexManager indexer = new FeatureIndexManager(context, geoPackage, featureDao);
            indexer.setIndexLocation(FeatureIndexType.GEOPACKAGE);
            indexer.index();
            indexer.close();
        }

    }
 
Example 9
Source File: FeaturePreviewUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test the GeoPackage draw feature preview
 *
 * @param activity   activity
 * @param geoPackage GeoPackage
 * @throws IOException upon error
 */
public static void testDraw(Activity activity, GeoPackage geoPackage) throws IOException {

    for (String featureTable : geoPackage.getFeatureTables()) {

        FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
        int count = featureDao.count(
                CoreSQLUtils.quoteWrap(featureDao.getGeometryColumnName())
                        + " IS NOT NULL");

        BoundingBox contentsBoundingBox = geoPackage
                .getContentsBoundingBox(featureTable);
        BoundingBox indexedBoundingBox = geoPackage
                .getBoundingBox(featureTable);
        boolean expectImage = (contentsBoundingBox != null
                || indexedBoundingBox != null) && count > 0;
        boolean epsg = featureDao.getProjection().getAuthority()
                .equalsIgnoreCase(ProjectionConstants.AUTHORITY_EPSG);

        FeaturePreview preview = new FeaturePreview(activity, geoPackage, featureDao);

        Bitmap image = preview.draw();
        if (epsg) {
            assertEquals(expectImage, image != null);
        }

        preview.setBufferPercentage(0.4);
        preview.setLimit((int) Math.ceil(count / 2.0));
        Bitmap imageLimit = preview.draw();
        if (epsg) {
            assertEquals(expectImage, imageLimit != null);
        }

        preview.setManual(true);
        preview.setBufferPercentage(0.05);
        preview.setLimit(null);
        FeatureTiles featureTiles = preview.getFeatureTiles();
        featureTiles.setTileWidth(TileUtils.TILE_PIXELS_DEFAULT);
        featureTiles.setTileHeight(TileUtils.TILE_PIXELS_DEFAULT);
        featureTiles.setDensity(
                TileUtils.density(TileUtils.TILE_PIXELS_DEFAULT));
        featureTiles.clearIconCache();
        Bitmap imageManual = preview.draw();
        if (epsg) {
            assertNotNull(imageManual);
        }

        preview.setBufferPercentage(0.35);
        preview.setLimit(Math.max(count - 1, 1));
        Bitmap imageManualLimit = preview.draw();
        if (epsg) {
            assertNotNull(imageManualLimit);
        }

        preview.setBufferPercentage(0.15);
        preview.setLimit(null);
        preview.appendWhere(
                CoreSQLUtils.quoteWrap(featureDao.getIdColumnName()) + " > "
                        + ((int) Math.floor(count / 2.0)));
        Bitmap imageManualWhere = preview.draw();
        if (epsg) {
            assertNotNull(imageManualWhere);
        }

        if(image != null) {
            image.recycle();
        }
        if(imageLimit != null) {
            imageLimit.recycle();
        }
        if(imageManual != null) {
            imageManual.recycle();
        }
        if(imageManualLimit != null) {
            imageManualLimit.recycle();
        }
        if(imageManualWhere != null) {
            imageManualWhere.recycle();
        }

        preview.close();
    }

}
 
Example 10
Source File: GeoPackageTestUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test deleting tables by name
 *
 * @param geoPackage
 * @throws SQLException
 */
public static void testDeleteTables(GeoPackage geoPackage)
        throws SQLException {

    GeometryColumnsDao geometryColumnsDao = geoPackage
            .getGeometryColumnsDao();
    TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao();
    ContentsDao contentsDao = geoPackage.getContentsDao();

    TestCase.assertTrue(geometryColumnsDao.isTableExists()
            || tileMatrixSetDao.isTableExists());

    geoPackage.foreignKeys(false);

    if (geometryColumnsDao.isTableExists()) {

        TestCase.assertEquals(geoPackage.getFeatureTables().size(),
                geometryColumnsDao.countOf());
        for (String featureTable : geoPackage.getFeatureTables()) {
            TestCase.assertTrue(geoPackage.isTable(featureTable));
            TestCase.assertNotNull(contentsDao.queryForId(featureTable));
            geoPackage.deleteTable(featureTable);
            TestCase.assertFalse(geoPackage.isTable(featureTable));
            TestCase.assertNull(contentsDao.queryForId(featureTable));
        }
        TestCase.assertEquals(0, geometryColumnsDao.countOf());

        geoPackage.dropTable(GeometryColumns.TABLE_NAME);

        TestCase.assertFalse(geometryColumnsDao.isTableExists());
    }

    if (tileMatrixSetDao.isTableExists()) {
        TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao();

        TestCase.assertTrue(tileMatrixSetDao.isTableExists());
        TestCase.assertTrue(tileMatrixDao.isTableExists());

        TestCase.assertEquals(geoPackage.getTables(ContentsDataType.TILES).size() + geoPackage.getTables(ContentsDataType.GRIDDED_COVERAGE).size(),
                tileMatrixSetDao.countOf());
        for (String tileTable : geoPackage.getTileTables()) {
            TestCase.assertTrue(geoPackage.isTable(tileTable));
            TestCase.assertNotNull(contentsDao.queryForId(tileTable));
            geoPackage.deleteTable(tileTable);
            TestCase.assertFalse(geoPackage.isTable(tileTable));
            TestCase.assertNull(contentsDao.queryForId(tileTable));
        }
        TestCase.assertEquals(geoPackage.getTables(ContentsDataType.GRIDDED_COVERAGE).size(), tileMatrixSetDao.countOf());

        geoPackage.dropTable(TileMatrix.TABLE_NAME);
        geoPackage.dropTable(TileMatrixSet.TABLE_NAME);

        TestCase.assertFalse(tileMatrixSetDao.isTableExists());
        TestCase.assertFalse(tileMatrixDao.isTableExists());
    }

    for (String attributeTable : geoPackage.getAttributesTables()) {

        TestCase.assertTrue(geoPackage.isTable(attributeTable));
        TestCase.assertNotNull(contentsDao.queryForId(attributeTable));
        geoPackage.deleteTable(attributeTable);
        TestCase.assertFalse(geoPackage.isTable(attributeTable));
        TestCase.assertNull(contentsDao.queryForId(attributeTable));

    }

}
 
Example 11
Source File: GeoPackageExample.java    From geopackage-android with MIT License 4 votes vote down vote up
private static void insertRelatedTablesMediaPreviewExtensionRows(Activity activity,
                                                                 GeoPackage geoPackage, RelatedTablesExtension relatedTables)
        throws IOException {

    ContentsIdExtension contentsId = new ContentsIdExtension(geoPackage);

    MediaTable mediaTable = MediaTable.create("preview");
    UserMappingTable userMappingTable = UserMappingTable
            .create("features_" + mediaTable.getTableName());

    ExtendedRelation relation = relatedTables.addMediaRelationship(
            ContentsId.TABLE_NAME, mediaTable, userMappingTable);

    MediaDao mediaDao = relatedTables.getMediaDao(relation);
    UserMappingDao userMappingDao = relatedTables.getMappingDao(relation);

    for (String featureTable : geoPackage.getFeatureTables()) {

        long featureContentsId = contentsId.getOrCreateId(featureTable);

        FeaturePreview preview = new FeaturePreview(activity, geoPackage,
                featureTable);
        try {
            preview.setManual(true);
            preview.setBufferPercentage(0.1);
            Bitmap previewImage = preview.draw();
            byte[] previewBytes = BitmapConverter.toBytes(previewImage,
                    Bitmap.CompressFormat.PNG);

            MediaRow mediaRow = mediaDao.newRow();
            mediaRow.setData(previewBytes);
            mediaRow.setContentType("image/png");
            long mediaRowId = mediaDao.create(mediaRow);

            UserMappingRow userMappingRow = userMappingDao.newRow();
            userMappingRow.setBaseId(featureContentsId);
            userMappingRow.setRelatedId(mediaRowId);
            userMappingDao.create(userMappingRow);
        } finally {
            preview.close();
        }
    }

}
 
Example 12
Source File: FeatureTableIndexUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test table index delete all
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDeleteAll(GeoPackage geoPackage) throws SQLException {

	// Test indexing each feature table
	List<String> featureTables = geoPackage.getFeatureTables();
	for (String featureTable : featureTables) {

		FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
		FeatureTableIndex featureTableIndex = new FeatureTableIndex(
				geoPackage, featureDao);

		if (featureTableIndex.isIndexed()) {
			featureTableIndex.deleteIndex();
		}

		TestCase.assertFalse(featureTableIndex.isIndexed());

		TestUtils.validateGeoPackage(geoPackage);

		// Test indexing
		featureTableIndex.index();
		TestUtils.validateGeoPackage(geoPackage);

		TestCase.assertTrue(featureTableIndex.isIndexed());

	}

	ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
	GeometryIndexDao geometryIndexDao = geoPackage.getGeometryIndexDao();
	TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();

	TestCase.assertTrue(geometryIndexDao.isTableExists());
	TestCase.assertTrue(tableIndexDao.isTableExists());
	TestCase.assertTrue(extensionsDao.queryByExtension(
			FeatureTableIndex.EXTENSION_NAME).size() > 0);

	TestCase.assertTrue(geometryIndexDao.countOf() > 0);
	long count = tableIndexDao.countOf();
	TestCase.assertTrue(count > 0);

	int deleteCount = tableIndexDao.deleteAllCascade();
	TestCase.assertEquals(count, deleteCount);

	TestCase.assertTrue(geometryIndexDao.countOf() == 0);
	TestCase.assertTrue(tableIndexDao.countOf() == 0);
}
 
Example 13
Source File: FeaturePreviewUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test the GeoPackage draw feature preview
 * 
 * @param geoPackage
 *            GeoPackage
 * @throws IOException
 *             upon error
 */
public static void testDraw(GeoPackage geoPackage) throws IOException {

	for (String featureTable : geoPackage.getFeatureTables()) {

		FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
		int count = featureDao.count(
				CoreSQLUtils.quoteWrap(featureDao.getGeometryColumnName())
						+ " IS NOT NULL");

		BoundingBox contentsBoundingBox = geoPackage
				.getContentsBoundingBox(featureTable);
		BoundingBox indexedBoundingBox = geoPackage
				.getBoundingBox(featureTable);
		boolean expectImage = (contentsBoundingBox != null
				|| indexedBoundingBox != null) && count > 0;
		boolean epsg = featureDao.getProjection().getAuthority()
				.equalsIgnoreCase(ProjectionConstants.AUTHORITY_EPSG);

		FeaturePreview preview = new FeaturePreview(geoPackage, featureDao);

		BufferedImage image = preview.draw();
		if (epsg) {
			assertEquals(expectImage, image != null);
		}
		if (writeImages) {
			ImageIO.write(image, "png", new File("image.png"));
		}

		preview.setBufferPercentage(0.4);
		preview.setLimit((int) Math.ceil(count / 2.0));
		BufferedImage imageLimit = preview.draw();
		if (epsg) {
			assertEquals(expectImage, imageLimit != null);
		}
		if (writeImages) {
			ImageIO.write(imageLimit, "png", new File("image_limit.png"));
		}

		preview.setManual(true);
		preview.setBufferPercentage(0.05);
		preview.setLimit(null);
		FeatureTiles featureTiles = preview.getFeatureTiles();
		featureTiles.setTileWidth(TileUtils.TILE_PIXELS_DEFAULT);
		featureTiles.setTileHeight(TileUtils.TILE_PIXELS_DEFAULT);
		featureTiles.setScale(
				TileUtils.tileScale(TileUtils.TILE_PIXELS_DEFAULT));
		featureTiles.clearIconCache();
		BufferedImage imageManual = preview.draw();
		if (epsg) {
			assertNotNull(imageManual);
		}
		if (writeImages) {
			ImageIO.write(imageManual, "png", new File("image_manual.png"));
		}

		preview.setBufferPercentage(0.35);
		preview.setLimit(Math.max(count - 1, 1));
		BufferedImage imageManualLimit = preview.draw();
		if (epsg) {
			assertNotNull(imageManualLimit);
		}
		if (writeImages) {
			ImageIO.write(imageManualLimit, "png",
					new File("image_manual_limit.png"));
		}

		preview.setBufferPercentage(0.15);
		preview.setLimit(null);
		preview.appendWhere(
				CoreSQLUtils.quoteWrap(featureDao.getIdColumnName()) + " > "
						+ ((int) Math.floor(count / 2.0)));
		BufferedImage imageManualWhere = preview.draw();
		if (epsg) {
			assertNotNull(imageManualWhere);
		}
		if (writeImages) {
			ImageIO.write(imageManualWhere, "png",
					new File("image_manual_where.png"));
			System.out.println("Breakpoint here");
		}

	}

}
 
Example 14
Source File: GeoPackageTestUtils.java    From geopackage-java with MIT License 4 votes vote down vote up
/**
 * Test deleting tables by name
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDeleteTables(GeoPackage geoPackage)
		throws SQLException {

	GeometryColumnsDao geometryColumnsDao = geoPackage
			.getGeometryColumnsDao();
	TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao();
	ContentsDao contentsDao = geoPackage.getContentsDao();

	TestCase.assertTrue(geometryColumnsDao.isTableExists()
			|| tileMatrixSetDao.isTableExists());

	geoPackage.foreignKeys(false);

	if (geometryColumnsDao.isTableExists()) {

		TestCase.assertEquals(geoPackage.getFeatureTables().size(),
				geometryColumnsDao.countOf());
		for (String featureTable : geoPackage.getFeatureTables()) {
			TestCase.assertTrue(geoPackage.isTable(featureTable));
			TestCase.assertNotNull(contentsDao.queryForId(featureTable));
			geoPackage.deleteTable(featureTable);
			TestCase.assertFalse(geoPackage.isTable(featureTable));
			TestCase.assertNull(contentsDao.queryForId(featureTable));
		}
		TestCase.assertEquals(0, geometryColumnsDao.countOf());

		geoPackage.dropTable(GeometryColumns.TABLE_NAME);

		TestCase.assertFalse(geometryColumnsDao.isTableExists());
	}

	if (tileMatrixSetDao.isTableExists()) {
		TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao();

		TestCase.assertTrue(tileMatrixSetDao.isTableExists());
		TestCase.assertTrue(tileMatrixDao.isTableExists());

		TestCase.assertEquals(geoPackage.getTables(ContentsDataType.TILES)
				.size()
				+ geoPackage.getTables(ContentsDataType.GRIDDED_COVERAGE)
						.size(),
				tileMatrixSetDao.countOf());
		for (String tileTable : geoPackage.getTileTables()) {
			TestCase.assertTrue(geoPackage.isTable(tileTable));
			TestCase.assertNotNull(contentsDao.queryForId(tileTable));
			geoPackage.deleteTable(tileTable);
			TestCase.assertFalse(geoPackage.isTable(tileTable));
			TestCase.assertNull(contentsDao.queryForId(tileTable));
		}
		TestCase.assertEquals(geoPackage
				.getTables(ContentsDataType.GRIDDED_COVERAGE).size(),
				tileMatrixSetDao.countOf());

		geoPackage.dropTable(TileMatrix.TABLE_NAME);
		geoPackage.dropTable(TileMatrixSet.TABLE_NAME);

		TestCase.assertFalse(tileMatrixSetDao.isTableExists());
		TestCase.assertFalse(tileMatrixDao.isTableExists());
	}

	for (String attributeTable : geoPackage.getAttributesTables()) {

		TestCase.assertTrue(geoPackage.isTable(attributeTable));
		TestCase.assertNotNull(contentsDao.queryForId(attributeTable));
		geoPackage.deleteTable(attributeTable);
		TestCase.assertFalse(geoPackage.isTable(attributeTable));
		TestCase.assertNull(contentsDao.queryForId(attributeTable));

	}

}
 
Example 15
Source File: FeatureTableIndexUtils.java    From geopackage-android with MIT License 4 votes vote down vote up
/**
 * Test table index delete all
 *
 * @param geoPackage
 * @throws SQLException
 */
public static void testDeleteAll(GeoPackage geoPackage) throws SQLException {

    // Test indexing each feature table
    List<String> featureTables = geoPackage.getFeatureTables();
    for (String featureTable : featureTables) {

        FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
        FeatureTableIndex featureTableIndex = new FeatureTableIndex(
                geoPackage, featureDao);

        if(featureTableIndex.isIndexed()){
            featureTableIndex.deleteIndex();
        }

        TestCase.assertFalse(featureTableIndex.isIndexed());

        TestUtils.validateGeoPackage(geoPackage);

        // Test indexing
        featureTableIndex.index();
        TestUtils.validateGeoPackage(geoPackage);

        TestCase.assertTrue(featureTableIndex.isIndexed());

    }

    ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
    GeometryIndexDao geometryIndexDao = geoPackage.getGeometryIndexDao();
    TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();

    TestCase.assertTrue(geometryIndexDao.isTableExists());
    TestCase.assertTrue(tableIndexDao.isTableExists());
    TestCase.assertTrue(extensionsDao.queryByExtension(
            FeatureTableIndex.EXTENSION_NAME).size() > 0);

    TestCase.assertTrue(geometryIndexDao.countOf() > 0);
    long count = tableIndexDao.countOf();
    TestCase.assertTrue(count > 0);

    int deleteCount = tableIndexDao.deleteAllCascade();
    TestCase.assertEquals(count, deleteCount);

    TestCase.assertTrue(geometryIndexDao.countOf() == 0);
    TestCase.assertTrue(tableIndexDao.countOf() == 0);
}
 
Example 16
Source File: FeatureIndexManagerUtils.java    From geopackage-java with MIT License 3 votes vote down vote up
/**
 * Test large index
 *
 * @param geoPackage
 *            GeoPackage
 * @param compareProjectionCounts
 *            compare projection counts and query counts
 * @param verbose
 *            verbose printing
 * @throws SQLException
 *             upon error
 */
public static void testTimedIndex(GeoPackage geoPackage,
		boolean compareProjectionCounts, boolean verbose)
		throws SQLException {
	for (String featureTable : geoPackage.getFeatureTables()) {
		testTimedIndex(geoPackage, featureTable, compareProjectionCounts,
				verbose);
	}
}
 
Example 17
Source File: GeoPackageExample.java    From geopackage-android with MIT License 3 votes vote down vote up
private static void createRTreeSpatialIndexExtension(GeoPackage geoPackage) {

        RTreeIndexExtension extension = new RTreeIndexExtension(geoPackage);

        List<String> featureTables = geoPackage.getFeatureTables();
        for (String tableName : featureTables) {

            FeatureDao featureDao = geoPackage.getFeatureDao(tableName);
            FeatureTable featureTable = featureDao.getTable();

            extension.create(featureTable);
        }

    }
 
Example 18
Source File: GeoPackageExample.java    From geopackage-java with MIT License 3 votes vote down vote up
private static void createRTreeSpatialIndexExtension(
		GeoPackage geoPackage) {

	RTreeIndexExtension extension = new RTreeIndexExtension(geoPackage);

	List<String> featureTables = geoPackage.getFeatureTables();
	for (String tableName : featureTables) {

		FeatureDao featureDao = geoPackage.getFeatureDao(tableName);
		FeatureTable featureTable = featureDao.getTable();

		extension.create(featureTable);
	}

}