svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wmts / struct / WMTSLayer.java @ 40769
History | View | Annotate | Download (6.78 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.util.ArrayList; |
27 |
|
28 |
import org.gvsig.remoteclient.wmts.WMTSServerDescription; |
29 |
|
30 |
/**
|
31 |
* Describes the attributes of a layer in a WMTS server
|
32 |
*
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
34 |
*/
|
35 |
public abstract class WMTSLayer extends WMTSBaseStruct { |
36 |
protected WMTSBoundingBox wgs84bbox = null; |
37 |
protected WMTSBoundingBox bbox = null; |
38 |
//WMTSStyle
|
39 |
private ArrayList style = null; |
40 |
private ArrayList imageFormat = null; |
41 |
private ArrayList infoFormat = null; |
42 |
private ArrayList keywords = null; |
43 |
private WMTSDimension dimension = null; |
44 |
private String metadata = null; |
45 |
//WMTSTileMatrixSetLink
|
46 |
private ArrayList tileMatrixSetLinkList = null; |
47 |
private WMTSResourceURL resourceURL = null; |
48 |
protected WMTSServerDescription status = null; |
49 |
protected boolean forceLongitudeFirstAxisOrder = false; |
50 |
|
51 |
/**
|
52 |
* Sets longitude first in the axis order read from the capabilities file
|
53 |
* @param force
|
54 |
*/
|
55 |
public void setForceLongitudeFirstAxisOrder(boolean force) { |
56 |
this.forceLongitudeFirstAxisOrder = force;
|
57 |
} |
58 |
|
59 |
public WMTSLayer(WMTSServerDescription status) {
|
60 |
this.status = status;
|
61 |
} |
62 |
|
63 |
public String getMetadata() { |
64 |
return metadata;
|
65 |
} |
66 |
|
67 |
public void setMetadata(String metadata) { |
68 |
this.metadata = metadata;
|
69 |
} |
70 |
|
71 |
public ArrayList getFormat() { |
72 |
if(imageFormat == null) |
73 |
imageFormat = new ArrayList(); |
74 |
return imageFormat;
|
75 |
} |
76 |
|
77 |
public ArrayList getInfoFormat() { |
78 |
if(infoFormat == null) |
79 |
infoFormat = new ArrayList(); |
80 |
return infoFormat;
|
81 |
} |
82 |
|
83 |
public ArrayList getKeywords() { |
84 |
return keywords;
|
85 |
} |
86 |
|
87 |
public void setKeywords(ArrayList k) { |
88 |
this.keywords = k;
|
89 |
} |
90 |
|
91 |
public abstract WMTSBoundingBox getWGS84BBox(); |
92 |
|
93 |
public abstract WMTSBoundingBox getBBox(); |
94 |
|
95 |
public WMTSResourceURL getResourceURL() {
|
96 |
if(resourceURL == null) |
97 |
resourceURL = (WMTSResourceURL)status.createVersionObject("WMTSResourceURL");
|
98 |
return resourceURL;
|
99 |
} |
100 |
|
101 |
public WMTSDimension getDimension() {
|
102 |
if(dimension == null) |
103 |
dimension = (WMTSDimension)status.createVersionObject("WMTSDimension");
|
104 |
return dimension;
|
105 |
} |
106 |
|
107 |
public ArrayList getStyle() { |
108 |
if(style == null) |
109 |
style = new ArrayList();//(WMTSStyle)status.createVersionObject("WMTSStyle"); |
110 |
return style;
|
111 |
} |
112 |
|
113 |
public ArrayList getTileMatrixSetLink() { |
114 |
if(tileMatrixSetLinkList == null) |
115 |
tileMatrixSetLinkList = new ArrayList(); |
116 |
return tileMatrixSetLinkList;
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* Returns the initial level of this layer inside the matrix set.
|
121 |
* @return
|
122 |
*/
|
123 |
public int getInitialLevel(String tileMatrixSetId) { |
124 |
int initialLevel = 0; |
125 |
for (int i = 0; i < tileMatrixSetLinkList.size(); i++) { |
126 |
WMTSTileMatrixSetLink tileMatrixSetLink = (WMTSTileMatrixSetLink)tileMatrixSetLinkList.get(i); |
127 |
String id = tileMatrixSetLink.getTileMatrixSetId();
|
128 |
if(tileMatrixSetId.compareTo(id) == 0) { |
129 |
ArrayList tileMatrixLimits = tileMatrixSetLink.getTileMatrixLimits();
|
130 |
if(tileMatrixLimits != null && tileMatrixLimits.size() > 0) { |
131 |
String ref = ((WMTSTileMatrixLimits)tileMatrixLimits.get(0)).getRefToTileMatrix(); |
132 |
ArrayList tileMatrixList = tileMatrixSetLink.getTileMatrixSet().getTileMatrix();
|
133 |
for (int j = 0; j < tileMatrixList.size(); j++) { |
134 |
String idTileMatrix = ((WMTSTileMatrix)tileMatrixList.get(j)).getIdentifier();
|
135 |
if(idTileMatrix.compareTo(ref) == 0) |
136 |
return initialLevel;
|
137 |
initialLevel ++; |
138 |
} |
139 |
} |
140 |
} |
141 |
} |
142 |
return initialLevel;
|
143 |
} |
144 |
|
145 |
/**
|
146 |
* Links the TileMatrixSet with the limits inside the layer structure
|
147 |
* @param tileMatrixSetList
|
148 |
*/
|
149 |
public void linkTileMatrixSets(ArrayList tileMatrixSetList) { |
150 |
//Recorre la lista de TileMatrixSetLink y a cada uno le asigna su TileMatrixSet
|
151 |
//Para cada TileMatrixLimits contenido en el TileMatrixSetLimits asociado le asigna
|
152 |
//el objeto TileMatrix a partir de su referencia.
|
153 |
if(tileMatrixSetLinkList == null) |
154 |
return;
|
155 |
for (int i = 0; i < tileMatrixSetLinkList.size(); i++) { |
156 |
WMTSTileMatrixSetLink tileMatrixSetLink = (WMTSTileMatrixSetLink)tileMatrixSetLinkList.get(i); |
157 |
String id = tileMatrixSetLink.getTileMatrixSetId();
|
158 |
for (int j = 0; j < tileMatrixSetList.size(); j++) { |
159 |
WMTSTileMatrixSet tileMatrixSet = (WMTSTileMatrixSet)tileMatrixSetList.get(j); |
160 |
if(tileMatrixSet.getIdentifier().compareTo(id) == 0) { |
161 |
tileMatrixSetLink.setTileMatrixSet(tileMatrixSet); |
162 |
tileMatrixSetLink.linkTileMatrix(tileMatrixSet); |
163 |
break;
|
164 |
} |
165 |
} |
166 |
} |
167 |
} |
168 |
|
169 |
/**
|
170 |
* Gets the list of srs's supported
|
171 |
* @return
|
172 |
*/
|
173 |
public ArrayList getSrsList() { |
174 |
ArrayList list = new ArrayList(); |
175 |
for (int i = 0; i < tileMatrixSetLinkList.size(); i++) { |
176 |
WMTSTileMatrixSetLink link = (WMTSTileMatrixSetLink)tileMatrixSetLinkList.get(i); |
177 |
WMTSTileMatrixSet tileMatrixSet = link.getTileMatrixSet(); |
178 |
list.add(tileMatrixSet.getSupportedCRS()); |
179 |
} |
180 |
return list;
|
181 |
} |
182 |
|
183 |
public void print() { |
184 |
System.out.println("*****WMTSLayer******"); |
185 |
System.out.println("Abstract:" + getAbstract()); |
186 |
System.out.println("Identifier:" + getIdentifier()); |
187 |
System.out.println("Keywords:"); |
188 |
for (int i = 0; i < keywords.size(); i++) { |
189 |
System.out.println("Keyword:" + keywords.get(i)); |
190 |
} |
191 |
System.out.println("Title:" + getTitle()); |
192 |
for (int i = 0; i < getFormat().size(); i++) { |
193 |
System.out.println("Format:" + getFormat().get(i)); |
194 |
} |
195 |
for (int i = 0; i < getInfoFormat().size(); i++) { |
196 |
System.out.println("InfoFormat:" + getInfoFormat().get(i)); |
197 |
} |
198 |
getBBox().print(); |
199 |
getWGS84BBox().print(); |
200 |
getDimension().print(); |
201 |
System.out.println("Metadata:" + getMetadata()); |
202 |
for (int i = 0; i < getTileMatrixSetLink().size(); i++) { |
203 |
((WMTSTileMatrixSetLink)getTileMatrixSetLink().get(i)).print(); |
204 |
} |
205 |
} |
206 |
|
207 |
} |