Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wmts / struct / WMTSBoundingBox.java @ 38531

History | View | Annotate | Download (3.09 KB)

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