Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.ogc / org.gvsig.raster.wmts.ogc.impl / src / main / java / org / gvsig / raster / wmts / ogc / impl / struct / WMTSBoundingBoxImpl.java @ 2613

History | View | Annotate | Download (3.31 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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.wmts.ogc.impl.struct;
23

    
24
import java.awt.geom.Rectangle2D;
25
import java.io.IOException;
26

    
27
import org.gvsig.raster.wmts.ogc.struct.WMTSBoundingBox;
28
import org.kxml2.io.KXmlParser;
29
import org.xmlpull.v1.XmlPullParserException;
30

    
31
/**
32
 * Describes the bounding box of a layer in a WMTS server
33
 *
34
 * @author Nacho Brodin (nachobrodin@gmail.com)
35
 */
36
public abstract class WMTSBoundingBoxImpl implements WMTSBoundingBox {
37
        private double[]   lowerCorner                  = new double[2];
38
        private double[]   upperCorner                  = new double[2];
39
        private String     crs                          = "";
40
        private int        dimensions                   = 2;
41
        //protected boolean  forceLongitudeFirstAxisOrder = false;
42
        
43
        /**
44
         * Sets longitude first in the axis order read from the capabilities file
45
         * @param force
46
         */
47
        /*public void setForceLongitudeFirstAxisOrder(boolean force) {
48
                this.forceLongitudeFirstAxisOrder = force;
49
        }*/
50
        
51
        /**
52
     * Parses this service ID
53
     * @param parser
54
     * @param content
55
     * @throws IOException
56
     * @throws XmlPullParserException
57
     */
58
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; 
59
    
60
        
61
        public double[] getLowerCorner() {
62
                return lowerCorner;
63
        }
64
        
65
        public void setLowerCorner(double[] lowerCorner) {
66
                this.lowerCorner = lowerCorner;
67
        }
68
        
69
        public double[] getUpperCorner() {
70
                return upperCorner;
71
        }
72
        
73
        public void setUpperCorner(double[] upperCorner) {
74
                this.upperCorner = upperCorner;
75
        }
76
        
77
        public String getCrs() {
78
                return crs;
79
        }
80
        
81
        public void setCrs(String crs) {
82
                this.crs = crs;
83
        }
84
        
85
        public int getDimensions() {
86
                return dimensions;
87
        }
88
        
89
        public void setDimensions(int dimensions) {
90
                this.dimensions = dimensions;
91
        }
92
        
93
        public Rectangle2D toRectangle2D() {
94
                return new Rectangle2D.Double(Math.min(upperCorner[0], lowerCorner[0]), 
95
                                Math.min(upperCorner[1], lowerCorner[1]), 
96
                                Math.abs(upperCorner[0] - lowerCorner[0]), 
97
                                Math.abs(upperCorner[1] - lowerCorner[1]));
98
        }
99
        
100
        public boolean isValid() {
101
                return lowerCorner[0] != 0 || lowerCorner[1] != 0 || upperCorner[0] != 0 || upperCorner[1] != 0;
102
        }
103
        
104
        public void print() {
105
                System.out.println("*****WMTSBoundingBox******");
106
                System.out.println("LowerCorner:" + getLowerCorner()[0] + "," + getLowerCorner()[1]);
107
                System.out.println("UpperCorner:" + getUpperCorner()[0] + "," + getUpperCorner()[1]);
108
                System.out.println("Crs:" + getCrs());
109
                System.out.println("Dimensions:" + getDimensions());
110
        }
111
}