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