mil.nga.geopackage.core.contents.Contents Java Examples
The following examples show how to use
mil.nga.geopackage.core.contents.Contents.
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: GeoPackageRepository.java From geopackage-mapcache-android with MIT License | 6 votes |
/** * 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 #2
Source File: GeoPackageImpl.java From geopackage-android with MIT License | 6 votes |
/** * {@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 File: GeoPackageImpl.java From geopackage-android with MIT License | 6 votes |
/** * {@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 File: GeoPackageImpl.java From geopackage-android with MIT License | 6 votes |
/** * {@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 File: FeatureDao.java From geopackage-android with MIT License | 6 votes |
/** * 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 #6
Source File: RelatedTablesCoreExtension.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #7
Source File: GeoPackageImpl.java From geopackage-java with MIT License | 6 votes |
/** * {@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 #8
Source File: GeoPackageImpl.java From geopackage-java with MIT License | 6 votes |
/** * {@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 #9
Source File: GeometryColumns.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #10
Source File: GeometryColumnsSqlMm.java From geopackage-core-java with MIT License | 6 votes |
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 #11
Source File: GeometryColumnsSfSql.java From geopackage-core-java with MIT License | 6 votes |
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 #12
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #13
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #14
Source File: GeoPackageDaoManager.java From geopackage-core-java with MIT License | 6 votes |
/** * 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 #15
Source File: TileMatrix.java From geopackage-core-java with MIT License | 6 votes |
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 #16
Source File: GeoPackageTextOutput.java From geopackage-java with MIT License | 6 votes |
/** * 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 #17
Source File: SpatialReferenceSystemDao.java From geopackage-core-java with MIT License | 5 votes |
/** * Get or create a Contents DAO * * @return contents dao * @throws SQLException * upon creation failure */ private ContentsDao getContentsDao() throws SQLException { if (contentsDao == null) { contentsDao = DaoManager .createDao(connectionSource, Contents.class); } return contentsDao; }
Example #18
Source File: SpatialReferenceSystemDao.java From geopackage-core-java with MIT License | 5 votes |
/** * Delete the Spatial Reference System, cascading * * @param srs * spatial reference system * @return deleted count * @throws SQLException * upon deletion failure */ public int deleteCascade(SpatialReferenceSystem srs) throws SQLException { int count = 0; if (srs != null) { // Delete Contents ForeignCollection<Contents> contentsCollection = srs.getContents(); if (!contentsCollection.isEmpty()) { ContentsDao dao = getContentsDao(); dao.deleteCascade(contentsCollection); } // Delete Geometry Columns GeometryColumnsDao geometryColumnsDao = getGeometryColumnsDao(); if (geometryColumnsDao.isTableExists()) { ForeignCollection<GeometryColumns> geometryColumnsCollection = srs .getGeometryColumns(); if (!geometryColumnsCollection.isEmpty()) { geometryColumnsDao.delete(geometryColumnsCollection); } } // Delete Tile Matrix Set TileMatrixSetDao tileMatrixSetDao = getTileMatrixSetDao(); if (tileMatrixSetDao.isTableExists()) { ForeignCollection<TileMatrixSet> tileMatrixSetCollection = srs .getTileMatrixSet(); if (!tileMatrixSetCollection.isEmpty()) { tileMatrixSetDao.delete(tileMatrixSetCollection); } } // Delete count = delete(srs); } return count; }
Example #19
Source File: FeatureTileUtils.java From geopackage-java with MIT License | 5 votes |
public static void updateLastChange(GeoPackage geoPackage, FeatureDao featureDao) throws SQLException { Contents contents = featureDao.getGeometryColumns().getContents(); contents.setLastChange(new Date()); ContentsDao contentsDao = geoPackage.getContentsDao(); contentsDao.update(contents); }
Example #20
Source File: TransactionTest.java From geopackage-java with MIT License | 5 votes |
/** * Test a transaction on the GeoPackage * * @param geoPackage * GeoPackage * @param successful * true for a successful transaction * @throws SQLException * upon error */ private void testGeoPackage(GeoPackage geoPackage, boolean successful) throws SQLException { 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 #21
Source File: DataColumns.java From geopackage-core-java with MIT License | 5 votes |
public void setContents(Contents contents) { this.contents = contents; if (contents != null) { tableName = contents.getId(); } else { tableName = null; } }
Example #22
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public String getTableType(String table) { String tableType = null; Contents contents = getTableContents(table); if (contents != null) { tableType = contents.getDataTypeString(); } return tableType; }
Example #23
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 5 votes |
/** * {@inheritDoc} */ @Override public Contents getTableContents(String table) { ContentsDao contentDao = getContentsDao(); Contents contents = null; try { contents = contentDao.queryForId(table); } catch (SQLException e) { throw new GeoPackageException( "Failed to retrieve table contents: " + table, e); } return contents; }
Example #24
Source File: GeoPackageCoreImpl.java From geopackage-core-java with MIT License | 5 votes |
/** * {@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 #25
Source File: AttributesTable.java From geopackage-core-java with MIT License | 5 votes |
/** * {@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 #26
Source File: GeoPackageImpl.java From geopackage-android with MIT License | 5 votes |
/** * {@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 #27
Source File: FeatureTable.java From geopackage-core-java with MIT License | 5 votes |
/** * {@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 #28
Source File: GriddedTile.java From geopackage-core-java with MIT License | 5 votes |
/** * Set the contents * * @param contents * contents */ public void setContents(Contents contents) { this.contents = contents; if (contents != null) { tableName = contents.getTableName(); } else { tableName = null; } }
Example #29
Source File: RelatedSimpleAttributesUtils.java From geopackage-java with MIT License | 5 votes |
/** * 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 #30
Source File: FeatureTableCoreIndex.java From geopackage-core-java with MIT License | 5 votes |
/** * 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; }