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 / TileMatrixLimits.java @ 85

History | View | Annotate | Download (2.99 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
import java.awt.geom.Point2D;
25

    
26
/**
27
 * Limits of a tile matrix
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public class TileMatrixLimits {
31
        private TileMatrix             tileMatrix           = null;
32
        private int                    minTileRow           = 0;
33
        private int                    maxTileRow           = 0;
34
        private int                    minTileCol           = 0;
35
        private int                    maxTileCol           = 0;
36
        
37
        public TileMatrix getTileMatrix() {
38
                if(tileMatrix == null)
39
                        tileMatrix = new TileMatrix();
40
                return tileMatrix;
41
        }
42

    
43
        /**
44
         * Gets the upper left corner and the lower right corner of the 
45
         * selected tile
46
         * @param x X tile position
47
         * @param y Y tile position
48
         * @return
49
         */
50
        public Point2D[] getTileExtent(int x, int y) {
51
                double sizeXTile = getTileMatrix().getTileWidth() * getTileMatrix().getScaleXDenominator();
52
                double sizeYTile = getTileMatrix().getTileWidth() * getTileMatrix().getScaleYDenominator();
53
                double initX = getTileMatrix().getTopLeftCorner()[0] + (sizeXTile * x);
54
                double initY = getTileMatrix().getTopLeftCorner()[1] - (sizeYTile * y);
55
                Point2D[] p = new Point2D[2];
56
                p[0] = new Point2D.Double(initX, initY);
57
                p[1] = new Point2D.Double(initX + sizeXTile, initY - sizeYTile);
58
                return p;
59
        }
60
        
61
        public int getMinTileRow() {
62
                return minTileRow;
63
        }
64
        
65
        public void setMinTileRow(int minTileRow) {
66
                this.minTileRow = minTileRow;
67
        }
68
        
69
        public int getMaxTileRow() {
70
                return maxTileRow;
71
        }
72
        
73
        public void setMaxTileRow(int maxTileRow) {
74
                this.maxTileRow = maxTileRow;
75
        }
76
        
77
        public int getMinTileCol() {
78
                return minTileCol;
79
        }
80
        
81
        public void setMinTileCol(int minTileCol) {
82
                this.minTileCol = minTileCol;
83
        }
84
        
85
        public int getMaxTileCol() {
86
                return maxTileCol;
87
        }
88
        
89
        public void setMaxTileCol(int maxTileCol) {
90
                this.maxTileCol = maxTileCol;
91
        }
92
        
93
        public void print() {
94
                System.out.println("  *****TileMatrixLimits******");
95
                System.out.println("  MaxTileCol:" + getMaxTileCol());
96
                System.out.println("  MaxTileRow:" + getMaxTileRow());
97
                System.out.println("  MinTileCol:" + getMinTileCol());
98
                System.out.println("  MinTileRow:" + getMinTileRow());
99
                if(tileMatrix != null)
100
                        tileMatrix.print();
101
        }
102
}