public void createArc() { List<Point> points = drawingPane.getDrawObjectsAsGeoPoints(); ApplicationContainer<?> appCont = digitizerModule.getApplicationContainer(); if (points.size() >= 3) { try { Curve curve = GeometryUtils.calcCircleCoordinates( points.get(0).getPosition(), getRadius(), getNoOfVertices(), points.get(1).getPosition(), points.get(2).getPosition(), points.get(1).getCoordinateSystem()); MapModel mapModel = appCont.getMapModel(null); Layer layer = mapModel.getLayersSelectedForAction(MapModel.SELECTION_EDITING).get(0); FeatureAdapter featureAdapter = (FeatureAdapter) layer.getDataAccess().get(0); FeatureType ft = featureAdapter.getSchema(); Feature feat = featureAdapter.getDefaultFeature(ft.getName()); feat = feat.cloneDeep(); QualifiedName geomProperty = ft.getGeometryProperties()[0].getName(); feat.getProperties(geomProperty)[0].setValue(curve); Command cmd = new InsertFeatureCommand(featureAdapter, feat); appCont.getCommandProcessor().executeSychronously(cmd, true); } catch (Exception ex) { LOG.logError(ex); DialogFactory.openErrorDialog( appCont.getViewPlatform(), DrawArcDialog.this, Messages.getMessage(getLocale(), "$MD11628"), Messages.getMessage(getLocale(), "$MD11629"), ex); } } }
/** opens a dialog for selecting a WPS dialog */ public void open() { MapModel mapModel = appContainer.getMapModel(null); List<Layer> layers = mapModel.getLayersSelectedForAction(MapModel.SELECTION_ACTION); if (layers.size() > 0 && this.componentStateAdapter.isClosed()) { this.componentStateAdapter.setClosed(false); createIView(); } }
private CopyCoordinatesPanel createCopyCoordinatesPanel( MapTool<?> mapTool, MapModel mapModel, Container container) { CopyCoordinatesPanel copyCoordinatesPanel = new CopyCoordinatesPanel(mapTool, container); int width = mapModel.getTargetDevice().getPixelWidth(); int height = mapModel.getTargetDevice().getPixelHeight(); copyCoordinatesPanel.setBounds(0, 0, width, height); copyCoordinatesPanel.setBackground(new Color(255, 255, 255, 0)); copyCoordinatesPanel.setVisible(true); return copyCoordinatesPanel; }
/** * force invoking a WPS process * * @param parameter */ @SuppressWarnings("unchecked") public void process(Map<String, Object> parameter) { String s1 = (String) parameter.get("$PROCESS"); String s2 = (String) parameter.get("$WPS"); String mmId = getInitParameter("assignedMapModel"); MapModel mm = appContainer.getMapModel(new Identifier(mmId)); SelectedFeaturesVisitor visitor = new SelectedFeaturesVisitor(-1); try { mm.walkLayerTree(visitor); } catch (Exception e) { throw new ModuleException(e.getMessage(), e); } FeatureCollection tmp = visitor.col; List<Layer> layers = mm.getLayersSelectedForAction(MapModel.SELECTION_ACTION); if (tmp.size() == 0) { for (Layer layer : layers) { List<DataAccessAdapter> dada = layer.getDataAccess(); for (DataAccessAdapter dataAccessAdapter : dada) { if (dataAccessAdapter instanceof FeatureAdapter) { tmp.addAllUncontained(((FeatureAdapter) dataAccessAdapter).getFeatureCollection()); } } } } parameter.put("$InputGeometry$", tmp); String className = getInitParameter(s1 + '@' + s2); try { Class<Command> clzz = (Class<Command>) Class.forName(className); Constructor<Command> constructor = clzz.getConstructor(new Class[] {Layer.class, Map.class}); Command command = constructor.newInstance(new Object[] {layers.get(0), parameter}); appContainer.getCommandProcessor().executeASychronously(command); } catch (Exception e) { throw new ModuleException(e.getMessage(), e); } }
/** * @param layer * @param supportUndo */ public UnselectFeaturesCommand(MapModel mapModel, boolean supportUndo) { this.supportUndo = supportUndo; this.layers = new ArrayList<Layer>(100); try { mapModel.walkLayerTree( new MapModelVisitor() { public void visit(Layer layer) throws Exception { layers.add(layer); } public void visit(LayerGroup layerGroup) throws Exception {} }); } catch (Exception e) { LOG.logError(e.getMessage(), e); } }
/* * (non-Javadoc) * * @see org.deegree.igeo.modules.remotecontrol.RequestHandler#perform(java.util.Map, * org.deegree.igeo.ApplicationContainer) */ public String perform(Map<String, String> paramater, ApplicationContainer<?> appContainer) throws ModuleException { String tmp = paramater.get("OBJECTIDS"); if (tmp == null || tmp.length() == 0) { throw new ModuleException(Messages.get("$DG10091")); } List<String> objIds = StringTools.toList(tmp, ",;", true); tmp = paramater.get("LAYER"); if (tmp == null) { throw new ModuleException(Messages.get("$DG10092")); } MapModel mapModel = appContainer.getMapModel(null); LocalMapModelVisitor mv = new LocalMapModelVisitor(tmp); try { mapModel.walkLayerTree(mv); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } Layer layer = mv.getResult(); if (layer == null) { throw new ModuleException(Messages.get("$DG10093", tmp)); } layer.setVisible(true); // first select features in layer List<Identifier> ids = new ArrayList<Identifier>(); for (String id : objIds) { ids.add(new Identifier(id)); } SelectFeatureCommand cmd = new SelectFeatureCommand(layer, ids, false); try { appContainer.getCommandProcessor().executeSychronously(cmd, true); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } // get selected features as FeatureCollection and so their common bounding box FeatureCollection fc = layer.getSelectedFeatures(); if (fc.size() == 0) { throw new ModuleException(Messages.get("$DG10094", paramater.get("OBJECTIDS"))); } Envelope env = null; try { env = fc.getBoundedBy(); if (env.getWidth() < 0.0001) { // feature collection just contains one point; set fix bbox width/height // 25 map units env = env.getBuffer(25); } } catch (GeometryException e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } // zoom to common bounding box of selected features ZoomCommand zcmd = new ZoomCommand(mapModel); zcmd.setZoomBox( env, mapModel.getTargetDevice().getPixelWidth(), mapModel.getTargetDevice().getPixelHeight()); if ("TRUE".equalsIgnoreCase(paramater.get("sync"))) { try { appContainer.getCommandProcessor().executeSychronously(zcmd, true); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new ModuleException(e.getMessage()); } } else { appContainer.getCommandProcessor().executeASychronously(zcmd); } return "feature selected"; }