ClientMapInfo overviewMap = null; for (ClientMapInfo map : appInfo.getMaps()) { if (GdmLayout.MAPMAIN_ID.equals(map.getId())) { mainMap = map; if (GdmLayout.MAPOVERVIEW_ID.equals(map.getId())) { overviewMap = map; mainMap.getLayers().clear(); mainMap.getLayers().addAll(addLayers(geodesk.getMainMapLayers(), blueprint.getMainMapLayers())); } else if (!blueprint.getMainMapLayers().isEmpty()) { mainMap.getLayers().clear(); mainMap.getLayers().addAll(addLayers(blueprint.getMainMapLayers(), null)); overviewMap.getLayers().clear(); overviewMap.getLayers().addAll( addLayers(geodesk.getOverviewMapLayers(), blueprint.getOverviewMapLayers())); } else if (!blueprint.getOverviewMapLayers().isEmpty()) { overviewMap.getLayers().clear(); overviewMap.getLayers().addAll(addLayers(blueprint.getOverviewMapLayers(), null)); Bbox bounds = GeometryService.getBounds(convertorService .toDto(geodesk.getOwner().getGeometry())); mainMap.setMaxBounds(bounds); mainMap.setInitialBounds(bounds); overviewMap.setMaxBounds(bounds); overviewMap.setInitialBounds(bounds); } catch (GeomajasException e) { LOG.warn("Unable to apply loket territory bounds, falling back to default. {}",
@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; }
public void initialize(ClientMapInfo mapInfo) { pointStyle = mapInfo.getPointSelectStyle(); lineStyle = mapInfo.getLineSelectStyle(); ringStyle = mapInfo.getPolygonSelectStyle(); }
/** * Retrieve the list of ClientWidgetInfo's from a userapplications main map. This consists of the widget infos * defined in the UserApplication itself, and those defined in the {@link UserApplicationInfo#getApplicationInfo()}. * * @param uai the user application info * @return List of ClientWidgetInfo as defined in the user application */ public static Map<String, ClientWidgetInfo> getMainMapClientWidgetInfo(UserApplicationInfo uai) { Map<String, ClientWidgetInfo> widgetInfos = new HashMap<String, ClientWidgetInfo>(); for (ClientMapInfo cmi : uai.getApplicationInfo().getMaps()) { if (GdmLayout.MAPMAIN_ID.equals(cmi.getId())) { widgetInfos.putAll(cmi.getWidgetInfo()); } } widgetInfos.putAll(uai.getMainMapWidgetInfos()); return widgetInfos; }
/** * Updates blueprint that has no layers set so that the layers configured in the userApplication are inserted into * the database. * */ @Transactional(rollbackFor = { Exception.class }) private void updateBluePrintMainMapFromUserApplication(Blueprint bp) { UserApplicationInfo uai = getUserApplication(bp.getUserApplicationKey()); if (uai != null) { ClientMapInfo mainMap = null; for (ClientMapInfo map : uai.getApplicationInfo().getMaps()) { if (GdmLayout.MAPMAIN_ID.equals(map.getId())) { mainMap = map; } } Map<String, LayerModel> layerModels = new HashMap<String, LayerModel>(); for (LayerModel lm : layerModelService.getLayerModelsInternal()) { layerModels.put(lm.getClientLayerId(), lm); } for (ClientLayerInfo clientLayer : mainMap.getLayers()) { org.geomajas.plugin.deskmanager.domain.ClientLayer layer = new org.geomajas.plugin.deskmanager.domain.ClientLayer(); layer.setLayerModel(layerModels.get(clientLayer.getId())); bp.getMainMapLayers().add(layer); } } }
public ClientMapInfo getMapInfo(String mapId, String applicationId) { if (null == mapId || null == applicationId) { return null; } ClientApplicationInfo application = applicationMap.get(applicationId); if (application != null) { for (ClientMapInfo map : application.getMaps()) { if (mapId.equals(map.getId())) { return map; } } } return null; }
private Layer createLayer(ClientLayerInfo layerInfo) { ServerLayer<?> layer = null; switch (layerInfo.getLayerType()) { case RASTER: layer = layerFactory.createRasterLayer((ClientRasterLayerInfo) layerInfo, viewPort, eventBus); break; default: layer = layerFactory.createVectorLayer((ClientVectorLayerInfo) layerInfo, viewPort, eventBus); break; } if (!mapInfo.getLayers().contains(layer.getLayerInfo())) { mapInfo.getLayers().add(layer.getLayerInfo()); } return layer; }
.getWidgetInfo(MapRasterizingInfo.WIDGET_KEY); ByteArrayOutputStream stream = new ByteArrayOutputStream(MAP_BUFFER_SIZE); ReportingCacheContainer container = new ReportingCacheContainer(); for (ClientLayerInfo clientLayerInfo : clientMapInfo.getLayers()) { if (clientLayerInfo instanceof ClientVectorLayerInfo) { VectorLayerRasterizingInfo vectorRasterizingInfo = (VectorLayerRasterizingInfo) clientLayerInfo for (ClientLayerInfo clientLayerInfo : clientMapInfo.getLayers()) { if (layerId.equals(clientLayerInfo.getServerLayerId())) { List<InternalFeature> features = vectorLayerService.getFeatures(layerId, geoService.getCrs2(clientMapInfo.getCrs()), getFilter(request.getFilter(), request.getFeatureIds()), null, VectorLayerService.FEATURE_INCLUDE_ALL);
@Override public void render(PdfContext context) { try { bbox = createBbox(); MapRasterizingInfo mapRasterizingInfo = (MapRasterizingInfo) clientMapInfo .getWidgetInfo(MapRasterizingInfo.WIDGET_KEY); mapRasterizingInfo.setBounds(new Bbox(bbox.getMinX(), bbox.getMinY(), bbox.getWidth(), bbox.getHeight())); mapRasterizingInfo.setScale(getMap().getPpUnit()); Graphics2D graphics = context.getGraphics2D(getBounds()); imageService.writeMap(graphics, clientMapInfo); graphics.dispose(); } catch (Exception e) { log.warn("Failed to render rasterized layers", e); } super.render(context); }
@Override public List<RasterCapabilitiesInfo> getRasterCapabilities(Map<String, String> connectionProperties) throws Exception { URL url = new URL(connectionProperties.get(GetWmsCapabilitiesRequest.GET_CAPABILITIES_URL)); SimpleHttpClient httpClient = new SimpleHttpClient(); if (connectionProperties.containsKey(WmsLayerBeanFactory.WMS_USERNAME)) { httpClient.setUser(connectionProperties.get(WmsLayerBeanFactory.WMS_USERNAME)); httpClient.setPassword(connectionProperties.get(WmsLayerBeanFactory.WMS_PASSWORD)); } WebMapServer wms = new WebMapServer(url, httpClient); WMSCapabilities capabilities = wms.getCapabilities(); List<RasterCapabilitiesInfo> layers = new ArrayList<RasterCapabilitiesInfo>(); List<RasterCapabilitiesInfo> nonNativeLayers = new ArrayList<RasterCapabilitiesInfo>(); for (org.geotools.data.ows.Layer owsLayer : WMSUtils.getNamedLayers(capabilities)) { if (owsLayer.getSrs().contains(defaultGeodesk.getMaps().get(0).getCrs())) { // Only add default crs layers.add(dtoFactoryService.buildRasterCapabilitesInfoFromWms(wms, owsLayer, defaultGeodesk.getMaps().get(0).getCrs())); } else { // Add all available crs-es for (String srs : owsLayer.getSrs()) { try { nonNativeLayers.add(dtoFactoryService.buildRasterCapabilitesInfoFromWms(wms, owsLayer, srs)); } catch (LayerException e) { log.warn("Got unknown crs from wms server, ignoring: {}", srs); } } } } layers.addAll(nonNativeLayers); return layers; }
/** * Calculate max bounds based on the map's max bounds, combined with the layer's bounds. * @return Polygon based on the max bounds bbox. */ private Geometry getMaxBoundsAsGeometry() { ClientMapInfo mapModel = territoryMap.getMapModel().getMapInfo(); Bbox result = mapModel.getMaxBounds(); for (ClientLayerInfo layer : mapModel.getLayers()) { result = BboxService.union(result, layer.getMaxExtent()); } if (result == null || result.getHeight() == 0 || result.getWidth() == 0) { result = new Bbox(); result.setX(Double.MIN_VALUE); result.setY(Double.MIN_VALUE); result.setMaxX(Double.MAX_VALUE); result.setMaxY(Double.MAX_VALUE); } return GeometryService.toPolygon(result); }
UnitType displayUnitType = map.getDisplayUnitType(); log.debug("calculateSize getMap.getId({}), res {}", getMap().getId(), map); Crs crs; try { crs = geoService.getCrs2(map.getCrs()); unit = crs.getCoordinateSystem().getAxis(0).getUnit().toString(); if (UnitType.ENGLISH == displayUnitType || UnitType.ENGLISH_FOOT == displayUnitType) {
public void onActivate(MapPresenter mapPresenter) { super.onActivate(mapPresenter); idleController.onActivate(mapPresenter); insertController.setMaxBounds(mapPresenter.getConfiguration().getServerConfiguration().getMaxBounds()); dragController.setMaxBounds(mapPresenter.getConfiguration().getServerConfiguration().getMaxBounds()); }
/** * Updates blueprint that has no layers set so that the layers configured in the userApplication are inserted into * the database. * */ @Transactional(rollbackFor = { Exception.class }) private void updateBluePrintMainMapFromUserApplication(Blueprint bp) { UserApplicationInfo uai = getUserApplication(bp.getUserApplicationKey()); if (uai != null) { ClientMapInfo mainMap = null; for (ClientMapInfo map : uai.getApplicationInfo().getMaps()) { if (GdmLayout.MAPMAIN_ID.equals(map.getId())) { mainMap = map; } } Map<String, LayerModel> layerModels = new HashMap<String, LayerModel>(); for (LayerModel lm : layerModelService.getLayerModelsInternal()) { layerModels.put(lm.getClientLayerId(), lm); } for (ClientLayerInfo clientLayer : mainMap.getLayers()) { org.geomajas.plugin.deskmanager.domain.ClientLayer layer = new org.geomajas.plugin.deskmanager.domain.ClientLayer(); layer.setLayerModel(layerModels.get(clientLayer.getId())); bp.getMainMapLayers().add(layer); } } }
/** * Retrieve the list of ClientWidgetInfo's from the userapplication's overview map. used. * * @param userApplication * the userapplication * @return List of ClientWidgetInfo as defined in the userapplication */ public static Map<String, ClientWidgetInfo> getOverviewMapClientWidgetInfo(UserApplicationInfo userApplication) { Map<String, ClientWidgetInfo> widgetInfos = new HashMap<String, ClientWidgetInfo>(); for (ClientMapInfo mapInfo : userApplication.getApplicationInfo().getMaps()) { if (mapInfo.getId().equals(GdmLayout.MAPOVERVIEW_ID)) { widgetInfos.putAll(mapInfo.getWidgetInfo()); } } widgetInfos.putAll(userApplication.getOverviewMapWidgetInfos()); return widgetInfos; }
/** * Retrieve the mapinfo from the userapplication's main map. * * @param userApplication * the userapplication * @return the mapInfo */ public static ClientMapInfo getMainMap(UserApplicationInfo userApplication) { for (ClientMapInfo mapInfo : userApplication.getApplicationInfo().getMaps()) { if (mapInfo.getId().equals(GdmLayout.MAPMAIN_ID)) { return mapInfo; } } return null; }
protected void initialize() { themeInfo = (ThemesInfo) mapWidget.getMapModel().getMapInfo().getWidgetInfo(ThemesInfo.IDENTIFIER); buildWidget(); for (Layer<?> layer : mapWidget.getMapModel().getLayers()) { layer.addLayerChangedHandler(this); } // Set default viewConfig active is configured for (ViewConfigItem viewConfig : viewConfigItems) { if (viewConfig.getViewConfig().isActiveByDefault()) { activateViewConfig(viewConfig); } } }
@Override public List<RasterCapabilitiesInfo> getRasterCapabilities(Map<String, String> connectionProperties) throws Exception { URL url = new URL(connectionProperties.get(GetWmsCapabilitiesRequest.GET_CAPABILITIES_URL)); SimpleHttpClient httpClient = new SimpleHttpClient(); if (connectionProperties.containsKey(WmsLayerBeanFactory.WMS_USERNAME)) { httpClient.setUser(connectionProperties.get(WmsLayerBeanFactory.WMS_USERNAME)); httpClient.setPassword(connectionProperties.get(WmsLayerBeanFactory.WMS_PASSWORD)); } WebMapServer wms = new WebMapServer(url, httpClient); WMSCapabilities capabilities = wms.getCapabilities(); List<RasterCapabilitiesInfo> layers = new ArrayList<RasterCapabilitiesInfo>(); List<RasterCapabilitiesInfo> nonNativeLayers = new ArrayList<RasterCapabilitiesInfo>(); for (org.geotools.data.ows.Layer owsLayer : WMSUtils.getNamedLayers(capabilities)) { if (owsLayer.getSrs().contains(defaultGeodesk.getMaps().get(0).getCrs())) { // Only add default crs layers.add(dtoFactoryService.buildRasterCapabilitesInfoFromWms(wms, owsLayer, defaultGeodesk.getMaps().get(0).getCrs())); } else { // Add all available crs-es for (String srs : owsLayer.getSrs()) { try { nonNativeLayers.add(dtoFactoryService.buildRasterCapabilitesInfoFromWms(wms, owsLayer, srs)); } catch (LayerException e) { LOG.warn("Got unknown crs from wms server, ignoring: {}", srs); } } } } layers.addAll(nonNativeLayers); return layers; }
ClientMapInfo overviewMap = null; for (ClientMapInfo map : appInfo.getMaps()) { if (GdmLayout.MAPMAIN_ID.equals(map.getId())) { mainMap = map; if (GdmLayout.MAPOVERVIEW_ID.equals(map.getId())) { overviewMap = map; mainMap.getLayers().clear(); mainMap.getLayers().addAll(addLayers(geodesk.getMainMapLayers(), blueprint.getMainMapLayers())); } else if (!blueprint.getMainMapLayers().isEmpty()) { mainMap.getLayers().clear(); mainMap.getLayers().addAll(addLayers(blueprint.getMainMapLayers(), null)); overviewMap.getLayers().clear(); overviewMap.getLayers().addAll( addLayers(geodesk.getOverviewMapLayers(), blueprint.getOverviewMapLayers())); } else if (!blueprint.getOverviewMapLayers().isEmpty()) { overviewMap.getLayers().clear(); overviewMap.getLayers().addAll(addLayers(blueprint.getOverviewMapLayers(), null)); Bbox bounds = GeometryService.getBounds(convertorService .toDto(geodesk.getOwner().getGeometry())); mainMap.setMaxBounds(bounds); mainMap.setInitialBounds(bounds); overviewMap.setMaxBounds(bounds); overviewMap.setInitialBounds(bounds); } catch (GeomajasException e) { log.warn("Unable to apply loket territory bounds, falling back to default. {}",