Java Code Examples for mil.nga.geopackage.features.index.FeatureIndexType

The following examples show how to use mil.nga.geopackage.features.index.FeatureIndexType. These examples are extracted from open source projects. 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 Project: geopackage-android   Source File: AlterTableUtils.java    License: MIT License 6 votes vote down vote up
/**
 * Test the feature indexes
 *
 * @param indexManager    index manager
 * @param geoPackageCount GeoPackage index count
 * @param rTreeCount      RTree index count
 */
private static void testIndex(FeatureIndexManager indexManager,
                              int geoPackageCount, int rTreeCount) {

    TestCase.assertTrue(
            indexManager.isIndexed(FeatureIndexType.GEOPACKAGE));
    indexManager.prioritizeQueryLocation(FeatureIndexType.GEOPACKAGE);
    TestCase.assertEquals(geoPackageCount, indexManager.count());

    //TestCase.assertTrue(indexManager.isIndexed(FeatureIndexType.RTREE));
    if (indexManager.isIndexed(FeatureIndexType.RTREE)) {
        indexManager.prioritizeQueryLocation(FeatureIndexType.RTREE);
        TestCase.assertEquals(rTreeCount, indexManager.count());
    }

}
 
Example 2
Source Project: geopackage-android   Source File: FeatureIndexManagerUtils.java    License: MIT License 5 votes vote down vote up
private static void testTimedIndex(Activity activity, GeoPackage geoPackage,
                                   FeatureIndexType type, FeatureDao featureDao,
                                   List<FeatureIndexTestEnvelope> envelopes, double precision,
                                   boolean compareProjectionCounts, double projectionPrecision, boolean verbose) {
    testTimedIndex(activity, geoPackage, type, featureDao, envelopes, precision,
            precision, compareProjectionCounts, projectionPrecision, verbose);
}
 
Example 3
Source Project: geopackage-android   Source File: GeoPackageExample.java    License: 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 4
Source Project: geopackage-android   Source File: FeatureTilesTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test feature tiles
 *
 * @throws java.sql.SQLException
 */
public void testFeatureTiles(boolean useIcon) throws SQLException {

    FeatureDao featureDao = FeatureTileUtils.createFeatureDao(geoPackage);

    int num = FeatureTileUtils.insertFeatures(geoPackage, featureDao);

    FeatureTiles featureTiles = FeatureTileUtils.createFeatureTiles(activity, geoPackage, featureDao, useIcon);

    try {
        FeatureIndexer indexer = new FeatureIndexer(activity, featureDao);
        try {
            indexer.index();
        } finally {
            indexer.close();
        }

        FeatureIndexManager indexManager = new FeatureIndexManager(activity, geoPackage, featureDao);
        featureTiles.setIndexManager(indexManager);

        indexManager.setIndexLocation(FeatureIndexType.GEOPACKAGE);
        int indexed = indexManager.index();
        assertEquals(num, indexed);

        createTiles(featureTiles, 0, 3);
    } finally {
        featureTiles.close();
    }
}
 
Example 5
Source Project: geopackage-mapcache-android   Source File: IndexerTask.java    License: MIT License 5 votes vote down vote up
/**
 * Index features
 *
 * @param activity
 * @param callback
 * @param database
 * @param tableName
 * @param indexLocation
 */
public static void indexFeatures(Activity activity, IIndexerTask callback,
                                 String database, String tableName,
                                 FeatureIndexType indexLocation) {

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

    FeatureDao featureDao = geoPackage.getFeatureDao(tableName);

    FeatureIndexManager indexer = new FeatureIndexManager(activity, geoPackage, featureDao);
    indexer.setIndexLocation(indexLocation);

    ProgressDialog progressDialog = new ProgressDialog(activity);
    final IndexerTask indexTask = new IndexerTask(activity,
            callback, progressDialog, geoPackage, indexer);

    int max = featureDao.count();
    indexTask.setMax(max);
    indexer.setProgress(indexTask);

    progressDialog.setMessage(activity
            .getString(R.string.geopackage_table_index_features_index_title)
            + ": "
            + geoPackage.getName() + " - " + tableName);
    progressDialog.setCancelable(false);
    progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
    progressDialog.setIndeterminate(false);
    progressDialog.setMax(max);
    progressDialog.setButton(ProgressDialog.BUTTON_NEGATIVE,
            activity.getString(R.string.button_cancel_label),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    indexTask.cancel(true);
                }
            });

    indexTask.execute();
}
 
Example 6
Source Project: geopackage-java   Source File: FeatureIndexManagerUtils.java    License: MIT License 5 votes vote down vote up
private static void testTimedIndex(GeoPackage geoPackage,
		FeatureIndexType type, FeatureDao featureDao,
		List<FeatureIndexTestEnvelope> envelopes, double precision,
		boolean compareProjectionCounts, double projectionPrecision,
		boolean verbose) {
	testTimedIndex(geoPackage, type, featureDao, envelopes, precision,
			precision, compareProjectionCounts, projectionPrecision,
			verbose);
}
 
Example 7
Source Project: geopackage-java   Source File: AlterTableUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Test the feature indexes
 * 
 * @param indexManager
 *            index manager
 * @param geoPackageCount
 *            GeoPackage index count
 * @param rTreeCount
 *            RTree index count
 */
private static void testIndex(FeatureIndexManager indexManager,
		int geoPackageCount, int rTreeCount) {

	TestCase.assertTrue(
			indexManager.isIndexed(FeatureIndexType.GEOPACKAGE));
	indexManager.prioritizeQueryLocation(FeatureIndexType.GEOPACKAGE);
	TestCase.assertEquals(geoPackageCount, indexManager.count());

	TestCase.assertTrue(indexManager.isIndexed(FeatureIndexType.RTREE));
	indexManager.prioritizeQueryLocation(FeatureIndexType.RTREE);
	TestCase.assertEquals(rTreeCount, indexManager.count());

}
 
Example 8
Source Project: geopackage-android   Source File: OAPIFeatureGeneratorTest.java    License: MIT License 4 votes vote down vote up
/**
 * 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 9
Source Project: geopackage-android   Source File: FeatureIndexManagerUtils.java    License: MIT License 3 votes vote down vote up
/**
 * Test index
 *
 * @param activity   activity
 * @param geoPackage GeoPackage
 * @throws SQLException upon error
 */
public static void testIndex(Activity activity, GeoPackage geoPackage) throws SQLException {
    geoPackage.getCursorFactory().setDebugLogQueries(true);
    testIndex(activity, geoPackage, FeatureIndexType.RTREE, true);
    testIndex(activity, geoPackage, FeatureIndexType.GEOPACKAGE, false);
    testIndex(activity, geoPackage, FeatureIndexType.METADATA, false);
}
 
Example 10
Source Project: geopackage-android   Source File: FeatureCacheUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Test cache
 *
 * @param activity   activity
 * @param geoPackage GeoPackage
 * @throws SQLException upon error
 */
public static void testCache(Activity activity, GeoPackage geoPackage) throws SQLException {
    testCache(activity, geoPackage, FeatureIndexType.GEOPACKAGE);
    testCache(activity, geoPackage, FeatureIndexType.METADATA);
    testCache(activity, geoPackage, FeatureIndexType.RTREE);
}
 
Example 11
Source Project: geopackage-java   Source File: FeatureCacheUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Test cache
 *
 * @param geoPackage
 *            GeoPackage
 * @throws SQLException
 *             upon error
 */
public static void testCache(GeoPackage geoPackage) throws SQLException {
	testCache(geoPackage, FeatureIndexType.GEOPACKAGE);
	testCache(geoPackage, FeatureIndexType.RTREE);
}
 
Example 12
Source Project: geopackage-java   Source File: FeatureIndexManagerUtils.java    License: MIT License 2 votes vote down vote up
/**
 * Test index
 *
 * @param geoPackage
 *            GeoPackage
 * @throws SQLException
 *             upon error
 */
public static void testIndex(GeoPackage geoPackage) throws SQLException {
	testIndex(geoPackage, FeatureIndexType.GEOPACKAGE, false);
	testIndex(geoPackage, FeatureIndexType.RTREE, true);
}