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

The following examples show how to use mil.nga.geopackage.features.user.FeatureTable. 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-core-java   Source File: RTreeIndexCoreExtension.java    License: 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 Project: geopackage-android-map   Source File: TestUtils.java    License: 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 3
Source Project: geopackage-android-map   Source File: TestUtils.java    License: 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 4
Source Project: geopackage-java   Source File: GeoPackageImpl.java    License: 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 5
Source Project: geopackage-java   Source File: TestUtils.java    License: 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 6
Source Project: geopackage-java   Source File: TestUtils.java    License: 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 7
Source Project: geopackage-android   Source File: GeoPackageImpl.java    License: 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 8
Source Project: geopackage-android   Source File: TestUtils.java    License: 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 9
Source Project: geopackage-java   Source File: AlterTableUtils.java    License: 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 Project: geopackage-android   Source File: AlterTableUtils.java    License: 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 11
Source Project: geopackage-core-java   Source File: GeoPackageCoreImpl.java    License: MIT License 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void createFeatureTable(FeatureTable table) {
	createUserTable(table);
}
 
Example 12
Source Project: geopackage-android   Source File: GeoPackageExample.java    License: 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 Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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 14
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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 15
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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 16
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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 17
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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 Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Set the feature table style default
 *
 * @param featureTable feature table
 * @param style        style row
 */
public void setTableStyleDefault(FeatureTable featureTable, StyleRow style) {
    setTableStyleDefault(featureTable.getTableName(), style);
}
 
Example 19
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Set the feature table style for the geometry type
 *
 * @param featureTable feature table
 * @param geometryType geometry type
 * @param style        style row
 */
public void setTableStyle(FeatureTable featureTable,
                          GeometryType geometryType, StyleRow style) {
    setTableStyle(featureTable.getTableName(), geometryType, style);
}
 
Example 20
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Set the feature table default icons
 *
 * @param featureTable feature table
 * @param icons        default icons
 */
public void setTableIcons(FeatureTable featureTable, Icons icons) {
    setTableIcons(featureTable.getTableName(), icons);
}
 
Example 21
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Set the feature table icon default
 *
 * @param featureTable feature table
 * @param icon         icon row
 */
public void setTableIconDefault(FeatureTable featureTable, IconRow icon) {
    setTableIconDefault(featureTable.getTableName(), icon);
}
 
Example 22
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Set the feature table icon for the geometry type
 *
 * @param featureTable feature table
 * @param geometryType geometry type
 * @param icon         icon row
 */
public void setTableIcon(FeatureTable featureTable,
                         GeometryType geometryType, IconRow icon) {
    setTableIcon(featureTable.getTableName(), geometryType, icon);
}
 
Example 23
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Delete all feature styles including table styles, table icons, style, and
 * icons
 *
 * @param featureTable feature table
 */
public void deleteAllFeatureStyles(FeatureTable featureTable) {
    deleteAllFeatureStyles(featureTable.getTableName());
}
 
Example 24
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Delete all styles including table styles and feature row styles
 *
 * @param featureTable feature table
 */
public void deleteAllStyles(FeatureTable featureTable) {
    deleteAllStyles(featureTable.getTableName());
}
 
Example 25
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Delete all icons including table icons and feature row icons
 *
 * @param featureTable feature table
 */
public void deleteAllIcons(FeatureTable featureTable) {
    deleteAllIcons(featureTable.getTableName());
}
 
Example 26
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Delete the feature table feature styles
 *
 * @param featureTable feature table
 */
public void deleteTableFeatureStyles(FeatureTable featureTable) {
    deleteTableFeatureStyles(featureTable.getTableName());
}
 
Example 27
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Delete the feature table styles
 *
 * @param featureTable feature table
 */
public void deleteTableStyles(FeatureTable featureTable) {
    deleteTableStyles(featureTable.getTableName());
}
 
Example 28
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: MIT License 2 votes vote down vote up
/**
 * Delete the feature table default style
 *
 * @param featureTable feature table
 */
public void deleteTableStyleDefault(FeatureTable featureTable) {
    deleteTableStyleDefault(featureTable.getTableName());
}
 
Example 29
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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 30
Source Project: geopackage-android   Source File: FeatureStyleExtension.java    License: 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());
}