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