TileMatrixSet.pm

Summary
TileMatrixSet.pm
BE4::TileMatrixSetLoad and store all information about a Tile Matrix Set.
Constructors
newTileMatrixSet constructor.
_loadRead and parse the Tile Matrix Set XML file to create a TileMatrix object for each level.
Getters - Setters
getPathFilename
getSRS
getInversion
getName
getPath
getFile
getTopLevel
getBottomLevel
getTopResolution
getBottomResolution
getTileWidth
getTileHeight
isQTree
getTileMatrixByArrayReturns the tile matrix array in the ascending resolution order.
getTileMatrixReturns the tile matrix from the supplied ID.
getCountTileMatrixReturns the count of tile matrix in the TMS.
getIDfromOrderReturns the tile matrix ID from the ascending resolution order (integer).
getBelowLevelIDReturns the tile matrix ID below the given tile matrix (ID).
getOrderfromIDReturns the tile matrix order from the ID.
Tile Matrix manager
computeTmSourceDefines the tile matrix for the provided one.
Export methods
exportForDebugReturns all informations about the tile matrix set.
DetailsDetails about TMS file.

BE4::TileMatrixSet

Exporter
BE4::TileMatrixSet

Load and store all information about a Tile Matrix Set.  A Tile Matrix Set is a XML file which describe a grid for several levels.

We tell the difference between :

  • quad tree TMS : resolutions go by tows and borders are aligned.  To generate a pyramid which is based on this kind of TMS, we use QTree
  • ”nearest neighbour” TMS : centers are aligned (used for DTM generations, with a “nearest neighbour” interpolation).  To generate a pyramid which is based on this kind of TMS, we use <Graph>

Using

use BE4::TileMatrixSet;

my $filepath = "/home/ign/tms/LAMB93_50cm.tms";
my $objTMS = BE4::TileMatrixSet->new($filepath);

$objTMS->getTileMatrixCount()};      # ie 19
$objTMS->getTileMatrix(12);          # object TileMatrix with level id = 12
$objTMS->getSRS();                   # ie 'IGNF:LAMB93'
$objTMS->getName();                  # ie 'LAMB93_50cm'
$objTMS->getFile();                  # ie 'LAMB93_50cm.tms'
$objTMS->getPath();                  # ie '/home/ign/tms/'

Attributes

PATHFILENAMEstring - Complete file path : /path/to/SRS_RES.tms
namestring - Basename part of PATHFILENAME : SRS_RES
filenamestring - Filename part of PATHFILENAME : SRS_RES.tms
filepathstring - Directory part of PATHFILENAME : /path/to
levelsBindhash - Link between Tile matrix identifiants (string, the key) and order in ascending resolutions (integer, the value).
topIDstring - Higher level ID.
topResolutiondouble - Higher level resolution.
bottomIDstring - Lower level ID.
bottomResolutiondouble - Lower level resolution.
srsstring - Spatial Reference System, casted in uppercase (EPSG:4326).
coordinatesInversionboolean - Precise if we have to reverse coordinates to harvest in this SRS.  For some SRS, we have to reverse coordinates when we compose WMS request (1.3.0).  Used test to determine this SRSs is : if the SRS is geographic and an EPSG one.
tileMatrixTileMatrix hash - Keys are Tile Matrix identifiant, values are TileMatrix objects.
isQTreeboolean - Precise if this TMS match with a quad tree.  TRUE if this TMS describe a quad tree, FALSE otherwise.

Limitations

File name of tms must be with extension : tms or TMS.

All levels must be continuous (QuadTree) and unique.

Summary
Constructors
newTileMatrixSet constructor.
_loadRead and parse the Tile Matrix Set XML file to create a TileMatrix object for each level.
Getters - Setters
getPathFilename
getSRS
getInversion
getName
getPath
getFile
getTopLevel
getBottomLevel
getTopResolution
getBottomResolution
getTileWidth
getTileHeight
isQTree
getTileMatrixByArrayReturns the tile matrix array in the ascending resolution order.
getTileMatrixReturns the tile matrix from the supplied ID.
getCountTileMatrixReturns the count of tile matrix in the TMS.
getIDfromOrderReturns the tile matrix ID from the ascending resolution order (integer).
getBelowLevelIDReturns the tile matrix ID below the given tile matrix (ID).
getOrderfromIDReturns the tile matrix order from the ID.
Tile Matrix manager
computeTmSourceDefines the tile matrix for the provided one.
Export methods
exportForDebugReturns all informations about the tile matrix set.
DetailsDetails about TMS file.

Constructors

new

sub new

TileMatrixSet constructor.  Bless an instance.  Fill file’s informations.

Parameters (list)

pathfilestring - Path to the Tile Matrix File (with extension .tms or .TMS)

See also

_load

_load

sub _load

Read and parse the Tile Matrix Set XML file to create a TileMatrix object for each level.

It determines if the TMS match with a quad tree

  • resolutions go by twos between two contigues levels
  • top left corner coordinates and pixel dimensions are same for all levels

If TMS is not a quad tree, we have to determine the lower source level for each level (used for the genaration).

See also

computeTmSource

Getters - Setters

getPathFilename

sub getPathFilename

getSRS

sub getSRS

getInversion

sub getInversion

getName

sub getName

getPath

sub getPath

getFile

sub getFile

getTopLevel

sub getTopLevel

getBottomLevel

sub getBottomLevel

getTopResolution

sub getTopResolution

getBottomResolution

sub getBottomResolution

getTileWidth

sub getTileWidth

Parameters (list)

IDstring - Level identifiant whose tile pixel width we want.

getTileHeight

sub getTileHeight

Parameters (list)

IDstring - Level identifiant whose tile pixel height we want.

isQTree

sub isQTree

getTileMatrixByArray

sub getTileMatrixByArray

Returns the tile matrix array in the ascending resolution order.

getTileMatrix

sub getTileMatrix

Returns the tile matrix from the supplied ID.  This ID is the TMS ID (string) and not the ascending resolution order (integer).  Returns undef if ID is undefined or if asked level doesn’t exist.

Parameters (list)

IDstring - Wanted level identifiant

getCountTileMatrix

sub getCountTileMatrix

Returns the count of tile matrix in the TMS.

getIDfromOrder

sub getIDfromOrder

Returns the tile matrix ID from the ascending resolution order (integer).

  • 0 (bottom level, smallest resolution)
  • NumberOfTM-1 (top level, biggest resolution).

Parameters (list)

orderinteger - Level order, whose identifiant we want.

getBelowLevelID

sub getBelowLevelID

Returns the tile matrix ID below the given tile matrix (ID).

Parameters (list)

IDstring - Level identifiant, whose below level ID we want.

getOrderfromID

sub getOrderfromID

Returns the tile matrix order from the ID.

  • 0 (bottom level, smallest resolution)
  • NumberOfTM-1 (top level, biggest resolution).

Parameters (list)

IDstring - Level identifiant, whose order we want.

Tile Matrix manager

computeTmSource

sub computeTmSource

Defines the tile matrix for the provided one.  This method is only used for “nearest neighbour” TMS (Pixels between different level have the same centre).

Parameters (list)

tmTargetTileMatrix - Tile matrix whose source tile matrix we want to know.

Returns

FALSE if there is no TM source for TM target (unless TM target is BotttomTM) TRUE if there is a TM source (obj) for the TM target (obj) in argument.

Export methods

exportForDebug

sub exportForDebug

Returns all informations about the tile matrix set.  Useful for debug.

Example

Object BE4::TileMatrixSet :
     TMS file complete path : /home/ign/TMS/LAMB93_10cm.tms
     Top level identifiant : 0
     Top level resolution : 209715.2
     Bottom level identifiant : 21
     Bottom level resolution : 0.1
     Spatial Reference System : IGNF:LAMB93
     Coordinates have not to be inversed to harvest with WMS 1.3.0
     This TMS is a quad tree
     TileMatrix Array :
                 ID    | Order |  Resolution
            -----------+-------+------------------
                    21 |  0    | 0.1
                    20 |  1    | 0.2
                    19 |  2    | 0.4
                    18 |  3    | 0.8
                    17 |  4    | 1.6
                    16 |  5    | 3.2
                    15 |  6    | 6.4
                    14 |  7    | 12.8
                    13 |  8    | 25.6
                    12 |  9    | 51.2
                    11 |  10   | 102.4
                    10 |  11   | 204.8
                     9 |  12   | 409.6
                     8 |  13   | 819.2
                     7 |  14   | 1638.4
                     6 |  15   | 3276.8
                     5 |  16   | 6553.6
                     4 |  17   | 13107.2
                     3 |  18   | 26214.4
                     2 |  19   | 52428.8
                     1 |  20   | 104857.6
                     0 |  21   | 209715.2

Details

Details about TMS file.

Sample TMS file (LAMB93_50cm.tms)

<tileMatrixSet>
    <crs>IGNF:LAMB93</crs>
    <tileMatrix>
        <id>0</id>
        <resolution>131072</resolution>
        <topLeftCornerX> 0 </topLeftCornerX>
        <topLeftCornerY> 12000000 </topLeftCornerY>
        <tileWidth>256</tileWidth>
        <tileHeight>256</tileHeight>
        <matrixWidth>1</matrixWidth>
        <matrixHeight>1</matrixHeight>
    </tileMatrix>
    <tileMatrix>
        <id>1</id>
        <resolution>65536</resolution>
        <topLeftCornerX> 0 </topLeftCornerX>
        <topLeftCornerY> 12000000 </topLeftCornerY>
        <tileWidth>256</tileWidth>
        <tileHeight>256</tileHeight>
        <matrixWidth>1</matrixWidth>
        <matrixHeight>1</matrixHeight>
    </tileMatrix>
    .
    .
    .
    <tileMatrix>
        <id>17</id>
        <resolution>1</resolution>
        <topLeftCornerX> 0 </topLeftCornerX>
        <topLeftCornerY> 12000000 </topLeftCornerY>
        <tileWidth>256</tileWidth>
        <tileHeight>256</tileHeight>
        <matrixWidth>5040</matrixWidth>
        <matrixHeight>42040</matrixHeight>
    </tileMatrix>
    <tileMatrix>
        <id>18</id>
        <resolution>0.5</resolution>
        <topLeftCornerX> 0 </topLeftCornerX>
        <topLeftCornerY> 12000000 </topLeftCornerY>
        <tileWidth>256</tileWidth>
        <tileHeight>256</tileHeight>
        <matrixWidth>10080</matrixWidth>
        <matrixHeight>84081</matrixHeight>
    </tileMatrix>
</tileMatrixSet>
sub new
TileMatrixSet constructor.
sub _load
Read and parse the Tile Matrix Set XML file to create a TileMatrix object for each level.
sub getPathFilename
sub getSRS
sub getInversion
sub getName
sub getPath
sub getFile
sub getTopLevel
sub getBottomLevel
sub getTopResolution
sub getBottomResolution
sub getTileWidth
sub getTileHeight
sub isQTree
sub getTileMatrixByArray
Returns the tile matrix array in the ascending resolution order.
sub getTileMatrix
Returns the tile matrix from the supplied ID.
sub getCountTileMatrix
Returns the count of tile matrix in the TMS.
sub getIDfromOrder
Returns the tile matrix ID from the ascending resolution order (integer).
sub getBelowLevelID
Returns the tile matrix ID below the given tile matrix (ID).
sub getOrderfromID
Returns the tile matrix order from the ID.
sub computeTmSource
Defines the tile matrix for the provided one.
sub exportForDebug
Returns all informations about the tile matrix set.
Representation of a quad tree image pyramid : pyramid’s image = Node
A Tile Matrix defines a grid for a level.
Close