Statistics
| Revision:

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
/* 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
import org.gvsig.remoteclient.wmts.WMTSServerDescription;
27

    
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
        protected WMTSBoundingBox       wgs84bbox                    = null;
35
        protected WMTSBoundingBox       bbox                         = null;
36
        //WMTSStyle
37
        private ArrayList               style                        = null;
38
        private ArrayList               imageFormat                  = null;
39
        private ArrayList               infoFormat                   = null;
40
        private ArrayList               keywords                     = null;
41
        private WMTSDimension           dimension                    = null;
42
        private String                  metadata                     = null;
43
        //WMTSTileMatrixSetLink
44
        private ArrayList               tileMatrixSetLinkList        = null;
45
        private WMTSResourceURL         resourceURL                  = null;
46
        protected WMTSServerDescription status                       = null;
47
        protected boolean               forceLongitudeFirstAxisOrder = false;
48
        
49
        /**
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
        public WMTSLayer(WMTSServerDescription status) {
58
                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
                if(imageFormat == null)
71
                        imageFormat = new ArrayList();
72
                return imageFormat;
73
        }
74
        
75
        public ArrayList getInfoFormat() {
76
                if(infoFormat == null)
77
                        infoFormat = new ArrayList();
78
                return infoFormat;
79
        }
80
        
81
        public ArrayList getKeywords() {
82
                return keywords;
83
        }
84
        
85
        public void setKeywords(ArrayList k) {
86
                this.keywords = k;
87
        }
88
        
89
        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
        public ArrayList getStyle() {
106
                if(style == null)
107
                        style = new ArrayList();//(WMTSStyle)status.createVersionObject("WMTSStyle");
108
                return style;
109
        }
110

    
111
        public ArrayList getTileMatrixSetLink() {
112
                if(tileMatrixSetLinkList == null)
113
                        tileMatrixSetLinkList = new ArrayList();
114
                return tileMatrixSetLinkList;
115
        }
116
        
117
        /**
118
         * 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
         * 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
        }
166
        
167
        /**
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
        public void print() {
182
                System.out.println("*****WMTSLayer******");
183
                System.out.println("Abstract:" + getAbstract());
184
                System.out.println("Identifier:" + getIdentifier());
185
                System.out.println("Keywords:");
186
                for (int i = 0; i < keywords.size(); i++) {
187
                        System.out.println("Keyword:" + keywords.get(i));
188
                }
189
                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
                for (int i = 0; i < getTileMatrixSetLink().size(); i++) {
201
                        ((WMTSTileMatrixSetLink)getTileMatrixSetLink().get(i)).print();
202
                }
203
        }
204

    
205
}