Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wmts / struct / WMTSLayer.java @ 35469

History | View | Annotate | Download (5.44 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 WMTSDimension           dimension                    = null;
41
        private String                  metadata                     = null;
42
        //WMTSTileMatrixSetLink
43
        private ArrayList               tileMatrixSetLinkList        = null;
44
        private WMTSResourceURL         resourceURL                  = null;
45
        protected WMTSServerDescription status                       = null;
46
        protected boolean               forceLongitudeFirstAxisOrder = false;
47
        
48
        /**
49
         * Sets longitude first in the axis order read from the capabilities file
50
         * @param force
51
         */
52
        public void setForceLongitudeFirstAxisOrder(boolean force) {
53
                this.forceLongitudeFirstAxisOrder = force;
54
        }
55
        
56
        public WMTSLayer(WMTSServerDescription status) {
57
                this.status = status;
58
        }
59
        
60
        public String getMetadata() {
61
                return metadata;
62
        }
63
        
64
        public void setMetadata(String metadata) {
65
                this.metadata = metadata;
66
        }
67
        
68
        public ArrayList getFormat() {
69
                if(imageFormat == null)
70
                        imageFormat = new ArrayList();
71
                return imageFormat;
72
        }
73
        
74
        public ArrayList getInfoFormat() {
75
                if(infoFormat == null)
76
                        infoFormat = new ArrayList();
77
                return infoFormat;
78
        }
79
        
80
        public abstract WMTSBoundingBox getWGS84BBox();
81
        
82
        public abstract WMTSBoundingBox getBBox();
83
        
84
        public WMTSResourceURL getResourceURL() {
85
                if(resourceURL == null)
86
                        resourceURL = (WMTSResourceURL)status.createVersionObject("WMTSResourceURL");
87
                return resourceURL;
88
        }
89

    
90
        public WMTSDimension getDimension() {
91
                if(dimension == null)
92
                        dimension = (WMTSDimension)status.createVersionObject("WMTSDimension");
93
                return dimension;
94
        }
95

    
96
        public ArrayList getStyle() {
97
                if(style == null)
98
                        style = new ArrayList();//(WMTSStyle)status.createVersionObject("WMTSStyle");
99
                return style;
100
        }
101

    
102
        public ArrayList getTileMatrixSetLink() {
103
                if(tileMatrixSetLinkList == null)
104
                        tileMatrixSetLinkList = new ArrayList();
105
                return tileMatrixSetLinkList;
106
        }
107
        
108
        /**
109
         * Links the TileMatrixSet with the limits inside the layer structure
110
         * @param tileMatrixSetList
111
         */
112
        public void linkTileMatrixSets(ArrayList tileMatrixSetList) {
113
                //Recorre la lista de TileMatrixSetLink y a cada uno le asigna su TileMatrixSet
114
                //Para cada TileMatrixLimits contenido en el TileMatrixSetLimits asociado le asigna
115
                //el objeto TileMatrix a partir de su referencia.
116
                if(tileMatrixSetLinkList == null)
117
                        return;
118
                for (int i = 0; i < tileMatrixSetLinkList.size(); i++) {
119
                        WMTSTileMatrixSetLink tileMatrixSetLink = (WMTSTileMatrixSetLink)tileMatrixSetLinkList.get(i);
120
                        String id = tileMatrixSetLink.getTileMatrixSetId();
121
                        for (int j = 0; j < tileMatrixSetList.size(); j++) {
122
                                WMTSTileMatrixSet tileMatrixSet = (WMTSTileMatrixSet)tileMatrixSetList.get(j);
123
                                if(tileMatrixSet.getIdentifier().compareTo(id) == 0) {
124
                                        tileMatrixSetLink.setTileMatrixSet(tileMatrixSet);
125
                                        tileMatrixSetLink.linkTileMatrix(tileMatrixSet);
126
                                        break;
127
                                }
128
                        }
129
                }
130
        }
131
        
132
        /**
133
         * Gets the list of srs's supported
134
         * @return
135
         */
136
        public ArrayList getSrsList() {
137
                ArrayList list = new ArrayList();
138
                for (int i = 0; i < tileMatrixSetLinkList.size(); i++) {
139
                        WMTSTileMatrixSetLink link = (WMTSTileMatrixSetLink)tileMatrixSetLinkList.get(i);
140
                        WMTSTileMatrixSet tileMatrixSet = link.getTileMatrixSet();
141
                        list.add(tileMatrixSet.getSupportedCRS());
142
                }
143
                return list;
144
        }
145
        
146
        public void print() {
147
                System.out.println("*****WMTSLayer******");
148
                System.out.println("Abstract:" + getAbstract());
149
                System.out.println("Identifier:" + getIdentifier());
150
                System.out.println("Keywords:" + getKeywords());
151
                System.out.println("Title:" + getTitle());
152
                for (int i = 0; i < getFormat().size(); i++) {
153
                        System.out.println("Format:" + getFormat().get(i));
154
                }
155
                for (int i = 0; i < getInfoFormat().size(); i++) {
156
                        System.out.println("InfoFormat:" + getInfoFormat().get(i));
157
                }
158
                getBBox().print();
159
                getWGS84BBox().print();
160
                getDimension().print();
161
                System.out.println("Metadata:" + getMetadata());
162
                for (int i = 0; i < getTileMatrixSetLink().size(); i++) {
163
                        ((WMTSTileMatrixSetLink)getTileMatrixSetLink().get(i)).print();
164
                }
165
        }
166

    
167
}