Java Code Examples for mil.nga.geopackage.core.contents.Contents#getDataType()

The following examples show how to use mil.nga.geopackage.core.contents.Contents#getDataType() . 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: GeometryColumns.java    From geopackage-core-java with MIT License 6 votes vote down vote up
/**
 * Set the contents
 * 
 * @param contents
 *            contents
 */
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a features data type (Spec Requirement
		// 23)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null || dataType != ContentsDataType.FEATURES) {
			throw new GeoPackageException(
					"The " + Contents.class.getSimpleName() + " of a "
							+ GeometryColumns.class.getSimpleName()
							+ " must have a data type of "
							+ ContentsDataType.FEATURES.getName());
		}
		tableName = contents.getId();
	} else {
		tableName = null;
	}
}
 
Example 2
Source File: GeometryColumnsSqlMm.java    From geopackage-core-java with MIT License 6 votes vote down vote up
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a features data type (Spec Requirement
		// 23)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null || dataType != ContentsDataType.FEATURES) {
			throw new GeoPackageException("The "
					+ Contents.class.getSimpleName() + " of a "
					+ GeometryColumnsSqlMm.class.getSimpleName()
					+ " must have a data type of "
					+ ContentsDataType.FEATURES.getName());
		}
		tableName = contents.getId();
	}
}
 
Example 3
Source File: GeometryColumnsSfSql.java    From geopackage-core-java with MIT License 6 votes vote down vote up
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a features data type (Spec Requirement
		// 23)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null || dataType != ContentsDataType.FEATURES) {
			throw new GeoPackageException("The "
					+ Contents.class.getSimpleName() + " of a "
					+ GeometryColumnsSfSql.class.getSimpleName()
					+ " must have a data type of "
					+ ContentsDataType.FEATURES.getName());
		}
		fTableName = contents.getId();
	}
}
 
Example 4
Source File: TileMatrix.java    From geopackage-core-java with MIT License 6 votes vote down vote up
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a tiles data type (Spec Requirement 42)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null
				|| (dataType != ContentsDataType.TILES && dataType != ContentsDataType.GRIDDED_COVERAGE)) {
			throw new GeoPackageException("The "
					+ Contents.class.getSimpleName() + " of a "
					+ TileMatrix.class.getSimpleName()
					+ " must have a data type of "
					+ ContentsDataType.TILES.getName() + " or "
					+ ContentsDataType.GRIDDED_COVERAGE.getName());
		}
		tableName = contents.getId();
	} else {
		tableName = null;
	}
}
 
Example 5
Source File: TileMatrixSet.java    From geopackage-core-java with MIT License 6 votes vote down vote up
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		// Verify the Contents have a tiles data type (Spec Requirement 33)
		ContentsDataType dataType = contents.getDataType();
		if (dataType == null
				|| (dataType != ContentsDataType.TILES && dataType != ContentsDataType.GRIDDED_COVERAGE)) {
			throw new GeoPackageException("The "
					+ Contents.class.getSimpleName() + " of a "
					+ TileMatrixSet.class.getSimpleName()
					+ " must have a data type of "
					+ ContentsDataType.TILES.getName() + " or "
					+ ContentsDataType.GRIDDED_COVERAGE.getName());
		}
		tableName = contents.getId();
	} else {
		tableName = null;
	}
}
 
Example 6
Source File: GeoPackageImpl.java    From geopackage-java with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AttributesDao getAttributesDao(Contents contents) {

	if (contents == null) {
		throw new GeoPackageException("Non null "
				+ Contents.class.getSimpleName() + " is required to create "
				+ AttributesDao.class.getSimpleName());
	}
	if (contents.getDataType() != ContentsDataType.ATTRIBUTES) {
		throw new GeoPackageException(Contents.class.getSimpleName()
				+ " is required to be of type "
				+ ContentsDataType.ATTRIBUTES + ". Actual: "
				+ contents.getDataTypeString());
	}

	// Read the existing table and create the dao
	AttributesTableReader tableReader = new AttributesTableReader(
			contents.getTableName());
	final AttributesTable attributesTable = tableReader.readTable(database);
	attributesTable.setContents(contents);
	AttributesDao dao = new AttributesDao(getName(), database,
			attributesTable);

	return dao;
}
 
Example 7
Source File: GeoPackageImpl.java    From geopackage-android with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AttributesDao getAttributesDao(Contents contents) {

    if (contents == null) {
        throw new GeoPackageException("Non null "
                + Contents.class.getSimpleName()
                + " is required to create "
                + AttributesDao.class.getSimpleName());
    }
    if (contents.getDataType() != ContentsDataType.ATTRIBUTES) {
        throw new GeoPackageException(Contents.class.getSimpleName()
                + " is required to be of type "
                + ContentsDataType.ATTRIBUTES + ". Actual: "
                + contents.getDataTypeString());
    }

    // Read the existing table and create the dao
    AttributesTableReader tableReader = new AttributesTableReader(
            contents.getTableName());
    final AttributesTable attributesTable = tableReader.readTable(database);
    attributesTable.setContents(contents);
    AttributesDao dao = new AttributesDao(getName(), database,
            attributesTable);

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

                @Override
                public Cursor wrapCursor(Cursor cursor) {
                    return new AttributesCursor(attributesTable, cursor);
                }
            });

    return dao;
}
 
Example 8
Source File: FeatureTable.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void validateContents(Contents contents) {
	// Verify the Contents have a features data type
	ContentsDataType dataType = contents.getDataType();
	if (dataType == null || dataType != ContentsDataType.FEATURES) {
		throw new GeoPackageException(
				"The " + Contents.class.getSimpleName() + " of a "
						+ FeatureTable.class.getSimpleName()
						+ " must have a data type of "
						+ ContentsDataType.FEATURES.getName());
	}
}
 
Example 9
Source File: AttributesTable.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void validateContents(Contents contents) {
	// Verify the Contents have an attributes data type
	ContentsDataType dataType = contents.getDataType();
	if (dataType == null || dataType != ContentsDataType.ATTRIBUTES) {
		throw new GeoPackageException(
				"The " + Contents.class.getSimpleName() + " of a "
						+ AttributesTable.class.getSimpleName()
						+ " must have a data type of "
						+ ContentsDataType.ATTRIBUTES.getName());
	}
}
 
Example 10
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isFeatureOrTileTable(String table) {
	boolean isType = false;
	Contents contents = getTableContents(table);
	if (contents != null) {
		ContentsDataType dataType = contents.getDataType();
		isType = dataType != null && (dataType == ContentsDataType.FEATURES
				|| dataType == ContentsDataType.TILES);
	}
	return isType;
}
 
Example 11
Source File: GeoPackageCoreImpl.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public ContentsDataType getTableDataType(String table) {
	ContentsDataType tableType = null;
	Contents contents = getTableContents(table);
	if (contents != null) {
		tableType = contents.getDataType();
	}
	return tableType;
}
 
Example 12
Source File: TileTable.java    From geopackage-core-java with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void validateContents(Contents contents) {
	// Verify the Contents have a tiles data type
	ContentsDataType dataType = contents.getDataType();
	if (dataType == null || (dataType != ContentsDataType.TILES
			&& dataType != ContentsDataType.GRIDDED_COVERAGE)) {
		throw new GeoPackageException(
				"The " + Contents.class.getSimpleName() + " of a "
						+ TileTable.class.getSimpleName()
						+ " must have a data type of "
						+ ContentsDataType.TILES.getName() + " or "
						+ ContentsDataType.GRIDDED_COVERAGE.getName());
	}
}