idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
127,300
private void validate ( ) { LibraryUtils . checkArgumentNotNull ( config , "configuration is null" ) ; LibraryUtils . checkArgumentNotNull ( exceptionHandler , "exceptionHandler is null" ) ; LibraryUtils . checkArgumentNotNull ( progressReporter , "progressReporter is null" ) ; LibraryUtils . checkArgumentNotNull ( sqs...
Convenient function to validate input .
127,301
private Properties loadProperty ( String propertiesFile ) { Properties prop = new Properties ( ) ; try { InputStream in = getClass ( ) . getResourceAsStream ( propertiesFile ) ; prop . load ( in ) ; in . close ( ) ; } catch ( IOException e ) { throw new IllegalStateException ( "Cannot load property file at " + properti...
Load properties from a classpath property file .
127,302
private int getIntProperty ( Properties prop , String name ) { String propertyValue = prop . getProperty ( name ) ; return Integer . parseInt ( propertyValue ) ; }
Convert a string representation of a property to an integer type .
127,303
private Boolean getBooleanProperty ( Properties prop , String name ) { String propertyValue = prop . getProperty ( name ) ; return Boolean . parseBoolean ( propertyValue ) ; }
Convert a string representation of a property to a boolean type .
127,304
private void validateEvent ( CloudTrailEvent event ) { if ( event . getEventData ( ) . getAccountId ( ) == null ) { logger . error ( String . format ( "Event %s doesn't have account ID." , event . getEventData ( ) ) ) ; } }
Do simple validation before processing .
127,305
public List < CloudTrailSource > getSources ( ) { List < Message > sqsMessages = sqsManager . pollQueue ( ) ; return sqsManager . parseMessage ( sqsMessages ) ; }
Poll messages from SQS queue and convert messages to CloudTrailSource .
127,306
public void processSource ( CloudTrailSource source ) { boolean filterSourceOut = false ; boolean downloadLogSuccess = true ; boolean processSourceSuccess = false ; ProgressStatus processSourceStatus = new ProgressStatus ( ProgressState . processSource , new BasicProcessSourceInfo ( source , processSourceSuccess ) ) ; ...
Retrieve S3 object URL from source then downloads the object processes each event through call back functions .
127,307
private void deleteMessageAfterProcessSource ( ProgressState progressState , CloudTrailSource source ) { ProgressStatus deleteMessageStatus = new ProgressStatus ( progressState , new BasicProcessSourceInfo ( source , false ) ) ; sqsManager . deleteMessageFromQueue ( ( ( SQSBasedSource ) source ) . getSqsMessage ( ) , d...
Delete SQS message after processing source .
127,308
public void start ( ) { logger . info ( "Started AWSCloudTrailProcessingLibrary." ) ; validateBeforeStart ( ) ; scheduledThreadPool . scheduleAtFixedRate ( new ScheduledJob ( readerFactory ) , 0L , EXECUTION_DELAY , TimeUnit . MICROSECONDS ) ; }
Start processing AWS CloudTrail logs .
127,309
private void validateBeforeStart ( ) { LibraryUtils . checkArgumentNotNull ( config , "Configuration is null." ) ; config . validate ( ) ; LibraryUtils . checkArgumentNotNull ( sourceFilter , "sourceFilter is null." ) ; LibraryUtils . checkArgumentNotNull ( eventFilter , "eventFilter is null." ) ; LibraryUtils . checkA...
Validate the user s input before processing logs .
127,310
public CloudTrailEventMetadata getMetadata ( int charStart , int charEnd ) { String rawEvent = logFile . substring ( charStart , charEnd + 1 ) ; int offset = rawEvent . indexOf ( "{" ) ; rawEvent = rawEvent . substring ( offset ) ; CloudTrailEventMetadata metadata = new LogDeliveryInfo ( ctLog , charStart + offset , ch...
Find the raw event in string format from logFileContent based on character start index and end index .
127,311
protected void readArrayHeader ( ) throws IOException { if ( jsonParser . nextToken ( ) != JsonToken . START_OBJECT ) { throw new JsonParseException ( "Not a Json object" , jsonParser . getCurrentLocation ( ) ) ; } jsonParser . nextToken ( ) ; if ( ! jsonParser . getText ( ) . equals ( RECORDS ) ) { throw new JsonParse...
Read the header of an AWS CloudTrail log .
127,312
public boolean hasNextEvent ( ) throws IOException { JsonToken nextToken = jsonParser . nextToken ( ) ; return nextToken == JsonToken . START_OBJECT || nextToken == JsonToken . START_ARRAY ; }
Indicates whether the CloudTrail log has more events to read .
127,313
public CloudTrailEvent getNextEvent ( ) throws IOException { CloudTrailEventData eventData = new CloudTrailEventData ( ) ; String key ; int charStart = ( int ) jsonParser . getTokenLocation ( ) . getCharOffset ( ) ; while ( jsonParser . nextToken ( ) != JsonToken . END_OBJECT ) { key = jsonParser . getCurrentName ( ) ;...
Get the next event from the CloudTrail log and parse it .
127,314
private void setAccountId ( CloudTrailEventData eventData ) { if ( eventData . getRecipientAccountId ( ) != null ) { eventData . add ( "accountId" , eventData . getRecipientAccountId ( ) ) ; return ; } if ( eventData . getUserIdentity ( ) != null && eventData . getUserIdentity ( ) . getAccountId ( ) != null ) { eventDa...
Set AccountId in CloudTrailEventData top level from either recipientAccountID or from UserIdentity . If recipientAccountID exists then recipientAccountID is set to accountID ; otherwise accountID is retrieved from UserIdentity .
127,315
private void parseReadOnly ( CloudTrailEventData eventData ) throws IOException { jsonParser . nextToken ( ) ; Boolean readOnly = null ; if ( jsonParser . getCurrentToken ( ) != JsonToken . VALUE_NULL ) { readOnly = jsonParser . getBooleanValue ( ) ; } eventData . add ( CloudTrailEventField . readOnly . name ( ) , read...
Parses the event readOnly attribute .
127,316
private void parseManagementEvent ( CloudTrailEventData eventData ) throws IOException { jsonParser . nextToken ( ) ; Boolean managementEvent = null ; if ( jsonParser . getCurrentToken ( ) != JsonToken . VALUE_NULL ) { managementEvent = jsonParser . getBooleanValue ( ) ; } eventData . add ( CloudTrailEventField . manag...
Parses the event managementEvent attribute .
127,317
private void parseResources ( CloudTrailEventData eventData ) throws IOException { JsonToken nextToken = jsonParser . nextToken ( ) ; if ( nextToken == JsonToken . VALUE_NULL ) { eventData . add ( CloudTrailEventField . resources . name ( ) , null ) ; return ; } if ( nextToken != JsonToken . START_ARRAY ) { throw new J...
Parses a list of Resource .
127,318
private Resource parseResource ( ) throws IOException { if ( jsonParser . getCurrentToken ( ) != JsonToken . START_OBJECT ) { throw new JsonParseException ( "Not a Resource object" , jsonParser . getCurrentLocation ( ) ) ; } Resource resource = new Resource ( ) ; while ( jsonParser . nextToken ( ) != JsonToken . END_OB...
Parses a single Resource .
127,319
private String parseDefaultValue ( String key ) throws IOException { jsonParser . nextToken ( ) ; String value = null ; JsonToken currentToken = jsonParser . getCurrentToken ( ) ; if ( currentToken != JsonToken . VALUE_NULL ) { if ( currentToken == JsonToken . START_ARRAY || currentToken == JsonToken . START_OBJECT ) {...
Parses the event with key as default value .
127,320
private Map < String , String > parseAttributes ( ) throws IOException { if ( jsonParser . nextToken ( ) != JsonToken . START_OBJECT ) { throw new JsonParseException ( "Not a Attributes object" , jsonParser . getCurrentLocation ( ) ) ; } Map < String , String > attributes = new HashMap < > ( ) ; while ( jsonParser . ne...
Parses attributes as a Map used in both parseWebIdentitySessionContext and parseSessionContext
127,321
private Date convertToDate ( String dateInString ) throws IOException { Date date = null ; if ( dateInString != null ) { try { date = LibraryUtils . getUtcSdf ( ) . parse ( dateInString ) ; } catch ( ParseException e ) { throw new IOException ( "Cannot parse " + dateInString + " as Date" , e ) ; } } return date ; }
This method convert a String to Date type . When parse error happened return current date .
127,322
public static void endToProcess ( ProgressReporter progressReporter , boolean processSuccess , ProgressStatus progressStatus , Object reportObject ) { progressStatus . getProgressInfo ( ) . setIsSuccess ( processSuccess ) ; progressReporter . reportEnd ( progressStatus , reportObject ) ; }
A wrapper function of reporting the result of the processing .
127,323
private void validate ( ) { LibraryUtils . checkArgumentNotNull ( config , "Configuration is null." ) ; LibraryUtils . checkArgumentNotNull ( eventsProcessor , "Events Processor is null." ) ; LibraryUtils . checkArgumentNotNull ( sourceFilter , "Source Filter is null." ) ; LibraryUtils . checkArgumentNotNull ( eventFil...
Validate input parameters .
127,324
public void handleException ( ProcessingLibraryException exception ) { ProgressStatus status = exception . getStatus ( ) ; ProgressState state = status . getProgressState ( ) ; ProgressInfo info = status . getProgressInfo ( ) ; logger . error ( String . format ( "Exception. Progress State: %s. Progress Information: %s....
Exception handler that simply log progress state and progress information .
127,325
public boolean filterEvent ( CloudTrailEvent event ) throws CallbackException { CloudTrailEventData eventData = event . getEventData ( ) ; String eventSource = eventData . getEventSource ( ) ; String eventName = eventData . getEventName ( ) ; return eventSource . equals ( EC2_EVENTS ) && eventName . startsWith ( "Delet...
Event filter that only keep EC2 deletion API calls .
127,326
@ SuppressWarnings ( "unchecked" ) public List < Resource > getResources ( ) { return ( List < Resource > ) get ( CloudTrailEventField . resources . name ( ) ) ; }
Get the resources used in the operation .
127,327
public boolean filterSource ( CloudTrailSource source ) throws CallbackException { source = ( SQSBasedSource ) source ; Map < String , String > sourceAttributes = source . getSourceAttributes ( ) ; String accountId = sourceAttributes . get ( SourceAttributeKeys . ACCOUNT_ID . getAttributeKey ( ) ) ; String receivedCoun...
This Sample Source Filter filter out messages that have been received more than 3 times and accountIDs in a certain range .
127,328
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public Map < String , String > getAttributes ( ) { return ( Map ) this . get ( CloudTrailEventField . attributes . name ( ) ) ; }
Get attributes .
127,329
public byte [ ] downloadLog ( CloudTrailLog ctLog , CloudTrailSource source ) { boolean success = false ; ProgressStatus downloadLogStatus = new ProgressStatus ( ProgressState . downloadLog , new BasicProcessLogInfo ( source , ctLog , success ) ) ; final Object downloadSourceReportObject = progressReporter . reportStar...
Downloads an AWS CloudTrail log from the specified source .
127,330
public S3Object getObject ( String bucketName , String objectKey ) { try { return s3Client . getObject ( bucketName , objectKey ) ; } catch ( AmazonServiceException e ) { logger . error ( "Failed to get object " + objectKey + " from s3 bucket " + bucketName ) ; throw e ; } }
Download an S3 object .
127,331
private void validate ( ) { LibraryUtils . checkArgumentNotNull ( config , "configuration is null" ) ; LibraryUtils . checkArgumentNotNull ( exceptionHandler , "exceptionHandler is null" ) ; LibraryUtils . checkArgumentNotNull ( progressReporter , "progressReporter is null" ) ; LibraryUtils . checkArgumentNotNull ( s3C...
Validates input parameters .
127,332
public SourceType identifyWithEventName ( String source , String eventName ) { if ( eventName . startsWith ( CREATE_EVENT_PREFIX ) ) { return getCloudTrailSourceType ( source ) ; } return SourceType . Other ; }
Identify the source type with event action .
127,333
public static int resultSetTypeToSqlLite ( int columnType ) { int type ; switch ( columnType ) { case Types . INTEGER : case Types . BIGINT : case Types . SMALLINT : case Types . TINYINT : case Types . BOOLEAN : type = ResultUtils . FIELD_TYPE_INTEGER ; break ; case Types . VARCHAR : case Types . DATE : type = ResultUt...
Get the SQLite type from the ResultSetMetaData column type
127,334
public static boolean create ( File file ) { boolean created = false ; if ( GeoPackageIOUtils . hasFileExtension ( file ) ) { GeoPackageValidate . validateGeoPackageExtension ( file ) ; } else { file = GeoPackageIOUtils . addFileExtension ( file , GeoPackageConstants . GEOPACKAGE_EXTENSION ) ; } if ( file . exists ( ) ...
Create a GeoPackage
127,335
public static GeoPackage open ( String name , File file ) { if ( GeoPackageIOUtils . hasFileExtension ( file ) ) { GeoPackageValidate . validateGeoPackageExtension ( file ) ; } else { file = GeoPackageIOUtils . addFileExtension ( file , GeoPackageConstants . GEOPACKAGE_EXTENSION ) ; } GeoPackageConnection connection = ...
Open a GeoPackage
127,336
private static GeoPackageConnection connect ( File file ) { String databaseUrl = "jdbc:sqlite:" + file . getPath ( ) ; try { Class . forName ( "org.sqlite.JDBC" ) ; } catch ( ClassNotFoundException e ) { throw new GeoPackageException ( "Failed to load the SQLite JDBC driver" , e ) ; } Connection databaseConnection ; tr...
Connect to a GeoPackage file
127,337
public void setTileData ( BufferedImage image , String imageFormat ) throws IOException { byte [ ] bytes = ImageUtils . writeImageToBytes ( image , imageFormat ) ; setTileData ( bytes ) ; }
Set the tile data from an image
127,338
public ResultSet query ( String sql , String [ ] args ) { return SQLUtils . query ( connection , sql , args ) ; }
Perform a database query
127,339
public boolean hasTile ( BoundingBox requestBoundingBox ) { boolean hasTile = false ; ProjectionTransform transformRequestToTiles = requestProjection . getTransformation ( tilesProjection ) ; BoundingBox tilesBoundingBox = requestBoundingBox . transform ( transformRequestToTiles ) ; List < TileMatrix > tileMatrices = g...
Check if the tile table contains a tile for the request bounding box
127,340
public GeoPackageTile getTile ( BoundingBox requestBoundingBox ) { GeoPackageTile tile = null ; ProjectionTransform transformRequestToTiles = requestProjection . getTransformation ( tilesProjection ) ; BoundingBox tilesBoundingBox = requestBoundingBox . transform ( transformRequestToTiles ) ; List < TileMatrix > tileMa...
Get the tile from the request bounding box in the request projection
127,341
private GeoPackageTile drawTile ( TileMatrix tileMatrix , TileResultSet tileResults , BoundingBox requestProjectedBoundingBox , int tileWidth , int tileHeight ) { GeoPackageTile geoPackageTile = null ; Graphics graphics = null ; while ( tileResults . moveToNext ( ) ) { TileRow tileRow = tileResults . getRow ( ) ; Buffe...
Draw the tile from the tile results
127,342
private BufferedImage reprojectTile ( BufferedImage tile , int requestedTileWidth , int requestedTileHeight , BoundingBox requestBoundingBox , ProjectionTransform transformRequestToTiles , BoundingBox tilesBoundingBox ) { final double requestedWidthUnitsPerPixel = ( requestBoundingBox . getMaxLongitude ( ) - requestBou...
Reproject the tile to the requested projection
127,343
public BoundingBox getBoundingBox ( ) { GeometryEnvelope envelope = null ; long offset = 0 ; boolean hasResults = true ; while ( hasResults ) { hasResults = false ; FeatureResultSet resultSet = featureDao . queryForChunk ( chunkLimit , offset ) ; try { while ( resultSet . moveToNext ( ) ) { hasResults = true ; FeatureR...
Manually build the bounds of the feature table
127,344
private void createFunction ( String name , GeometryFunction function ) { try { Function . create ( getGeoPackage ( ) . getConnection ( ) . getConnection ( ) , name , function ) ; } catch ( SQLException e ) { log . log ( Level . SEVERE , "Failed to create function: " + name , e ) ; } }
Create the function for the connection
127,345
private BufferedImage drawTile ( int tileWidth , int tileHeight , String text ) { BufferedImage image = new BufferedImage ( tileWidth , tileHeight , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D graphics = image . createGraphics ( ) ; graphics . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VAL...
Draw a tile with the provided text label in the middle
127,346
public static BufferedImage createBufferedImage ( int width , int height , String imageFormat ) { int imageType ; switch ( imageFormat . toLowerCase ( ) ) { case IMAGE_FORMAT_JPG : case IMAGE_FORMAT_JPEG : imageType = BufferedImage . TYPE_INT_RGB ; break ; default : imageType = BufferedImage . TYPE_INT_ARGB ; } Buffere...
Create a buffered image for the dimensions and image format
127,347
public static boolean isFullyTransparent ( BufferedImage image ) { boolean transparent = true ; for ( int x = 0 ; x < image . getWidth ( ) ; x ++ ) { for ( int y = 0 ; y < image . getHeight ( ) ; y ++ ) { transparent = isTransparent ( image , x , y ) ; if ( ! transparent ) { break ; } } if ( ! transparent ) { break ; }...
Check if the image is fully transparent meaning it contains only transparent pixels as an empty image
127,348
public static boolean isTransparent ( BufferedImage image , int x , int y ) { int pixel = image . getRGB ( x , y ) ; boolean transparent = ( pixel >> 24 ) == 0x00 ; return transparent ; }
Check if the pixel in the image at the x and y is transparent
127,349
public static BufferedImage getImage ( byte [ ] imageBytes ) throws IOException { BufferedImage image = null ; if ( imageBytes != null ) { ByteArrayInputStream stream = new ByteArrayInputStream ( imageBytes ) ; image = ImageIO . read ( stream ) ; stream . close ( ) ; } return image ; }
Get a buffered image of the image bytes
127,350
public static byte [ ] writeImageToBytes ( BufferedImage image , String formatName , Float quality ) throws IOException { byte [ ] bytes = null ; if ( quality != null ) { bytes = compressAndWriteImageToBytes ( image , formatName , quality ) ; } else { bytes = writeImageToBytes ( image , formatName ) ; } return bytes ; ...
Write the image to bytes in the provided format and optional quality
127,351
public static byte [ ] writeImageToBytes ( BufferedImage image , String formatName ) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; ImageIO . write ( image , formatName , stream ) ; stream . flush ( ) ; byte [ ] bytes = stream . toByteArray ( ) ; stream . close ( ) ; return bytes ; ...
Write the image to bytes in the provided format
127,352
public static byte [ ] compressAndWriteImageToBytes ( BufferedImage image , String formatName , float quality ) { byte [ ] bytes = null ; Iterator < ImageWriter > writers = ImageIO . getImageWritersByFormatName ( formatName ) ; if ( writers == null || ! writers . hasNext ( ) ) { throw new GeoPackageException ( "No Imag...
Compress and write the image to bytes in the provided format and quality
127,353
public IconRow queryForRow ( StyleMappingRow styleMappingRow ) { IconRow iconRow = null ; UserCustomRow userCustomRow = queryForIdRow ( styleMappingRow . getRelatedId ( ) ) ; if ( userCustomRow != null ) { iconRow = getRow ( userCustomRow ) ; } return iconRow ; }
Query for the icon row from a style mapping row
127,354
public void setScale ( float scale ) { this . scale = scale ; linePaint . setStrokeWidth ( scale * lineStrokeWidth ) ; polygonPaint . setStrokeWidth ( scale * polygonStrokeWidth ) ; featurePaintCache . clear ( ) ; }
Set the scale
127,355
public byte [ ] drawTileBytes ( int x , int y , int zoom ) { BufferedImage image = drawTile ( x , y , zoom ) ; byte [ ] tileData = null ; if ( image != null ) { try { tileData = ImageUtils . writeImageToBytes ( image , compressFormat ) ; } catch ( IOException e ) { LOGGER . log ( Level . SEVERE , "Failed to create tile...
Draw the tile and get the bytes from the x y and zoom level
127,356
public BufferedImage drawTile ( int x , int y , int zoom ) { BufferedImage image ; if ( isIndexQuery ( ) ) { image = drawTileQueryIndex ( x , y , zoom ) ; } else { image = drawTileQueryAll ( x , y , zoom ) ; } return image ; }
Draw a tile image from the x y and zoom level
127,357
public BufferedImage drawTileQueryIndex ( int x , int y , int zoom ) { BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; BufferedImage image = null ; long tileCount = queryIndexedFeaturesCount ( webMercatorBoundingBox ) ; if ( tileCount > 0 ) { CloseableIterator < ...
Draw a tile image from the x y and zoom level by querying features in the tile location
127,358
public long queryIndexedFeaturesCount ( BoundingBox webMercatorBoundingBox ) { BoundingBox expandedQueryBoundingBox = expandBoundingBox ( webMercatorBoundingBox ) ; long count = featureIndex . count ( expandedQueryBoundingBox , WEB_MERCATOR_PROJECTION ) ; return count ; }
Query for feature result count in the bounding box
127,359
public CloseableIterator < GeometryIndex > queryIndexedFeatures ( int x , int y , int zoom ) { BoundingBox webMercatorBoundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; return queryIndexedFeatures ( webMercatorBoundingBox ) ; }
Query for feature results in the x y and zoom
127,360
public CloseableIterator < GeometryIndex > queryIndexedFeatures ( BoundingBox webMercatorBoundingBox ) { BoundingBox expandedQueryBoundingBox = expandBoundingBox ( webMercatorBoundingBox ) ; CloseableIterator < GeometryIndex > results = featureIndex . query ( expandedQueryBoundingBox , WEB_MERCATOR_PROJECTION ) ; retur...
Query for feature results in the bounding box
127,361
public BufferedImage drawTileQueryAll ( int x , int y , int zoom ) { BoundingBox boundingBox = TileBoundingBoxUtils . getWebMercatorBoundingBox ( x , y , zoom ) ; BufferedImage image = null ; FeatureResultSet resultSet = featureDao . queryForAll ( ) ; try { int totalCount = resultSet . getCount ( ) ; if ( totalCount > ...
Draw a tile image from the x y and zoom level by querying all features . This could be very slow if there are a lot of features
127,362
protected Graphics2D getGraphics ( BufferedImage image ) { Graphics2D graphics = image . createGraphics ( ) ; graphics . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; return graphics ; }
Get a graphics for the image
127,363
private Paint getStylePaint ( StyleRow style , FeatureDrawType drawType ) { Paint paint = featurePaintCache . getPaint ( style , drawType ) ; if ( paint == null ) { mil . nga . geopackage . style . Color color = null ; Float strokeWidth = null ; switch ( drawType ) { case CIRCLE : color = style . getColorOrDefault ( ) ...
Get the style paint from cache or create and cache it
127,364
protected boolean isTransparent ( BufferedImage image ) { boolean transparent = false ; if ( image != null ) { WritableRaster raster = image . getAlphaRaster ( ) ; if ( raster != null ) { transparent = true ; done : for ( int x = 0 ; x < image . getWidth ( ) ; x ++ ) { for ( int y = 0 ; y < image . getHeight ( ) ; y ++...
Determine if the image is transparent
127,365
public ContentValues toContentValues ( ) { ContentValues contentValues = new ContentValues ( ) ; for ( TColumn column : table . getColumns ( ) ) { if ( ! column . isPrimaryKey ( ) ) { Object value = values [ column . getIndex ( ) ] ; String columnName = column . getName ( ) ; if ( value == null ) { contentValues . putN...
Convert the row to content values
127,366
protected void columnToContentValue ( ContentValues contentValues , TColumn column , Object value ) { String columnName = column . getName ( ) ; if ( value instanceof Number ) { if ( value instanceof Byte ) { validateValue ( column , value , Byte . class , Short . class , Integer . class , Long . class ) ; contentValue...
Map the column to the content values
127,367
public UserCustomResultSet queryByIds ( long baseId , long relatedId ) { return query ( buildWhereIds ( baseId , relatedId ) , buildWhereIdsArgs ( baseId , relatedId ) ) ; }
Query by both base id and related id
127,368
public boolean isIndexed ( FeatureIndexType type ) { boolean indexed = false ; if ( type == null ) { indexed = isIndexed ( ) ; } else { switch ( type ) { case GEOPACKAGE : indexed = featureTableIndex . isIndexed ( ) ; break ; case RTREE : indexed = rTreeIndexTableDao . has ( ) ; break ; default : throw new GeoPackageEx...
Is the feature table indexed in the provided type location
127,369
public FeatureIndexResults query ( ) { FeatureIndexResults results = null ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : long count = featureTableIndex . count ( ) ; CloseableIterator < GeometryIndex > geometryIndices = featureTableIndex . query ( ) ; results = new FeatureIndexGeoPackageResults ( featureTableIndex...
Query for all feature index results
127,370
public long count ( BoundingBox boundingBox ) { long count = 0 ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : count = featureTableIndex . count ( boundingBox ) ; break ; case RTREE : count = rTreeIndexTableDao . count ( boundingBox ) ; break ; default : count = manualFeatureQuery . count ( boundingBox ) ; } return...
Query for feature index count within the bounding box projected correctly
127,371
public FeatureIndexResults query ( GeometryEnvelope envelope ) { FeatureIndexResults results = null ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : long count = featureTableIndex . count ( envelope ) ; CloseableIterator < GeometryIndex > geometryIndices = featureTableIndex . query ( envelope ) ; results = new Featu...
Query for feature index results within the Geometry Envelope
127,372
public long count ( GeometryEnvelope envelope ) { long count = 0 ; switch ( getIndexedType ( ) ) { case GEOPACKAGE : count = featureTableIndex . count ( envelope ) ; break ; case RTREE : count = rTreeIndexTableDao . count ( envelope ) ; break ; default : count = manualFeatureQuery . count ( envelope ) ; } return count ...
Query for feature index count within the Geometry Envelope
127,373
public Integer getZoomLevelMax ( int zoomLevel ) { Integer zoomMax = zoomLevelMax . get ( zoomLevel ) ; if ( zoomMax == null ) { zoomMax = 0 ; } return zoomMax ; }
Get the max at the zoom level
127,374
public int getZoomLevelProgress ( int zoomLevel ) { Integer zoomProgress = zoomLevelProgress . get ( zoomLevel ) ; if ( zoomProgress == null ) { zoomProgress = 0 ; } return zoomProgress ; }
Get the total progress at the zoom level
127,375
public BufferedImage createImage ( ) { BufferedImage image = null ; Graphics2D graphics = null ; for ( int layer = 0 ; layer < 4 ; layer ++ ) { BufferedImage layerImage = layeredImage [ layer ] ; if ( layerImage != null ) { if ( image == null ) { image = layerImage ; graphics = layeredGraphics [ layer ] ; } else { grap...
Create the final image from the layers resets the layers
127,376
public void dispose ( ) { for ( int layer = 0 ; layer < 4 ; layer ++ ) { Graphics2D graphics = layeredGraphics [ layer ] ; if ( graphics != null ) { graphics . dispose ( ) ; layeredGraphics [ layer ] = null ; } BufferedImage image = layeredImage [ layer ] ; if ( image != null ) { image . flush ( ) ; layeredImage [ laye...
Dispose of the layered graphics and images
127,377
private BufferedImage getImage ( int layer ) { BufferedImage image = layeredImage [ layer ] ; if ( image == null ) { createImageAndGraphics ( layer ) ; image = layeredImage [ layer ] ; } return image ; }
Get the bitmap for the layer index
127,378
private Graphics2D getGraphics ( int layer ) { Graphics2D graphics = layeredGraphics [ layer ] ; if ( graphics == null ) { createImageAndGraphics ( layer ) ; graphics = layeredGraphics [ layer ] ; } return graphics ; }
Get the graphics for the layer index
127,379
private void createImageAndGraphics ( int layer ) { layeredImage [ layer ] = new BufferedImage ( tileWidth , tileHeight , BufferedImage . TYPE_INT_ARGB ) ; layeredGraphics [ layer ] = layeredImage [ layer ] . createGraphics ( ) ; layeredGraphics [ layer ] . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , Renderi...
Create a new empty Image and Graphics
127,380
public void resize ( int maxSize ) { this . maxSize = maxSize ; if ( cache . size ( ) > maxSize ) { int count = 0 ; Iterator < Long > rowIds = cache . keySet ( ) . iterator ( ) ; while ( rowIds . hasNext ( ) ) { rowIds . next ( ) ; if ( ++ count > maxSize ) { rowIds . remove ( ) ; } } } }
Resize the cache
127,381
private CoverageDataTileMatrixResults getResults ( BoundingBox requestProjectedBoundingBox , TileMatrix tileMatrix , int overlappingPixels ) { CoverageDataTileMatrixResults results = null ; BoundingBox paddedBoundingBox = padBoundingBox ( tileMatrix , requestProjectedBoundingBox , overlappingPixels ) ; TileResultSet ti...
Get the coverage data tile results for a specified tile matrix
127,382
private TileResultSet retrieveSortedTileResults ( BoundingBox projectedRequestBoundingBox , TileMatrix tileMatrix ) { TileResultSet tileResults = null ; if ( tileMatrix != null ) { TileGrid tileGrid = TileBoundingBoxUtils . getTileGrid ( coverageBoundingBox , tileMatrix . getMatrixWidth ( ) , tileMatrix . getMatrixHeig...
Get the tile row results of coverage data tiles needed to create the requested bounding box coverage data sorted by row and then column
127,383
public List < MediaRow > getRows ( List < Long > ids ) { List < MediaRow > mediaRows = new ArrayList < > ( ) ; for ( long id : ids ) { UserCustomRow userCustomRow = queryForIdRow ( id ) ; if ( userCustomRow != null ) { mediaRows . add ( getRow ( userCustomRow ) ) ; } } return mediaRows ; }
Get the media rows that exist with the provided ids
127,384
private static Color getColor ( String colorString ) { Color color = null ; String [ ] colorParts = colorString . split ( "," ) ; try { switch ( colorParts . length ) { case 1 : Field field = Color . class . getField ( colorString ) ; color = ( Color ) field . get ( null ) ; break ; case 3 : color = new Color ( Integer...
Get the color from the string
127,385
private static String colorString ( Color color ) { return color . getRed ( ) + "," + color . getGreen ( ) + "," + color . getBlue ( ) + "," + color . getAlpha ( ) ; }
Get a r g b a color string from the color
127,386
public Integer getIntegerProperty ( String property , boolean required ) { Integer integerValue = null ; String value = getProperty ( property , required ) ; if ( value != null ) { try { integerValue = Integer . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new GeoPackageException ( GEOPACKAGE_PROPERT...
Get the Integer property
127,387
public Double getDoubleProperty ( String property , boolean required ) { Double doubleValue = null ; String value = getProperty ( property , required ) ; if ( value != null ) { try { doubleValue = Double . valueOf ( value ) ; } catch ( NumberFormatException e ) { throw new GeoPackageException ( GEOPACKAGE_PROPERTIES_FI...
Get the Double property
127,388
public String getProperty ( String property , boolean required ) { if ( properties == null ) { throw new GeoPackageException ( "Properties must be loaded before reading" ) ; } String value = properties . getProperty ( property ) ; if ( value == null && required ) { throw new GeoPackageException ( GEOPACKAGE_PROPERTIES_...
Get the String property
127,389
public void writeFile ( TileDao tileDao ) { try { PrintWriter pw = new PrintWriter ( propertiesFile ) ; TileMatrixSet tileMatrixSet = tileDao . getTileMatrixSet ( ) ; pw . println ( GEOPACKAGE_PROPERTIES_EPSG + "=" + tileMatrixSet . getSrs ( ) . getOrganizationCoordsysId ( ) ) ; pw . println ( GEOPACKAGE_PROPERTIES_MIN...
Write the properties file using the tile dao
127,390
public String header ( ) { StringBuilder output = new StringBuilder ( ) ; output . append ( "GeoPackage File: " + geoPackage . getPath ( ) ) ; output . append ( "\nGeoPackage Name: " + geoPackage . getName ( ) ) ; return output . toString ( ) ; }
Get the GeoPackage file and name header text
127,391
public String tileTable ( String table ) { StringBuilder output = new StringBuilder ( ) ; TileDao tileDao = geoPackage . getTileDao ( table ) ; output . append ( "Table Name: " + tileDao . getTableName ( ) ) ; long minZoom = tileDao . getMinZoom ( ) ; long maxZoom = tileDao . getMaxZoom ( ) ; output . append ( "\nMin Z...
Build text from a tile table
127,392
public String textOutput ( SpatialReferenceSystem srs ) { StringBuilder output = new StringBuilder ( ) ; output . append ( "\tSRS " + SpatialReferenceSystem . COLUMN_ORGANIZATION + ": " + srs . getOrganization ( ) ) ; output . append ( "\n\tSRS " + SpatialReferenceSystem . COLUMN_ORGANIZATION_COORDSYS_ID + ": " + srs ....
Text output from a SRS
127,393
public String textOutput ( Contents contents ) { StringBuilder output = new StringBuilder ( ) ; output . append ( "\t" + Contents . COLUMN_TABLE_NAME + ": " + contents . getTableName ( ) ) ; output . append ( "\n\t" + Contents . COLUMN_DATA_TYPE + ": " + contents . getDataType ( ) ) ; output . append ( "\n\t" + Content...
Text output from a Contents
127,394
public String textOutput ( TileMatrixSet tileMatrixSet ) { StringBuilder output = new StringBuilder ( ) ; output . append ( "\t" + TileMatrixSet . COLUMN_TABLE_NAME + ": " + tileMatrixSet . getTableName ( ) ) ; output . append ( "\n" + textOutput ( tileMatrixSet . getSrs ( ) ) ) ; output . append ( "\n\t" + TileMatrixS...
Text output from a TileMatrixSet
127,395
public String textOutput ( TileMatrix tileMatrix ) { StringBuilder output = new StringBuilder ( ) ; output . append ( "\t" + TileMatrix . COLUMN_TABLE_NAME + ": " + tileMatrix . getTableName ( ) ) ; output . append ( "\n\t" + TileMatrix . COLUMN_ZOOM_LEVEL + ": " + tileMatrix . getZoomLevel ( ) ) ; output . append ( "\...
Text output from a Tile Matrix
127,396
public String textOutput ( BoundingBox boundingBox ) { StringBuilder output = new StringBuilder ( ) ; output . append ( "\tMin Longitude: " + boundingBox . getMinLongitude ( ) ) ; output . append ( "\n\tMin Latitude: " + boundingBox . getMinLatitude ( ) ) ; output . append ( "\n\tMax Longitude: " + boundingBox . getMax...
Text output from a bounding box
127,397
public void writeTiff ( ) { if ( directory . getWriteRasters ( ) != null ) { TIFFImage tiffImage = new TIFFImage ( ) ; tiffImage . add ( directory ) ; try { imageBytes = TiffWriter . writeTiffToBytes ( tiffImage ) ; } catch ( IOException e ) { throw new GeoPackageException ( "Failed to write TIFF image" , e ) ; } } }
Write the TIFF file to the image bytes
127,398
public float getPixel ( int x , int y ) { float pixel = - 1 ; if ( rasters == null ) { readPixels ( ) ; } if ( rasters != null ) { pixel = rasters . getFirstPixelSample ( x , y ) . floatValue ( ) ; } else { throw new GeoPackageException ( "Could not retrieve pixel value" ) ; } return pixel ; }
Get the pixel at the coordinate
127,399
public void setStyle ( StyleRow styleRow , GeometryType geometryType ) { if ( geometryType != null ) { if ( styleRow != null ) { styles . put ( geometryType , styleRow ) ; } else { styles . remove ( geometryType ) ; } } else { defaultStyle = styleRow ; } }
Set the style for the geometry type