Revision 40283

View differences:

tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/RemoteClient.java
1

  
2
package org.gvsig.remoteclient;
3

  
4
import org.gvsig.compat.net.ICancellable;
5

  
6

  
7
/**
8
 * <p></p>
9
 *
10
 */
11
public abstract class RemoteClient {
12

  
13
/**
14
 * <p>Represents ...</p>
15
 *
16
 */
17
    protected String hostName;
18

  
19
/**
20
 * <p>Represents ...</p>
21
 *
22
 */
23
    protected int port;
24

  
25
/**
26
 * <p>Represents ...</p>
27
 *
28
 */
29
    protected String serviceName;
30

  
31
/**
32
 * <p>Represents ...</p>
33
 *
34
 */
35
    private String type;
36

  
37
/**
38
 * <p>Represents ...</p>
39
 *
40
 */
41
    private String subtype;
42

  
43
/**
44
 * <p>Represents ...</p>
45
 *
46
 *
47
 * @return
48
 */
49
    public String getHost() {
50
        return hostName;
51
    }
52

  
53
/**
54
 * <p>Represents ...</p>
55
 *
56
 *
57
 * @param _hostName
58
 */
59
    public void setHost(String _hostName) {
60
        hostName = _hostName;
61
    }
62

  
63
/**
64
 * <p>Represents ...</p>
65
 *
66
 *
67
 * @return
68
 */
69
    public int getPort() {
70
        // your code here
71
        return port;
72
    }
73

  
74
/**
75
 * <p>Does ...</p>
76
 *
77
 *
78
 * @param _port
79
 */
80
    public void setPort(int _port) {
81
        port = _port;
82
    }
83

  
84
/**
85
 * <p>Does ...</p>
86
 *
87
 *
88
 * @return
89
 */
90
    public String getServiceName() {
91
        // your code here
92
        return serviceName;
93
    }
94

  
95
/**
96
 * <p>Does ...</p>
97
 *
98
 *
99
 * @param _serviceName
100
 */
101
    public void setServiceName(String _serviceName) {
102
        serviceName = _serviceName;
103
    }
104

  
105
/**
106
 * <p>Does ...</p>
107
 *
108
 */
109
    public abstract boolean connect(boolean override, ICancellable cancel);
110

  
111
/**
112
 * <p>Does ...</p>
113
 *
114
 */
115
    public abstract void close();
116

  
117
/**
118
 * <p>Represents ...</p>
119
 *
120
 *
121
 * @return
122
 */
123
    public String getType() {
124
        return type;
125
    }
126

  
127
/**
128
 * <p>Represents ...</p>
129
 *
130
 *
131
 * @param _type
132
 */
133
    public void setType(String _type) {
134
        type = _type;
135
    }
136

  
137
/**
138
 * <p>Represents ...</p>
139
 *
140
 *
141
 * @return
142
 */
143
    public String getSubtype() {
144
        return subtype;
145
    }
146

  
147
/**
148
 * <p>Represents ...</p>
149
 *
150
 *
151
 * @param _subtype
152
 */
153
    public void setSubtype(String _subtype) {
154
        subtype = _subtype;
155
    }
156
 }
0 157

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSResourceURL.java
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.io.IOException;
25

  
26
import org.kxml2.io.KXmlParser;
27
import org.xmlpull.v1.XmlPullParserException;
28

  
29
/**
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 */
32
public abstract class WMTSResourceURL {
33

  
34
	public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException;
35

  
36
}
0 37

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSServiceIdentification.java
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

  
25
/**
26
 * General information about this server
27
 *
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public abstract class WMTSServiceIdentification extends WMTSBaseStruct {
31
	private String      serviceType         = null;
32
	private String      serviceTypeVersion  = null;
33
	private String      profile             = null;
34
	private String      fees                = null;
35
	private String      accessConstraints   = null;
36
	
37
	public String getServiceType() {
38
		return serviceType;
39
	}
40
	
41
	public void setServiceType(String serviceType) {
42
		this.serviceType = serviceType;
43
	}
44
	
45
	public String getServiceTypeVersion() {
46
		return serviceTypeVersion;
47
	}
48
	
49
	public void setServiceTypeVersion(String serviceTypeVersion) {
50
		this.serviceTypeVersion = serviceTypeVersion;
51
	}
52

  
53
	public String getProfile() {
54
		return profile;
55
	}
56

  
57
	public void setProfile(String profile) {
58
		this.profile = profile;
59
	}
60

  
61
	public String getFees() {
62
		return fees;
63
	}
64

  
65
	public void setFees(String fees) {
66
		this.fees = fees;
67
	}
68

  
69
	public String getAccessConstraints() {
70
		return accessConstraints;
71
	}
72

  
73
	public void setAccessConstraints(String accessConstraints) {
74
		this.accessConstraints = accessConstraints;
75
	}
76
}
0 77

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSServiceProvider.java
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

  
25
/**
26
 * General information about this server
27
 *
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public abstract class WMTSServiceProvider extends WMTSBaseStruct {
31
	private String      providerName      = null;
32
	private String      providerSite      = null;
33
	private String      serviceContact    = null;
34
	
35
	public String getProviderName() {
36
		return providerName;
37
	}
38
	
39
	public void setProviderSite(String providerSite) {
40
		this.providerSite = providerSite;
41
	}
42
	
43
	public String getProviderSite() {
44
		return providerSite;
45
	}
46
	
47
	public void setProviderName(String providerName) {
48
		this.providerName = providerName;
49
	}
50

  
51
	public String getServiceContact() {
52
		return serviceContact;
53
	}
54

  
55
	public void setServiceContact(String serviceContact) {
56
		this.serviceContact = serviceContact;
57
	}
58
}
0 59

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSLayer.java
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
}
0 206

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSTileMatrixSetLink.java
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.io.IOException;
25
import java.util.ArrayList;
26

  
27
import org.kxml2.io.KXmlParser;
28
import org.xmlpull.v1.XmlPullParserException;
29

  
30
/**
31
 * Set of tiles
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 */
34
public abstract class WMTSTileMatrixSetLink {
35
	private String            tileMatrixSetId              = null;
36
	private WMTSTileMatrixSet tileMatrixSet                = null;
37
	private ArrayList         tileMatrixLimits             = null;
38
	protected boolean         forceLongitudeFirstAxisOrder = false;
39
	//protected WMTSBoundingBox layerBBox                    = null;
40
	/**
41
	 * Sets longitude first in the axis order read from the capabilities file
42
	 * @param force
43
	 */
44
	public void setForceLongitudeFirstAxisOrder(boolean force) {
45
		this.forceLongitudeFirstAxisOrder = force;
46
	}
47
	
48
    /**
49
     * Parses this service
50
     * @param parser
51
     * @param content
52
     * @throws IOException
53
     * @throws XmlPullParserException
54
     */
55
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; 
56
    
57
	public String getTileMatrixSetId() {
58
		return tileMatrixSetId;
59
	}
60
	
61
	public void setTileMatrixSetId(String tileMatrixSetId) {
62
		this.tileMatrixSetId = tileMatrixSetId;
63
	}
64
	
65
	public WMTSTileMatrixSet getTileMatrixSet() {
66
		return tileMatrixSet;
67
	}
68
	
69
	public void setTileMatrixSet(WMTSTileMatrixSet tileMatrixSet) {
70
		this.tileMatrixSet = tileMatrixSet;
71
	}
72
	
73
	public ArrayList getTileMatrixLimits() {
74
		if(tileMatrixLimits == null)
75
			tileMatrixLimits = new ArrayList();
76
		return tileMatrixLimits;
77
	}
78
	
79
	/**
80
	 * Links the TileMatrixLimits with the TileMatrix
81
	 * @param tileMatrixSet
82
	 */
83
	public void linkTileMatrix(WMTSTileMatrixSet tileMatrixSet) {
84
		//Recorre la lista de TileMatrixLimits y asigna a cada uno el TileMatrix asociado 
85
		//definido en la etiqueta
86
		if(tileMatrixLimits == null)
87
			return;
88
		java.util.List<String> idListToRemove = new ArrayList<String>();
89
		for (int i = 0; i < tileMatrixLimits.size(); i++) {
90
			WMTSTileMatrixLimits limits = (WMTSTileMatrixLimits)tileMatrixLimits.get(i);
91
			String id = limits.getRefToTileMatrix();
92
			boolean isWithoutReference = true;
93
			for (int j = 0; j < tileMatrixSet.getTileMatrix().size(); j++) {
94
				WMTSTileMatrix tileMatrix = (WMTSTileMatrix)tileMatrixSet.getTileMatrix().get(j);
95
				if(tileMatrix.getIdentifier().compareTo(id) == 0) {
96
					limits.setTileMatrix(tileMatrix);
97
					isWithoutReference = false;
98
					break;
99
				}
100
			}
101
			if(isWithoutReference) {
102
				idListToRemove.add(id);
103
			}
104
		}
105
		removeLevelsFromTileMatrix(idListToRemove);
106
	}
107
	
108
	/**
109
	 * Removes form the <code>WMTSTileMatrixLimits</code> the elements in the
110
	 * ID list. These elements are <code>WMTSTileMatrix</code> without reference
111
	 * @param idList 
112
	 *        List of identifiers
113
	 */
114
	private void removeLevelsFromTileMatrix(java.util.List<String> idList) {
115
		if(tileMatrixLimits == null || idList == null || idList.size() == 0)
116
			return;
117
		for (int i = 0; i < idList.size(); i++) {
118
			String id = idList.get(i);
119
			for (int j = 0; j < tileMatrixLimits.size(); j++) {
120
				WMTSTileMatrixLimits limits = (WMTSTileMatrixLimits)tileMatrixLimits.get(j);
121
				if(id.equals(limits.getRefToTileMatrix())) {
122
					tileMatrixLimits.remove(j);
123
					break;
124
				}
125
			}
126
		}
127
	}
128
	
129
	
130
	public void print() {
131
		System.out.println(" *****WMTSTileMatrixSetLink******");
132
		System.out.println("TileMatrixSet ID:" + getTileMatrixSetId());
133
		for (int i = 0; i < getTileMatrixLimits().size(); i++) {
134
			WMTSTileMatrixLimits limits = ((WMTSTileMatrixLimits)getTileMatrixLimits().get(i));
135
			limits.print();
136
		}
137
	}
138
}
0 139

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSBoundingBox.java
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.awt.geom.Rectangle2D;
25
import java.io.IOException;
26

  
27
import org.kxml2.io.KXmlParser;
28
import org.xmlpull.v1.XmlPullParserException;
29

  
30
/**
31
 * Describes the bounding box of a layer in a WMTS server
32
 *
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public abstract class WMTSBoundingBox {
36
	private double[]   lowerCorner                  = new double[2];
37
	private double[]   upperCorner                  = new double[2];
38
	private String     crs                          = "";
39
	private int        dimensions                   = 2;
40
	protected boolean  forceLongitudeFirstAxisOrder = false;
41
	
42
	/**
43
	 * Sets longitude first in the axis order read from the capabilities file
44
	 * @param force
45
	 */
46
	public void setForceLongitudeFirstAxisOrder(boolean force) {
47
		this.forceLongitudeFirstAxisOrder = force;
48
	}
49
	
50
	/**
51
     * Parses this service ID
52
     * @param parser
53
     * @param content
54
     * @throws IOException
55
     * @throws XmlPullParserException
56
     */
57
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; 
58
    
59
	
60
	public double[] getLowerCorner() {
61
		return lowerCorner;
62
	}
63
	
64
	public void setLowerCorner(double[] lowerCorner) {
65
		this.lowerCorner = lowerCorner;
66
	}
67
	
68
	public double[] getUpperCorner() {
69
		return upperCorner;
70
	}
71
	
72
	public void setUpperCorner(double[] upperCorner) {
73
		this.upperCorner = upperCorner;
74
	}
75
	
76
	public String getCrs() {
77
		return crs;
78
	}
79
	
80
	public void setCrs(String crs) {
81
		this.crs = crs;
82
	}
83
	
84
	public int getDimensions() {
85
		return dimensions;
86
	}
87
	
88
	public void setDimensions(int dimensions) {
89
		this.dimensions = dimensions;
90
	}
91
	
92
	public Rectangle2D toRectangle2D() {
93
		return new Rectangle2D.Double(Math.min(upperCorner[0], lowerCorner[0]), 
94
				Math.min(upperCorner[1], lowerCorner[1]), 
95
				Math.abs(upperCorner[0] - lowerCorner[0]), 
96
				Math.abs(upperCorner[1] - lowerCorner[1]));
97
	}
98
	
99
	public boolean isValid() {
100
		return lowerCorner[0] != 0 || lowerCorner[1] != 0 || upperCorner[0] != 0 || upperCorner[1] != 0;
101
	}
102
	
103
	public void print() {
104
		System.out.println("*****WMTSBoundingBox******");
105
		System.out.println("LowerCorner:" + getLowerCorner()[0] + "," + getLowerCorner()[1]);
106
		System.out.println("UpperCorner:" + getUpperCorner()[0] + "," + getUpperCorner()[1]);
107
		System.out.println("Crs:" + getCrs());
108
		System.out.println("Dimensions:" + getDimensions());
109
	}
110
}
0 111

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSTileMatrixSet.java
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.io.IOException;
25
import java.util.ArrayList;
26

  
27
import org.kxml2.io.KXmlParser;
28
import org.xmlpull.v1.XmlPullParserException;
29

  
30

  
31
/**
32
 * <p>Defines a OGC style. Theme that describes the appeareance of certain layer.</p>
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public abstract class WMTSTileMatrixSet extends WMTSBaseStruct {
36
    protected WMTSBoundingBox bbox                         = null;
37
    private String            supportedCRS                 = null;
38
    private String            wellKnownScaleSet            = null;
39
    //WMTSTileMatrix
40
    protected ArrayList       tileMatrix                   = null;
41
    protected boolean         forceLongitudeFirstAxisOrder = false;
42
	
43
	/**
44
	 * Sets longitude first in the axis order read from the capabilities file
45
	 * @param force
46
	 */
47
	public void setForceLongitudeFirstAxisOrder(boolean force) {
48
		this.forceLongitudeFirstAxisOrder = force;
49
	}
50
	
51
    /**
52
     * Parses this service ID
53
     * @param parser
54
     * @param content
55
     * @throws IOException
56
     * @throws XmlPullParserException
57
     */
58
	public abstract void parse(KXmlParser parser, ArrayList list) throws IOException, XmlPullParserException; 
59
    
60
	public void setLayerBBox(WMTSBoundingBox bbox) {
61
		if(bbox != null) {
62
			this.bbox = bbox;
63
			for (int i = 0; i < getTileMatrix().size(); i++) {
64
				((WMTSTileMatrix)getTileMatrix().get(i)).setBBoxTileMatrixSet(bbox.toRectangle2D());
65
			}
66
		}
67
	}
68
    
69
    public abstract WMTSBoundingBox getBoundingBox();
70
    
71
	public String getWellKnownScaleSet() {
72
		return wellKnownScaleSet;
73
	}
74

  
75
	public void setWellKnownScaleSet(String wellKnownScaleSet) {
76
		this.wellKnownScaleSet = wellKnownScaleSet;
77
	}
78
	
79
	public ArrayList getTileMatrix() {
80
		if(tileMatrix == null)
81
			tileMatrix = new ArrayList();
82
		return tileMatrix;
83
	}
84

  
85
	public String getSupportedCRS() {
86
		if(supportedCRS.compareTo("CRS:84") == 0)
87
			supportedCRS = "EPSG:4326";
88
		return supportedCRS;
89
	}
90

  
91
	public void setSupportedCRS(String supportedCRS) {
92
		if(supportedCRS.compareTo("CRS:84") == 0)
93
			supportedCRS = "EPSG:4326";
94
		this.supportedCRS = supportedCRS;
95
	}
96
	
97
	public void parse(KXmlParser parser) throws IOException,
98
			XmlPullParserException {
99
	}
100
	
101
	public void print() {
102
		System.out.println("*****WMTSTileMatrixSet******");
103
		if(bbox != null)
104
			bbox.print();
105
		System.out.println("supportedCRS:" + getSupportedCRS());
106
		System.out.println("wellKnownScaleSet:" + getWellKnownScaleSet());
107
		for (int i = 0; i < tileMatrix.size(); i++) {
108
			((WMTSTileMatrix)tileMatrix.get(i)).print();	
109
		}
110
	}
111
}
0 112

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSBaseStruct.java
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.io.IOException;
25

  
26
import org.gvsig.remoteclient.utils.CapabilitiesTags;
27
import org.kxml2.io.KXmlParser;
28
import org.xmlpull.v1.XmlPullParserException;
29

  
30
/**
31
 * Base class for WMTS structures
32
 * @author Nacho Brodin (nachobrodin@gmail.com)
33
 */
34
public abstract class WMTSBaseStruct {
35
	public  static String        gmlTag              = CapabilitiesTags.WMTS_GMLTAG;
36
	private String               identifier          = null;
37
	private String               title               = null;
38
    private String               abstractObj         = null;
39
    
40
    /**
41
     * Parses this service ID
42
     * @param parser
43
     * @param content
44
     * @throws IOException
45
     * @throws XmlPullParserException
46
     */
47
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; 
48
    
49
    
50
    public String getIdentifier() {
51
		return identifier;
52
	}
53

  
54
	public void setIdentifier(String identifier) {
55
		this.identifier = identifier;
56
	}
57

  
58
	public String getTitle() {
59
		return title;
60
	}
61

  
62
	public void setTitle(String title) {
63
		this.title = title;
64
	}
65

  
66
	public String getAbstract() {
67
		return abstractObj;
68
	}
69

  
70
	public void setAbstract(String abstr) {
71
		this.abstractObj = abstr;
72
	}
73

  
74
    /**
75
     * Compares the next name in the selected parser with the string passed
76
     * by value.
77
     * @param parser
78
     * @param name
79
     * @return
80
     */
81
    public boolean compareName(KXmlParser parser, String name) {
82
    	String s = parser.getName();
83
    	if(s.compareTo(name) == 0 || s.compareTo(gmlTag + name) == 0)
84
    		return true;
85
    	return false;
86
    }
87
    
88
    /**
89
     * Gets the next text from the parser if this exists
90
     * @param parser
91
     * @return
92
     * @throws XmlPullParserException
93
     * @throws IOException
94
     */
95
    public String nextText(KXmlParser parser) throws XmlPullParserException, IOException {
96
    	return !parser.isEmptyElementTag() ? parser.nextText() : "";
97
    }
98
}
0 99

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSStyle.java
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
/**
25
 * <p>Defines a OGC style. Theme that describes the appeareance of certain layer.</p>
26
 * @author Nacho Brodin (nachobrodin@gmail.com)
27
 */
28
public abstract class WMTSStyle extends WMTSBaseStruct {
29
    protected WMTSLegendURL   legendURL     = null;
30
    private boolean           isDefault     = false;
31

  
32
	public abstract WMTSLegendURL getLegendURL();
33

  
34
	public boolean isDefault() {
35
		return isDefault;
36
	}
37

  
38
	public void setDefault(boolean isDefault) {
39
		this.isDefault = isDefault;
40
	}
41
	
42
	public String toString() {
43
		return getTitle();
44
	}
45
}
0 46

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSLegendURL.java
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.io.IOException;
25

  
26
import org.kxml2.io.KXmlParser;
27
import org.xmlpull.v1.XmlPullParserException;
28

  
29
/**
30
 * Description of an image that represents the legend of the map
31
 * @author Nacho Brodin (nachobrodin@gmail.com)
32
 */
33
public abstract class WMTSLegendURL {
34
	private int    width               = 0;
35
	private int    height              = 0;
36
	private double minScaleDenominator = 0;
37
	private double maxScaleDenominator = 0;
38
	private String format              = "";
39
	private String href                = "";
40
	
41
	/**
42
     * Parses this service
43
     * @param parser
44
     * @param content
45
     * @throws IOException
46
     * @throws XmlPullParserException
47
     */
48
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; 
49
    
50
    
51
	public int getWidth() {
52
		return width;
53
	}
54
	
55
	public void setWidth(int width) {
56
		this.width = width;
57
	}
58
	
59
	public int getHeight() {
60
		return height;
61
	}
62
	
63
	public void setHeight(int height) {
64
		this.height = height;
65
	}
66
	
67
	public double getMinScaleDenominator() {
68
		return minScaleDenominator;
69
	}
70
	
71
	public void setMinScaleDenominator(double minScaleDenominator) {
72
		this.minScaleDenominator = minScaleDenominator;
73
	}
74
	
75
	public double getMaxScaleDenominator() {
76
		return maxScaleDenominator;
77
	}
78
	
79
	public void setMaxScaleDenominator(double maxScaleDenominator) {
80
		this.maxScaleDenominator = maxScaleDenominator;
81
	}
82
	
83
	public String getFormat() {
84
		return format;
85
	}
86
	
87
	public void setFormat(String format) {
88
		this.format = format;
89
	}
90
	
91
	public String getHref() {
92
		return href;
93
	}
94
	
95
	public void setHref(String href) {
96
		this.href = href;
97
	}
98
}
0 99

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSTheme.java
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
/**
27
 * Layer hierarchy
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public abstract class WMTSTheme extends WMTSBaseStruct {
31
	//WMTSTheme
32
	private ArrayList        theme      = null;
33
	//String
34
	private ArrayList        layerRef   = null;
35
	private WMTSLayer        layer      = null; 
36
	
37
	public void setLayer(WMTSLayer layer) {
38
		this.layer = layer;
39
	}
40
	
41
	public WMTSLayer getLayer() {
42
		return layer;
43
	}
44
	
45
	public ArrayList getThemeList() {
46
		if(theme == null)
47
			theme = new ArrayList();
48
		return theme;
49
	}
50
	
51
	public ArrayList getLayerRef() {
52
		if(layerRef == null)
53
			layerRef = new ArrayList();
54
		return layerRef;
55
	}
56
	
57
	/**
58
	 * Assign the layer associated
59
	 * @param layers
60
	 */
61
	public void calculateLayers(ArrayList layers) {
62
		if(theme != null && theme.size() > 0) {
63
			for (int i = 0; i < theme.size(); i++) {
64
				((WMTSTheme)theme.get(i)).calculateLayers(layers);
65
			}
66
		}
67
			
68
		if(layerRef != null && layerRef.size() > 0) {
69
			for (int i = 0; i < layers.size(); i++) {
70
				WMTSLayer tmpLayer = (WMTSLayer)layers.get(i);
71
				for (int j = 0; j < layerRef.size(); j++) {
72
					String layerRef_I = (String)layerRef.get(j);
73
					if(tmpLayer.getTitle().compareTo(layerRef_I) == 0) {
74
						layer = tmpLayer;
75
					}
76
				}
77
			}
78
		}
79
	}
80
	
81
	/**
82
	 * Gets a node by its name
83
	 * @param name
84
	 * @return
85
	 */
86
	public WMTSTheme getNodeByName(String name) {
87
		WMTSTheme result = null;
88
		if(theme == null)
89
			return null;
90
		
91
		for (int i = 0; i < theme.size(); i++) {
92
			WMTSTheme t = ((WMTSTheme)(theme.get(i)));
93
			String title = t.getTitle();
94
			
95
			if(title.compareTo(name) == 0)
96
				result = t;
97
			else 
98
				result = t.getNodeByName(name);
99
			
100
			if(result != null)
101
				return result;
102
		}
103
		
104
		return null;
105
	}
106
	
107
	/**
108
	 * Gets the number of nodes
109
	 * @param parent
110
	 * @return
111
	 */
112
	public int getChildCount() {
113
		if(theme == null || theme.size() == 0)
114
			return 0;
115
		else {
116
			int acum = 0;
117
			for (int i = 0; i < theme.size(); i++) {
118
				acum += 1 + ((WMTSTheme)theme.get(i)).getChildCount();
119
			}
120
			return acum;
121
		}
122
	}
123
	
124
	/**
125
	 * Gets the children of the index position
126
	 * @param index
127
	 * @return
128
	 */
129
	public WMTSTheme getChildren(int index) {
130
		if(theme != null)
131
			return (WMTSTheme)theme.get(index);	
132
		return null;
133
	}
134
	
135
	/**
136
	 * Gets the index of a children
137
	 * @param parent
138
	 * @param child
139
	 * @return
140
	 */
141
	public int getIndexOfChild(WMTSTheme child) {
142
		if(theme != null) {
143
			for (int i = 0; i < theme.size(); i++)
144
				if (child == getChildren(i)) 
145
					return i;
146
		}
147
		return -1;
148
	}
149
	
150
	public String toString() {
151
		return this.getTitle();
152
	}
153
}
0 154

  
tags/libraries/org.gvsig.remoteclient/2.0/src/org/gvsig/remoteclient/wmts/struct/WMTSTileMatrix.java
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.awt.geom.AffineTransform;
25
import java.awt.geom.NoninvertibleTransformException;
26
import java.awt.geom.Point2D;
27
import java.awt.geom.Rectangle2D;
28
import java.io.File;
29
import java.io.IOException;
30
import java.util.ArrayList;
31

  
32
import org.kxml2.io.KXmlParser;
33
import org.xmlpull.v1.XmlPullParserException;
34

  
35
/**
36
 * Description of a tile matrix
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public abstract class WMTSTileMatrix extends WMTSBaseStruct {
40
    private double                  scaleDenominator             = 0;
41
    private Rectangle2D             bboxTileMatrixSet            = null;
42
    private double[]                topLeftCorner                = null;
43
    private int                     tileWidth                    = 0;
44
    private int                     tileHeight                   = 0;
45
    private long                    matrixWidth                  = 0;
46
    private long                    matrixHeight                 = 0;
47
    private static final double     MTS_X_GRADO                  = 111319.490793274;
48
    protected boolean               forceLongitudeFirstAxisOrder = false;
49
    private double                  epsilon                      = 1e-6;
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 void setBBoxTileMatrixSet(Rectangle2D bbox) {
60
		if(bboxTileMatrixSet == null)
61
			this.bboxTileMatrixSet = bbox;
62
	}
63
	
64
	public Rectangle2D getBBoxTileMatrixSet() {
65
		return bboxTileMatrixSet;
66
	}
67

  
68
    public class Tile {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff