svn-gvsig-desktop / trunk / extensions / extPublishMapserver / src / org / gvsig / publish / mapserver / model / Mapserver.java @ 32206
History | View | Annotate | Download (6.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; |
42 |
|
43 |
import java.io.File; |
44 |
import java.io.FileNotFoundException; |
45 |
|
46 |
import org.gvsig.publish.PublishLogger; |
47 |
import org.gvsig.publish.exceptions.PublishException; |
48 |
import org.gvsig.publish.mapserver.conf.FontsFile; |
49 |
import org.gvsig.publish.mapserver.conf.MapFile; |
50 |
import org.gvsig.publish.mapserver.conf.SymbolsFile; |
51 |
import org.gvsig.publish.mapserver.conf.MapFile.ConfigFile; |
52 |
import org.gvsig.publish.mapserver.conf.MapFile.OutputFormat; |
53 |
import org.gvsig.publish.serversmodel.PublicationProcess; |
54 |
import org.gvsig.publish.serversmodel.Server; |
55 |
|
56 |
import com.iver.utiles.FileUtils; |
57 |
import com.iver.utiles.NotExistInXMLEntity; |
58 |
import com.iver.utiles.XMLEntity; |
59 |
/**
|
60 |
* Server that represents Mapserver
|
61 |
* <p>
|
62 |
*
|
63 |
* @author jvhigon
|
64 |
*
|
65 |
*/
|
66 |
public class Mapserver extends Server { |
67 |
|
68 |
public static final String REGISTER_TAG="Mapserver 5.x"; |
69 |
|
70 |
private MapserverProcess process =null; |
71 |
/*
|
72 |
* dependences
|
73 |
*/
|
74 |
private MapFile.ConfigFile config = null; |
75 |
private SymbolsFile.WellKnowSymbolsFile symbolsconfig = null; |
76 |
private FontsFile.WellKnowFontsFile fontsconfig=null; |
77 |
private File mapfile = null; |
78 |
private File symbolsfile = null; |
79 |
//private String symbolsfilename = null;
|
80 |
private File imagepath_file = null; |
81 |
private String shapepath=null; |
82 |
private boolean isAGGEnabled=true; |
83 |
|
84 |
public boolean isAGGEnabled() { |
85 |
return isAGGEnabled;
|
86 |
} |
87 |
|
88 |
public void setAGGEnabled(boolean isAGGEnabled) { |
89 |
this.isAGGEnabled = isAGGEnabled;
|
90 |
} |
91 |
|
92 |
private boolean debug=false; |
93 |
/**
|
94 |
* Constructor
|
95 |
*/
|
96 |
public Mapserver(){
|
97 |
super();
|
98 |
} |
99 |
|
100 |
|
101 |
/**
|
102 |
* check compatible
|
103 |
*
|
104 |
*/
|
105 |
public void postInitialize() { |
106 |
// TODO Auto-generated method stub
|
107 |
|
108 |
} |
109 |
/**
|
110 |
*
|
111 |
* @return the mapfile
|
112 |
*/
|
113 |
public MapFile.ConfigFile getConfigFile(){
|
114 |
return config;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
*
|
119 |
* @return mapfile File
|
120 |
*/
|
121 |
public File getMapfileFile(){ |
122 |
return mapfile;
|
123 |
} |
124 |
/**
|
125 |
* Sets the mapfile file
|
126 |
* @param
|
127 |
*/
|
128 |
public void setMapfileFile(File file){ |
129 |
mapfile = file; |
130 |
} |
131 |
|
132 |
/**
|
133 |
* Gets the IMAGEPATH
|
134 |
* @return
|
135 |
*/
|
136 |
public File getImagePath() { |
137 |
return imagepath_file;
|
138 |
} |
139 |
/**
|
140 |
* Sets the IMAGEPATH directory
|
141 |
* @param imagepath
|
142 |
*/
|
143 |
public void setImagePath(File imagepath_file) { |
144 |
this.imagepath_file = imagepath_file;
|
145 |
} |
146 |
|
147 |
|
148 |
public String getClassName() { |
149 |
return "Mapserver"; |
150 |
} |
151 |
/**
|
152 |
* Initializes the Mapserver
|
153 |
* @see Server#setXMLEntity(XMLEntity)
|
154 |
*/
|
155 |
public void setXMLEntity(XMLEntity xml) { |
156 |
//check version
|
157 |
int version = xml.getIntProperty("version"); |
158 |
if (version != getVersion()){
|
159 |
PublishLogger.getLog().error("ERROR: " + getClassName() + ": the version doesn't match!"); |
160 |
return;
|
161 |
} |
162 |
super.setXMLEntity(xml);
|
163 |
//set mapfile
|
164 |
try{
|
165 |
String file = xml.getStringProperty("mapfile"); |
166 |
setMapfileFile(new File(file)); |
167 |
}catch (NotExistInXMLEntity e){
|
168 |
PublishLogger.getLog().warn("WARNING " + getClassName() + ":mapfile doesn't exist"); |
169 |
} |
170 |
//set imagepath
|
171 |
String file = xml.getStringProperty("imagepath"); |
172 |
if (file !=null) |
173 |
setImagePath(new File(file)); |
174 |
//set shapepath
|
175 |
try{
|
176 |
setShapepath(xml.getStringProperty("shapepath"));
|
177 |
}catch (NotExistInXMLEntity e){
|
178 |
PublishLogger.getLog().warn("WARNING Mapserver: the property shapepath doesn't exist");
|
179 |
} |
180 |
setDebug(xml.getBooleanProperty("isdebug"));
|
181 |
} |
182 |
/*
|
183 |
* (non-Javadoc)
|
184 |
* @see org.gvsig.publish.serversmodel.Server#getXMLEntity()
|
185 |
*/
|
186 |
public XMLEntity getXMLEntity() {
|
187 |
XMLEntity xml=super.getXMLEntity();
|
188 |
//put version and name
|
189 |
xml.setName(getClassName()); |
190 |
xml.putProperty("version", getVersion());
|
191 |
//put Mapserver properties
|
192 |
if (getMapfileFile() != null) |
193 |
xml.putProperty("mapfile", getMapfileFile().getAbsolutePath());
|
194 |
|
195 |
if (getImagePath() == null){ |
196 |
xml.putProperty("imagepath", null); |
197 |
}else{
|
198 |
xml.putProperty("imagepath", getImagePath().getAbsolutePath());
|
199 |
} |
200 |
|
201 |
if (shapepath !=null){ |
202 |
xml.putProperty("shapepath", shapepath);
|
203 |
} |
204 |
xml.putProperty("isdebug", isDebug());
|
205 |
return xml;
|
206 |
} |
207 |
|
208 |
public String getShapepath() { |
209 |
return shapepath;
|
210 |
} |
211 |
|
212 |
public void setShapepath(String shapepath) { |
213 |
this.shapepath = shapepath;
|
214 |
} |
215 |
|
216 |
/*
|
217 |
* (non-Javadoc)
|
218 |
* @see org.gvsig.publish.serversmodel.Server#getId()
|
219 |
*/
|
220 |
public String getId() { |
221 |
|
222 |
return "mapserver_id"; |
223 |
} |
224 |
|
225 |
/*
|
226 |
* (non-Javadoc)
|
227 |
* @see org.gvsig.publish.serversmodel.Server#getVersion()
|
228 |
*/
|
229 |
public int getVersion() { |
230 |
return 1; |
231 |
} |
232 |
|
233 |
/*
|
234 |
* (non-Javadoc)
|
235 |
* @see org.gvsig.publish.serversmodel.Server#getRegisterTag()
|
236 |
*/
|
237 |
public String getRegisterTag() { |
238 |
return REGISTER_TAG;
|
239 |
} |
240 |
|
241 |
/*
|
242 |
* (non-Javadoc)
|
243 |
* @see java.lang.Object#toString()
|
244 |
*/
|
245 |
public String toString(){ |
246 |
return getRegisterTag();
|
247 |
} |
248 |
/**
|
249 |
* @return the debug
|
250 |
*/
|
251 |
public boolean isDebug() { |
252 |
return debug;
|
253 |
} |
254 |
/**
|
255 |
* @param debug the debug to set
|
256 |
*/
|
257 |
public void setDebug(boolean debug) { |
258 |
this.debug = debug;
|
259 |
} |
260 |
/*
|
261 |
* (non-Javadoc)
|
262 |
* @see org.gvsig.publish.serversmodel.Server#getPublicationProcess()
|
263 |
*/
|
264 |
public PublicationProcess getPublicationProcess() {
|
265 |
//if (process == null){
|
266 |
process = new MapserverProcess(this); |
267 |
//}
|
268 |
return process;
|
269 |
} |
270 |
|
271 |
public void setConfigFile(ConfigFile mapfile2) { |
272 |
this.config = mapfile2;
|
273 |
} |
274 |
|
275 |
} |