Statistics
| Revision:

gvsig-osm / org.gvsig.raster.osm / trunk / org.gvsig.raster.osm / org.gvsig.raster.osm.io / src / main / java / org / gvsig / raster / osm / cachestruct / TileMatrix.java @ 85

History | View | Annotate | Download (3.82 KB)

1
/* OSM layers for gvSIG. 
2
 * Geographic Information System of the Valencian Government
3
*
4
* Copyright (C) 2012 Nacho Brodin
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.osm.cachestruct;
23

    
24

    
25
/**
26
 * Description of a tile matrix
27
 * @author Nacho Brodin (nachobrodin@gmail.com)
28
 */
29
public class TileMatrix {
30
    private double                      scaleXDenominator    = 0;
31
    private double                      scaleYDenominator    = 0;
32
    private double[]                    topLeftCorner       = null;
33
    private int                         tileWidth           = 0;
34
    private int                         tileHeight          = 0;
35
    private long                        matrixWidth         = 0;
36
    private long                        matrixHeight        = 0;
37
    private static final double         MTS_X_GRADO         = 111319.490793274;
38
    
39
        public double getScaleXDenominator() {
40
                return scaleXDenominator;
41
        }
42

    
43
        public void setScaleXDenominator(double scaleXDenominator) {
44
                this.scaleXDenominator = scaleXDenominator;
45
        }
46
        
47
        public double getScaleYDenominator() {
48
                return scaleYDenominator;
49
        }
50

    
51
        public void setScaleYDenominator(double scaleYDenominator) {
52
                this.scaleYDenominator = scaleYDenominator;
53
        }
54

    
55
        public int getTileWidth() {
56
                return tileWidth;
57
        }
58

    
59
        public void setTileWidth(int tileWidth) {
60
                this.tileWidth = tileWidth;
61
        }
62

    
63
        public int getTileHeight() {
64
                return tileHeight;
65
        }
66

    
67
        public void setTileHeight(int tileHeight) {
68
                this.tileHeight = tileHeight;
69
        }
70

    
71
        public long getMatrixWidth() {
72
                return matrixWidth;
73
        }
74

    
75
        public void setMatrixWidth(long matrixWidth) {
76
                this.matrixWidth = matrixWidth;
77
        }
78

    
79
        public long getMatrixHeight() {
80
                return matrixHeight;
81
        }
82

    
83
        public void setMatrixHeight(long matrixHeight) {
84
                this.matrixHeight = matrixHeight;
85
        }
86

    
87
        public double[] getTopLeftCorner() {
88
                return topLeftCorner;
89
        }
90
        
91
        public void setTopLeftCorner(double[] topLeftCorner) {
92
                this.topLeftCorner = topLeftCorner;
93
        }
94
    
95
    /**
96
     * Gets the width in meters of a tile
97
     * @param projected
98
     * @return
99
     */
100
    public double getWidthMtsTile(boolean projected) {
101
            if(!projected) {
102
                    return (scaleXDenominator * tileWidth * 0.28) / (MTS_X_GRADO * 1000);
103
            } else {
104
                    return (scaleXDenominator * tileWidth * 0.28) / 1000;
105
            }
106
    }
107
    
108
    /**
109
     * Gets the height in meters of a tile
110
     * @param projected
111
     * @return
112
     */
113
    public double getHeightMtsTile(boolean projected) {
114
            if(!projected) {
115
                    return (scaleYDenominator * tileHeight * 0.28) / (MTS_X_GRADO * 1000);
116
            } else {
117
                    return (scaleYDenominator * tileHeight * 0.28) / 1000;
118
            }
119
    }
120
    
121
        public void print() {
122
                System.out.println("   *****TileMatrix******");
123
                System.out.println("   scaleXDenominator:" + getScaleXDenominator());
124
                System.out.println("   scaleYDenominator:" + getScaleYDenominator());
125
                if(topLeftCorner != null)
126
                        System.out.println("   topLeftCorner:" + topLeftCorner[0] + ", " + topLeftCorner[1]);
127
                System.out.println("   tileWidth:" + getTileWidth());
128
                System.out.println("   tileHeight:" + getTileHeight());
129
                System.out.println("   matrixWidth:" + getMatrixWidth());
130
                System.out.println("   matrixHeight:" + getMatrixHeight());
131
        }
132
}