svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wmts / struct / WMTSBoundingBox.java @ 40769
History | View | Annotate | Download (3.29 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.remoteclient.wmts.struct; |
25 |
|
26 |
import java.awt.geom.Rectangle2D; |
27 |
import java.io.IOException; |
28 |
|
29 |
import org.kxml2.io.KXmlParser; |
30 |
import org.xmlpull.v1.XmlPullParserException; |
31 |
|
32 |
/**
|
33 |
* Describes the bounding box of a layer in a WMTS server
|
34 |
*
|
35 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
36 |
*/
|
37 |
public abstract class WMTSBoundingBox { |
38 |
private double[] lowerCorner = new double[2]; |
39 |
private double[] upperCorner = new double[2]; |
40 |
private String crs = ""; |
41 |
private int dimensions = 2; |
42 |
protected boolean forceLongitudeFirstAxisOrder = false; |
43 |
|
44 |
/**
|
45 |
* Sets longitude first in the axis order read from the capabilities file
|
46 |
* @param force
|
47 |
*/
|
48 |
public void setForceLongitudeFirstAxisOrder(boolean force) { |
49 |
this.forceLongitudeFirstAxisOrder = force;
|
50 |
} |
51 |
|
52 |
/**
|
53 |
* Parses this service ID
|
54 |
* @param parser
|
55 |
* @param content
|
56 |
* @throws IOException
|
57 |
* @throws XmlPullParserException
|
58 |
*/
|
59 |
public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; |
60 |
|
61 |
|
62 |
public double[] getLowerCorner() { |
63 |
return lowerCorner;
|
64 |
} |
65 |
|
66 |
public void setLowerCorner(double[] lowerCorner) { |
67 |
this.lowerCorner = lowerCorner;
|
68 |
} |
69 |
|
70 |
public double[] getUpperCorner() { |
71 |
return upperCorner;
|
72 |
} |
73 |
|
74 |
public void setUpperCorner(double[] upperCorner) { |
75 |
this.upperCorner = upperCorner;
|
76 |
} |
77 |
|
78 |
public String getCrs() { |
79 |
return crs;
|
80 |
} |
81 |
|
82 |
public void setCrs(String crs) { |
83 |
this.crs = crs;
|
84 |
} |
85 |
|
86 |
public int getDimensions() { |
87 |
return dimensions;
|
88 |
} |
89 |
|
90 |
public void setDimensions(int dimensions) { |
91 |
this.dimensions = dimensions;
|
92 |
} |
93 |
|
94 |
public Rectangle2D toRectangle2D() { |
95 |
return new Rectangle2D.Double(Math.min(upperCorner[0], lowerCorner[0]), |
96 |
Math.min(upperCorner[1], lowerCorner[1]), |
97 |
Math.abs(upperCorner[0] - lowerCorner[0]), |
98 |
Math.abs(upperCorner[1] - lowerCorner[1])); |
99 |
} |
100 |
|
101 |
public boolean isValid() { |
102 |
return lowerCorner[0] != 0 || lowerCorner[1] != 0 || upperCorner[0] != 0 || upperCorner[1] != 0; |
103 |
} |
104 |
|
105 |
public void print() { |
106 |
System.out.println("*****WMTSBoundingBox******"); |
107 |
System.out.println("LowerCorner:" + getLowerCorner()[0] + "," + getLowerCorner()[1]); |
108 |
System.out.println("UpperCorner:" + getUpperCorner()[0] + "," + getUpperCorner()[1]); |
109 |
System.out.println("Crs:" + getCrs()); |
110 |
System.out.println("Dimensions:" + getDimensions()); |
111 |
} |
112 |
} |