Ejemplo n.º 1
0
  public int[] obtainIndexForOptionalLayers(String[] menuSelected) {

    if (menuSelected.length == 0) { // if not entry return null
      return null;
    }

    ArrayList<Integer> result = new ArrayList(); // temporal list to hold values
    Layer tempLayer = null;
    for (int index = 0;
        index < layersManager.getVectorLayers().size();
        index++) { // loop each vector layer
      tempLayer = layersManager.getVectorLayers().get(index); // temp variable

      // each tree value has to be send separately.
      // becuase the vector layers are all on one level of the tree
      for (int menuNumber = 0; menuNumber < menuSelected.length; menuNumber++) {
        if (tempLayer.isThisLayer(
            StringAndNumbers.strArrayFromStringColon(menuSelected[menuNumber]))) {
          // check to see if the layer is selected
          result.add(Integer.valueOf(index));
          break;
        }
      }
    }
    // convert into array of ints and then return.
    return ConvertionTools.convertObjectArrayToIntArray(result.toArray());
  }
Ejemplo n.º 2
0
  /**
   * Creates the javascript of the layers that are going to be shown separatly. Each layer is an
   * object first is the raster layers then the vector layers.
   *
   * @param idsBaseLayers
   * @param idsExtraLayers
   * @return
   */
  private String createSeparateLayerScript(int[] idsBaseLayers, int[] idsExtraLayers) {
    String layersScript = "";
    Layer actualLayer = null;
    int layerCount = 0;

    String backgroundLayer = mapConfig.getProperty("backgroundLayer");

    switch (backgroundLayer) {
      case "wms": // Read the background layer from xml file
        // add the layers that are the background.
        for (int i = 0; i < layersManager.getBackgroundLayers().size(); i++) {
          actualLayer = layersManager.getBackgroundLayers().get(i);
          if (actualLayer.getName() != null) {
            layersScript += layerHelper(actualLayer, layerCount, true);
            layerCount++;
          } // If layer not null
        }
        break;
      case "osm": // Add OpenStreetMap as the background layer
        layersScript += addOpenStreetMapLayer(layersScript, layerCount);
        layerCount++;
        break;
      case "binga": // Add Aerial Bing layer as the background layer
        layersScript += addBingLayer(layersScript, layerCount, "Aerial");
        layerCount++;
        break;
      case "bingr": // Add Road Bing layer as the background layer
        layersScript += addBingLayer(layersScript, layerCount, "Road");
        layerCount++;
        break;
      case "bingh": // Add Hybrid Bing layer as the background layer
        layersScript += addBingLayer(layersScript, layerCount, "AerialWithLabels");
        layerCount++;
        break;
      case "mapquesta": // Add MapQuest as the background layer
      case "mapquestr": // Add MapQuest as the background layer
      case "mapquesth": // Add MapQuest as the background layer
        layersScript += addMapQuest(layersScript, layerCount, backgroundLayer);
        layerCount++;
        break;
    }

    // Generates the layer configuration for OpenLayers
    // The name of the layer variable inside OpenLayers is of the form layer'number of layer'
    for (int i = 0; i < idsBaseLayers.length; i++) {
      actualLayer = layersManager.getMainLayers().get(idsBaseLayers[i]);
      if (actualLayer.getName() != null) {
        layersScript += layerHelper(actualLayer, layerCount, true);
        layerCount++;
      } // If layer not null
    }

    for (int i = 0; i < layersManager.getVectorLayers().size(); i++) {
      actualLayer = layersManager.getVectorLayers().get(i);
      if (StringAndNumbers.intArrayContains(
          idsExtraLayers, i)) { // Si esta en los seleccionados lo mostramos
        // Si no no
        layersScript += layerHelper(actualLayer, layerCount, true);
      } else {
        layersScript += layerHelper(actualLayer, layerCount, false);
      }
      layerCount++;
    }
    return layersScript;
  }