comparison src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 252:eae3fe89e669

Added raster layer support.
author raimund renkert <raimund.renkert@intevation.de>
date Mon, 15 Aug 2011 12:07:09 +0200
parents 4c59d8c36418
children cedb23deb057
comparison
equal deleted inserted replaced
251:6b80e46b8f38 252:eae3fe89e669
299 299
300 //The layer type. 300 //The layer type.
301 String type = layerElement.getAttribute("type"); 301 String type = layerElement.getAttribute("type");
302 if(type.equals("point")) { 302 if(type.equals("point")) {
303 layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT); 303 layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT);
304 } 304 layer.setTileitem("");
305 }
305 else if (type.equals("line")) { 306 else if (type.equals("line")) {
306 layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE); 307 layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE);
308 layer.setTileitem("");
307 } 309 }
308 else if (type.equals("polygon")) { 310 else if (type.equals("polygon")) {
309 layer.setType(MS_LAYER_TYPE.MS_LAYER_POLYGON); 311 layer.setType(MS_LAYER_TYPE.MS_LAYER_POLYGON);
310 } 312 layer.setTileitem("");
311 layer.setTileitem(""); 313 }
314 else if(type.equals("raster")) {
315 layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER);
316 }
312 317
313 //The layer datasource. 318 //The layer datasource.
314 String con_type = layerElement.getAttribute("connection_type"); 319 String con_type = layerElement.getAttribute("connection_type");
315 if(con_type.equals("local")) { 320 if(con_type.equals("local")) {
316 // The data source is a local file. (.shp) 321 // The data source is a local file. (.shp)
321 } 326 }
322 datasource += layerElement.getAttribute("data_source"); 327 datasource += layerElement.getAttribute("data_source");
323 datasource = datasource.replaceAll("\\\\", "/"); 328 datasource = datasource.replaceAll("\\\\", "/");
324 layer.setData(datasource); 329 layer.setData(datasource);
325 } 330 }
326 else if(con_type.equals("SDE")) { 331 else if(con_type.equals("SDE") && !type.equals("raster")) {
327 // The data source is a sde database. 332 // The data source is a sde database.
328 logger.info( 333 logger.info(
329 "SDE datasource found." + 334 "SDE datasource found." +
330 " Please edit password in mapfile."); 335 " Please edit password in mapfile.");
331 layer.setConnectionType( 336 layer.setConnectionType(
389 layer.setFilter("where " + 394 layer.setFilter("where " +
390 layerElement.getAttribute("definition_query")); 395 layerElement.getAttribute("definition_query"));
391 } 396 }
392 } 397 }
393 } 398 }
394 layer.setTemplate("PleaseInsertAValidTemplateForGFI"); 399 else if(con_type.equals("SDE") && type.equals("raster")) {
400 // The data source is a sde database.
401 logger.info(
402 "SDE datasource found." +
403 " Please edit password in mapfile.");
404 String database_auth = layerElement.getAttribute("database");
405 if (database_auth.equals("") || database_auth == null) {
406 logger.warn("Could not set the database connection user." +
407 " Setting to \"sde\" as default.");
408 database_auth = "sde";
409 }
410
411 String port = layerElement.getAttribute("instance");
412 StringBuffer strBuff = new StringBuffer();
413 char c;
414
415 for (int j = 0; j < port.length() ; j++) {
416 c = port.charAt(j);
417 if(Character.isDigit(c)) {
418 strBuff.append(c);
419 }
420 }
421
422 layer.setData(
423 "SDE:" + layerElement.getAttribute("server") +
424 "," + strBuff +
425 "," + layerElement.getAttribute("database") +
426 "," + layerElement.getAttribute("user") +
427 ",<PASSWORD>," + layerElement.getAttribute("dataset"));
428 layer.setType(MS_LAYER_TYPE.MS_LAYER_RASTER);
429 if(layerElement.hasAttribute("definition_query") &&
430 !layerElement.getAttribute("definition_query").equals("")) {
431 layer.setFilter("where " +
432 layerElement.getAttribute("definition_query"));
433 }
434 }
435 if(!type.equals("raster")) {
436 layer.setTemplate("PleaseInsertAValidTemplateForGFI");
437 }
395 438
396 // Create labelitem 439 // Create labelitem
397 NodeList labels = layerElement.getElementsByTagName("label"); 440 NodeList labels = layerElement.getElementsByTagName("label");
398 if(labels.getLength() > 0) { 441 if(labels.getLength() > 0) {
399 Element label = (Element)labels.item(0); 442 Element label = (Element)labels.item(0);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)