Exemplo n.º 1
0
  private void handleSldFromStyleStore(
      File file,
      String namedLayer,
      Map<String, String> map,
      String layerName,
      Map<String, Pair<File, URL>> legends,
      Map<String, Boolean> glgUrls) {
    // already loaded from workspace
    String styleId = file.getName().substring(0, file.getName().length() - 4);
    StyleStore store = styleManager.get(styleId);

    if (store != null) {
      LOG.info("Using SLD file loaded from style store.");
      for (Style s : store.getAll(namedLayer)) {
        s.setName(map.get(s.getName()));
        registry.put(layerName, s, false);
        Pair<File, URL> p = legends.get(s.getName());
        if (p != null && p.first != null) {
          s.setLegendFile(p.first);
        } else if (p != null) {
          s.setLegendURL(p.second);
        }
        s.setPrefersGetLegendGraphicUrl(
            glgUrls.get(s.getName()) != null && glgUrls.get(s.getName()));
      }
      return;
    }
  }
Exemplo n.º 2
0
 private Style findStyle(File legendFile, File stylesDir, String layerName) {
   Style style;
   if (legendFile.getParentFile().equals(stylesDir)) {
     // already loaded from style store
     String styleId = legendFile.getName().substring(0, legendFile.getName().length() - 4);
     StyleStore store = styleManager.get(styleId);
     if (store != null) {
       style = store.getStyle(null).copy();
     } else {
       LOG.warn("Style store {} was not available, trying to load directly.", styleId);
       style = registry.loadNoImport(layerName, legendFile, true);
     }
   } else {
     style = registry.loadNoImport(layerName, legendFile, true);
   }
   return style;
 }