public byte [ ] getRL2Image ( Geometry geom , String geomEpsg , int width , int height ) throws Exception { String sql ; String rasterName = getName ( ) ; if ( geomEpsg != null ) { sql = "select GetMapImageFromRaster('" + rasterName + "', ST_Transform(ST_GeomFromText('" + geom . toText ( ) + "', " + geomEpsg + "), " + srid + ") , " + width + " , " + height + ", 'default', 'image/png', '#ffffff', 0, 80, 1 )" ; } else { sql = "select GetMapImageFromRaster('" + rasterName + "', ST_GeomFromText('" + geom . toText ( ) + "') , " + width + " , " + height + ", 'default', 'image/png', '#ffffff', 0, 80, 1 )" ; } return database . execOnConnection ( mConn -> { try ( IHMStatement stmt = mConn . createStatement ( ) ) { IHMResultSet resultSet = stmt . executeQuery ( sql ) ; if ( resultSet . next ( ) ) { byte [ ] bytes = resultSet . getBytes ( 1 ) ; return bytes ; } } return null ; } ) ; }
Extract an image from the database .