mil.nga.geopackage.features.user.FeatureTable Java Examples

The following examples show how to use mil.nga.geopackage.features.user.FeatureTable. 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: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Get the RTree Table
 * 
 * @param featureTable
 *            feature table
 * @return RTree table
 */
protected UserCustomTable getRTreeTable(FeatureTable featureTable) {

	List<UserCustomColumn> columns = new ArrayList<>();
	columns.add(UserCustomColumn.createPrimaryKeyColumn(COLUMN_ID));
	columns.add(UserCustomColumn.createColumn(COLUMN_MIN_X,
			GeoPackageDataType.FLOAT));
	columns.add(UserCustomColumn.createColumn(COLUMN_MAX_X,
			GeoPackageDataType.FLOAT));
	columns.add(UserCustomColumn.createColumn(COLUMN_MIN_Y,
			GeoPackageDataType.FLOAT));
	columns.add(UserCustomColumn.createColumn(COLUMN_MAX_Y,
			GeoPackageDataType.FLOAT));

	String rTreeTableName = getRTreeTableName(featureTable.getTableName(),
			featureTable.getGeometryColumnName());

	UserCustomTable userCustomTable = new UserCustomTable(rTreeTableName,
			columns);

	return userCustomTable;
}
 
Example #2
Source File: TestUtils.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Build an example feature table
 *
 * @param tableName
 * @param geometryColumn
 * @param geometryType
 * @return
 */
public static FeatureTable buildFeatureTable(String tableName,
                                             String geometryColumn, GeometryType geometryType) {

    List<FeatureColumn> columns = new ArrayList<FeatureColumn>();

    columns.add(FeatureColumn.createPrimaryKeyColumn(0, "id"));
    columns.add(FeatureColumn.createColumn(7, "test_text_limited",
            GeoPackageDataType.TEXT, 5L, false, null));
    columns.add(FeatureColumn.createColumn(8, "test_blob_limited",
            GeoPackageDataType.BLOB, 7L, false, null));
    columns.add(FeatureColumn.createGeometryColumn(1, geometryColumn,
            geometryType, false, null));
    columns.add(FeatureColumn.createColumn(2, "test_text",
            GeoPackageDataType.TEXT, false, ""));
    columns.add(FeatureColumn.createColumn(3, "test_real",
            GeoPackageDataType.REAL, false, null));
    columns.add(FeatureColumn.createColumn(4, "test_boolean",
            GeoPackageDataType.BOOLEAN, false, null));
    columns.add(FeatureColumn.createColumn(5, "test_blob",
            GeoPackageDataType.BLOB, false, null));
    columns.add(FeatureColumn.createColumn(6, TEST_INTEGER_COLUMN,
            GeoPackageDataType.INTEGER, false, null));

    FeatureTable table = new FeatureTable(tableName, columns);

    return table;
}
 
Example #3
Source File: GeoPackageImpl.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(GeometryColumns geometryColumns) {

	if (geometryColumns == null) {
		throw new GeoPackageException(
				"Non null " + GeometryColumns.class.getSimpleName()
						+ " is required to create "
						+ FeatureDao.class.getSimpleName());
	}

	// Read the existing table and create the dao
	FeatureTableReader tableReader = new FeatureTableReader(
			geometryColumns);
	final FeatureTable featureTable = tableReader.readTable(database);
	featureTable.setContents(geometryColumns.getContents());
	FeatureDao dao = new FeatureDao(getName(), database, geometryColumns,
			featureTable);

	// If the GeoPackage is writable and the feature table has a RTree Index
	// extension, create the SQL functions
	if (writable) {
		RTreeIndexExtension rtree = new RTreeIndexExtension(this);
		rtree.createFunctions(featureTable);
	}

	return dao;
}
 
Example #4
Source File: TestUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Create the feature table with data columns entry
 * 
 * @param geoPackage
 * @param contents
 * @param geometryColumn
 * @param geometryType
 * @return feature table
 * @throws SQLException
 */
public static FeatureTable createFeatureTable(GeoPackage geoPackage,
		Contents contents, String geometryColumn, GeometryType geometryType)
		throws SQLException {

	FeatureTable table = buildFeatureTable(contents.getTableName(),
			geometryColumn, geometryType);
	geoPackage.createFeatureTable(table);

	double random = Math.random();

	DataColumnsDao dataColumnsDao = geoPackage.getDataColumnsDao();
	DataColumns dataColumns = new DataColumns();
	dataColumns.setContents(contents);
	dataColumns.setColumnName(TEST_INTEGER_COLUMN);
	dataColumns.setName(contents.getTableName());
	dataColumns.setTitle("TEST_TITLE");
	dataColumns.setDescription("TEST_DESCRIPTION");
	dataColumns.setMimeType("TEST_MIME_TYPE");

	if (random < (1.0 / 3.0)) {
		dataColumns.setConstraintName(SAMPLE_RANGE_CONSTRAINT);
	} else if (random < (2.0 / 3.0)) {
		dataColumns.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
	} else {
		dataColumns.setConstraintName(SAMPLE_GLOB_CONSTRAINT);
	}

	dataColumnsDao.create(dataColumns);

	return table;
}
 
Example #5
Source File: TestUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Build an example feature table
 * 
 * @param tableName
 * @param geometryColumn
 * @param geometryType
 * @return feature table
 */
public static FeatureTable buildFeatureTable(String tableName,
		String geometryColumn, GeometryType geometryType) {

	List<FeatureColumn> columns = new ArrayList<FeatureColumn>();

	columns.add(FeatureColumn.createPrimaryKeyColumn(0, "id"));
	columns.add(FeatureColumn.createColumn(7, "test_text_limited",
			GeoPackageDataType.TEXT, 5L));
	columns.add(FeatureColumn.createColumn(8, "test_blob_limited",
			GeoPackageDataType.BLOB, 7L));
	columns.add(FeatureColumn.createColumn(9, "test_date",
			GeoPackageDataType.DATE));
	columns.add(FeatureColumn.createColumn(10, "test_datetime",
			GeoPackageDataType.DATETIME));
	columns.add(FeatureColumn.createGeometryColumn(1, geometryColumn,
			geometryType));
	columns.add(FeatureColumn.createColumn(2, "test_text",
			GeoPackageDataType.TEXT, false, ""));
	columns.add(FeatureColumn.createColumn(3, "test_real",
			GeoPackageDataType.REAL));
	columns.add(FeatureColumn.createColumn(4, "test_boolean",
			GeoPackageDataType.BOOLEAN));
	columns.add(FeatureColumn.createColumn(5, "test_blob",
			GeoPackageDataType.BLOB));
	columns.add(FeatureColumn.createColumn(6, TEST_INTEGER_COLUMN,
			GeoPackageDataType.INTEGER));

	FeatureTable table = new FeatureTable(tableName, geometryColumn,
			columns);

	return table;
}
 
Example #6
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(GeometryColumns geometryColumns) {

    if (geometryColumns == null) {
        throw new GeoPackageException("Non null "
                + GeometryColumns.class.getSimpleName()
                + " is required to create "
                + FeatureDao.class.getSimpleName());
    }

    // Read the existing table and create the dao
    FeatureTableReader tableReader = new FeatureTableReader(geometryColumns);
    final FeatureTable featureTable = tableReader.readTable(database);
    featureTable.setContents(geometryColumns.getContents());
    FeatureDao dao = new FeatureDao(getName(), database, geometryColumns, featureTable);

    // Register the table name (with and without quotes) to wrap cursors with the feature cursor
    registerCursorWrapper(geometryColumns.getTableName(),
            new GeoPackageCursorWrapper() {

                @Override
                public Cursor wrapCursor(Cursor cursor) {
                    return new FeatureCursor(featureTable, cursor);
                }
            });

    // If the GeoPackage is writable and the feature table has a RTree Index
    // extension, drop the RTree triggers.  User defined functions are currently not supported.
    if (writable) {
        RTreeIndexExtension rtree = new RTreeIndexExtension(this);
        rtree.dropTriggers(featureTable);
    }

    return dao;
}
 
Example #7
Source File: TestUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Build an example feature table
 *
 * @param tableName
 * @param geometryColumn
 * @param geometryType
 * @return
 */
public static FeatureTable buildFeatureTable(String tableName,
                                             String geometryColumn, GeometryType geometryType) {

    List<FeatureColumn> columns = new ArrayList<FeatureColumn>();

    columns.add(FeatureColumn.createPrimaryKeyColumn(0, "id"));
    columns.add(FeatureColumn.createColumn(7, "test_text_limited",
            GeoPackageDataType.TEXT, 5L));
    columns.add(FeatureColumn.createColumn(8, "test_blob_limited",
            GeoPackageDataType.BLOB, 7L));
    columns.add(FeatureColumn.createColumn(9, "test_date",
            GeoPackageDataType.DATE));
    columns.add(FeatureColumn.createColumn(10, "test_datetime",
            GeoPackageDataType.DATETIME));
    columns.add(FeatureColumn.createGeometryColumn(1, geometryColumn,
            geometryType));
    columns.add(FeatureColumn.createColumn(2, "test_text",
            GeoPackageDataType.TEXT, false, ""));
    columns.add(FeatureColumn.createColumn(3, "test_real",
            GeoPackageDataType.REAL));
    columns.add(FeatureColumn.createColumn(4, "test_boolean",
            GeoPackageDataType.BOOLEAN));
    columns.add(FeatureColumn.createColumn(5, "test_blob",
            GeoPackageDataType.BLOB));
    columns.add(FeatureColumn.createColumn(6, TEST_INTEGER_COLUMN,
            GeoPackageDataType.INTEGER));

    FeatureTable table = new FeatureTable(tableName, geometryColumn, columns);

    return table;
}
 
Example #8
Source File: AlterTableUtils.java    From geopackage-java with MIT License 5 votes vote down vote up
/**
 * Create a table view
 * 
 * @param db
 *            connection
 * @param featureTable
 *            feature column
 * @param viewName
 *            view name
 * @param quoteWrap
 */
private static void createViewWithName(GeoPackageConnection db,
		FeatureTable featureTable, String viewName, boolean quoteWrap) {

	StringBuilder view = new StringBuilder("CREATE VIEW ");
	if (quoteWrap) {
		viewName = CoreSQLUtils.quoteWrap(viewName);
	}
	view.append(viewName);
	view.append(" AS SELECT ");
	for (int i = 0; i < featureTable.columnCount(); i++) {
		if (i > 0) {
			view.append(", ");
		}
		view.append(CoreSQLUtils.quoteWrap(featureTable.getColumnName(i)));
		view.append(" AS ");
		String columnName = "column" + (i + 1);
		if (quoteWrap) {
			columnName = CoreSQLUtils.quoteWrap(columnName);
		}
		view.append(columnName);
	}
	view.append(" FROM ");
	String tableName = featureTable.getTableName();
	if (quoteWrap) {
		tableName = CoreSQLUtils.quoteWrap(tableName);
	}
	view.append(tableName);

	db.execSQL(view.toString());
}
 
Example #9
Source File: AlterTableUtils.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * Create a table view
 *
 * @param db           connection
 * @param featureTable feature column
 * @param viewName     view name
 * @param quoteWrap
 */
private static void createViewWithName(GeoPackageConnection db,
                                       FeatureTable featureTable, String viewName, boolean quoteWrap) {

    StringBuilder view = new StringBuilder("CREATE VIEW ");
    if (quoteWrap) {
        viewName = CoreSQLUtils.quoteWrap(viewName);
    }
    view.append(viewName);
    view.append(" AS SELECT ");
    for (int i = 0; i < featureTable.columnCount(); i++) {
        if (i > 0) {
            view.append(", ");
        }
        view.append(CoreSQLUtils.quoteWrap(featureTable.getColumnName(i)));
        view.append(" AS ");
        String columnName = "column" + (i + 1);
        if (quoteWrap) {
            columnName = CoreSQLUtils.quoteWrap(columnName);
        }
        view.append(columnName);
    }
    view.append(" FROM ");
    String tableName = featureTable.getTableName();
    if (quoteWrap) {
        tableName = CoreSQLUtils.quoteWrap(tableName);
    }
    view.append(tableName);

    db.execSQL(view.toString());
}
 
Example #10
Source File: TestUtils.java    From geopackage-android-map with MIT License 5 votes vote down vote up
/**
 * Create the feature table with data columns entry
 *
 * @param geoPackage
 * @param contents
 * @param geometryColumn
 * @param geometryType
 * @return
 * @throws SQLException
 */
public static FeatureTable createFeatureTable(GeoPackage geoPackage,
                                              Contents contents, String geometryColumn, GeometryType geometryType)
        throws SQLException {

    FeatureTable table = buildFeatureTable(contents.getTableName(),
            geometryColumn, geometryType);
    geoPackage.createFeatureTable(table);

    double random = Math.random();

    DataColumnsDao dataColumnsDao = geoPackage.getDataColumnsDao();
    DataColumns dataColumns = new DataColumns();
    dataColumns.setContents(contents);
    dataColumns.setColumnName(TEST_INTEGER_COLUMN);
    dataColumns.setName(contents.getTableName());
    dataColumns.setTitle("TEST_TITLE");
    dataColumns.setDescription("TEST_DESCRIPTION");
    dataColumns.setMimeType("TEST_MIME_TYPE");

    if (random < (1.0 / 3.0)) {
        dataColumns.setConstraintName(SAMPLE_RANGE_CONSTRAINT);
    } else if (random < (2.0 / 3.0)) {
        dataColumns.setConstraintName(SAMPLE_ENUM_CONSTRAINT);
    } else {
        dataColumns.setConstraintName(SAMPLE_GLOB_CONSTRAINT);
    }

    dataColumnsDao.create(dataColumns);

    return table;
}
 
Example #11
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createFeatureTable(FeatureTable table) {
	createUserTable(table);
}
 
Example #12
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 #13
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Delete all feature styles
 * 
 * @param featureTable
 *            feature table
 */
public void deleteFeatureStyles(FeatureTable featureTable) {
	deleteFeatureStyles(featureTable.getTableName());
}
 
Example #14
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Delete the feature table icon for the geometry type
 * 
 * @param featureTable
 *            feature table
 * @param geometryType
 *            geometry type
 */
public void deleteTableIcon(FeatureTable featureTable,
		GeometryType geometryType) {
	deleteTableIcon(featureTable.getTableName(), geometryType);
}
 
Example #15
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Delete all styles
 * 
 * @param featureTable
 *            feature table
 */
public void deleteStyles(FeatureTable featureTable) {
	deleteStyles(featureTable.getTableName());
}
 
Example #16
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Delete the feature table default icon
 * 
 * @param featureTable
 *            feature table
 */
public void deleteTableIconDefault(FeatureTable featureTable) {
	deleteTableIconDefault(featureTable.getTableName());
}
 
Example #17
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Set the feature table default styles
 * 
 * @param featureTable
 *            feature table
 * @param styles
 *            default styles
 */
public void setTableStyles(FeatureTable featureTable, Styles styles) {
	setTableStyles(featureTable.getTableName(), styles);
}
 
Example #18
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Set the feature table default feature styles
 * 
 * @param featureTable
 *            feature table
 * @param featureStyles
 *            default feature styles
 */
public void setTableFeatureStyles(FeatureTable featureTable,
		FeatureStyles featureStyles) {
	setTableFeatureStyles(featureTable.getTableName(), featureStyles);
}
 
Example #19
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Delete the feature table icons
 * 
 * @param featureTable
 *            feature table
 */
public void deleteTableIcons(FeatureTable featureTable) {
	deleteTableIcons(featureTable.getTableName());
}
 
Example #20
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Delete the RTree Index extension for the feature table. Drops the
 * triggers, RTree table, and deletes the extension.
 * 
 * @param featureTable
 *            feature table
 */
public void delete(FeatureTable featureTable) {
	delete(featureTable.getTableName(),
			featureTable.getGeometryColumnName());
}
 
Example #21
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Delete the feature table style for the geometry type
 * 
 * @param featureTable
 *            feature table
 * @param geometryType
 *            geometry type
 */
public void deleteTableStyle(FeatureTable featureTable,
		GeometryType geometryType) {
	deleteTableStyle(featureTable.getTableName(), geometryType);
}
 
Example #22
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get the feature table default icons
 * 
 * @param featureTable
 *            feature table
 * @return table icons or null
 */
public Icons getTableIcons(FeatureTable featureTable) {
	return getTableIcons(featureTable.getTableName());
}
 
Example #23
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get the feature table default styles
 * 
 * @param featureTable
 *            feature table
 * @return table styles or null
 */
public Styles getTableStyles(FeatureTable featureTable) {
	return getTableStyles(featureTable.getTableName());
}
 
Example #24
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get the feature table default feature styles
 * 
 * @param featureTable
 *            feature table
 * @return table feature styles or null
 */
public FeatureStyles getTableFeatureStyles(FeatureTable featureTable) {
	return getTableFeatureStyles(featureTable.getTableName());
}
 
Example #25
Source File: GeoPackageCore.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Create a new feature table
 * 
 * @param table
 *            feature table
 */
public void createFeatureTable(FeatureTable table);
 
Example #26
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Drop Triggers that Maintain Spatial Index Values
 * 
 * @param featureTable
 *            feature table
 */
public void dropAllTriggers(FeatureTable featureTable) {
	dropAllTriggers(featureTable.getTableName(),
			featureTable.getGeometryColumnName());
}
 
Example #27
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Check if the feature table has the RTree extension and if found, drop the
 * triggers
 * 
 * @param featureTable
 *            feature table
 */
public void dropTriggers(FeatureTable featureTable) {
	dropTriggers(featureTable.getTableName(),
			featureTable.getGeometryColumnName());
}
 
Example #28
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Drop the RTree Index Virtual Table
 * 
 * @param featureTable
 *            feature table
 */
public void dropRTreeIndex(FeatureTable featureTable) {
	dropRTreeIndex(featureTable.getTableName(),
			featureTable.getGeometryColumnName());
}
 
Example #29
Source File: RTreeIndexCoreExtension.java    From geopackage-core-java with MIT License 2 votes vote down vote up
/**
 * Drop the the triggers and RTree table for the feature table
 * 
 * @param featureTable
 *            feature table
 */
public void drop(FeatureTable featureTable) {
	drop(featureTable.getTableName(), featureTable.getGeometryColumnName());
}
 
Example #30
Source File: FeatureStyleExtension.java    From geopackage-java with MIT License 2 votes vote down vote up
/**
 * Get all the unique icon row ids the features map to
 *
 * @param featureTable
 *            feature table
 * @return icon row ids
 */
public List<Long> getAllIconIds(FeatureTable featureTable) {
	return getAllIconIds(featureTable.getTableName());
}