idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
1,500 | public static Object getFloatValue ( Result result , int index , GeoPackageDataType dataType ) { Object value = null ; if ( dataType == null ) { dataType = GeoPackageDataType . DOUBLE ; } switch ( dataType ) { case FLOAT : value = result . getFloat ( index ) ; break ; case DOUBLE : case REAL : case INTEGER : case INT : value = result . getDouble ( index ) ; break ; default : throw new GeoPackageException ( "Data Type " + dataType + " is not a float type" ) ; } if ( result . wasNull ( ) ) { value = null ; } return value ; } | Get the float value from the cursor of the column |
1,501 | public static Object buildSingleResult ( Result result , int column , GeoPackageDataType dataType ) { Object value = null ; try { if ( result . moveToNext ( ) ) { value = result . getValue ( column , dataType ) ; } } finally { result . close ( ) ; } return value ; } | Build single result value from the column |
1,502 | public static List < Object > buildSingleColumnResults ( Result result , int column , GeoPackageDataType dataType , Integer limit ) { List < Object > results = new ArrayList < > ( ) ; try { while ( result . moveToNext ( ) ) { Object value = result . getValue ( column , dataType ) ; results . add ( value ) ; if ( limit != null && results . size ( ) >= limit ) { break ; } } } finally { result . close ( ) ; } return results ; } | Build single column result rows from the result and the optional limit |
1,503 | public static List < List < Object > > buildResults ( Result result , GeoPackageDataType [ ] dataTypes , Integer limit ) { List < List < Object > > results = new ArrayList < > ( ) ; try { int columns = result . getColumnCount ( ) ; while ( result . moveToNext ( ) ) { List < Object > row = new ArrayList < > ( ) ; for ( int i = 0 ; i < columns ; i ++ ) { row . add ( result . getValue ( i , dataTypes != null ? dataTypes [ i ] : null ) ) ; } results . add ( row ) ; if ( limit != null && results . size ( ) >= limit ) { break ; } } } finally { result . close ( ) ; } return results ; } | Build the result rows from the result and the optional limit |
1,504 | protected Extensions getOrCreate ( String extensionName , String tableName , String columnName , String definition , ExtensionScopeType scopeType ) { Extensions extension = get ( extensionName , tableName , columnName ) ; if ( extension == null ) { try { if ( ! extensionsDao . isTableExists ( ) ) { geoPackage . createExtensionsTable ( ) ; } extension = new Extensions ( ) ; extension . setTableName ( tableName ) ; extension . setColumnName ( columnName ) ; extension . setExtensionName ( extensionName ) ; extension . setDefinition ( definition ) ; extension . setScope ( scopeType ) ; extensionsDao . create ( extension ) ; } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to create '" + extensionName + "' extension for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } } return extension ; } | Get the extension or create as needed |
1,505 | protected Extensions get ( String extensionName , String tableName , String columnName ) { Extensions extension = null ; try { if ( extensionsDao . isTableExists ( ) ) { extension = extensionsDao . queryByExtension ( extensionName , tableName , columnName ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for '" + extensionName + "' extension for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName + ", Column Name: " + columnName , e ) ; } return extension ; } | Get the extension for the name table name and column name |
1,506 | protected List < Extensions > getExtensions ( String extensionName , String tableName ) { List < Extensions > extensions = null ; try { if ( extensionsDao . isTableExists ( ) ) { extensions = extensionsDao . queryByExtension ( extensionName , tableName ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for '" + extensionName + "' extension for GeoPackage: " + geoPackage . getName ( ) + ", Table Name: " + tableName , e ) ; } return extensions ; } | Get the extension for the name and table name |
1,507 | public static BoundingBox overlap ( BoundingBox boundingBox , BoundingBox boundingBox2 , boolean allowEmpty ) { return boundingBox . overlap ( boundingBox2 , allowEmpty ) ; } | Get the overlapping bounding box between the two bounding boxes |
1,508 | public static float getXPixel ( long width , BoundingBox boundingBox , double longitude ) { double boxWidth = boundingBox . getMaxLongitude ( ) - boundingBox . getMinLongitude ( ) ; double offset = longitude - boundingBox . getMinLongitude ( ) ; double percentage = offset / boxWidth ; float pixel = ( float ) ( percentage * width ) ; return pixel ; } | Get the X pixel for where the longitude fits into the bounding box |
1,509 | public static double getLongitudeFromPixel ( long width , BoundingBox boundingBox , float pixel ) { return getLongitudeFromPixel ( width , boundingBox , boundingBox , pixel ) ; } | Get the longitude from the pixel location bounding box and image width |
1,510 | public static float getYPixel ( long height , BoundingBox boundingBox , double latitude ) { double boxHeight = boundingBox . getMaxLatitude ( ) - boundingBox . getMinLatitude ( ) ; double offset = boundingBox . getMaxLatitude ( ) - latitude ; double percentage = offset / boxHeight ; float pixel = ( float ) ( percentage * height ) ; return pixel ; } | Get the Y pixel for where the latitude fits into the bounding box |
1,511 | public static double getLatitudeFromPixel ( long height , BoundingBox boundingBox , float pixel ) { return getLatitudeFromPixel ( height , boundingBox , boundingBox , pixel ) ; } | Get the latitude from the pixel location bounding box and image height |
1,512 | public static BoundingBox getBoundingBox ( int x , int y , int zoom ) { int tilesPerSide = tilesPerSide ( zoom ) ; double tileWidthDegrees = tileWidthDegrees ( tilesPerSide ) ; double tileHeightDegrees = tileHeightDegrees ( tilesPerSide ) ; double minLon = - 180.0 + ( x * tileWidthDegrees ) ; double maxLon = minLon + tileWidthDegrees ; double maxLat = 90.0 - ( y * tileHeightDegrees ) ; double minLat = maxLat - tileHeightDegrees ; BoundingBox box = new BoundingBox ( minLon , minLat , maxLon , maxLat ) ; return box ; } | Get the tile bounding box from the Google Maps API tile coordinates and zoom level |
1,513 | public static BoundingBox getWebMercatorBoundingBox ( long x , long y , int zoom ) { double tileSize = tileSizeWithZoom ( zoom ) ; double minLon = ( - 1 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) + ( x * tileSize ) ; double maxLon = ( - 1 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) + ( ( x + 1 ) * tileSize ) ; double minLat = ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH - ( ( y + 1 ) * tileSize ) ; double maxLat = ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH - ( y * tileSize ) ; BoundingBox box = new BoundingBox ( minLon , minLat , maxLon , maxLat ) ; return box ; } | Get the Web Mercator tile bounding box from the Google Maps API tile coordinates and zoom level |
1,514 | public static BoundingBox getWebMercatorBoundingBox ( TileGrid tileGrid , int zoom ) { double tileSize = tileSizeWithZoom ( zoom ) ; double minLon = ( - 1 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) + ( tileGrid . getMinX ( ) * tileSize ) ; double maxLon = ( - 1 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) + ( ( tileGrid . getMaxX ( ) + 1 ) * tileSize ) ; double minLat = ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH - ( ( tileGrid . getMaxY ( ) + 1 ) * tileSize ) ; double maxLat = ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH - ( tileGrid . getMinY ( ) * tileSize ) ; BoundingBox box = new BoundingBox ( minLon , minLat , maxLon , maxLat ) ; return box ; } | Get the Web Mercator tile bounding box from the Google Maps API tile grid and zoom level |
1,515 | public static BoundingBox getProjectedBoundingBox ( Projection projection , TileGrid tileGrid , int zoom ) { BoundingBox boundingBox = getWebMercatorBoundingBox ( tileGrid , zoom ) ; if ( projection != null ) { ProjectionTransform transform = webMercator . getTransformation ( projection ) ; boundingBox = boundingBox . transform ( transform ) ; } return boundingBox ; } | Get the Projected tile bounding box from the Google Maps API tile grid and zoom level |
1,516 | public static TileGrid getTileGridFromWGS84 ( Point point , int zoom ) { Projection projection = ProjectionFactory . getProjection ( ProjectionConstants . EPSG_WORLD_GEODETIC_SYSTEM ) ; return getTileGrid ( point , zoom , projection ) ; } | Get the tile grid for the location specified as WGS84 |
1,517 | public static TileGrid getTileGrid ( Point point , int zoom , Projection projection ) { ProjectionTransform toWebMercator = projection . getTransformation ( ProjectionConstants . EPSG_WEB_MERCATOR ) ; Point webMercatorPoint = toWebMercator . transform ( point ) ; BoundingBox boundingBox = new BoundingBox ( webMercatorPoint . getX ( ) , webMercatorPoint . getY ( ) , webMercatorPoint . getX ( ) , webMercatorPoint . getY ( ) ) ; return getTileGrid ( boundingBox , zoom ) ; } | Get the tile grid for the location specified as the projection |
1,518 | public static BoundingBox toWebMercator ( BoundingBox boundingBox ) { double minLatitude = Math . max ( boundingBox . getMinLatitude ( ) , ProjectionConstants . WEB_MERCATOR_MIN_LAT_RANGE ) ; double maxLatitude = Math . min ( boundingBox . getMaxLatitude ( ) , ProjectionConstants . WEB_MERCATOR_MAX_LAT_RANGE ) ; Point lowerLeftPoint = new Point ( false , false , boundingBox . getMinLongitude ( ) , minLatitude ) ; Point upperRightPoint = new Point ( false , false , boundingBox . getMaxLongitude ( ) , maxLatitude ) ; ProjectionTransform toWebMercator = ProjectionFactory . getProjection ( ProjectionConstants . EPSG_WORLD_GEODETIC_SYSTEM ) . getTransformation ( ProjectionConstants . EPSG_WEB_MERCATOR ) ; lowerLeftPoint = toWebMercator . transform ( lowerLeftPoint ) ; upperRightPoint = toWebMercator . transform ( upperRightPoint ) ; BoundingBox mercatorBox = new BoundingBox ( lowerLeftPoint . getX ( ) , lowerLeftPoint . getY ( ) , upperRightPoint . getX ( ) , upperRightPoint . getY ( ) ) ; return mercatorBox ; } | Convert the bounding box coordinates to a new web mercator bounding box |
1,519 | public static double zoomLevelOfTileSize ( double tileSize ) { double tilesPerSide = ( 2 * ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH ) / tileSize ; double zoom = Math . log ( tilesPerSide ) / Math . log ( 2 ) ; return zoom ; } | Get the zoom level from the tile size in meters |
1,520 | public static int getYAsOppositeTileFormat ( int zoom , int y ) { int tilesPerSide = tilesPerSide ( zoom ) ; int oppositeY = tilesPerSide - y - 1 ; return oppositeY ; } | Get the standard y tile location as TMS or a TMS y location as standard |
1,521 | public static TileGrid getTileGrid ( BoundingBox totalBox , long matrixWidth , long matrixHeight , BoundingBox boundingBox ) { long minColumn = getTileColumn ( totalBox , matrixWidth , boundingBox . getMinLongitude ( ) ) ; long maxColumn = getTileColumn ( totalBox , matrixWidth , boundingBox . getMaxLongitude ( ) ) ; if ( minColumn < matrixWidth && maxColumn >= 0 ) { if ( minColumn < 0 ) { minColumn = 0 ; } if ( maxColumn >= matrixWidth ) { maxColumn = matrixWidth - 1 ; } } long maxRow = getTileRow ( totalBox , matrixHeight , boundingBox . getMinLatitude ( ) ) ; long minRow = getTileRow ( totalBox , matrixHeight , boundingBox . getMaxLatitude ( ) ) ; if ( minRow < matrixHeight && maxRow >= 0 ) { if ( minRow < 0 ) { minRow = 0 ; } if ( maxRow >= matrixHeight ) { maxRow = matrixHeight - 1 ; } } TileGrid tileGrid = new TileGrid ( minColumn , minRow , maxColumn , maxRow ) ; return tileGrid ; } | Get the tile grid |
1,522 | public static long getTileColumn ( BoundingBox totalBox , long matrixWidth , double longitude ) { double minX = totalBox . getMinLongitude ( ) ; double maxX = totalBox . getMaxLongitude ( ) ; long tileId ; if ( longitude < minX ) { tileId = - 1 ; } else if ( longitude >= maxX ) { tileId = matrixWidth ; } else { double matrixWidthMeters = totalBox . getMaxLongitude ( ) - totalBox . getMinLongitude ( ) ; double tileWidth = matrixWidthMeters / matrixWidth ; tileId = ( long ) ( ( longitude - minX ) / tileWidth ) ; } return tileId ; } | Get the tile column of the longitude in constant units |
1,523 | public static long getTileRow ( BoundingBox totalBox , long matrixHeight , double latitude ) { double minY = totalBox . getMinLatitude ( ) ; double maxY = totalBox . getMaxLatitude ( ) ; long tileId ; if ( latitude <= minY ) { tileId = matrixHeight ; } else if ( latitude > maxY ) { tileId = - 1 ; } else { double matrixHeightMeters = totalBox . getMaxLatitude ( ) - totalBox . getMinLatitude ( ) ; double tileHeight = matrixHeightMeters / matrixHeight ; tileId = ( long ) ( ( maxY - latitude ) / tileHeight ) ; } return tileId ; } | Get the tile row of the latitude in constant units |
1,524 | public static BoundingBox getBoundingBox ( BoundingBox totalBox , TileMatrix tileMatrix , long tileColumn , long tileRow ) { return getBoundingBox ( totalBox , tileMatrix . getMatrixWidth ( ) , tileMatrix . getMatrixHeight ( ) , tileColumn , tileRow ) ; } | Get the bounding box of the tile column and row in the tile matrix using the total bounding box with constant units |
1,525 | public static BoundingBox getBoundingBox ( BoundingBox totalBox , long tileMatrixWidth , long tileMatrixHeight , long tileColumn , long tileRow ) { TileGrid tileGrid = new TileGrid ( tileColumn , tileRow , tileColumn , tileRow ) ; return getBoundingBox ( totalBox , tileMatrixWidth , tileMatrixHeight , tileGrid ) ; } | Get the bounding box of the tile column and row in the tile width and height bounds using the total bounding box with constant units |
1,526 | public static BoundingBox getBoundingBox ( BoundingBox totalBox , TileMatrix tileMatrix , TileGrid tileGrid ) { return getBoundingBox ( totalBox , tileMatrix . getMatrixWidth ( ) , tileMatrix . getMatrixHeight ( ) , tileGrid ) ; } | Get the bounding box of the tile grid in the tile matrix using the total bounding box with constant units |
1,527 | public static BoundingBox getBoundingBox ( BoundingBox totalBox , long tileMatrixWidth , long tileMatrixHeight , TileGrid tileGrid ) { double matrixMinX = totalBox . getMinLongitude ( ) ; double matrixMaxX = totalBox . getMaxLongitude ( ) ; double matrixWidth = matrixMaxX - matrixMinX ; double tileWidth = matrixWidth / tileMatrixWidth ; double minLon = matrixMinX + ( tileWidth * tileGrid . getMinX ( ) ) ; double maxLon = matrixMinX + ( tileWidth * ( tileGrid . getMaxX ( ) + 1 ) ) ; double matrixMinY = totalBox . getMinLatitude ( ) ; double matrixMaxY = totalBox . getMaxLatitude ( ) ; double matrixHeight = matrixMaxY - matrixMinY ; double tileHeight = matrixHeight / tileMatrixHeight ; double maxLat = matrixMaxY - ( tileHeight * tileGrid . getMinY ( ) ) ; double minLat = matrixMaxY - ( tileHeight * ( tileGrid . getMaxY ( ) + 1 ) ) ; BoundingBox boundingBox = new BoundingBox ( minLon , minLat , maxLon , maxLat ) ; return boundingBox ; } | Get the bounding box of the tile grid in the tile width and height bounds using the total bounding box with constant units |
1,528 | public static int getZoomLevel ( BoundingBox webMercatorBoundingBox ) { double worldLength = ProjectionConstants . WEB_MERCATOR_HALF_WORLD_WIDTH * 2 ; double longitudeDistance = webMercatorBoundingBox . getMaxLongitude ( ) - webMercatorBoundingBox . getMinLongitude ( ) ; double latitudeDistance = webMercatorBoundingBox . getMaxLatitude ( ) - webMercatorBoundingBox . getMinLatitude ( ) ; if ( longitudeDistance <= 0 ) { longitudeDistance = Double . MIN_VALUE ; } if ( latitudeDistance <= 0 ) { latitudeDistance = Double . MIN_VALUE ; } int widthTiles = ( int ) ( worldLength / longitudeDistance ) ; int heightTiles = ( int ) ( worldLength / latitudeDistance ) ; int tilesPerSide = Math . min ( widthTiles , heightTiles ) ; tilesPerSide = Math . max ( tilesPerSide , 1 ) ; int zoom = zoomFromTilesPerSide ( tilesPerSide ) ; return zoom ; } | Get the zoom level of where the web mercator bounding box fits into the complete world |
1,529 | public static double getPixelXSize ( BoundingBox webMercatorBoundingBox , long matrixWidth , int tileWidth ) { double pixelXSize = ( webMercatorBoundingBox . getMaxLongitude ( ) - webMercatorBoundingBox . getMinLongitude ( ) ) / matrixWidth / tileWidth ; return pixelXSize ; } | Get the pixel x size for the bounding box with matrix width and tile width |
1,530 | public static double getPixelYSize ( BoundingBox webMercatorBoundingBox , long matrixHeight , int tileHeight ) { double pixelYSize = ( webMercatorBoundingBox . getMaxLatitude ( ) - webMercatorBoundingBox . getMinLatitude ( ) ) / matrixHeight / tileHeight ; return pixelYSize ; } | Get the pixel y size for the bounding box with matrix height and tile height |
1,531 | public static BoundingBox boundDegreesBoundingBoxWithWebMercatorLimits ( BoundingBox boundingBox ) { BoundingBox bounded = new BoundingBox ( boundingBox ) ; if ( bounded . getMinLatitude ( ) < ProjectionConstants . WEB_MERCATOR_MIN_LAT_RANGE ) { bounded . setMinLatitude ( ProjectionConstants . WEB_MERCATOR_MIN_LAT_RANGE ) ; } if ( bounded . getMaxLatitude ( ) < ProjectionConstants . WEB_MERCATOR_MIN_LAT_RANGE ) { bounded . setMaxLatitude ( ProjectionConstants . WEB_MERCATOR_MIN_LAT_RANGE ) ; } if ( bounded . getMaxLatitude ( ) > ProjectionConstants . WEB_MERCATOR_MAX_LAT_RANGE ) { bounded . setMaxLatitude ( ProjectionConstants . WEB_MERCATOR_MAX_LAT_RANGE ) ; } if ( bounded . getMinLatitude ( ) > ProjectionConstants . WEB_MERCATOR_MAX_LAT_RANGE ) { bounded . setMinLatitude ( ProjectionConstants . WEB_MERCATOR_MAX_LAT_RANGE ) ; } return bounded ; } | Bound the upper and lower bounds of the degrees bounding box with web mercator limits |
1,532 | public static BoundingBox getWGS84BoundingBox ( TileGrid tileGrid , int zoom ) { int tilesPerLat = tilesPerWGS84LatSide ( zoom ) ; int tilesPerLon = tilesPerWGS84LonSide ( zoom ) ; double tileSizeLat = tileSizeLatPerWGS84Side ( tilesPerLat ) ; double tileSizeLon = tileSizeLonPerWGS84Side ( tilesPerLon ) ; double minLon = ( - 1 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) + ( tileGrid . getMinX ( ) * tileSizeLon ) ; double maxLon = ( - 1 * ProjectionConstants . WGS84_HALF_WORLD_LON_WIDTH ) + ( ( tileGrid . getMaxX ( ) + 1 ) * tileSizeLon ) ; double minLat = ProjectionConstants . WGS84_HALF_WORLD_LAT_HEIGHT - ( ( tileGrid . getMaxY ( ) + 1 ) * tileSizeLat ) ; double maxLat = ProjectionConstants . WGS84_HALF_WORLD_LAT_HEIGHT - ( tileGrid . getMinY ( ) * tileSizeLat ) ; BoundingBox box = new BoundingBox ( minLon , minLat , maxLon , maxLat ) ; return box ; } | Get the WGS84 tile bounding box from the tile grid and zoom level |
1,533 | public static TileGrid tileGridZoom ( TileGrid tileGrid , int fromZoom , int toZoom ) { TileGrid newTileGrid = null ; int zoomChange = toZoom - fromZoom ; if ( zoomChange > 0 ) { newTileGrid = tileGridZoomIncrease ( tileGrid , zoomChange ) ; } else if ( zoomChange < 0 ) { zoomChange = Math . abs ( zoomChange ) ; newTileGrid = tileGridZoomDecrease ( tileGrid , zoomChange ) ; } else { newTileGrid = tileGrid ; } return newTileGrid ; } | Get the tile grid starting from the tile grid and current zoom to the new zoom level |
1,534 | public int deleteCascade ( TableIndex tableIndex ) throws SQLException { int count = 0 ; if ( tableIndex != null ) { GeometryIndexDao geometryIndexDao = getGeometryIndexDao ( ) ; if ( geometryIndexDao . isTableExists ( ) ) { DeleteBuilder < GeometryIndex , GeometryIndexKey > db = geometryIndexDao . deleteBuilder ( ) ; db . where ( ) . eq ( GeometryIndex . COLUMN_TABLE_NAME , tableIndex . getTableName ( ) ) ; PreparedDelete < GeometryIndex > deleteQuery = db . prepare ( ) ; geometryIndexDao . delete ( deleteQuery ) ; } count = delete ( tableIndex ) ; } return count ; } | Delete the TableIndex cascading |
1,535 | public int deleteCascade ( Collection < TableIndex > tableIndexCollection ) throws SQLException { int count = 0 ; if ( tableIndexCollection != null ) { for ( TableIndex tableIndex : tableIndexCollection ) { count += deleteCascade ( tableIndex ) ; } } return count ; } | Delete the collection of TableIndex cascading |
1,536 | public int deleteCascade ( PreparedQuery < TableIndex > preparedDelete ) throws SQLException { int count = 0 ; if ( preparedDelete != null ) { List < TableIndex > tableIndexList = query ( preparedDelete ) ; count = deleteCascade ( tableIndexList ) ; } return count ; } | Delete the TableIndex matching the prepared query cascading |
1,537 | public int deleteByIdCascade ( String id ) throws SQLException { int count = 0 ; if ( id != null ) { TableIndex tableIndex = queryForId ( id ) ; if ( tableIndex != null ) { count = deleteCascade ( tableIndex ) ; } } return count ; } | Delete a TableIndex by id cascading |
1,538 | private GeometryIndexDao getGeometryIndexDao ( ) throws SQLException { if ( geometryIndexDao == null ) { geometryIndexDao = DaoManager . createDao ( connectionSource , GeometryIndex . class ) ; } return geometryIndexDao ; } | Get or create a Geometry Index DAO |
1,539 | public int deleteAll ( ) throws SQLException { int count = 0 ; if ( isTableExists ( ) ) { DeleteBuilder < TableIndex , String > db = deleteBuilder ( ) ; PreparedDelete < TableIndex > deleteQuery = db . prepare ( ) ; count = delete ( deleteQuery ) ; } return count ; } | Delete all table indices |
1,540 | public static String quoteWrap ( String name ) { String quoteName = null ; if ( name != null ) { if ( name . startsWith ( "\"" ) && name . endsWith ( "\"" ) ) { quoteName = name ; } else { quoteName = "\"" + name + "\"" ; } } return quoteName ; } | Wrap the name in double quotes |
1,541 | public static String [ ] quoteWrap ( String [ ] names ) { String [ ] quoteNames = null ; if ( names != null ) { quoteNames = new String [ names . length ] ; for ( int i = 0 ; i < names . length ; i ++ ) { quoteNames [ i ] = quoteWrap ( names [ i ] ) ; } } return quoteNames ; } | Wrap the names in double quotes |
1,542 | public static String [ ] buildColumnsAs ( String [ ] columns , String [ ] columnsAs ) { String [ ] columnsWithAs = null ; if ( columnsAs != null ) { columnsWithAs = new String [ columns . length ] ; for ( int i = 0 ; i < columns . length ; i ++ ) { String column = columns [ i ] ; String columnsAsValue = columnsAs [ i ] ; String columnWithAs = null ; if ( columnsAsValue != null ) { columnWithAs = columnsAsValue + " AS " + column ; } else { columnWithAs = column ; } columnsWithAs [ i ] = columnWithAs ; } } else { columnsWithAs = columns ; } return columnsWithAs ; } | Build the columns as query values for the provided columns and columns as values for use in select statements . The columns as size should equal the number of columns and only provide values at the indices for desired columns . |
1,543 | 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 ) ; } | Set the contents in the user table |
1,544 | public List < ExtendedRelation > getRelationships ( ) { List < ExtendedRelation > result = null ; try { if ( extendedRelationsDao . isTableExists ( ) ) { result = extendedRelationsDao . queryForAll ( ) ; } else { result = new ArrayList < > ( ) ; } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to query for relationships " + "in " + EXTENSION_NAME , e ) ; } return result ; } | Returns the relationships defined through this extension |
1,545 | public ExtendedRelation addFeaturesRelationship ( String baseFeaturesTableName , String relatedFeaturesTableName , String mappingTableName ) { return addRelationship ( baseFeaturesTableName , relatedFeaturesTableName , mappingTableName , RelationType . FEATURES ) ; } | Adds a features relationship between the base feature and related feature table . Creates a default user mapping table if needed . |
1,546 | public ExtendedRelation addFeaturesRelationship ( String baseFeaturesTableName , String relatedFeaturesTableName , UserMappingTable userMappingTable ) { return addRelationship ( baseFeaturesTableName , relatedFeaturesTableName , userMappingTable , RelationType . FEATURES ) ; } | Adds a features relationship between the base feature and related feature table . Creates the user mapping table if needed . |
1,547 | public ExtendedRelation addMediaRelationship ( String baseTableName , MediaTable mediaTable , String mappingTableName ) { return addRelationship ( baseTableName , mediaTable , mappingTableName ) ; } | Adds a media relationship between the base table and user media related table . Creates a default user mapping table and the media table if needed . |
1,548 | public ExtendedRelation addMediaRelationship ( String baseTableName , MediaTable mediaTable , UserMappingTable userMappingTable ) { return addRelationship ( baseTableName , mediaTable , userMappingTable ) ; } | Adds a media relationship between the base table and user media related table . Creates the user mapping table and media table if needed . |
1,549 | public ExtendedRelation addSimpleAttributesRelationship ( String baseTableName , SimpleAttributesTable simpleAttributesTable , String mappingTableName ) { return addRelationship ( baseTableName , simpleAttributesTable , mappingTableName ) ; } | Adds a simple attributes relationship between the base table and user simple attributes related table . Creates a default user mapping table and the simple attributes table if needed . |
1,550 | public ExtendedRelation addSimpleAttributesRelationship ( String baseTableName , SimpleAttributesTable simpleAttributesTable , UserMappingTable userMappingTable ) { return addRelationship ( baseTableName , simpleAttributesTable , userMappingTable ) ; } | Adds a simple attributes relationship between the base table and user simple attributes related table . Creates the user mapping table and simple attributes table if needed . |
1,551 | public ExtendedRelation addAttributesRelationship ( String baseTableName , String relatedAttributesTableName , String mappingTableName ) { return addRelationship ( baseTableName , relatedAttributesTableName , mappingTableName , RelationType . ATTRIBUTES ) ; } | Adds an attributes relationship between the base table and related attributes table . Creates a default user mapping table if needed . |
1,552 | public ExtendedRelation addAttributesRelationship ( String baseTableName , String relatedAttributesTableName , UserMappingTable userMappingTable ) { return addRelationship ( baseTableName , relatedAttributesTableName , userMappingTable , RelationType . ATTRIBUTES ) ; } | Adds an attributes relationship between the base table and related attributes table . Creates the user mapping table if needed . |
1,553 | public ExtendedRelation addAttributesRelationship ( String baseTableName , AttributesTable attributesTable , String mappingTableName ) { return addRelationship ( baseTableName , attributesTable , mappingTableName ) ; } | Adds an attributes relationship between the base table and user attributes related table . Creates a default user mapping table and the attributes table if needed . |
1,554 | public ExtendedRelation addAttributesRelationship ( String baseTableName , AttributesTable attributesTable , UserMappingTable userMappingTable ) { return addRelationship ( baseTableName , attributesTable , userMappingTable ) ; } | Adds an attributes relationship between the base table and user attributes related table . Creates the user mapping table and an attributes table if needed . |
1,555 | public ExtendedRelation addTilesRelationship ( String baseTableName , String relatedTilesTableName , String mappingTableName ) { return addRelationship ( baseTableName , relatedTilesTableName , mappingTableName , RelationType . TILES ) ; } | Adds a tiles relationship between the base table and related tiles table . Creates a default user mapping table if needed . |
1,556 | public ExtendedRelation addTilesRelationship ( String baseTableName , String relatedTilesTableName , UserMappingTable userMappingTable ) { return addRelationship ( baseTableName , relatedTilesTableName , userMappingTable , RelationType . TILES ) ; } | Adds a tiles relationship between the base table and related tiles table . Creates the user mapping table if needed . |
1,557 | public ExtendedRelation addTilesRelationship ( String baseTableName , TileTable tileTable , String mappingTableName ) { return addRelationship ( baseTableName , tileTable , mappingTableName ) ; } | Adds a tiles relationship between the base table and user tiles related table . Creates a default user mapping table and the tile table if needed . |
1,558 | public ExtendedRelation addTilesRelationship ( String baseTableName , TileTable tileTable , UserMappingTable userMappingTable ) { return addRelationship ( baseTableName , tileTable , userMappingTable ) ; } | Adds a tiles relationship between the base table and user tiles related table . Creates the user mapping table and a tile table if needed . |
1,559 | private void validateRelationship ( String baseTableName , String relatedTableName , String relationName ) { if ( ! geoPackage . isTable ( baseTableName ) ) { throw new GeoPackageException ( "Base Relationship table does not exist: " + baseTableName + ", Relation: " + relationName ) ; } if ( ! geoPackage . isTable ( relatedTableName ) ) { throw new GeoPackageException ( "Related Relationship table does not exist: " + relatedTableName + ", Relation: " + relationName ) ; } RelationType relationType = RelationType . fromName ( relationName ) ; if ( relationType != null ) { validateRelationship ( baseTableName , relatedTableName , relationType ) ; } } | Validate that the relation name is valid between the base and related table |
1,560 | private void validateRelationship ( String baseTableName , String relatedTableName , RelationType relationType ) { if ( relationType != null ) { if ( ! geoPackage . isTableType ( relationType . getDataType ( ) , relatedTableName ) ) { throw new GeoPackageException ( "The related table must be a " + relationType . getDataType ( ) + " table. Related Table: " + relatedTableName + ", Type: " + geoPackage . getTableType ( relatedTableName ) ) ; } } } | Determine if the relation type is valid between the base and related table |
1,561 | public boolean createUserMappingTable ( String mappingTableName ) { UserMappingTable userMappingTable = UserMappingTable . create ( mappingTableName ) ; return createUserMappingTable ( userMappingTable ) ; } | Create a default user mapping table and extension row if either does not exist . When not created there is no guarantee that an existing table has the same schema as the provided tabled . |
1,562 | public boolean createUserMappingTable ( UserMappingTable userMappingTable ) { boolean created = false ; String userMappingTableName = userMappingTable . getTableName ( ) ; getOrCreate ( userMappingTableName ) ; if ( ! geoPackage . isTable ( userMappingTableName ) ) { geoPackage . createUserTable ( userMappingTable ) ; created = true ; } return created ; } | Create a user mapping table and extension row if either does not exist . When not created there is no guarantee that an existing table has the same schema as the provided tabled . |
1,563 | public boolean createRelatedTable ( UserTable < ? extends UserColumn > relatedTable ) { boolean created = false ; String relatedTableName = relatedTable . getTableName ( ) ; if ( ! geoPackage . isTable ( relatedTableName ) ) { geoPackage . createUserTable ( relatedTable ) ; try { Contents contents = new Contents ( ) ; contents . setTableName ( relatedTableName ) ; contents . setDataTypeString ( relatedTable . getDataType ( ) ) ; contents . setIdentifier ( relatedTableName ) ; ContentsDao contentsDao = geoPackage . getContentsDao ( ) ; contentsDao . create ( contents ) ; contentsDao . refresh ( contents ) ; relatedTable . setContents ( contents ) ; } catch ( RuntimeException e ) { geoPackage . deleteTableQuietly ( relatedTableName ) ; throw e ; } catch ( SQLException e ) { geoPackage . deleteTableQuietly ( relatedTableName ) ; throw new GeoPackageException ( "Failed to create table and metadata: " + relatedTableName , e ) ; } created = true ; } return created ; } | Create a user related table if it does not exist . When not created there is no guarantee that an existing table has the same schema as the provided tabled . |
1,564 | public void removeRelationships ( String table ) { try { if ( extendedRelationsDao . isTableExists ( ) ) { List < ExtendedRelation > extendedRelations = extendedRelationsDao . getTableRelations ( table ) ; for ( ExtendedRelation extendedRelation : extendedRelations ) { removeRelationship ( extendedRelation ) ; } } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to remove relationships for table: " + table , e ) ; } } | Remove all relationships that include the table |
1,565 | public void removeRelationshipsWithMappingTable ( String mappingTable ) { try { if ( extendedRelationsDao . isTableExists ( ) ) { List < ExtendedRelation > extendedRelations = getRelations ( null , null , mappingTable ) ; for ( ExtendedRelation extendedRelation : extendedRelations ) { removeRelationship ( extendedRelation ) ; } } } catch ( SQLException e ) { throw new GeoPackageException ( "Failed to remove relationships for mapping table: " + mappingTable , e ) ; } } | Remove all relationships with the mapping table |
1,566 | public List < ExtendedRelation > getRelations ( String baseTable , String relatedTable ) throws SQLException { return getRelations ( baseTable , null , relatedTable , null , null , null ) ; } | Get the relations to the base table and related table |
1,567 | private void validateRangeValue ( String column , Object value ) { if ( constraintType != null && value != null && ! getConstraintType ( ) . equals ( DataColumnConstraintType . RANGE ) ) { throw new GeoPackageException ( "The " + column + " must be null for " + DataColumnConstraintType . ENUM + " and " + DataColumnConstraintType . GLOB + " constraints" ) ; } } | Validate the constraint type when a range value is set |
1,568 | public static FeatureColumn createGeometryColumn ( int index , String name , GeometryType type , boolean notNull , Object defaultValue ) { if ( type == null ) { throw new GeoPackageException ( "Geometry Type is required to create geometry column: " + name ) ; } return new FeatureColumn ( index , name , GeoPackageDataType . BLOB , null , notNull , defaultValue , false , type ) ; } | Create a new geometry column |
1,569 | public List < String > getTileTables ( ) throws SQLException { List < String > tableNames = new ArrayList < String > ( ) ; List < TileMatrixSet > tileMatrixSets = queryForAll ( ) ; for ( TileMatrixSet tileMatrixSet : tileMatrixSets ) { tableNames . add ( tileMatrixSet . getTableName ( ) ) ; } return tableNames ; } | Get all the tile table names |
1,570 | public static MediaTable create ( String tableName , List < UserCustomColumn > additionalColumns ) { return create ( tableName , null , additionalColumns ) ; } | Create a media table with the minimum required columns followed by the additional columns |
1,571 | public static MediaTable create ( String tableName , String idColumnName ) { return create ( tableName , idColumnName , null ) ; } | Create a media table with the id column and minimum required columns |
1,572 | public static MediaTable create ( String tableName , String idColumnName , List < UserCustomColumn > additionalColumns ) { List < UserCustomColumn > columns = new ArrayList < > ( ) ; columns . addAll ( createRequiredColumns ( idColumnName ) ) ; if ( additionalColumns != null ) { columns . addAll ( additionalColumns ) ; } return new MediaTable ( tableName , columns , idColumnName ) ; } | Create a media table with the id column and minimum required columns followed by the additional columns |
1,573 | public static List < UserCustomColumn > createRequiredColumns ( int startingIndex , String idColumnName ) { if ( idColumnName == null ) { idColumnName = COLUMN_ID ; } List < UserCustomColumn > columns = new ArrayList < > ( ) ; columns . add ( createIdColumn ( startingIndex ++ , idColumnName ) ) ; columns . add ( createDataColumn ( startingIndex ++ ) ) ; columns . add ( createContentTypeColumn ( startingIndex ++ ) ) ; return columns ; } | Create the required table columns with id column name starting at the provided index |
1,574 | public static UserCustomColumn createDataColumn ( int index ) { return UserCustomColumn . createColumn ( index , COLUMN_DATA , GeoPackageDataType . BLOB , true , null ) ; } | Create a data column |
1,575 | public static UserCustomColumn createContentTypeColumn ( int index ) { return UserCustomColumn . createColumn ( index , COLUMN_CONTENT_TYPE , GeoPackageDataType . TEXT , true , null ) ; } | Create a content type column |
1,576 | public List < String > getProperties ( ) { List < String > properties = null ; if ( has ( ) ) { properties = getDao ( ) . querySingleColumnTypedResults ( "SELECT DISTINCT " + COLUMN_PROPERTY + " FROM " + TABLE_NAME , null ) ; } else { properties = new ArrayList < > ( ) ; } return properties ; } | Get the properties |
1,577 | public int numValues ( String property ) { int count = 0 ; if ( has ( ) ) { TResult result = queryForValues ( property ) ; try { count = result . getCount ( ) ; } finally { result . close ( ) ; } } return count ; } | Get the number of values for the property |
1,578 | public String getValue ( String property ) { String value = null ; List < String > values = getValues ( property ) ; if ( ! values . isEmpty ( ) ) { value = values . get ( 0 ) ; } return value ; } | Get the first value for the property |
1,579 | public boolean hasValue ( String property , String value ) { boolean hasValue = false ; if ( has ( ) ) { Map < String , Object > fieldValues = buildFieldValues ( property , value ) ; TResult result = getDao ( ) . queryForFieldValues ( fieldValues ) ; try { hasValue = result . getCount ( ) > 0 ; } finally { result . close ( ) ; } } return hasValue ; } | Check if the property has the value |
1,580 | public boolean addValue ( String property , String value ) { if ( ! has ( ) ) { getOrCreate ( ) ; } boolean added = false ; if ( ! hasValue ( property , value ) ) { TRow row = newRow ( ) ; row . setValue ( COLUMN_PROPERTY , property ) ; row . setValue ( COLUMN_VALUE , value ) ; getDao ( ) . insert ( row ) ; added = true ; } return added ; } | Add a property value creating the extension if needed |
1,581 | public int deleteProperty ( String property ) { int count = 0 ; if ( has ( ) ) { TDao dao = getDao ( ) ; String where = dao . buildWhere ( COLUMN_PROPERTY , property ) ; String [ ] whereArgs = dao . buildWhereArgs ( property ) ; count = dao . delete ( where , whereArgs ) ; } return count ; } | Delete the property and all the property values |
1,582 | public int deleteValue ( String property , String value ) { int count = 0 ; if ( has ( ) ) { Map < String , Object > fieldValues = buildFieldValues ( property , value ) ; count = getDao ( ) . delete ( fieldValues ) ; } return count ; } | Delete the property value |
1,583 | private Map < String , Object > buildFieldValues ( String property , String value ) { Map < String , Object > fieldValues = new HashMap < String , Object > ( ) ; fieldValues . put ( COLUMN_PROPERTY , property ) ; fieldValues . put ( COLUMN_VALUE , value ) ; return fieldValues ; } | Build field values from the property and value |
1,584 | private TResult queryForValues ( String property ) { TResult result = null ; if ( has ( ) ) { result = getDao ( ) . queryForEq ( COLUMN_PROPERTY , property ) ; } return result ; } | Query for the property values |
1,585 | private List < String > getValues ( UserCoreResult < ? , ? , ? > results ) { List < String > values = null ; if ( results != null ) { try { if ( results . getCount ( ) > 0 ) { int columnIndex = results . getColumnIndex ( COLUMN_VALUE ) ; values = getColumnResults ( columnIndex , results ) ; } else { values = new ArrayList < > ( ) ; } } finally { results . close ( ) ; } } else { values = new ArrayList < > ( ) ; } return values ; } | Get the values from the results and close the results |
1,586 | private List < String > getColumnResults ( int columnIndex , UserCoreResult < ? , ? , ? > results ) { List < String > values = new ArrayList < > ( ) ; while ( results . moveToNext ( ) ) { values . add ( results . getString ( columnIndex ) ) ; } return values ; } | Get the results of a column at the index and close the results |
1,587 | protected Object copyValue ( TColumn column , Object value ) { Object copyValue = value ; switch ( column . getDataType ( ) ) { case BLOB : if ( value instanceof byte [ ] ) { byte [ ] bytes = ( byte [ ] ) value ; copyValue = Arrays . copyOf ( bytes , bytes . length ) ; } else { throw new GeoPackageException ( "Unsupported copy value type. column: " + column . getName ( ) + ", value type: " + value . getClass ( ) . getName ( ) + ", data type: " + column . getDataType ( ) ) ; } break ; case DATE : case DATETIME : if ( value instanceof Date ) { Date date = ( Date ) value ; copyValue = new Date ( date . getTime ( ) ) ; } else if ( ! ( value instanceof String ) ) { throw new GeoPackageException ( "Unsupported copy value type. column: " + column . getName ( ) + ", value type: " + value . getClass ( ) . getName ( ) + ", data type: " + column . getDataType ( ) ) ; } break ; default : } } | Copy the value of the data type |
1,588 | public List < T > getGeoPackages ( ) { List < T > geoPackages = new ArrayList < > ( ) ; for ( PropertiesCoreExtension < T , ? , ? , ? > properties : propertiesMap . values ( ) ) { geoPackages . add ( properties . getGeoPackage ( ) ) ; } return geoPackages ; } | Get the GeoPackages |
1,589 | public T getGeoPackage ( String name ) { T geoPackage = null ; PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . get ( name ) ; if ( properties != null ) { geoPackage = properties . getGeoPackage ( ) ; } return geoPackage ; } | Get the GeoPackage for the GeoPackage name |
1,590 | public void closeGeoPackages ( ) { for ( PropertiesCoreExtension < T , ? , ? , ? > properties : propertiesMap . values ( ) ) { properties . getGeoPackage ( ) . close ( ) ; } propertiesMap . clear ( ) ; } | Close all GeoPackages in the manager |
1,591 | public T removeGeoPackage ( String name ) { T removed = null ; PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . remove ( name ) ; if ( properties != null ) { removed = properties . getGeoPackage ( ) ; } return removed ; } | Remove the GeoPackage with the name but does not close it |
1,592 | public Set < String > getProperties ( ) { Set < String > allProperties = new HashSet < > ( ) ; for ( PropertiesCoreExtension < T , ? , ? , ? > properties : propertiesMap . values ( ) ) { allProperties . addAll ( properties . getProperties ( ) ) ; } return allProperties ; } | Get the unique properties |
1,593 | public Set < String > getValues ( String property ) { Set < String > allValues = new HashSet < > ( ) ; for ( PropertiesCoreExtension < T , ? , ? , ? > properties : propertiesMap . values ( ) ) { allValues . addAll ( properties . getValues ( property ) ) ; } return allValues ; } | Get the unique values for the property |
1,594 | public List < T > hasValue ( String property , String value ) { List < T > geoPackages = new ArrayList < > ( ) ; for ( PropertiesCoreExtension < T , ? , ? , ? > properties : propertiesMap . values ( ) ) { if ( properties . hasValue ( property , value ) ) { geoPackages . add ( properties . getGeoPackage ( ) ) ; } } return geoPackages ; } | Get the GeoPackages with the property name and value |
1,595 | public int addValue ( String property , String value ) { int count = 0 ; for ( String geoPackage : propertiesMap . keySet ( ) ) { if ( addValue ( geoPackage , property , value ) ) { count ++ ; } } return count ; } | Add a property value to all GeoPackages |
1,596 | public boolean addValue ( String geoPackage , String property , String value ) { boolean added = false ; PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . get ( geoPackage ) ; if ( properties != null ) { added = properties . addValue ( property , value ) ; } return added ; } | Add a property value to a specified GeoPackage |
1,597 | public int deleteProperty ( String property ) { int count = 0 ; for ( String geoPackage : propertiesMap . keySet ( ) ) { if ( deleteProperty ( geoPackage , property ) ) { count ++ ; } } return count ; } | Delete the property and values from all GeoPackages |
1,598 | public boolean deleteProperty ( String geoPackage , String property ) { boolean deleted = false ; PropertiesCoreExtension < T , ? , ? , ? > properties = propertiesMap . get ( geoPackage ) ; if ( properties != null ) { deleted = properties . deleteProperty ( property ) > 0 ; } return deleted ; } | Delete the property and values from a specified GeoPackage |
1,599 | public int deleteValue ( String property , String value ) { int count = 0 ; for ( String geoPackage : propertiesMap . keySet ( ) ) { if ( deleteValue ( geoPackage , property , value ) ) { count ++ ; } } return count ; } | Delete the property value from all GeoPackages |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.