idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
1,600
public boolean deleteValue ( String geoPackage , String property , String value ) { boolean deleted = false ; PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . get ( geoPackage ) ; if ( properties != null ) { deleted = properties . deleteValue ( property , value ) > 0 ; } return deleted ; }
Delete the property value from a specified GeoPackage
1,601
public int deleteAll ( ) { int count = 0 ; for ( String geoPackage : propertiesMap . keySet ( ) ) { if ( deleteAll ( geoPackage ) ) { count ++ ; } } return count ; }
Delete all properties and values from all GeoPackages
1,602
public boolean deleteAll ( String geoPackage ) { boolean deleted = false ; PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . get ( geoPackage ) ; if ( properties != null ) { deleted = properties . deleteAll ( ) > 0 ; } return deleted ; }
Delete all properties and values from a specified GeoPackage
1,603
public void removeExtension ( String geoPackage ) { PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . get ( geoPackage ) ; if ( properties != null ) { properties . removeExtension ( ) ; } }
Remove the extension from a specified GeoPackage
1,604
public void addColumn ( String tableName , String columnName , String columnDef ) { execSQL ( "ALTER TABLE " + CoreSQLUtils . quoteWrap ( tableName ) + " ADD COLUMN " + CoreSQLUtils . quoteWrap ( columnName ) + " " + columnDef + ";" ) ; }
Add a new column to the table
1,605
public < T > T querySingleTypedResult ( String sql , String [ ] args ) { @ SuppressWarnings ( "unchecked" ) T result = ( T ) querySingleResult ( sql , args ) ; return result ; }
Query the SQL for a single result typed object in the first column
1,606
public < T > List < T > querySingleColumnTypedResults ( String sql , String [ ] args ) { @ SuppressWarnings ( "unchecked" ) List < T > result = ( List < T > ) querySingleColumnResults ( sql , args ) ; return result ; }
Query for values from the first column
1,607
public void setApplicationId ( String applicationId ) { int applicationIdInt = ByteBuffer . wrap ( applicationId . getBytes ( ) ) . asIntBuffer ( ) . get ( ) ; execSQL ( String . format ( "PRAGMA application_id = %d;" , applicationIdInt ) ) ; }
Set the GeoPackage application id
1,608
public String getApplicationId ( ) { String applicationId = null ; Integer applicationIdObject = querySingleTypedResult ( "PRAGMA application_id" , null , GeoPackageDataType . MEDIUMINT ) ; if ( applicationIdObject != null ) { try { applicationId = new String ( ByteBuffer . allocate ( 4 ) . putInt ( applicationIdObject ) . array ( ) , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new GeoPackageException ( "Unexpected application id character encoding" , e ) ; } } return applicationId ; }
Get the application id
1,609
public int getUserVersion ( ) { int userVersion = - 1 ; Integer userVersionObject = querySingleTypedResult ( "PRAGMA user_version" , null , GeoPackageDataType . MEDIUMINT ) ; if ( userVersionObject != null ) { userVersion = userVersionObject ; } return userVersion ; }
Get the user version
1,610
public void fromBytes ( byte [ ] bytes ) { this . bytes = bytes ; ByteReader reader = new ByteReader ( bytes ) ; String magic = null ; try { magic = reader . readString ( 2 ) ; } catch ( UnsupportedEncodingException e ) { throw new GeoPackageException ( "Unexpected GeoPackage Geometry magic number character encoding: Expected: " + GeoPackageConstants . GEO_PACKAGE_GEOMETRY_MAGIC_NUMBER ) ; } if ( ! magic . equals ( GeoPackageConstants . GEO_PACKAGE_GEOMETRY_MAGIC_NUMBER ) ) { throw new GeoPackageException ( "Unexpected GeoPackage Geometry magic number: " + magic + ", Expected: " + GeoPackageConstants . GEO_PACKAGE_GEOMETRY_MAGIC_NUMBER ) ; } byte version = reader . readByte ( ) ; if ( version != GeoPackageConstants . GEO_PACKAGE_GEOMETRY_VERSION_1 ) { throw new GeoPackageException ( "Unexpected GeoPackage Geometry version: " + version + ", Expected: " + GeoPackageConstants . GEO_PACKAGE_GEOMETRY_VERSION_1 ) ; } byte flags = reader . readByte ( ) ; int envelopeIndicator = readFlags ( flags ) ; reader . setByteOrder ( byteOrder ) ; srsId = reader . readInt ( ) ; envelope = readEnvelope ( envelopeIndicator , reader ) ; wkbGeometryIndex = reader . getNextByte ( ) ; if ( ! empty ) { geometry = GeometryReader . readGeometry ( reader ) ; } }
Populate the geometry data from the bytes
1,611
public byte [ ] toBytes ( ) throws IOException { ByteWriter writer = new ByteWriter ( ) ; writer . writeString ( GeoPackageConstants . GEO_PACKAGE_GEOMETRY_MAGIC_NUMBER ) ; writer . writeByte ( GeoPackageConstants . GEO_PACKAGE_GEOMETRY_VERSION_1 ) ; byte flags = buildFlagsByte ( ) ; writer . writeByte ( flags ) ; writer . setByteOrder ( byteOrder ) ; writer . writeInt ( srsId ) ; writeEnvelope ( writer ) ; wkbGeometryIndex = writer . size ( ) ; if ( ! empty ) { GeometryWriter . writeGeometry ( writer , geometry ) ; } bytes = writer . getBytes ( ) ; writer . close ( ) ; return bytes ; }
Write the geometry to bytes
1,612
private int readFlags ( byte flags ) { int reserved7 = ( flags >> 7 ) & 1 ; int reserved6 = ( flags >> 6 ) & 1 ; if ( reserved7 != 0 || reserved6 != 0 ) { throw new GeoPackageException ( "Unexpected GeoPackage Geometry flags. Flag bit 7 and 6 should both be 0, 7=" + reserved7 + ", 6=" + reserved6 ) ; } int binaryType = ( flags >> 5 ) & 1 ; extended = binaryType == 1 ; int emptyValue = ( flags >> 4 ) & 1 ; empty = emptyValue == 1 ; int envelopeIndicator = ( flags >> 1 ) & 7 ; if ( envelopeIndicator > 4 ) { throw new GeoPackageException ( "Unexpected GeoPackage Geometry flags. Envelope contents indicator must be between 0 and 4. Actual: " + envelopeIndicator ) ; } int byteOrderValue = flags & 1 ; byteOrder = byteOrderValue == 0 ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; return envelopeIndicator ; }
Read the flags from the flag byte and return the envelope indicator
1,613
private byte buildFlagsByte ( ) { byte flag = 0 ; int binaryType = extended ? 1 : 0 ; flag += ( binaryType << 5 ) ; int emptyValue = empty ? 1 : 0 ; flag += ( emptyValue << 4 ) ; int envelopeIndicator = envelope == null ? 0 : getIndicator ( envelope ) ; flag += ( envelopeIndicator << 1 ) ; int byteOrderValue = ( byteOrder == ByteOrder . BIG_ENDIAN ) ? 0 : 1 ; flag += byteOrderValue ; return flag ; }
Build the flags byte from the flag values
1,614
private GeometryEnvelope readEnvelope ( int envelopeIndicator , ByteReader reader ) { GeometryEnvelope envelope = null ; if ( envelopeIndicator > 0 ) { double minX = reader . readDouble ( ) ; double maxX = reader . readDouble ( ) ; double minY = reader . readDouble ( ) ; double maxY = reader . readDouble ( ) ; boolean hasZ = false ; Double minZ = null ; Double maxZ = null ; boolean hasM = false ; Double minM = null ; Double maxM = null ; if ( envelopeIndicator == 2 || envelopeIndicator == 4 ) { hasZ = true ; minZ = reader . readDouble ( ) ; maxZ = reader . readDouble ( ) ; } if ( envelopeIndicator == 3 || envelopeIndicator == 4 ) { hasM = true ; minM = reader . readDouble ( ) ; maxM = reader . readDouble ( ) ; } envelope = new GeometryEnvelope ( hasZ , hasM ) ; envelope . setMinX ( minX ) ; envelope . setMaxX ( maxX ) ; envelope . setMinY ( minY ) ; envelope . setMaxY ( maxY ) ; if ( hasZ ) { envelope . setMinZ ( minZ ) ; envelope . setMaxZ ( maxZ ) ; } if ( hasM ) { envelope . setMinM ( minM ) ; envelope . setMaxM ( maxM ) ; } } return envelope ; }
Read the envelope based upon the indicator value
1,615
private void writeEnvelope ( ByteWriter writer ) throws IOException { if ( envelope != null ) { writer . writeDouble ( envelope . getMinX ( ) ) ; writer . writeDouble ( envelope . getMaxX ( ) ) ; writer . writeDouble ( envelope . getMinY ( ) ) ; writer . writeDouble ( envelope . getMaxY ( ) ) ; if ( envelope . hasZ ( ) ) { writer . writeDouble ( envelope . getMinZ ( ) ) ; writer . writeDouble ( envelope . getMaxZ ( ) ) ; } if ( envelope . hasM ( ) ) { writer . writeDouble ( envelope . getMinM ( ) ) ; writer . writeDouble ( envelope . getMaxM ( ) ) ; } } }
Write the envelope bytes
1,616
public void setGeometry ( Geometry geometry ) { this . geometry = geometry ; empty = geometry == null ; if ( geometry != null ) { extended = GeometryExtensions . isNonStandard ( geometry . getGeometryType ( ) ) ; } }
Set the geometry . Updates the empty flag and if the geometry is not null the extended flag
1,617
public byte [ ] getWkbBytes ( ) { int wkbByteCount = bytes . length - wkbGeometryIndex ; byte [ ] wkbBytes = new byte [ wkbByteCount ] ; System . arraycopy ( bytes , wkbGeometryIndex , wkbBytes , 0 , wkbByteCount ) ; return wkbBytes ; }
Get the Well - Known Binary Geometry bytes
1,618
public ByteBuffer getWkbByteBuffer ( ) { return ByteBuffer . wrap ( bytes , wkbGeometryIndex , bytes . length - wkbGeometryIndex ) . order ( byteOrder ) ; }
Get the Well - Known Binary Geometry bytes already ordered in a Byte Buffer
1,619
public GeometryEnvelope getOrBuildEnvelope ( ) { GeometryEnvelope envelope = getEnvelope ( ) ; if ( envelope == null ) { Geometry geometry = getGeometry ( ) ; if ( geometry != null ) { envelope = GeometryEnvelopeBuilder . buildEnvelope ( geometry ) ; } } return envelope ; }
Get the envelope if it exists or build it from the geometry if not null
1,620
public static int getIndicator ( GeometryEnvelope envelope ) { int indicator = 1 ; if ( envelope . hasZ ( ) ) { indicator ++ ; } if ( envelope . hasM ( ) ) { indicator += 2 ; } return indicator ; }
Get the envelope flag indicator
1,621
public String getDefinition_12_063 ( long srsId ) { String definition = null ; if ( hasDefinition_12_063 ( ) ) { definition = crsWktExtension . getDefinition ( srsId ) ; } return definition ; }
Query to get the definition 12 063 value if the extension exists
1,622
public void setDefinition_12_063 ( SpatialReferenceSystem srs ) { if ( srs != null ) { String definition = getDefinition_12_063 ( srs . getSrsId ( ) ) ; if ( definition != null ) { srs . setDefinition_12_063 ( definition ) ; } } }
Query and set the definition 12 063 in the srs object if the extension exists
1,623
public void updateDefinition_12_063 ( SpatialReferenceSystem srs ) { if ( srs != null ) { String definition = srs . getDefinition_12_063 ( ) ; if ( definition != null ) { updateDefinition_12_063 ( srs . getSrsId ( ) , definition ) ; } } }
Update the definition 12 063 in the database if the extension exists
1,624
public SpatialReferenceSystem getOrCreateCode ( String organization , long coordsysId ) throws SQLException { SpatialReferenceSystem srs = queryForOrganizationCoordsysId ( organization , coordsysId ) ; srs = createIfNeeded ( srs , organization , coordsysId ) ; return srs ; }
Get or Create the Spatial Reference System for the provided organization and id
1,625
public SpatialReferenceSystem queryForOrganizationCoordsysId ( String organization , long organizationCoordsysId ) throws SQLException { SpatialReferenceSystem srs = null ; QueryBuilder < SpatialReferenceSystem , Long > qb = queryBuilder ( ) ; qb . where ( ) . like ( SpatialReferenceSystem . COLUMN_ORGANIZATION , organization ) ; qb . where ( ) . eq ( SpatialReferenceSystem . COLUMN_ORGANIZATION_COORDSYS_ID , organizationCoordsysId ) ; PreparedQuery < SpatialReferenceSystem > preparedQuery = qb . prepare ( ) ; List < SpatialReferenceSystem > results = query ( preparedQuery ) ; if ( ! results . isEmpty ( ) ) { if ( results . size ( ) > 1 ) { throw new SQLException ( "More than one " + SpatialReferenceSystem . class . getSimpleName ( ) + " returned for Organization: " + organization + ", Organization Coordsys Id: " + organizationCoordsysId ) ; } srs = results . get ( 0 ) ; } return srs ; }
Query for the organization coordsys id
1,626
private SpatialReferenceSystem createIfNeeded ( SpatialReferenceSystem srs , String organization , long id ) throws SQLException { if ( srs == null ) { if ( organization . equalsIgnoreCase ( ProjectionConstants . AUTHORITY_EPSG ) ) { switch ( ( int ) id ) { case ProjectionConstants . EPSG_WORLD_GEODETIC_SYSTEM : srs = createWgs84 ( ) ; break ; case ProjectionConstants . EPSG_WEB_MERCATOR : srs = createWebMercator ( ) ; break ; case ProjectionConstants . EPSG_WORLD_GEODETIC_SYSTEM_GEOGRAPHICAL_3D : srs = createWgs84Geographical3D ( ) ; break ; default : throw new GeoPackageException ( "Spatial Reference System not supported for metadata creation. Organization: " + organization + ", id: " + id ) ; } } else if ( organization . equalsIgnoreCase ( ProjectionConstants . AUTHORITY_NONE ) ) { switch ( ( int ) id ) { case ProjectionConstants . UNDEFINED_CARTESIAN : srs = createUndefinedCartesian ( ) ; break ; case ProjectionConstants . UNDEFINED_GEOGRAPHIC : srs = createUndefinedGeographic ( ) ; break ; default : throw new GeoPackageException ( "Spatial Reference System not supported for metadata creation. Organization: " + organization + ", id: " + id ) ; } } else { throw new GeoPackageException ( "Spatial Reference System not supported for metadata creation. Organization: " + organization + ", id: " + id ) ; } } else { setDefinition_12_063 ( srs ) ; } return srs ; }
Create the srs if needed
1,627
public int deleteCascade ( SpatialReferenceSystem srs ) throws SQLException { int count = 0 ; if ( srs != null ) { ForeignCollection < Contents > contentsCollection = srs . getContents ( ) ; if ( ! contentsCollection . isEmpty ( ) ) { ContentsDao dao = getContentsDao ( ) ; dao . deleteCascade ( contentsCollection ) ; } GeometryColumnsDao geometryColumnsDao = getGeometryColumnsDao ( ) ; if ( geometryColumnsDao . isTableExists ( ) ) { ForeignCollection < GeometryColumns > geometryColumnsCollection = srs . getGeometryColumns ( ) ; if ( ! geometryColumnsCollection . isEmpty ( ) ) { geometryColumnsDao . delete ( geometryColumnsCollection ) ; } } TileMatrixSetDao tileMatrixSetDao = getTileMatrixSetDao ( ) ; if ( tileMatrixSetDao . isTableExists ( ) ) { ForeignCollection < TileMatrixSet > tileMatrixSetCollection = srs . getTileMatrixSet ( ) ; if ( ! tileMatrixSetCollection . isEmpty ( ) ) { tileMatrixSetDao . delete ( tileMatrixSetCollection ) ; } } count = delete ( srs ) ; } return count ; }
Delete the Spatial Reference System cascading
1,628
public int deleteCascade ( Collection < SpatialReferenceSystem > srsCollection ) throws SQLException { int count = 0 ; if ( srsCollection != null ) { for ( SpatialReferenceSystem srs : srsCollection ) { count += deleteCascade ( srs ) ; } } return count ; }
Delete the collection of Spatial Reference Systems cascading
1,629
public int deleteCascade ( PreparedQuery < SpatialReferenceSystem > preparedDelete ) throws SQLException { int count = 0 ; if ( preparedDelete != null ) { List < SpatialReferenceSystem > srsList = query ( preparedDelete ) ; count = deleteCascade ( srsList ) ; } return count ; }
Delete the Spatial Reference Systems matching the prepared query cascading
1,630
public int deleteByIdCascade ( Long id ) throws SQLException { int count = 0 ; if ( id != null ) { SpatialReferenceSystem srs = queryForId ( id ) ; if ( srs != null ) { count = deleteCascade ( srs ) ; } } return count ; }
Delete a Spatial Reference System by id cascading
1,631
private ContentsDao getContentsDao ( ) throws SQLException { if ( contentsDao == null ) { contentsDao = DaoManager . createDao ( connectionSource , Contents . class ) ; } return contentsDao ; }
Get or create a Contents DAO
1,632
public static TileColumn createIdColumn ( int index ) { return new TileColumn ( index , TileTable . COLUMN_ID , GeoPackageDataType . INTEGER , null , false , null , true ) ; }
Create an id column
1,633
public static TileColumn createZoomLevelColumn ( int index ) { return new TileColumn ( index , TileTable . COLUMN_ZOOM_LEVEL , GeoPackageDataType . INTEGER , null , true , 0 , false ) ; }
Create a zoom level column
1,634
public static TileColumn createTileColumnColumn ( int index ) { return new TileColumn ( index , TileTable . COLUMN_TILE_COLUMN , GeoPackageDataType . INTEGER , null , true , 0 , false ) ; }
Create a tile column column
1,635
public static TileColumn createTileRowColumn ( int index ) { return new TileColumn ( index , TileTable . COLUMN_TILE_ROW , GeoPackageDataType . INTEGER , null , true , 0 , false ) ; }
Create a tile row column
1,636
public static TileColumn createTileDataColumn ( int index ) { return new TileColumn ( index , TileTable . COLUMN_TILE_DATA , GeoPackageDataType . BLOB , null , true , null , false ) ; }
Create a tile data column
1,637
public static void deleteTableExtensions ( GeoPackageCore geoPackage , String table ) { NGAExtensions . deleteTableExtensions ( geoPackage , table ) ; deleteRTreeSpatialIndex ( geoPackage , table ) ; deleteRelatedTables ( geoPackage , table ) ; deleteGriddedCoverage ( geoPackage , table ) ; deleteSchema ( geoPackage , table ) ; deleteMetadata ( geoPackage , table ) ; delete ( geoPackage , table ) ; }
Delete all table extensions for the table within the GeoPackage
1,638
private static void delete ( GeoPackageCore geoPackage , String table ) { ExtensionsDao extensionsDao = geoPackage . getExtensionsDao ( ) ; try { if ( extensionsDao . isTableExists ( ) ) { extensionsDao . deleteByTableName ( table ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete Table extensions. GeoPackage: " + geoPackage . getName ( ) + ", Table: " + table , e ) ; } }
Delete the extensions for the table
1,639
private static void delete ( GeoPackageCore geoPackage ) { ExtensionsDao extensionsDao = geoPackage . getExtensionsDao ( ) ; try { if ( extensionsDao . isTableExists ( ) ) { geoPackage . dropTable ( extensionsDao . getTableName ( ) ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete all extensions. GeoPackage: " + geoPackage . getName ( ) , e ) ; } }
Delete the extensions
1,640
public static void deleteRTreeSpatialIndex ( GeoPackageCore geoPackage , String table ) { RTreeIndexCoreExtension rTreeIndexExtension = getRTreeIndexExtension ( geoPackage ) ; if ( rTreeIndexExtension . has ( table ) ) { rTreeIndexExtension . delete ( table ) ; } }
Delete the RTree Spatial extension for the table
1,641
public static void deleteRTreeSpatialIndexExtension ( GeoPackageCore geoPackage ) { RTreeIndexCoreExtension rTreeIndexExtension = getRTreeIndexExtension ( geoPackage ) ; if ( rTreeIndexExtension . has ( ) ) { rTreeIndexExtension . deleteAll ( ) ; } }
Delete the RTree Spatial extension
1,642
private static RTreeIndexCoreExtension getRTreeIndexExtension ( GeoPackageCore geoPackage ) { return new RTreeIndexCoreExtension ( geoPackage ) { public void createMinYFunction ( ) { } public void createMinXFunction ( ) { } public void createMaxYFunction ( ) { } public void createMaxXFunction ( ) { } public void createIsEmptyFunction ( ) { } } ; }
Get a RTree Index Extension used only for deletions
1,643
public static void deleteRelatedTables ( GeoPackageCore geoPackage , String table ) { RelatedTablesCoreExtension relatedTablesExtension = getRelatedTableExtension ( geoPackage ) ; if ( relatedTablesExtension . has ( ) ) { relatedTablesExtension . removeRelationships ( table ) ; } }
Delete the Related Tables extensions for the table
1,644
public static void deleteRelatedTablesExtension ( GeoPackageCore geoPackage ) { RelatedTablesCoreExtension relatedTablesExtension = getRelatedTableExtension ( geoPackage ) ; if ( relatedTablesExtension . has ( ) ) { relatedTablesExtension . removeExtension ( ) ; } }
Delete the Related Tables extension
1,645
private static RelatedTablesCoreExtension getRelatedTableExtension ( GeoPackageCore geoPackage ) { return new RelatedTablesCoreExtension ( geoPackage ) { public String getPrimaryKeyColumnName ( String tableName ) { return null ; } } ; }
Get a Related Table Extension used only for deletions
1,646
public static void deleteGriddedCoverage ( GeoPackageCore geoPackage , String table ) { if ( geoPackage . isTableType ( ContentsDataType . GRIDDED_COVERAGE , table ) ) { GriddedTileDao griddedTileDao = geoPackage . getGriddedTileDao ( ) ; GriddedCoverageDao griddedCoverageDao = geoPackage . getGriddedCoverageDao ( ) ; ExtensionsDao extensionsDao = geoPackage . getExtensionsDao ( ) ; try { if ( griddedTileDao . isTableExists ( ) ) { griddedTileDao . delete ( table ) ; } if ( griddedCoverageDao . isTableExists ( ) ) { griddedCoverageDao . delete ( table ) ; } if ( extensionsDao . isTableExists ( ) ) { extensionsDao . deleteByExtension ( CoverageDataCore . EXTENSION_NAME , table ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete Table Index. GeoPackage: " + geoPackage . getName ( ) + ", Table: " + table , e ) ; } } }
Delete the Gridded Coverage extensions for the table
1,647
public static void deleteGriddedCoverageExtension ( GeoPackageCore geoPackage ) { List < String > coverageTables = geoPackage . getTables ( ContentsDataType . GRIDDED_COVERAGE ) ; for ( String table : coverageTables ) { geoPackage . deleteTable ( table ) ; } GriddedTileDao griddedTileDao = geoPackage . getGriddedTileDao ( ) ; GriddedCoverageDao griddedCoverageDao = geoPackage . getGriddedCoverageDao ( ) ; ExtensionsDao extensionsDao = geoPackage . getExtensionsDao ( ) ; try { if ( griddedTileDao . isTableExists ( ) ) { geoPackage . dropTable ( griddedTileDao . getTableName ( ) ) ; } if ( griddedCoverageDao . isTableExists ( ) ) { geoPackage . dropTable ( griddedCoverageDao . getTableName ( ) ) ; } if ( extensionsDao . isTableExists ( ) ) { extensionsDao . deleteByExtension ( CoverageDataCore . EXTENSION_NAME ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete Gridded Coverage extension and tables. GeoPackage: " + geoPackage . getName ( ) , e ) ; } }
Delete the Gridded Coverage extension
1,648
public static void deleteSchema ( GeoPackageCore geoPackage , String table ) { DataColumnsDao dataColumnsDao = geoPackage . getDataColumnsDao ( ) ; try { if ( dataColumnsDao . isTableExists ( ) ) { dataColumnsDao . deleteByTableName ( table ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete Schema extension. GeoPackage: " + geoPackage . getName ( ) + ", Table: " + table , e ) ; } }
Delete the Schema extensions for the table
1,649
public static void deleteSchemaExtension ( GeoPackageCore geoPackage ) { SchemaExtension schemaExtension = new SchemaExtension ( geoPackage ) ; if ( schemaExtension . has ( ) ) { schemaExtension . removeExtension ( ) ; } }
Delete the Schema extension
1,650
public static void deleteMetadata ( GeoPackageCore geoPackage , String table ) { MetadataReferenceDao metadataReferenceDao = geoPackage . getMetadataReferenceDao ( ) ; try { if ( metadataReferenceDao . isTableExists ( ) ) { metadataReferenceDao . deleteByTableName ( table ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete Metadata extension. GeoPackage: " + geoPackage . getName ( ) + ", Table: " + table , e ) ; } }
Delete the Metadata extensions for the table
1,651
public static void deleteMetadataExtension ( GeoPackageCore geoPackage ) { MetadataExtension metadataExtension = new MetadataExtension ( geoPackage ) ; if ( metadataExtension . has ( ) ) { metadataExtension . removeExtension ( ) ; } }
Delete the Metadata extension
1,652
public static void deleteCrsWktExtension ( GeoPackageCore geoPackage ) { CrsWktExtension crsWktExtension = new CrsWktExtension ( geoPackage ) ; if ( crsWktExtension . has ( ) ) { crsWktExtension . removeExtension ( ) ; } }
Delete the WKT for Coordinate Reference Systems extension
1,653
private static TileMatrix getTileMatrixAtLengthIndex ( List < TileMatrix > tileMatrices , int index ) { return tileMatrices . get ( tileMatrices . size ( ) - index - 1 ) ; }
Get the tile matrix represented by the current length index
1,654
public static Long getApproximateZoomLevel ( double [ ] widths , double [ ] heights , List < TileMatrix > tileMatrices , double length ) { return getApproximateZoomLevel ( widths , heights , tileMatrices , length , length ) ; }
Get the approximate zoom level for the provided length in the default units . Tiles may or may not exist for the returned zoom level . The approximate zoom level is determined using a factor of 2 from the zoom levels with tiles .
1,655
public static Long getApproximateZoomLevel ( double [ ] widths , double [ ] heights , List < TileMatrix > tileMatrices , double width , double height ) { Long widthZoomLevel = getApproximateZoomLevel ( widths , tileMatrices , width ) ; Long heightZoomLevel = getApproximateZoomLevel ( heights , tileMatrices , height ) ; Long expectedZoomLevel ; if ( widthZoomLevel == null ) { expectedZoomLevel = heightZoomLevel ; } else if ( heightZoomLevel == null ) { expectedZoomLevel = widthZoomLevel ; } else { expectedZoomLevel = Math . max ( widthZoomLevel , heightZoomLevel ) ; } return expectedZoomLevel ; }
Get the approximate zoom level for the provided width and height in the default units . Tiles may or may not exist for the returned zoom level . The approximate zoom level is determined using a factor of 2 from the zoom levels with tiles .
1,656
private static Long getApproximateZoomLevel ( double [ ] lengths , List < TileMatrix > tileMatrices , double length ) { Long lengthZoomLevel = null ; double minLength = lengths [ 0 ] ; double maxLength = lengths [ lengths . length - 1 ] ; if ( length < minLength ) { double levelsIn = Math . log ( length / minLength ) / Math . log ( .5 ) ; long zoomAbove = ( long ) Math . floor ( levelsIn ) ; long zoomBelow = ( long ) Math . ceil ( levelsIn ) ; double lengthAbove = minLength * Math . pow ( .5 , zoomAbove ) ; double lengthBelow = minLength * Math . pow ( .5 , zoomBelow ) ; lengthZoomLevel = tileMatrices . get ( tileMatrices . size ( ) - 1 ) . getZoomLevel ( ) ; if ( lengthAbove - length <= length - lengthBelow ) { lengthZoomLevel += zoomAbove ; } else { lengthZoomLevel += zoomBelow ; } } else if ( length > maxLength ) { double levelsOut = Math . log ( length / maxLength ) / Math . log ( 2 ) ; long zoomAbove = ( long ) Math . ceil ( levelsOut ) ; long zoomBelow = ( long ) Math . floor ( levelsOut ) ; double lengthAbove = maxLength * Math . pow ( 2 , zoomAbove ) ; double lengthBelow = maxLength * Math . pow ( 2 , zoomBelow ) ; lengthZoomLevel = tileMatrices . get ( 0 ) . getZoomLevel ( ) ; if ( length - lengthBelow <= lengthAbove - length ) { lengthZoomLevel -= zoomBelow ; } else { lengthZoomLevel -= zoomAbove ; } } else { int lengthIndex = Arrays . binarySearch ( lengths , length ) ; if ( lengthIndex < 0 ) { lengthIndex = ( lengthIndex + 1 ) * - 1 ; } double zoomDistance = Math . log ( length / lengths [ lengthIndex ] ) / Math . log ( .5 ) ; long zoomLevelAbove = getTileMatrixAtLengthIndex ( tileMatrices , lengthIndex ) . getZoomLevel ( ) ; zoomLevelAbove += Math . round ( zoomDistance ) ; lengthZoomLevel = zoomLevelAbove ; } return lengthZoomLevel ; }
Get the approximate zoom level for length using the factor of 2 rule between zoom levels
1,657
public static double getMaxLength ( double [ ] widths , double [ ] heights ) { double maxWidth = getMaxLength ( widths ) ; double maxHeight = getMaxLength ( heights ) ; double maxLength = Math . min ( maxWidth , maxHeight ) ; return maxLength ; }
Get the max distance length that matches the tile widths and heights
1,658
public static double getMinLength ( double [ ] widths , double [ ] heights ) { double minWidth = getMinLength ( widths ) ; double minHeight = getMinLength ( heights ) ; double minLength = Math . max ( minWidth , minHeight ) ; return minLength ; }
Get the min distance length that matches the tile widths and heights
1,659
public GriddedTile query ( String tableName , long tileId ) { GriddedTile griddedTile = null ; try { QueryBuilder < GriddedTile , Long > qb = queryBuilder ( ) ; qb . where ( ) . eq ( GriddedTile . COLUMN_TABLE_NAME , tableName ) . and ( ) . eq ( GriddedTile . COLUMN_TABLE_ID , tileId ) ; PreparedQuery < GriddedTile > query = qb . prepare ( ) ; griddedTile = queryForFirst ( query ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for Gridded Tile objects by Table Name: " + tableName + ", Tile Id: " + tileId , e ) ; } return griddedTile ; }
Query by table name and table id
1,660
public GeoPackageDataType getDataType ( String type ) { GeoPackageDataType dataType = null ; try { dataType = GeoPackageDataType . fromName ( type ) ; } catch ( IllegalArgumentException dataTypeException ) { try { GeometryType . fromName ( type ) ; dataType = GeoPackageDataType . BLOB ; } catch ( IllegalArgumentException geometryException ) { throw new GeoPackageException ( "Unsupported column data type " + type , dataTypeException ) ; } } return dataType ; }
Get the data type of the string type .
1,661
public void setColor ( String color ) { setRed ( ColorUtils . getRed ( color ) ) ; setGreen ( ColorUtils . getGreen ( color ) ) ; setBlue ( ColorUtils . getBlue ( color ) ) ; String alpha = ColorUtils . getAlpha ( color ) ; if ( alpha != null ) { setAlpha ( alpha ) ; } }
Set the color in hex
1,662
public void setColor ( String red , String green , String blue , String alpha ) { setColor ( red , green , blue ) ; setAlpha ( alpha ) ; }
Set the color with individual hex colors and alpha
1,663
public void setColor ( int color ) { setRed ( ColorUtils . getRed ( color ) ) ; setGreen ( ColorUtils . getGreen ( color ) ) ; setBlue ( ColorUtils . getBlue ( color ) ) ; if ( color > 16777215 || color < 0 ) { setAlpha ( ColorUtils . getAlpha ( color ) ) ; } }
Set the color as a single integer
1,664
public int index ( boolean force ) { int count = 0 ; if ( force || ! isIndexed ( ) ) { getOrCreateExtension ( ) ; TableIndex tableIndex = getOrCreateTableIndex ( ) ; createOrClearGeometryIndices ( ) ; geoPackage . unindexGeometryIndexTable ( ) ; count = indexTable ( tableIndex ) ; geoPackage . indexGeometryIndexTable ( ) ; } return count ; }
Index the feature table
1,665
protected boolean index ( TableIndex tableIndex , long geomId , GeoPackageGeometryData geomData ) { boolean indexed = false ; if ( geomData != null ) { GeometryEnvelope envelope = geomData . getOrBuildEnvelope ( ) ; if ( envelope != null ) { GeometryIndex geometryIndex = geometryIndexDao . populate ( tableIndex , geomId , envelope ) ; try { geometryIndexDao . createOrUpdate ( geometryIndex ) ; indexed = true ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to create or update Geometry Index. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Geom Id: " + geomId , e ) ; } } } return indexed ; }
Index the geometry id and geometry data
1,666
protected void updateLastIndexed ( ) { TableIndex tableIndex = new TableIndex ( ) ; tableIndex . setTableName ( tableName ) ; tableIndex . setLastIndexed ( new Date ( ) ) ; try { tableIndexDao . createOrUpdate ( tableIndex ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to update last indexed date. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName , e ) ; } }
Update the last indexed time
1,667
public boolean deleteIndex ( ) { boolean deleted = false ; ExtensionsDao extensionsDao = geoPackage . getExtensionsDao ( ) ; TableIndexDao tableIndexDao = geoPackage . getTableIndexDao ( ) ; try { if ( tableIndexDao . isTableExists ( ) ) { deleted = tableIndexDao . deleteByIdCascade ( tableName ) > 0 ; } if ( extensionsDao . isTableExists ( ) ) { deleted = extensionsDao . deleteByExtension ( EXTENSION_NAME , tableName ) > 0 || deleted ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete Table Index. GeoPackage: " + geoPackage . getName ( ) + ", Table: " + tableName , e ) ; } return deleted ; }
Delete the feature table index
1,668
public int deleteIndex ( long geomId ) { int deleted = 0 ; GeometryIndexKey key = new GeometryIndexKey ( tableName , geomId ) ; try { deleted = geometryIndexDao . deleteById ( key ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to delete index, GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Geometry Id: " + geomId , e ) ; } return deleted ; }
Delete the index for the geometry id
1,669
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 ; }
Determine if the feature table is indexed
1,670
private TableIndex getOrCreateTableIndex ( ) { TableIndex tableIndex = getTableIndex ( ) ; if ( tableIndex == null ) { try { if ( ! tableIndexDao . isTableExists ( ) ) { geoPackage . createTableIndexTable ( ) ; } tableIndex = new TableIndex ( ) ; tableIndex . setTableName ( tableName ) ; tableIndex . setLastIndexed ( null ) ; tableIndexDao . create ( tableIndex ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to create Table Index for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } } return tableIndex ; }
Get or create if needed the table index
1,671
public TableIndex getTableIndex ( ) { TableIndex tableIndex = null ; try { if ( tableIndexDao . isTableExists ( ) ) { tableIndex = tableIndexDao . queryForId ( tableName ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for Table Index for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return tableIndex ; }
Get the table index
1,672
private int clearGeometryIndices ( ) { int deleted = 0 ; DeleteBuilder < GeometryIndex , GeometryIndexKey > db = geometryIndexDao . deleteBuilder ( ) ; try { db . where ( ) . eq ( GeometryIndex . COLUMN_TABLE_NAME , tableName ) ; PreparedDelete < GeometryIndex > deleteQuery = db . prepare ( ) ; deleted = geometryIndexDao . delete ( deleteQuery ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to clear Geometry Index rows for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return deleted ; }
Clear the Geometry Indices for the table name
1,673
private boolean createGeometryIndexTable ( ) { boolean created = false ; try { if ( ! geometryIndexDao . isTableExists ( ) ) { created = geoPackage . createGeometryIndexTable ( ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to create Geometry Index table for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return created ; }
Create the Geometry Index Table if needed
1,674
public BoundingBox getBoundingBox ( ) { GenericRawResults < Object [ ] > results = null ; Object [ ] values = null ; try { results = geometryIndexDao . queryRaw ( "SELECT MIN(" + GeometryIndex . COLUMN_MIN_X + "), MIN(" + GeometryIndex . COLUMN_MIN_Y + "), MAX(" + GeometryIndex . COLUMN_MAX_X + "), MAX(" + GeometryIndex . COLUMN_MAX_Y + ") FROM " + GeometryIndex . TABLE_NAME + " WHERE " + GeometryIndex . COLUMN_TABLE_NAME + " = ?" , new DataType [ ] { DataType . DOUBLE , DataType . DOUBLE , DataType . DOUBLE , DataType . DOUBLE } , tableName ) ; values = results . getFirstResult ( ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for indexed feature bounds: " + tableName , e ) ; } finally { if ( results != null ) { try { results . close ( ) ; } catch ( IOException e ) { logger . log ( Level . WARNING , "Failed to close bounds query results" , e ) ; } } } BoundingBox boundingBox = new BoundingBox ( ( double ) values [ 0 ] , ( double ) values [ 1 ] , ( double ) values [ 2 ] , ( double ) values [ 3 ] ) ; return boundingBox ; }
Query for the bounds of the feature table index
1,675
public QueryBuilder < GeometryIndex , GeometryIndexKey > queryBuilder ( ) { QueryBuilder < GeometryIndex , GeometryIndexKey > qb = geometryIndexDao . queryBuilder ( ) ; try { qb . where ( ) . eq ( GeometryIndex . COLUMN_TABLE_NAME , tableName ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to build query for all Geometry Indices. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return qb ; }
Build a query builder to query for all Geometry Index objects
1,676
public long count ( BoundingBox boundingBox ) { GeometryEnvelope envelope = boundingBox . buildEnvelope ( ) ; long count = count ( envelope ) ; return count ; }
Query for Geometry Index count within the bounding box projected correctly
1,677
public CloseableIterator < GeometryIndex > query ( GeometryEnvelope envelope ) { CloseableIterator < GeometryIndex > geometryIndices = null ; QueryBuilder < GeometryIndex , GeometryIndexKey > qb = queryBuilder ( envelope ) ; try { geometryIndices = qb . iterator ( ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for Geometry Indices. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return geometryIndices ; }
Query for Geometry Index objects within the Geometry Envelope
1,678
public long count ( GeometryEnvelope envelope ) { long count = 0 ; QueryBuilder < GeometryIndex , GeometryIndexKey > qb = queryBuilder ( envelope ) ; try { count = qb . countOf ( ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for Geometry Index count. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return count ; }
Query for Geometry Index count within the Geometry Envelope
1,679
public QueryBuilder < GeometryIndex , GeometryIndexKey > queryBuilder ( GeometryEnvelope envelope ) { QueryBuilder < GeometryIndex , GeometryIndexKey > qb = geometryIndexDao . queryBuilder ( ) ; try { double minX = envelope . getMinX ( ) - tolerance ; double maxX = envelope . getMaxX ( ) + tolerance ; double minY = envelope . getMinY ( ) - tolerance ; double maxY = envelope . getMaxY ( ) + tolerance ; Where < GeometryIndex , GeometryIndexKey > where = qb . where ( ) ; where . eq ( GeometryIndex . COLUMN_TABLE_NAME , tableName ) . and ( ) . le ( GeometryIndex . COLUMN_MIN_X , maxX ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_X , minX ) . and ( ) . le ( GeometryIndex . COLUMN_MIN_Y , maxY ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_Y , minY ) ; if ( envelope . hasZ ( ) ) { double minZ = envelope . getMinZ ( ) - tolerance ; double maxZ = envelope . getMaxZ ( ) + tolerance ; where . and ( ) . le ( GeometryIndex . COLUMN_MIN_Z , maxZ ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_Z , minZ ) ; } if ( envelope . hasM ( ) ) { double minM = envelope . getMinM ( ) - tolerance ; double maxM = envelope . getMaxM ( ) + tolerance ; where . and ( ) . le ( GeometryIndex . COLUMN_MIN_M , maxM ) . and ( ) . ge ( GeometryIndex . COLUMN_MAX_M , minM ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to build query for Geometry Indices. GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return qb ; }
Build a query builder to query for Geometry Index objects within the Geometry Envelope
1,680
public Extensions getOrCreate ( String tableName , String columnName , GeometryType geometryType ) { String extensionName = getExtensionName ( geometryType ) ; Extensions extension = getOrCreate ( extensionName , tableName , columnName , GEOMETRY_TYPES_EXTENSION_DEFINITION , ExtensionScopeType . READ_WRITE ) ; return extension ; }
Get or create the extension non - linear geometry type
1,681
public boolean has ( String tableName , String columnName , GeometryType geometryType ) { String extensionName = getExtensionName ( geometryType ) ; boolean exists = has ( extensionName , tableName , columnName ) ; return exists ; }
Determine if the GeoPackage has the extension non - linear geometry type
1,682
public static boolean isExtension ( GeometryType geometryType ) { return GeometryCodes . getCode ( geometryType ) > GeometryCodes . getCode ( GeometryType . GEOMETRYCOLLECTION ) ; }
Determine if the geometry type is an extension
1,683
public static boolean isNonStandard ( GeometryType geometryType ) { return GeometryCodes . getCode ( geometryType ) > GeometryCodes . getCode ( GeometryType . SURFACE ) ; }
Determine if the geometry type is non standard
1,684
public static boolean isGeoPackageExtension ( GeometryType geometryType ) { return GeometryCodes . getCode ( geometryType ) >= GeometryCodes . getCode ( GeometryType . CIRCULARSTRING ) && GeometryCodes . getCode ( geometryType ) <= GeometryCodes . getCode ( GeometryType . SURFACE ) ; }
Determine if the geometry type is a GeoPackage extension
1,685
public static String getExtensionName ( GeometryType geometryType ) { if ( ! isExtension ( geometryType ) ) { throw new GeoPackageException ( GeometryType . class . getSimpleName ( ) + " is not an extension: " + geometryType . getName ( ) ) ; } if ( ! isGeoPackageExtension ( geometryType ) ) { throw new GeoPackageException ( GeometryType . class . getSimpleName ( ) + " is not a GeoPackage extension, User-Defined requires an author: " + geometryType . getName ( ) ) ; } String extensionName = GeoPackageConstants . GEO_PACKAGE_EXTENSION_AUTHOR + Extensions . EXTENSION_NAME_DIVIDER + GeoPackageConstants . GEOMETRY_EXTENSION_PREFIX + Extensions . EXTENSION_NAME_DIVIDER + geometryType . getName ( ) ; return extensionName ; }
Get the extension name of a GeoPackage extension Geometry
1,686
public Extensions getOrCreate ( String tableName , String columnName , String author , GeometryType geometryType ) { String extensionName = getExtensionName ( author , geometryType ) ; String description = isGeoPackageExtension ( geometryType ) ? GEOMETRY_TYPES_EXTENSION_DEFINITION : USER_GEOMETRY_TYPES_EXTENSION_DEFINITION ; Extensions extension = getOrCreate ( extensionName , tableName , columnName , description , ExtensionScopeType . READ_WRITE ) ; return extension ; }
Get or create the extension user defined geometry type
1,687
protected void duplicateCheck ( int index , Integer previousIndex , String column ) { if ( previousIndex != null ) { throw new GeoPackageException ( "More than one " + column + " column was found for table '" + tableName + "'. Index " + previousIndex + " and " + index ) ; } }
Check for duplicate column names
1,688
protected void typeCheck ( GeoPackageDataType expected , TColumn column ) { GeoPackageDataType actual = column . getDataType ( ) ; if ( actual == null || ! actual . equals ( expected ) ) { throw new GeoPackageException ( "Unexpected " + column . getName ( ) + " column data type was found for table '" + tableName + "', expected: " + expected . name ( ) + ", actual: " + ( actual != null ? actual . name ( ) : "null" ) ) ; } }
Check for the expected data type
1,689
protected void missingCheck ( Integer index , String column ) { if ( index == null ) { throw new GeoPackageException ( "No " + column + " column was found for table '" + tableName + "'" ) ; } }
Check for missing columns
1,690
public int getColumnIndex ( String columnName ) { Integer index = nameToIndex . get ( columnName ) ; if ( index == null ) { throw new GeoPackageException ( "Column does not exist in table '" + tableName + "', column: " + columnName ) ; } return index ; }
Get the column index of the column name
1,691
public TColumn getPkColumn ( ) { TColumn column = null ; if ( hasPkColumn ( ) ) { column = columns . get ( pkIndex ) ; } return column ; }
Get the primary key column
1,692
public List < TColumn > columnsOfType ( GeoPackageDataType type ) { List < TColumn > columnsOfType = new ArrayList < > ( ) ; for ( TColumn column : columns ) { if ( column . getDataType ( ) == type ) { columnsOfType . add ( column ) ; } } return columnsOfType ; }
Get the columns with the provided data type
1,693
public static boolean hasGeoPackageExtension ( File file ) { String extension = GeoPackageIOUtils . getFileExtension ( file ) ; boolean isGeoPackage = extension != null && ( extension . equalsIgnoreCase ( GeoPackageConstants . GEOPACKAGE_EXTENSION ) || extension . equalsIgnoreCase ( GeoPackageConstants . GEOPACKAGE_EXTENDED_EXTENSION ) ) ; return isGeoPackage ; }
Check the file extension to see if it is a GeoPackage
1,694
public static void validateGeoPackageExtension ( File file ) { if ( ! hasGeoPackageExtension ( file ) ) { throw new GeoPackageException ( "GeoPackage database file '" + file + "' does not have a valid extension of '" + GeoPackageConstants . GEOPACKAGE_EXTENSION + "' or '" + GeoPackageConstants . GEOPACKAGE_EXTENDED_EXTENSION + "'" ) ; } }
Validate the extension file as a GeoPackage
1,695
public static boolean hasMinimumTables ( GeoPackageCore geoPackage ) { boolean hasMinimum ; try { hasMinimum = geoPackage . getSpatialReferenceSystemDao ( ) . isTableExists ( ) && geoPackage . getContentsDao ( ) . isTableExists ( ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to check for required minimum GeoPackage tables. GeoPackage Name: " + geoPackage . getName ( ) ) ; } return hasMinimum ; }
Check the GeoPackage for the minimum required tables
1,696
public static void validateMinimumTables ( GeoPackageCore geoPackage ) { if ( ! hasMinimumTables ( geoPackage ) ) { throw new GeoPackageException ( "Invalid GeoPackage. Does not contain required tables: " + SpatialReferenceSystem . TABLE_NAME + " & " + Contents . TABLE_NAME + ", GeoPackage Name: " + geoPackage . getName ( ) ) ; } }
Validate the GeoPackage has the minimum required tables
1,697
public int deleteByExtension ( String extensionName ) throws SQLException { DeleteBuilder < Extensions , Void > db = deleteBuilder ( ) ; db . where ( ) . eq ( Extensions . COLUMN_EXTENSION_NAME , extensionName ) ; int deleted = db . delete ( ) ; return deleted ; }
Delete by extension name
1,698
public int deleteByExtension ( String extensionName , String tableName ) throws SQLException { DeleteBuilder < Extensions , Void > db = deleteBuilder ( ) ; setUniqueWhere ( db . where ( ) , extensionName , true , tableName , false , null ) ; int deleted = db . delete ( ) ; return deleted ; }
Delete by extension name and table name
1,699
public List < Extensions > queryByExtension ( String extensionName ) throws SQLException { QueryBuilder < Extensions , Void > qb = queryBuilder ( ) ; setUniqueWhere ( qb . where ( ) , extensionName , false , null , false , null ) ; List < Extensions > extensions = qb . query ( ) ; return extensions ; }
Query by extension name