public Map<String, Object> getLayerUserData(MapContext mapContext, ClientLayerInfo clientLayerInfo) { Map<String, Object> userData = new HashMap<String, Object>(); RasterLayerRasterizingInfo extraInfo = (RasterLayerRasterizingInfo) clientLayerInfo .getWidgetInfo(RasterLayerRasterizingInfo.WIDGET_KEY); userData.put(USERDATA_KEY_SHOWING, extraInfo.isShowing()); return userData; }
@Override public Map<String, Object> createBeanLayerDefinitionParameters(DynamicLayerConfiguration lc) throws Exception { if (clientLayerInfoMap.containsKey(lc.getClientLayerInfo().getId())) { throw new DeskmanagerException(DeskmanagerException.CLIENT_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getId()); } if (serverLayerMap.containsKey(lc.getClientLayerInfo().getServerLayerId())) { throw new DeskmanagerException(DeskmanagerException.SERVER_LAYERID_ALREADY_IN_USE, lc.getClientLayerInfo() .getServerLayerId()); } Map<String, Object> params = new HashMap<String, Object>(); params.put(BeanFactory.BEAN_NAME, lc.getClientLayerInfo().getServerLayerId()); if (lc instanceof DynamicVectorLayerConfiguration) { createVectorLayerParams((DynamicVectorLayerConfiguration) lc, params); } else if (lc instanceof DynamicRasterLayerConfiguration) { createRasterLayerParams((DynamicRasterLayerConfiguration) lc, params); } else { return null; } return params; }
/** * Create a new layer that belongs to the given map model, using the given meta-data. * * @param layerInfo * The layer configuration from which to create the layer. * @param viewPort * The view port of the map. * @param eventBus * The map centric event bus. */ public AbstractServerLayer(T layerInfo, ViewPort viewPort, MapEventBus eventBus) { super(layerInfo.getId()); this.layerInfo = layerInfo; this.markedAsVisible = layerInfo.isVisible(); this.title = layerInfo.getLabel(); setViewPort(viewPort); setEventBus(eventBus); eventBus.addViewPortChangedHandler(new LayerScaleVisibilityHandler()); }
private void updateSystemLayers() { LOG.info("Updating systemlayers"); try { Map<String, LayerModel> models = toMap(layerModelService.getLayerModelsInternal()); for (ClientLayerInfo cli : layerMap.values()) { if (!models.containsKey(cli.getId())) { try { LayerModel lm = toLayerModel(cli); layerModelService.saveOrUpdateLayerModelInternal(lm); LOG.info(" - updated layermodel for: " + cli.getLabel()); } catch (Exception e) { LOG.error("Error creating layer, invalid configuration (service not available?): " + cli.getLabel()); } } } } catch (Exception e) { LOG.warn("Error updating system layers: " + e.getMessage()); } }
@Override public boolean isShowing() { if (markedAsVisible) { if (viewPort.getScale() >= layerInfo.getMinimumScale().getPixelPerUnit() && viewPort.getScale() <= layerInfo.getMaximumScale().getPixelPerUnit()) { return true; } } return false; } }
@Override public void execute(CreateLayerModelRequest request, LayerModelResponse response) throws Exception { if (request.getConfiguration() == null || request.getConfiguration().getClientLayerInfo() == null || request.getConfiguration().getClientLayerInfo().getUserData() == null) { Exception e = new IllegalArgumentException("Error while saving layermodel: configuration is required."); log.error(e.getLocalizedMessage()); throw e; } DeskmanagerClientLayerInfo ud = (DeskmanagerClientLayerInfo) request.getConfiguration().getClientLayerInfo() .getUserData(); ClientLayerInfo cvli = request.getConfiguration().getClientLayerInfo(); LayerModel lm = new LayerModel(); lm.setDynamicLayerConfiguration(request.getConfiguration()); lm.setActive(ud.isActive()); lm.setPublic(ud.isPublic()); lm.setName(cvli.getLabel()); lm.setClientLayerId(cvli.getId()); lm.setDefaultVisible(cvli.isVisible()); lm.setMaxScale(cvli.getMaximumScale()); lm.setMinScale(cvli.getMinimumScale()); lm.setLayerType(request.getConfiguration().getServerLayerInfo().getLayerType()); Territory g = ((DeskmanagerSecurityContext) securityContext).getTerritory(); if (g != null && g.getId() > 0) { // 0 = superuser lm.setOwner(groupService.getById(g.getId())); } layerModelService.saveOrUpdateLayerModel(lm); response.setLayerModel(dtoService.toDto(lm, false/* TODO: , request.getLocale() */)); }
.getBean(geodeskLayer.getLayerModel().getClientLayerId())); boolean isVectorLayer = serverCli instanceof ClientVectorLayerInfo; serverLayer = (Layer<?>) applicationContext.getBean(serverCli.getServerLayerId()); serverCli.setLayerInfo((LayerInfo) SerializationUtils.clone((LayerInfo) serverLayer.getLayerInfo())); if (isVectorLayer) { ClientVectorLayerInfo cvli = (ClientVectorLayerInfo) serverCli; targetCli.setLayerInfo(serverLayer.getLayerInfo()); targetCli.setMaxExtent(serverCli.getMaxExtent()); log.debug("Registering style for layer: " + targetCli.getLabel()); nsi.setName(styleService.registerStyle(targetCli.getServerLayerId(), nsi)); clientWidgetInfos.putAll(serverCli.getWidgetInfo()); clientWidgetInfos.putAll(geodeskLayer.getWidgetInfo()); targetCli.setWidgetInfo(clientWidgetInfos);
private LayerModel toLayerModel(ClientLayerInfo cli) { LayerModel lm = new LayerModel(); DeskmanagerClientLayerInfo ecli = layerModelService.getExtraInfo(cli); // Get layerInfo via server layer LayerInfo sli = null; Layer<LayerInfo> layer = serverLayerMap.get(cli.getServerLayerId()); if (null != layer) { sli = layer.getLayerInfo(); } lm.setActive(ecli.isActive()); lm.setClientLayerId(cli.getId()); lm.setName(ecli.getName() == null ? cli.getLabel() : ecli.getName()); lm.setPublic(ecli.isPublic()); lm.setMinScale(cli.getMinimumScale()); lm.setMaxScale(cli.getMaximumScale()); lm.setDefaultVisible(cli.isVisible()); lm.setReadOnly(true); lm.setLayerType(sli.getLayerType()); if (null != layer && LayerType.RASTER.equals(sli.getLayerType())) { lm.setDynamicLayerConfiguration(new DynamicRasterLayerConfiguration()); } else if (null != layer) { lm.setDynamicLayerConfiguration(new DynamicVectorLayerConfiguration()); } return lm; } }
public void show() { form.clearValues(); publicLayer.setValue(layer.getLayerModel().isPublic()); ClientLayerInfo cli = layer.getClientLayerInfo(); if (cli == null) { // If layerInfo not set (yet), copy from model. cli = layer.getReferencedLayerInfo(); } label.setValue(cli.getLabel()); defaultVisible.setValue(cli.isVisible()); minScale.setValue(SensibleScaleConverter.scaleToString(cli.getMinimumScale())); maxScale.setValue(SensibleScaleConverter.scaleToString(cli.getMaximumScale())); clearWidgetTabs(); loadWidgetTabs(layer); super.show(); }
private List<NamedObject> getClientLayerInfoObject(DynamicLayerConfiguration lc) throws Exception { if (lc == null) { throw new IllegalArgumentException("Need a DynamicLayerConfiguration"); } List<NamedObject> objects = new ArrayList<BeanDefinitionDtoConverterService.NamedObject>(); if (lc.getServerLayerInfo() instanceof VectorLayerInfo) { NamedStyleInfo nsi = ((VectorLayerInfo) lc.getServerLayerInfo()).getNamedStyleInfos().get(0); objects.add(new NamedObjectImpl(nsi, nsi.getName())); } objects.add(new NamedObjectImpl(lc.getClientLayerInfo(), lc.getClientLayerInfo().getId())); return objects; }
Map<String, List<ConfiguredSearch>> searches = new LinkedHashMap<String, List<ConfiguredSearch>>(); for (ClientLayerInfo clientLayerInfo : mapWidget.getMapModel().getMapInfo().getLayers()) { if (clientLayerInfo.getWidgetInfo().containsKey(ConfiguredSearchesInfo.IDENTIFIER)) { ConfiguredSearchesInfo searchesInfo = (ConfiguredSearchesInfo) clientLayerInfo.getWidgetInfo(). get(ConfiguredSearchesInfo.IDENTIFIER); List<ConfiguredSearch> searchConfigs = searchesInfo.getSearchConfigs(); if (searchConfigs != null && searchConfigs.size() > 0) { searches.put(clientLayerInfo.getId(), searchConfigs);
public void setData(DynamicLayerConfiguration layerConfig) { this.layerConfig = layerConfig; this.extraLayerInfo = (DeskmanagerClientLayerInfo) layerConfig.getClientLayerInfo().getUserData(); name.setValue(layerConfig.getClientLayerInfo().getLabel()); publicLayer.setValue(extraLayerInfo.isPublic()); active.setValue(extraLayerInfo.isActive()); visible.setValue(layerConfig.getClientLayerInfo().isVisible()); }
if (clientLayerInfo instanceof ClientVectorLayerInfo) { VectorLayerRasterizingInfo vectorRasterizingInfo = (VectorLayerRasterizingInfo) clientLayerInfo .getWidgetInfo(VectorLayerRasterizingInfo.WIDGET_KEY); int origSize = vectorRasterizingInfo.getStyle().getLabelStyle().getFontStyle().getSize(); vectorRasterizingInfo.getStyle().getLabelStyle().getFontStyle() List<Feature> containerFeatures = container.getFeatures(); for (ClientLayerInfo clientLayerInfo : clientMapInfo.getLayers()) { if (layerId.equals(clientLayerInfo.getServerLayerId())) { List<InternalFeature> features = vectorLayerService.getFeatures(layerId, geoService.getCrs2(clientMapInfo.getCrs()),
private static boolean checkVisibility(ClientLayerTreeNodeInfo node, String layerId) { List<ClientLayerInfo> layers = node.getLayers(); if (layers != null) { for (ClientLayerInfo layer : layers) { if (layer.getId().equals(layerId) && layer.isVisible()) { return true; } } } if (node.getTreeNodes() != null) { for (ClientLayerTreeNodeInfo innernode : node.getTreeNodes()) { if (checkVisibility(innernode, layerId)) { return true; } } } return false; }
public Layer createLayer(MapContext mapContext, ClientLayerInfo clientLayerInfo) throws GeomajasException { if (!(clientLayerInfo instanceof TilebasedClientLayerInfo)) { throw new IllegalArgumentException( "TileBasedClientLayerFactory.createLayer() should only be called with TilebasedClientLayerInfo"); } TilebasedClientLayerInfo rasterInfo = (TilebasedClientLayerInfo) clientLayerInfo; RasterLayerRasterizingInfo extraInfo = (RasterLayerRasterizingInfo) rasterInfo .getWidgetInfo(RasterLayerRasterizingInfo.WIDGET_KEY); List<RasterTile> tiles = rasterInfo.getTiles(); for (RasterTile rasterTile : tiles) { if (null != rasterTile.getUrl() && !rasterTile.getUrl().isEmpty()) { rasterTile.setUrl(calculateUrl(rasterTile.getUrl())); } } final RasterLayer layer = configurationService.getRasterLayer(clientLayerInfo.getServerLayerId()); RasterDirectLayer rasterLayer = new RasterDirectLayer(imageThreadPool, getHttpDownloader(layer), tiles, rasterInfo.getTileHeight(), rasterInfo.getTileWidth(), rasterInfo.getScale(), extraInfo.getCssStyle()); rasterLayer.setTitle(clientLayerInfo.getLabel()); rasterLayer.getUserData().put(USERDATA_KEY_LAYER_ID, rasterInfo.getId()); rasterLayer.getUserData().put(USERDATA_KEY_SHOWING, extraInfo.isShowing()); return rasterLayer; }
private void saved() { if (form.validate()) { if (layer.getClientLayerInfo() == null) { layer.setClientLayerInfo(layer.getReferencedLayerInfo()); // clone?? } ClientLayerInfo cli = layer.getClientLayerInfo(); cli.setLayerInfo(null); cli.setVisible(defaultVisible.getValueAsBoolean()); cli.setLabel(label.getValueAsString()); cli.setMinimumScale(SensibleScaleConverter.stringToScale(minScale.getValueAsString())); cli.setMaximumScale(SensibleScaleConverter.stringToScale(maxScale.getValueAsString())); if (cli instanceof ClientRasterLayerInfo && opacitySlider != null) { float opacityValue = opacitySlider.getValue() / 100; ((ClientRasterLayerInfo) cli).setStyle(String.valueOf(opacityValue)); } else if (cli instanceof ClientVectorLayerInfo && styleHelper != null) { styleHelper.apply((ClientVectorLayerInfo) cli); } for (WidgetEditorHandler h : widgetEditors) { h.save(layer); } hide(); destroy(); if (callback != null) { callback.execute(true); } } }
/** @todo javadoc unknown. */ public String getServerLayerId() { return layerInfo.getServerLayerId(); }
ListGridRecord record = new ListGridRecord(); if (layer.getClientLayerInfo() != null) { record.setAttribute(LayerListGrid.FLD_NAME, layer.getClientLayerInfo().getLabel()); } else if (layer.getReferencedLayerInfo() != null) { record.setAttribute(LayerListGrid.FLD_NAME, layer.getReferencedLayerInfo().getLabel()); ListGridRecord record = new ListGridRecord(); if (layer.getClientLayerInfo() != null) { record.setAttribute(LayerListGrid.FLD_NAME, layer.getClientLayerInfo().getLabel()); } else if (layer.getReferencedLayerInfo() != null) { record.setAttribute(LayerListGrid.FLD_NAME, layer.getReferencedLayerInfo().getLabel()); ListGridRecord record = new ListGridRecord(); if (layer.getClientLayerInfo() != null) { record.setAttribute(LayerListGrid.FLD_NAME, layer.getClientLayerInfo().getLabel()); } else if (layer.getReferencedLayerInfo() != null) { record.setAttribute(LayerListGrid.FLD_NAME, layer.getReferencedLayerInfo().getLabel());
@Override public void initialize(ClientMapInfo mapInfo, MapEventBus eventBus) { this.mapInfo = mapInfo; this.eventBus = eventBus; crs = mapInfo.getCrs(); // Calculate maximum bounds: maxBounds = new Bbox(mapInfo.getMaxBounds().getX(), mapInfo.getMaxBounds().getY(), mapInfo.getMaxBounds() .getWidth(), mapInfo.getMaxBounds().getHeight()); // if the max bounds was not configured, take the union of initial and layer bounds if (BboxService.equals(maxBounds, Bbox.ALL, 1e-10)) { maxBounds = new Bbox(mapInfo.getInitialBounds().getX(), mapInfo.getInitialBounds().getY(), mapInfo .getInitialBounds().getWidth(), mapInfo.getInitialBounds().getHeight()); if (mapInfo.getLayers() != null && mapInfo.getLayers().size() > 0) { for (ClientLayerInfo layerInfo : mapInfo.getLayers()) { if (layerInfo.getMaxExtent() != null) { maxBounds = BboxService.union(maxBounds, layerInfo.getMaxExtent()); } } } } // Set the best zoom strategy given the map info: if (mapInfo.getScaleConfiguration().getZoomLevels() != null && mapInfo.getScaleConfiguration().getZoomLevels().size() > 0) { zoomStrategy = new FixedStepZoomStrategy(mapInfo, maxBounds); } else { zoomStrategy = new FreeForAllZoomStrategy(mapInfo, maxBounds); } zoomStrategy.setMapSize(mapWidth, mapHeight); initialized = true; }
@Override public DeskmanagerClientLayerInfo getExtraInfo(ClientLayerInfo cli) { if (cli.getUserData() != null && cli.getUserData() instanceof DeskmanagerClientLayerInfo) { return (DeskmanagerClientLayerInfo) cli.getUserData(); } else { return DEFAULT_ECLI; } }