root / branches / v10 / extensions / extPublishMapserver / src / org / gvsig / publish / mapserver / model / wms / MapserverWMS.java @ 16177
History | View | Annotate | Download (4.21 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Iba?ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.publish.mapserver.model.wms; |
42 |
|
43 |
|
44 |
import org.gvsig.publish.mapserver.conf.MapFile.ConfigFile; |
45 |
import org.gvsig.publish.mapserver.model.Mapserver; |
46 |
import org.gvsig.publish.ogcmetadata.CommonOGCMetadata; |
47 |
import org.gvsig.publish.ogcmetadata.ServiceWMS111Metadata; |
48 |
import org.gvsig.publish.serversmodel.PublishException; |
49 |
import org.gvsig.publish.serversmodel.Server; |
50 |
import org.gvsig.publish.serversmodel.Service; |
51 |
|
52 |
import com.iver.utiles.XMLEntity; |
53 |
|
54 |
public class MapserverWMS extends Service{ |
55 |
public static String MAPSERVER_WMS="WMS 1.1.1"; |
56 |
/*
|
57 |
* ogc properties:
|
58 |
* common ogc metadata an specific wms 1.1.1 metadata
|
59 |
*/
|
60 |
private CommonOGCMetadata ogcMetadata= null; |
61 |
private ServiceWMS111Metadata wmsMetadata = null; |
62 |
/**
|
63 |
* Constructor
|
64 |
*
|
65 |
*/
|
66 |
public MapserverWMS(Mapserver mapserver){
|
67 |
super(mapserver);
|
68 |
ogcMetadata = new CommonOGCMetadata();
|
69 |
//the service always is OGC:WMS
|
70 |
ogcMetadata.setName("OGC:WMS");
|
71 |
wmsMetadata = new ServiceWMS111Metadata();
|
72 |
//initializes the onlineresource with the server URL
|
73 |
wmsMetadata.setOnlineresource(getServer().getServerURL()); |
74 |
} |
75 |
|
76 |
public String getType() { |
77 |
return MapserverWMS.MAPSERVER_WMS;
|
78 |
} |
79 |
/**
|
80 |
*
|
81 |
* @return common ogc metadata
|
82 |
*/
|
83 |
public CommonOGCMetadata getOgcMetadata(){
|
84 |
return ogcMetadata;
|
85 |
} |
86 |
/**
|
87 |
* Sets the common ogc metadata to the service
|
88 |
* @param ogcmetadata
|
89 |
*/
|
90 |
public void setOgcMetadata(CommonOGCMetadata ogcmetadata){ |
91 |
this.ogcMetadata = ogcmetadata;
|
92 |
} |
93 |
public ServiceWMS111Metadata getWmsMetadata() {
|
94 |
return wmsMetadata;
|
95 |
} |
96 |
|
97 |
public void setWmsMetadata(ServiceWMS111Metadata wmsMetadata) { |
98 |
this.wmsMetadata = wmsMetadata;
|
99 |
} |
100 |
private Mapserver getMapServer(){
|
101 |
//Cast to Mapserver
|
102 |
Mapserver mapserver = (Mapserver)getServer(); |
103 |
return mapserver;
|
104 |
} |
105 |
/**
|
106 |
* Preconditions:
|
107 |
* the objects config file, map, map.web and map.web.metadata has been created
|
108 |
*/
|
109 |
public void publish() throws PublishException{ |
110 |
//publish all the remote resources
|
111 |
super.publish();
|
112 |
|
113 |
//gets the mapfile from the server
|
114 |
ConfigFile mapfile = getMapServer().getConfigFile(); |
115 |
|
116 |
//generates the code into the MAP->WEB->METADATA
|
117 |
mapfile.web.metadata.wms_title = getOgcMetadata().getTitle(); |
118 |
mapfile.web.metadata.wms_abstract = getOgcMetadata().getAbstract(); |
119 |
mapfile.web.metadata.wms_onlineresource = getWmsMetadata().getOnlineresource().toString(); |
120 |
mapfile.web.metadata.wms_encoding ="utf8";
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* @see Server#getXMLEntity()
|
125 |
*/
|
126 |
public XMLEntity getXMLEntity() {
|
127 |
XMLEntity xml=super.getXMLEntity();
|
128 |
//put the specific properties
|
129 |
//xml.putProperty(MAPSERVERWMS_XXX_STRING, getXXX());
|
130 |
|
131 |
//put ogcmetadata
|
132 |
ogcMetadata.addXMLEntity(xml); |
133 |
//TODO: put wmsMetadata
|
134 |
wmsMetadata.addXMLEntity(xml); |
135 |
return xml;
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* @see Server#setXMLEntity(XMLEntity)
|
140 |
*/
|
141 |
public void setXMLEntity(XMLEntity xml) { |
142 |
super.setXMLEntity(xml);
|
143 |
//set properties
|
144 |
//xml.getStringProperty(MapserverWMS.PROPERTIE_STRING);
|
145 |
//set(Prpertie)
|
146 |
|
147 |
//set ogcmetadata
|
148 |
ogcMetadata.setXMLEntity(xml); |
149 |
//TODO: set wmsMetadata
|
150 |
wmsMetadata.setXMLEntity(xml); |
151 |
} |
152 |
|
153 |
|
154 |
} |