Revision 17833 branches/v10/extensions/extPublishMapserver/src/org/gvsig/publish/mapserver/model/wms/MapserverWMSLayer.java
MapserverWMSLayer.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.awt.Color; |
44 | 44 |
import java.awt.geom.Rectangle2D; |
45 |
import java.io.File; |
|
46 |
import java.io.IOException; |
|
45 | 47 |
|
46 | 48 |
import org.gvsig.publish.infoproject.IDataSourceInfo; |
47 | 49 |
import org.gvsig.publish.infoproject.ILayerInfo; |
... | ... | |
71 | 73 |
import org.gvsig.publish.serversmodel.PublishException; |
72 | 74 |
import org.gvsig.publish.serversmodel.RemoteResource; |
73 | 75 |
|
76 |
import com.iver.utiles.FileUtils; |
|
74 | 77 |
import com.iver.utiles.XMLEntity; |
75 | 78 |
|
76 | 79 |
|
80 |
|
|
77 | 81 |
public class MapserverWMSLayer extends RemoteResource{ |
78 | 82 |
public final static String MAPSERVER_WMS_LAYER="mapserver_wms_layer"; |
79 | 83 |
/* |
... | ... | |
168 | 172 |
super.publish(); |
169 | 173 |
} |
170 | 174 |
|
171 |
private void generateShapeLayer(IDataSourceInfo ds){ |
|
175 |
private void generateShapeLayer(IDataSourceInfo ds) throws PublishException{
|
|
172 | 176 |
//get the mapfile |
173 | 177 |
ConfigFile mapfile = getMapfile(); |
174 | 178 |
//get the file |
... | ... | |
177 | 181 |
//LAYER |
178 | 182 |
ShpLayer lyr = new ShpLayer(); |
179 | 183 |
lyr.name = getOgcMetadata().getName(); |
180 |
lyr.data = file.getAbsolutePath(); |
|
184 |
if (mapfile.mapShapePath ==null){ |
|
185 |
lyr.data = file.getAbsolutePath(); |
|
186 |
}else{ |
|
187 |
lyr.data = file.getFileName(); |
|
188 |
} |
|
181 | 189 |
lyr.type = ds.getDataType(); |
182 | 190 |
lyr.transparency = getLayerInfo().getOpacityPercent(); |
183 | 191 |
lyr.dump = getLayerWmsMetadata().isQueryable(); |
... | ... | |
214 | 222 |
//adds the layer into the map |
215 | 223 |
mapfile.add(lyr); |
216 | 224 |
} |
217 |
private void generatePostGISLayer(IDataSourceInfo ds){ |
|
225 |
private void generatePostGISLayer(IDataSourceInfo ds) throws PublishException{
|
|
218 | 226 |
//get the mapfile |
219 | 227 |
ConfigFile mapfile = getMapfile(); |
220 | 228 |
IDataBaseInfo db = (IDataBaseInfo)ds; |
... | ... | |
274 | 282 |
//LAYER |
275 | 283 |
ShpLayer lyr = new ShpLayer(); |
276 | 284 |
lyr.name = getOgcMetadata().getName(); |
277 |
lyr.data = ifile.getAbsolutePath(); |
|
285 |
if (mapfile.mapShapePath !=null){ |
|
286 |
lyr.data = ifile.getAbsolutePath(); |
|
287 |
}else{ |
|
288 |
lyr.data = ifile.getFileName(); |
|
289 |
} |
|
290 |
|
|
278 | 291 |
lyr.type = "RASTER"; |
279 | 292 |
lyr.transparency = getLayerInfo().getOpacityPercent(); |
280 | 293 |
|
... | ... | |
290 | 303 |
|
291 | 304 |
} |
292 | 305 |
|
293 |
private void generateSingleLegend(ISingleSymbolLegendInfo legend, MapLayer lyr) { |
|
306 |
private void generateSingleLegend(ISingleSymbolLegendInfo legend, MapLayer lyr) throws PublishException {
|
|
294 | 307 |
ISymbolInfo isymbol = legend.getSymbolInfo(); |
295 | 308 |
MapClass clase = new MapClass(); |
296 | 309 |
//put the size units |
... | ... | |
312 | 325 |
* The legend |
313 | 326 |
* @param lyr |
314 | 327 |
* The layer |
328 |
* @throws PublishException |
|
315 | 329 |
*/ |
316 |
private void generateIntervalLegend(IIntervalLegendInfo legend, MapLayer lyr) { |
|
330 |
private void generateIntervalLegend(IIntervalLegendInfo legend, MapLayer lyr) throws PublishException {
|
|
317 | 331 |
//check if is labeled |
318 | 332 |
boolean islabeled = false; |
319 | 333 |
if ( getLayerInfo().getLabeling().getLabelField() != null){ |
... | ... | |
334 | 348 |
} |
335 | 349 |
} |
336 | 350 |
|
337 |
private void generateUniqueLegend(IUniqueValuesLegendInfo legend, MapLayer lyr) { |
|
351 |
private void generateUniqueLegend(IUniqueValuesLegendInfo legend, MapLayer lyr) throws PublishException {
|
|
338 | 352 |
//check if is labeled |
339 | 353 |
boolean islabeled = false; |
340 | 354 |
if ( getLayerInfo().getLabeling().getLabelField() != null){ |
... | ... | |
360 | 374 |
} |
361 | 375 |
} |
362 | 376 |
|
363 |
public void generateStyle(ISymbolInfo isymbol, MapClass clase){ |
|
377 |
public void generateStyle(ISymbolInfo isymbol, MapClass clase) throws PublishException{
|
|
364 | 378 |
if (getLayerInfo().getDataSource().getDataType() == IDataSourceInfo.POINT_DATA){ |
365 | 379 |
//I can do a cast to Marker Symbol |
366 | 380 |
IMarkerSymbolInfo pointSymbol = (IMarkerSymbolInfo)isymbol; |
... | ... | |
389 | 403 |
//clase.etiqueta.type = "truetype"; |
390 | 404 |
} |
391 | 405 |
|
392 |
private void generateSymbol(IMarkerSymbolInfo pointSymbol, MapClass clase) { |
|
406 |
private void generateSymbol(IMarkerSymbolInfo pointSymbol, MapClass clase) throws PublishException {
|
|
393 | 407 |
clase.estilo = new StyleMap(); |
394 | 408 |
Color c = pointSymbol.getColor(); |
395 | 409 |
clase.estilo.styleColor = new RGB(c.getRed(), c.getGreen(), c.getBlue()); |
396 | 410 |
clase.estilo.size = pointSymbol.getSize(); |
397 | 411 |
clase.symbol = pointSymbol.getWellKnowMarkerName(); |
398 |
//if it's a image |
|
399 |
String icon = pointSymbol.getImageIconPath();
|
|
412 |
//if it's an image
|
|
413 |
File icon = pointSymbol.getImageIconFile();
|
|
400 | 414 |
if ( icon !=null){ |
401 |
clase.symbol = icon; |
|
415 |
clase.symbol = icon.getName();
|
|
402 | 416 |
} |
417 |
|
|
418 |
Mapserver m = (Mapserver)getService().getServer(); |
|
419 |
String s = m.getMapfileFile().getParentFile().getAbsolutePath(); |
|
420 |
File dst = new File(s+ File.separator+ icon.getName()); |
|
421 |
|
|
422 |
try { |
|
423 |
FileUtils.copy(icon, dst); |
|
424 |
} catch (IOException e) { |
|
425 |
throw new PublishException("cannot_copy_icons"); |
|
426 |
//e.printStackTrace(); |
|
427 |
} |
|
403 | 428 |
} |
404 | 429 |
/** |
405 | 430 |
* In Mapserver is impossible to have a dashed outline |
Also available in: Unified diff