Java Code Examples for mil.nga.geopackage.core.contents.Contents

The following examples show how to use mil.nga.geopackage.core.contents.Contents. 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: FeatureDao.java    License: MIT License 6 votes vote down vote up
/**
 * Constructor
 *
 * @param database        database name
 * @param db              connection
 * @param geometryColumns geometry columns
 * @param table           feature table
 */
public FeatureDao(String database, GeoPackageConnection db, GeometryColumns geometryColumns,
                  FeatureTable table) {
    super(database, db, new FeatureConnection(db), table);

    this.featureDb = (FeatureConnection) getUserDb();
    this.geometryColumns = geometryColumns;
    if (geometryColumns.getContents() == null) {
        throw new GeoPackageException(GeometryColumns.class.getSimpleName()
                + " " + geometryColumns.getId() + " has null "
                + Contents.class.getSimpleName());
    }
    if (geometryColumns.getSrs() == null) {
        throw new GeoPackageException(GeometryColumns.class.getSimpleName()
                + " " + geometryColumns.getId() + " has null "
                + SpatialReferenceSystem.class.getSimpleName());
    }

    projection = geometryColumns.getProjection();
}
 
Example 2
Source Project: geopackage-android   Source File: GeoPackageImpl.java    License: MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public FeatureDao getFeatureDao(Contents contents) {

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

    GeometryColumns geometryColumns = contents.getGeometryColumns();
    if (geometryColumns == null) {
        throw new GeoPackageException("No "
                + GeometryColumns.class.getSimpleName() + " exists for "
                + Contents.class.getSimpleName() + " " + contents.getId());
    }

    return getFeatureDao(geometryColumns);
}
 
Example 3
Source Project: geopackage-android   Source File: GeoPackageImpl.java    License: MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public TileDao getTileDao(Contents contents) {

    if (contents == null) {
        throw new GeoPackageException("Non null "
                + Contents.class.getSimpleName()
                + " is required to create " + TileDao.class.getSimpleName());
    }

    TileMatrixSet tileMatrixSet = contents.getTileMatrixSet();
    if (tileMatrixSet == null) {
        throw new GeoPackageException("No "
                + TileMatrixSet.class.getSimpleName() + " exists for "
                + Contents.class.getSimpleName() + " " + contents.getId());
    }

    return getTileDao(tileMatrixSet);
}
 
Example 4
Source Project: geopackage-android   Source File: GeoPackageImpl.java    License: MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AttributesDao getAttributesDao(String tableName) {

    ContentsDao dao = getContentsDao();
    Contents contents = null;
    try {
        contents = dao.queryForId(tableName);
    } catch (SQLException e) {
        throw new GeoPackageException("Failed to retrieve "
                + Contents.class.getSimpleName() + " for table name: "
                + tableName, e);
    }
    if (contents == null) {
        throw new GeoPackageException(
                "No Contents Table exists for table name: " + tableName);
    }
    return getAttributesDao(contents);
}
 
Example 5
Source Project: geopackage-java   Source File: GeoPackageImpl.java    License: 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 6
Source Project: geopackage-java   Source File: GeoPackageImpl.java    License: MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public AttributesDao getAttributesDao(String tableName) {

	ContentsDao dao = getContentsDao();
	Contents contents = null;
	try {
		contents = dao.queryForId(tableName);
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to retrieve " + Contents.class.getSimpleName()
						+ " for table name: " + tableName,
				e);
	}
	if (contents == null) {
		throw new GeoPackageException(
				"No Contents Table exists for table name: " + tableName);
	}
	return getAttributesDao(contents);
}
 
Example 7
Source Project: geopackage-core-java   Source File: RelatedTablesCoreExtension.java    License: MIT License 6 votes vote down vote up
/**
 * Set the contents in the user table
 * 
 * @param table
 *            user table
 */
public void setContents(UserTable<? extends UserColumn> table) {
	ContentsDao dao = geoPackage.getContentsDao();
	Contents contents = null;
	try {
		contents = dao.queryForId(table.getTableName());
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to retrieve " + Contents.class.getSimpleName()
						+ " for table name: " + table.getTableName(),
				e);
	}
	if (contents == null) {
		throw new GeoPackageException(
				"No Contents Table exists for table name: "
						+ table.getTableName());
	}
	table.setContents(contents);
}
 
Example 8
Source Project: geopackage-core-java   Source File: GeometryColumns.java    License: 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 9
Source Project: geopackage-core-java   Source File: GeometryColumnsSqlMm.java    License: 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 10
Source Project: geopackage-core-java   Source File: GeometryColumnsSfSql.java    License: 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 11
Source Project: geopackage-core-java   Source File: GeoPackageCoreImpl.java    License: MIT License 6 votes vote down vote up
/**
 * Copy the user table
 * 
 * @param tableName
 *            table name
 * @param newTableName
 *            new table name
 * @param transferContent
 *            transfer user table content flag
 * @param validateContents
 *            true to validate a contents was copied
 * @return copied contents
 * @since 3.3.0
 */
protected Contents copyUserTable(String tableName, String newTableName,
		boolean transferContent, boolean validateContents) {

	AlterTable.copyTable(database, tableName, newTableName,
			transferContent);

	Contents contents = copyContents(tableName, newTableName);

	if (contents == null && validateContents) {
		throw new GeoPackageException(
				"No table contents found for table: " + tableName);
	}

	return contents;
}
 
Example 12
Source Project: geopackage-core-java   Source File: GeoPackageCoreImpl.java    License: MIT License 6 votes vote down vote up
/**
 * Copy the contents
 * 
 * @param tableName
 *            table name
 * @param newTableName
 *            new table name
 * @return copied contents
 * @since 3.3.0
 */
protected Contents copyContents(String tableName, String newTableName) {

	Contents contents = getTableContents(tableName);

	if (contents != null) {

		contents.setTableName(newTableName);
		contents.setIdentifier(newTableName);

		try {
			getContentsDao().create(contents);
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to create contents for table: " + newTableName
							+ ", copied from table: " + tableName,
					e);
		}
	}

	return contents;
}
 
Example 13
Source Project: geopackage-core-java   Source File: GeoPackageDaoManager.java    License: MIT License 6 votes vote down vote up
/**
 * Unregister all GeoPackage DAO with the connection source
 * 
 * @param connectionSource
 *            connection source
 */
public static void unregisterDaos(ConnectionSource connectionSource) {
	// TODO when ormlite-core version > 5.1 is released, replace with:
	// "DaoManager.unregisterDaos(connectionSource);"
	// See https://github.com/j256/ormlite-core/pull/149
	unregisterDao(connectionSource, Contents.class,
			SpatialReferenceSystem.class,
			SpatialReferenceSystemSfSql.class,
			SpatialReferenceSystemSqlMm.class, Extensions.class,
			GriddedCoverage.class, GriddedTile.class, GeometryIndex.class,
			TableIndex.class, FeatureTileLink.class,
			ExtendedRelation.class, TileScaling.class,
			GeometryColumns.class, GeometryColumnsSfSql.class,
			GeometryColumnsSqlMm.class, Metadata.class,
			MetadataReference.class, DataColumns.class,
			DataColumnConstraints.class, TileMatrix.class,
			TileMatrixSet.class, ContentsId.class);
}
 
Example 14
Source Project: geopackage-core-java   Source File: TileMatrix.java    License: 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 15
Source Project: geopackage-java   Source File: GeoPackageTextOutput.java    License: MIT License 6 votes vote down vote up
/**
 * Text output from a Contents
 * 
 * @param contents
 *            contents
 * @return text
 */
public String textOutput(Contents contents) {
	StringBuilder output = new StringBuilder();
	output.append("\t" + Contents.COLUMN_TABLE_NAME + ": "
			+ contents.getTableName());
	output.append("\n\t" + Contents.COLUMN_DATA_TYPE + ": "
			+ contents.getDataType());
	output.append("\n\t" + Contents.COLUMN_IDENTIFIER + ": "
			+ contents.getIdentifier());
	output.append("\n\t" + Contents.COLUMN_DESCRIPTION + ": "
			+ contents.getDescription());
	output.append("\n\t" + Contents.COLUMN_LAST_CHANGE + ": "
			+ contents.getLastChange());
	output.append(
			"\n\t" + Contents.COLUMN_MIN_X + ": " + contents.getMinX());
	output.append(
			"\n\t" + Contents.COLUMN_MIN_Y + ": " + contents.getMinY());
	output.append(
			"\n\t" + Contents.COLUMN_MAX_X + ": " + contents.getMaxX());
	output.append(
			"\n\t" + Contents.COLUMN_MAX_Y + ": " + contents.getMaxY());
	output.append("\n" + textOutput(contents.getSrs()));
	return output.toString();
}
 
Example 16
Source Project: geopackage-mapcache-android   Source File: GeoPackageRepository.java    License: MIT License 6 votes vote down vote up
/**
 * Get table Contents object
 */
public Contents getTableContents(String gpName, String tableName) {
    GeoPackage geo = null;
    try{
        geo = manager.open(gpName);
        if(geo != null) {
            ContentsDao contentsDao = geo.getContentsDao();
            Contents contents = contentsDao.queryForId(tableName);
            return contents;
        }

    } catch (Exception e){

    } finally {
        if(geo !=  null){
            geo.close();
        }
    }
    return null;
}
 
Example 17
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 18
Source Project: geopackage-android   Source File: FeatureDao.java    License: MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public BoundingBox getBoundingBox(Projection projection) {
    Contents contents = geometryColumns.getContents();
    BoundingBox boundingBox = contents.getBoundingBox(projection);
    return boundingBox;
}
 
Example 19
Source Project: geopackage-android   Source File: AttributesDao.java    License: MIT License 5 votes vote down vote up
/**
 * Constructor
 *
 * @param database database
 * @param db       db connection
 * @param table    attributes table
 */
public AttributesDao(String database, GeoPackageConnection db,
                     AttributesTable table) {
    super(database, db, new AttributesConnection(db), table);

    this.attributesDb = (AttributesConnection) getUserDb();
    if (table.getContents() == null) {
        throw new GeoPackageException(AttributesTable.class.getSimpleName()
                + " " + table.getTableName() + " has null "
                + Contents.class.getSimpleName());
    }
}
 
Example 20
Source Project: geopackage-android   Source File: GeoPackageImpl.java    License: 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 21
Source Project: geopackage-java   Source File: GeoPackageImpl.java    License: MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public TileDao getTileDao(Contents contents) {

	if (contents == null) {
		throw new GeoPackageException("Non null "
				+ Contents.class.getSimpleName() + " is required to create "
				+ TileDao.class.getSimpleName());
	}

	TileMatrixSet tileMatrixSet = null;
	try {
		tileMatrixSet = getTileMatrixSetDao()
				.queryForId(contents.getTableName());
	} catch (SQLException e) {
		throw new GeoPackageException("No "
				+ TileMatrixSet.class.getSimpleName()
				+ " could be retrieved for "
				+ Contents.class.getSimpleName() + " " + contents.getId());
	}

	if (tileMatrixSet == null) {
		throw new GeoPackageException("No "
				+ TileMatrixSet.class.getSimpleName() + " exists for "
				+ Contents.class.getSimpleName() + " " + contents.getId());
	}

	return getTileDao(tileMatrixSet);
}
 
Example 22
Source Project: geopackage-java   Source File: RelatedSimpleAttributesUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Validate contents
 * 
 * @param simpleAttributesTable
 *            simple attributes table
 * @param contents
 *            contents
 */
private static void validateContents(
		SimpleAttributesTable simpleAttributesTable, Contents contents) {
	TestCase.assertNotNull(contents);
	TestCase.assertNotNull(contents.getDataType());
	TestCase.assertEquals(
			SimpleAttributesTable.RELATION_TYPE.getDataType(), contents
					.getDataType().getName());
	TestCase.assertEquals(
			SimpleAttributesTable.RELATION_TYPE.getDataType(),
			contents.getDataTypeString());
	TestCase.assertEquals(simpleAttributesTable.getTableName(),
			contents.getTableName());
	TestCase.assertNotNull(contents.getLastChange());
}
 
Example 23
Source Project: geopackage-android   Source File: RelatedMediaUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Validate contents
 *
 * @param mediaTable media table
 * @param contents   contents
 */
private static void validateContents(MediaTable mediaTable,
                                     Contents contents) {
    TestCase.assertNotNull(contents);
    TestCase.assertNotNull(contents.getDataType());
    TestCase.assertEquals(MediaTable.RELATION_TYPE.getDataType(), contents
            .getDataType().getName());
    TestCase.assertEquals(MediaTable.RELATION_TYPE.getDataType(),
            contents.getDataTypeString());
    TestCase.assertEquals(mediaTable.getTableName(),
            contents.getTableName());
    TestCase.assertNotNull(contents.getLastChange());
}
 
Example 24
Source Project: geopackage-android   Source File: RelatedSimpleAttributesUtils.java    License: MIT License 5 votes vote down vote up
/**
 * Validate contents
 *
 * @param simpleAttributesTable simple attributes table
 * @param contents              contents
 */
private static void validateContents(
        SimpleAttributesTable simpleAttributesTable, Contents contents) {
    TestCase.assertNotNull(contents);
    TestCase.assertNotNull(contents.getDataType());
    TestCase.assertEquals(
            SimpleAttributesTable.RELATION_TYPE.getDataType(), contents
                    .getDataType().getName());
    TestCase.assertEquals(
            SimpleAttributesTable.RELATION_TYPE.getDataType(),
            contents.getDataTypeString());
    TestCase.assertEquals(simpleAttributesTable.getTableName(),
            contents.getTableName());
    TestCase.assertNotNull(contents.getLastChange());
}
 
Example 25
Source Project: geopackage-java   Source File: FeatureDao.java    License: MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public BoundingBox getBoundingBox(Projection projection) {
	Contents contents = geometryColumns.getContents();
	BoundingBox boundingBox = contents.getBoundingBox(projection);
	return boundingBox;
}
 
Example 26
Source Project: geopackage-android   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 27
Source Project: geopackage-android   Source File: TransactionTest.java    License: MIT License 5 votes vote down vote up
/**
 * Test a transaction on the GeoPackage
 *
 * @param geoPackage GeoPackage
 * @param successful true for a successful transaction
 */
private void testGeoPackage(GeoPackage geoPackage, boolean successful) {

    int count = SQLiteMaster.countViewsOnTable(geoPackage.getConnection(),
            Contents.TABLE_NAME);

    geoPackage.beginTransaction();

    try {

        geoPackage.execSQL("CREATE VIEW " + Contents.TABLE_NAME
                + "_view AS SELECT table_name AS tableName FROM "
                + Contents.TABLE_NAME);

    } catch (Exception e) {

        geoPackage.failTransaction();
        TestCase.fail(e.getMessage());

    } finally {

        if (successful) {
            geoPackage.endTransaction();
        } else {
            geoPackage.failTransaction();
        }

    }

    TestCase.assertEquals(successful ? count + 1 : count, SQLiteMaster
            .countViewsOnTable(geoPackage.getConnection(),
                    Contents.TABLE_NAME));
}
 
Example 28
Source Project: geopackage-core-java   Source File: ContentsIdExtension.java    License: MIT License 5 votes vote down vote up
/**
 * Get by contents data type
 * 
 * @param type
 *            contents data type
 * @return contents ids
 */
public List<ContentsId> getIds(String type) {

	List<ContentsId> contentsIds = null;

	ContentsDao contentsDao = geoPackage.getContentsDao();

	try {

		if (contentsIdDao.isTableExists()) {

			QueryBuilder<Contents, String> contentsQueryBuilder = contentsDao
					.queryBuilder();
			QueryBuilder<ContentsId, Long> contentsIdQueryBuilder = contentsIdDao
					.queryBuilder();

			contentsQueryBuilder.where().eq(Contents.COLUMN_DATA_TYPE,
					type);
			contentsIdQueryBuilder.join(contentsQueryBuilder);

			contentsIds = contentsIdQueryBuilder.query();

		} else {
			contentsIds = new ArrayList<>();
		}
	} catch (SQLException e) {
		throw new GeoPackageException(
				"Failed to query for contents id by contents data type. GeoPackage: "
						+ geoPackage.getName() + ", Type: " + type,
				e);
	}

	return contentsIds;
}
 
Example 29
Source Project: geopackage-core-java   Source File: ContentsId.java    License: MIT License 5 votes vote down vote up
/**
 * Set the contents
 * 
 * @param contents
 *            contents
 */
public void setContents(Contents contents) {
	this.contents = contents;
	if (contents != null) {
		this.tableName = contents.getId();
	} else {
		this.tableName = null;
	}
}
 
Example 30
Source Project: geopackage-core-java   Source File: FeatureTableCoreIndex.java    License: MIT License 5 votes vote down vote up
/**
 * Determine if the feature table is indexed
 * 
 * @return true if indexed
 */
public boolean isIndexed() {
	boolean indexed = false;
	Extensions extension = getExtension();
	if (extension != null) {

		ContentsDao contentsDao = geoPackage.getContentsDao();
		try {
			Contents contents = contentsDao.queryForId(tableName);
			if (contents != null) {
				Date lastChange = contents.getLastChange();

				TableIndexDao tableIndexDao = geoPackage.getTableIndexDao();
				TableIndex tableIndex = tableIndexDao.queryForId(tableName);

				if (tableIndex != null) {
					Date lastIndexed = tableIndex.getLastIndexed();
					indexed = lastIndexed != null && lastIndexed
							.getTime() >= lastChange.getTime();
				}
			}
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to check if table is indexed, GeoPackage: "
							+ geoPackage.getName() + ", Table Name: "
							+ tableName,
					e);
		}
	}
	return indexed;
}