org.cts.op.transformation.grids
Class BleggGeographicGrid

java.lang.Object
  extended by org.cts.op.transformation.grids.GeographicGrid
      extended by org.cts.op.transformation.grids.BleggGeographicGrid
All Implemented Interfaces:
Grid

public class BleggGeographicGrid
extends GeographicGrid

Class containing codec functions to compress or uncompress a GeographicGrid in the BLEGG format (Bit Level Encoded Geographic Grid)

Format Specification :
5 bytes : "BLEGG"
4 bytes : integer (java), block size
4 bytes : integer (java), number of lines
4 bytes : integer (java), number of columns
4 bytes : integer (java), scale (terrain length = int value/scale)
8 bytes : double (java), x0 (x coordinate of the upper-left corner)
8 bytes : double (java), y0 (y coordinate of the upper-left corner)
8 bytes : double (java), total width of the grid (terrain coordinates)
8 bytes : double (java), total height of the grid (terrain coordinates)
4 bytes : integer value in the first line, first column
4 bytes : integer value in the first line, second column

n blocks follow : Ils décrivent la matrice suivant un parcours en zigzag (gauche-droite pour les lignes paires et droite-gauche pour les lignes impaires) commençant à la première ligne et 3ème colonne.

Chaque valeur codée représente la différence
(n-(n-1)) - ((n-1)-(n-2)) c'est à dire la variation de la pente

Description d'un bloc 1er octet : entier représentant le nombre de bits servant à stocker chaque valeur
p octets : p = taille bloc x valeur stockée dans le premier octet / 8
Chaque groupe de nbBits sert à coder une valeur de la matrice.
Le premier groupe du premier bloc représente la 3eme colonne de la premiere ligne.
C'est la différence des différences entre valeurs successives qui est codée :
C3 = (valeur3-valeur2) - (valeur2-valeur1)
Rappelons que le parcours des blocs décrit la matrice en zig-zag
Le dernier blocs peut être légèrement plus grand que nécessaire.

Author:
Michaël Michaud

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.cts.op.transformation.grids.Grid
Grid.InterpolationMethod
 
Field Summary
 
Fields inherited from class org.cts.op.transformation.grids.GeographicGrid
colNumber, context, dim, dx, dy, extent, modulo, rowNumber, values, x0, xL, y0, yL
 
Fields inherited from interface org.cts.op.transformation.grids.Grid
BICUBIC, BILINEAR, NEAREST
 
Constructor Summary
BleggGeographicGrid(InputStream is)
          Construct a GeographicGrid of floats from a compressed stream
 
Method Summary
static void compress(double[][][] values, int scale, int groupSize, double x0, double y0, double gridWidth, double gridHeight, OutputStream os)
          Compress and write a grid of double at the bit level
static void compress(double[][][] values, int scale, int groupSize, OutputStream os)
          Compress and write a grid of double at the bit level
 int getGroupSize()
           
 void setGroupSize(int groupSize)
           
static void write(GeographicGrid gg, OutputStream os)
          Write a GeographicGrid in a Blegg-compressed format.
 
Methods inherited from class org.cts.op.transformation.grids.GeographicGrid
bilinearInterpolation, getColumnNumber, getContext, getDX, getDY, getGridHeight, getGridWidth, getRowNumber, getScale, getValue, getValues, getValues, getX0, getXL, getY0, getYL, setScale, setValue, toString, toStringAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BleggGeographicGrid

public BleggGeographicGrid(InputStream is)
                    throws Exception

Construct a GeographicGrid of floats from a compressed stream

Parameters:
is - input stream
Throws:
Exception
Method Detail

getGroupSize

public int getGroupSize()

setGroupSize

public void setGroupSize(int groupSize)

compress

public static void compress(double[][][] values,
                            int scale,
                            int groupSize,
                            OutputStream os)
                     throws Exception

Compress and write a grid of double at the bit level

Parameters:
values - grid of double values. The array of array is supposed to be rectangle.
scale - scale factor used to transform doubles values to int : each value will be considered equal to Math.rint(value*scale)
groupSize - is the number of consecutive values coded with the same bit number (default is 16).
os - outputStream
Throws:
Exception

compress

public static void compress(double[][][] values,
                            int scale,
                            int groupSize,
                            double x0,
                            double y0,
                            double gridWidth,
                            double gridHeight,
                            OutputStream os)
                     throws Exception

Compress and write a grid of double at the bit level

Parameters:
values - grid of double values. The array of array is supposed to be rectangle.
scale - scale factor used to transform doubles values to int : each value will be considered equal to Math.rint(value*scale)
groupSize - is the number of consecutive values coded with the same bit number (default is 16).
x0 - longitude origine (may be negative)
y0 - latitude maximum
gridWidth - in degrees
gridHeight - in degrees
os - output stream
Throws:
Exception

write

public static void write(GeographicGrid gg,
                         OutputStream os)
                  throws Exception

Write a GeographicGrid in a Blegg-compressed format.

Parameters:
gg - grid to write.
os - OutputStream
Throws:
Exception


Copyright © 2014 IRSTV CNRS-FR-2488. All Rights Reserved.