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()); }
public int getTotalVisibleLayers() { int layerCount = 0; // loop incharge of the layers that are background. for (int i = 0; i < layersManager.getBackgroundLayers().size(); i++) { if (layersManager.getBackgroundLayers().get(i).getName() != null) { layerCount++; } } layerCount += 1; // represents the base layer. for (int i = 0; i < layersManager.getVectorLayers().size(); i++) { if (layersManager.getVectorLayers().get(i).getName() != null) { layerCount++; } // If layer not null } return layerCount; }
/** * This function creates the url to bring the data when the user clicks somewhere on the map. * * @param {int} baseLayer */ private String agregaURLparaTraerDatos(int baseLayer) { String layersScript = ""; Layer actualLayer = null; int layerCount = 0; layersScript = "\n\tfunction punctualData(evt) {\n"; // Se agrega al evento click del div map la siguiente // funcion layersScript += "\t\t if(mobile){owgis.mobile.closePanels();" + "\t\t\t owgis.interf.loadingatmap(true);}\n" + "\t\t var coordinate = evt.coordinate;\n" + "\t\t var currBBOX = ol3view.calculateExtent(map.getSize());\n" + "\t\t $('#popup').hide();\n" + "\t\t currPopupText = '<b>Lon: </b>'+coordinate[0].toFixed(2)+ ' <b>Lat: </b>'+coordinate[1].toFixed(2)+'<br>'\n" + "\t\t ol_popup.setPosition(coordinate);\n"; // En este for agrega las capas que son de fondo for (int i = 0; i < layersManager.getBackgroundLayers().size(); i++) { actualLayer = layersManager.getBackgroundLayers().get(i); if (actualLayer.getFeatureInfoLayer() != null) { layersScript += generateURLhelper(actualLayer, layerCount); } // If layer featureInfo not null layerCount++; } // Se agrega el URL de la capa base actualLayer = layersManager.getMainLayers().get(baseLayer); if (actualLayer.getFeatureInfoLayer() != null) { layersScript += generateURLhelper(actualLayer, layerCount); } // If layer featureInfo not null layerCount++; // Increment current layer (for javascript, 'layer0' or 'layer1'.... for (int i = 0; i < layersManager.getVectorLayers().size(); i++) { actualLayer = layersManager.getVectorLayers().get(i); if (actualLayer.getFeatureInfoLayer() != null) { layersScript += generateURLhelper(actualLayer, layerCount); } // If layer featureInfo not null layerCount++; } layersScript += // "\t\tMapViewersubmitForm();\n" + "\t}\n"; return layersScript; }
/** * Obtains the index of the list of vector layers or raster depending on the selection. * * @param {MenuEntry[]} menuEntry User selection array * @param {boolean} layerType layer type checking it can be HtmlTools.RASTER_LAYERS * @return int[] we return an array with the index of the layers. */ public int[] obtainArrayIndexOfLayers(MenuEntry[] menuEntry) { int index = 0; if (menuEntry.length == 0) { // if not entry return null return null; } ArrayList<Integer> resultado = new ArrayList(); // temporal list to hold values Layer tempLayer = null; // temp layer used to check // loop alentries until find the one selected for (index = 0; index < layersManager.getMainLayers().size(); index++) { tempLayer = layersManager.getMainLayers().get(index); // get index of this layer if (tempLayer.isThisLayer(menuEntry)) { // if this is the layer we are looking for resultado.add(Integer.valueOf(index)); // add layer to list of index break; // if found then break from for loop. } } // convert into array of ints and then return. return ConvertionTools.convertObjectArrayToIntArray(resultado.toArray()); }
public int getTotalLayers() { return layersManager.getBackgroundLayers().size() + layersManager.getMainLayers().size() + layersManager.getVectorLayers().size(); }
/** * Obtains a list of vector layers. * * @return ArrayList<Layer> */ public ArrayList<Layer> getVectorLayers() { return layersManager.getVectorLayers(); }
/** * Obtains e list of raster layers * * @return ArrayList<Layer> */ public ArrayList<Layer> getRasterLayers() { return layersManager.getMainLayers(); }
/** * Gets the list of Background layers * * @return ArrayList<Layer> */ public ArrayList<Layer> getBackgroundLayers() { return layersManager.getBackgroundLayers(); }
/** * 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; }
/** Class constructor, it defines the file that will store the layers info */ public OpenLayersManager() throws XMLFilesException { this.layersManager = LayerMenuManagerSingleton.getInstance(); mapConfig = OpenLayerMapConfig.getInstance(); }