Esempio n. 1
0
  public static GeopistaMap getMapISO88591(String FileName) throws Exception {
    File file = new File(FileName);
    String basePath = file.getParent();
    GeopistaMap sourceMap = null;
    try {

      InputStream is = new FileInputStream(file);

      String stringReader = FileUtil.parseISO88591(is);

      XML2Java converter = new XML2Java();
      converter.addCustomConverter(
          Date.class, GeopistaMapCustomConverter.getMapDateCustomConverter());

      sourceMap = (GeopistaMap) converter.read(stringReader, com.geopista.model.GeopistaMap.class);
      sourceMap.setBasePath(basePath);
    } catch (Exception e) {
      if (logger.isDebugEnabled()) {
        logger.debug(
            "getMap(String) - El fichero "
                + FileName
                + "no se puede leer. "
                + e.getLocalizedMessage());
      }
      throw e;
    }

    return sourceMap;
  }
  private void saveLayer(Layer layer, File dir, DataSource dataSource, String ext)
      throws Exception {
    String name = FileUtil.getFileNameFromLayerName(layer.getName());
    // remove extension if any (ex. for layer image.png, will remove png
    int dotPos = name.indexOf(".");
    if (dotPos > 0) name = name.substring(0, dotPos);
    File fileName = FileUtil.addExtensionIfNone(new File(name), ext);
    String path = new File(dir, fileName.getName()).getAbsolutePath();

    DriverProperties dp = new DriverProperties();
    dp.set("File", path);
    dataSource.setProperties(dp);

    DataSourceQuery dsq = new DataSourceQuery(dataSource, path, path);
    layer.setDataSourceQuery(dsq).setFeatureCollectionModified(false);

    dataSource
        .getConnection()
        .executeUpdate("", layer.getFeatureCollectionWrapper(), new DummyTaskMonitor());
  }