Class GeoPackageCoreImpl

    • Field Detail

      • writable

        protected final boolean writable
        Writable GeoPackage flag
    • Constructor Detail

      • GeoPackageCoreImpl

        protected GeoPackageCoreImpl​(String name,
                                     String path,
                                     GeoPackageCoreConnection database)
        Constructor
        Parameters:
        name - name
        path - path
        database - database
        Since:
        4.0.0
      • GeoPackageCoreImpl

        protected GeoPackageCoreImpl​(String name,
                                     String path,
                                     GeoPackageCoreConnection database,
                                     boolean writable)
        Constructor
        Parameters:
        name - name
        path - path
        database - database
        writable - true if writable
        Since:
        4.0.0
    • Method Detail

      • isWritable

        public boolean isWritable()
        Is the GeoPackage writable
        Specified by:
        isWritable in interface GeoPackageCore
        Returns:
        true if writable
      • getApplicationIdHex

        public String getApplicationIdHex()
        Get the application id as a hex string prefixed with 0x
        Specified by:
        getApplicationIdHex in interface GeoPackageCore
        Returns:
        application id hex string
      • getTables

        public List<String> getTables​(String type)
        Get the tables for the contents data type
        Specified by:
        getTables in interface GeoPackageCore
        Parameters:
        type - data type
        Returns:
        table names
      • getTables

        public List<String> getTables​(String... types)
        Get the tables for the contents data types
        Specified by:
        getTables in interface GeoPackageCore
        Parameters:
        types - data types
        Returns:
        table names
      • isFeatureTable

        public boolean isFeatureTable​(String table)
        Check if the table is a feature table
        Specified by:
        isFeatureTable in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        true if a feature table
      • isTileTable

        public boolean isTileTable​(String table)
        Check if the table is a tile table
        Specified by:
        isTileTable in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        true if a tile table
      • isAttributeTable

        public boolean isAttributeTable​(String table)
        Check if the table is an attribute table
        Specified by:
        isAttributeTable in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        true if an attribute table
      • isTableType

        public boolean isTableType​(String table,
                                   ContentsDataType type)
        Check if the table is the provided type
        Specified by:
        isTableType in interface GeoPackageCore
        Parameters:
        table - table name
        type - data type
        Returns:
        true if the type of table
      • isTableType

        public boolean isTableType​(String table,
                                   ContentsDataType... types)
        Check if the table is one of the provided types
        Specified by:
        isTableType in interface GeoPackageCore
        Parameters:
        table - table name
        types - data types
        Returns:
        true if the type of table
      • isTableType

        public boolean isTableType​(String table,
                                   String type)
        Check if the table is the provided type
        Specified by:
        isTableType in interface GeoPackageCore
        Parameters:
        table - table name
        type - data type
        Returns:
        true if the type of table
      • isTableType

        public boolean isTableType​(String table,
                                   String... types)
        Check if the table is one of the provided types
        Specified by:
        isTableType in interface GeoPackageCore
        Parameters:
        table - table name
        types - data types
        Returns:
        true if the type of table
      • isContentsTable

        public boolean isContentsTable​(String table)
        Check if the table exists as a user contents table
        Specified by:
        isContentsTable in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        true if a user contents table
      • isTable

        public boolean isTable​(String table)
        Check if the table exists
        Specified by:
        isTable in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        true if a table
      • isView

        public boolean isView​(String view)
        Check if the view exists
        Specified by:
        isView in interface GeoPackageCore
        Parameters:
        view - view name
        Returns:
        true if a view
      • isTableOrView

        public boolean isTableOrView​(String name)
        Check if the table or view exists
        Specified by:
        isTableOrView in interface GeoPackageCore
        Parameters:
        name - table or view name
        Returns:
        true if a table or view
      • getTableType

        public String getTableType​(String table)
        Get the contents data type of the user table
        Specified by:
        getTableType in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        table type
      • getTableDataType

        public ContentsDataType getTableDataType​(String table)
        Get the contents data type of the user table
        Specified by:
        getTableDataType in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        table type or null if not an enumerated type
      • getTableCoreDataType

        public ContentsDataType getTableCoreDataType​(String table)
        Get the data type of the user table only if it is a core data type (features, tiles, attributes)
        Specified by:
        getTableCoreDataType in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        core data type or null
      • isTableCoreDataType

        public boolean isTableCoreDataType​(String table)
        Determine if the user table is one of the core data types (features, tiles, attributes)
        Specified by:
        isTableCoreDataType in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        true if a core data type
      • getContentsBoundingBox

        public BoundingBox getContentsBoundingBox​(Projection projection)
        Get the bounding box for all table contents in the provided projection
        Specified by:
        getContentsBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        Returns:
        bounding box
      • getBoundingBox

        public BoundingBox getBoundingBox​(Projection projection)
        Get the bounding box for all tables in the provided projection, including contents and table metadata
        Specified by:
        getBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        Returns:
        bounding box
      • getBoundingBox

        public BoundingBox getBoundingBox​(Projection projection,
                                          boolean manual)
        Get the bounding box for all tables in the provided projection, including contents, table metadata, and manual queries if enabled
        Specified by:
        getBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        manual - manual query flag, true to determine missing bounds manually
        Returns:
        bounding box
      • getTableBoundingBox

        public BoundingBox getTableBoundingBox​(Projection projection)
        Get the bounding box for all tables in the provided projection, using only table metadata
        Specified by:
        getTableBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        Returns:
        bounding box
      • getTableBoundingBox

        public BoundingBox getTableBoundingBox​(Projection projection,
                                               boolean manual)
        Get the bounding box for all tables in the provided projection, using only table metadata and manual queries if enabled
        Specified by:
        getTableBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        manual - manual query flag, true to determine missing bounds manually
        Returns:
        bounding box
      • getContentsBoundingBox

        public BoundingBox getContentsBoundingBox​(String table)
        Get the bounding box from the contents for the table in the table's projection
        Specified by:
        getContentsBoundingBox in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        bounding box
      • getContentsBoundingBox

        public BoundingBox getContentsBoundingBox​(Projection projection,
                                                  String table)
        Get the bounding box from the contents for the table in the provided projection
        Specified by:
        getContentsBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        table - table name
        Returns:
        bounding box
      • getBoundingBox

        public BoundingBox getBoundingBox​(String table)
        Get the bounding box for the table in the table's projection, including contents and table metadata
        Specified by:
        getBoundingBox in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        bounding box
      • getBoundingBox

        public BoundingBox getBoundingBox​(Projection projection,
                                          String table)
        Get the bounding box for the table in the provided projection, including contents and table metadata
        Specified by:
        getBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        table - table name
        Returns:
        bounding box
      • getBoundingBox

        public BoundingBox getBoundingBox​(String table,
                                          boolean manual)
        Get the bounding box for the table in the table's projection, including contents, table metadata, and manual queries if enabled
        Specified by:
        getBoundingBox in interface GeoPackageCore
        Parameters:
        table - table name
        manual - manual query flag, true to determine missing bounds manually
        Returns:
        bounding box
      • getBoundingBox

        public BoundingBox getBoundingBox​(Projection projection,
                                          String table,
                                          boolean manual)
        Get the bounding box for the table in the provided projection, including contents, table metadata, and manual queries if enabled
        Specified by:
        getBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        table - table name
        manual - manual query flag, true to determine missing bounds manually
        Returns:
        bounding box
      • getTableBoundingBox

        public BoundingBox getTableBoundingBox​(String table)
        Get the bounding box for the table in the table's projection, using only table metadata
        Specified by:
        getTableBoundingBox in interface GeoPackageCore
        Parameters:
        table - table name
        Returns:
        bounding box
      • getTableBoundingBox

        public BoundingBox getTableBoundingBox​(Projection projection,
                                               String table)
        Get the bounding box for the table in the provided projection, using only table metadata
        Specified by:
        getTableBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        table - table name
        Returns:
        bounding box
      • getTableBoundingBox

        public BoundingBox getTableBoundingBox​(String table,
                                               boolean manual)
        Get the bounding box for the table in the table's projection, using only table metadata and manual queries if enabled
        Specified by:
        getTableBoundingBox in interface GeoPackageCore
        Parameters:
        table - table name
        manual - manual query flag, true to determine missing bounds manually
        Returns:
        bounding box
      • getTableBoundingBox

        public BoundingBox getTableBoundingBox​(Projection projection,
                                               String table,
                                               boolean manual)
        Get the bounding box for the table in the provided projection, using only table metadata and manual queries if enabled
        Specified by:
        getTableBoundingBox in interface GeoPackageCore
        Parameters:
        projection - desired bounding box projection
        table - table name
        manual - manual query flag, true to determine missing bounds manually
        Returns:
        bounding box
      • createGeometryColumnsTable

        public boolean createGeometryColumnsTable()
        Create the Geometry Columns table if it does not already exist
        Specified by:
        createGeometryColumnsTable in interface GeoPackageCore
        Returns:
        true if created
      • createFeatureTable

        public FeatureTable createFeatureTable​(FeatureTableMetadata metadata)
        Create a new feature table with GeoPackage metadata including: geometry columns table and row, user feature table, and contents row.
        Specified by:
        createFeatureTable in interface GeoPackageCore
        Parameters:
        metadata - feature table metadata
        Returns:
        feature table
      • createTileMatrixSetTable

        public boolean createTileMatrixSetTable()
        Create the Tile Matrix Set table if it does not already exist
        Specified by:
        createTileMatrixSetTable in interface GeoPackageCore
        Returns:
        true if created
      • createTileMatrixTable

        public boolean createTileMatrixTable()
        Create the Tile Matrix table if it does not already exist
        Specified by:
        createTileMatrixTable in interface GeoPackageCore
        Returns:
        true if created
      • createTileTable

        public TileTable createTileTable​(TileTableMetadata metadata)
        Create a new tile table with GeoPackage metadata including: tile matrix set table and row, tile matrix table, user tile table, and contents row.
        Specified by:
        createTileTable in interface GeoPackageCore
        Parameters:
        metadata - tile table metadata
        Returns:
        tile table
      • createExtensionsTable

        public boolean createExtensionsTable()
        Create the Extensions table if it does not already exist
        Specified by:
        createExtensionsTable in interface GeoPackageCore
        Returns:
        true if created
      • deleteTable

        public void deleteTable​(String table)
        Delete the user table (a feature or tile table) and all GeoPackage metadata
        Specified by:
        deleteTable in interface GeoPackageCore
        Parameters:
        table - table name
      • deleteTableQuietly

        public void deleteTableQuietly​(String tableName)
        Attempt to delete the user table (a feature or tile table) and all GeoPackage metadata quietly
        Specified by:
        deleteTableQuietly in interface GeoPackageCore
        Parameters:
        tableName - table name
      • createDao

        public <D extends GeoPackageDao<T,​?>,​T> D createDao​(Class<T> type)
        Create a dao
        Specified by:
        createDao in interface GeoPackageCore
        Type Parameters:
        D - dao type
        T - class type
        Parameters:
        type - dao class type
        Returns:
        base dao implementation
      • endAndBeginTransaction

        public void endAndBeginTransaction()
        End a transaction as successful and begin a new transaction
        Specified by:
        endAndBeginTransaction in interface GeoPackageCore
      • callInTransaction

        public <T> T callInTransaction​(Callable<T> callable)
                                throws SQLException
        Execute the Callable class inside an ORMLite transaction
        Specified by:
        callInTransaction in interface GeoPackageCore
        Type Parameters:
        T - callable type
        Parameters:
        callable - Callable to execute inside of the transaction.
        Returns:
        The object returned by the callable.
        Throws:
        SQLException - upon transaction error
      • enableForeignKeys

        public boolean enableForeignKeys()
        If foreign keys is disabled and there are no foreign key violations, enables foreign key checks, else logs violations
        Specified by:
        enableForeignKeys in interface GeoPackageCore
        Returns:
        true if enabled or already enabled, false if foreign key violations and not enabled
      • foreignKeys

        public boolean foreignKeys()
        Query for the foreign keys value
        Specified by:
        foreignKeys in interface GeoPackageCore
        Returns:
        true if enabled, false if disabled
      • foreignKeys

        public boolean foreignKeys​(boolean on)
        Change the foreign keys state
        Specified by:
        foreignKeys in interface GeoPackageCore
        Parameters:
        on - true to turn on, false to turn off
        Returns:
        previous foreign keys value
      • verifyWritable

        public void verifyWritable()
        Verify the GeoPackage is writable and throw an exception if it is not
        Specified by:
        verifyWritable in interface GeoPackageCore
      • dropTable

        public void dropTable​(String table)
        Drop the table if it exists. Drops the table with the table name, not limited to GeoPackage specific tables.
        Specified by:
        dropTable in interface GeoPackageCore
        Parameters:
        table - table name
      • dropView

        public void dropView​(String view)
        Drop the view if it exists. Drops the view with the view name, not limited to GeoPackage specific tables.
        Specified by:
        dropView in interface GeoPackageCore
        Parameters:
        view - view name
      • renameTable

        public void renameTable​(String tableName,
                                String newTableName)
        Rename the table
        Specified by:
        renameTable in interface GeoPackageCore
        Parameters:
        tableName - table name
        newTableName - new table name
      • copyTable

        public void copyTable​(String tableName,
                              String newTableName)
        Copy the table with transferred contents and extensions
        Specified by:
        copyTable in interface GeoPackageCore
        Parameters:
        tableName - table name
        newTableName - new table name
      • copyTableNoExtensions

        public void copyTableNoExtensions​(String tableName,
                                          String newTableName)
        Copy the table with transferred contents but no extensions
        Specified by:
        copyTableNoExtensions in interface GeoPackageCore
        Parameters:
        tableName - table name
        newTableName - new table name
      • copyTableAsEmpty

        public void copyTableAsEmpty​(String tableName,
                                     String newTableName)
        Copy the table but leave the user table empty and without extensions
        Specified by:
        copyTableAsEmpty in interface GeoPackageCore
        Parameters:
        tableName - table name
        newTableName - new table name
      • copyTable

        protected void copyTable​(String tableName,
                                 String newTableName,
                                 boolean transferContent,
                                 boolean extensions)
        Copy the table
        Parameters:
        tableName - table name
        newTableName - new table name
        transferContent - transfer content flag
        extensions - extensions copy flag
      • copyAttributeTable

        protected void copyAttributeTable​(String tableName,
                                          String newTableName,
                                          boolean transferContent)
        Copy the attribute table
        Parameters:
        tableName - table name
        newTableName - new table name
        transferContent - transfer content flag
        Since:
        3.3.0
      • copyFeatureTable

        protected void copyFeatureTable​(String tableName,
                                        String newTableName,
                                        boolean transferContent)
        Copy the feature table
        Parameters:
        tableName - table name
        newTableName - new table name
        transferContent - transfer content flag
        Since:
        3.3.0
      • copyTileTable

        protected void copyTileTable​(String tableName,
                                     String newTableName,
                                     boolean transferContent)
        Copy the tile table
        Parameters:
        tableName - table name
        newTableName - new table name
        transferContent - transfer content flag
        Since:
        3.3.0
      • copyUserTable

        protected Contents copyUserTable​(String tableName,
                                         String newTableName,
                                         boolean transferContent)
        Copy the user table
        Parameters:
        tableName - table name
        newTableName - new table name
        transferContent - transfer user table content flag
        Returns:
        copied contents
        Since:
        3.3.0
      • copyUserTable

        protected Contents copyUserTable​(String tableName,
                                         String newTableName,
                                         boolean transferContent,
                                         boolean validateContents)
        Copy the user table
        Parameters:
        tableName - table name
        newTableName - new table name
        transferContent - transfer user table content flag
        validateContents - true to validate a contents was copied
        Returns:
        copied contents
        Since:
        3.3.0
      • copyContents

        protected Contents copyContents​(String tableName,
                                        String newTableName)
        Copy the contents
        Parameters:
        tableName - table name
        newTableName - new table name
        Returns:
        copied contents
        Since:
        3.3.0
      • vacuum

        public void vacuum()
        Rebuild the GeoPackage, repacking it into a minimal amount of disk space
        Specified by:
        vacuum in interface GeoPackageCore