Examples of LayerGroupInfo


Examples of org.geoserver.catalog.LayerGroupInfo

       
        form.add(new GeoServerAjaxFormLink( "generateBounds") {
            @Override
            public void onClick(AjaxRequestTarget target, Form form) {
                // build a layer group with the current contents of the group
                LayerGroupInfo lg = getCatalog().getFactory().createLayerGroup();
                for ( LayerGroupEntry entry : lgEntryPanel.getEntries() ) {
                    lg.getLayers().add(entry.getLayer());
                    lg.getStyles().add(entry.getStyle());
                }
               
                try {
                    CoordinateReferenceSystem crs = crsPanel.getCRS();
                    if ( crs != null ) {
                        //ensure the bounds calculated in terms of the user specified crs
                        new CatalogBuilder( getCatalog() ).calculateLayerGroupBounds( lg, crs );
                    }
                    else {
                        //calculate from scratch
                        new CatalogBuilder( getCatalog() ).calculateLayerGroupBounds( lg );
                    }
                   
                    envelopePanel.setModelObject( lg.getBounds() );
                    target.addComponent( envelopePanel );
                   
                    if ( crs == null ) {
                        //update the crs as well
                        crsPanel.setModelObject( lg.getBounds().getCoordinateReferenceSystem() );
                        target.addComponent( crsPanel );
                    }
                   
                }
                catch (Exception e) {
                    throw new WicketRuntimeException( e );
                }
            }
        });
       
        form.add(lgEntryPanel = new LayerGroupEntryPanel( "layers", layerGroup ));
        form.add(new SubmitLink("save"){
            @Override
            public void onSubmit() {
                if(lgEntryPanel.getEntries().size() == 0) {
                    error((String) new ParamResourceModel("oneLayerMinimum", getPage()).getObject());
                    return;
                }
               
                // update the layer group entries
                LayerGroupInfo lg = (LayerGroupInfo) lgModel.getObject();
                lg.getLayers().clear();
                lg.getStyles().clear();
               
                for ( LayerGroupEntry entry : lgEntryPanel.getEntries() ) {
                    lg.getLayers().add(entry.getLayer());
                    lg.getStyles().add(entry.getStyle());
                }
               
                AbstractLayerGroupPage.this.onSubmit();
            }
        });
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

    class GroupNameValidator extends AbstractValidator {

        @Override
        protected void onValidate(IValidatable validatable) {
            String name = (String) validatable.getValue();
            LayerGroupInfo other = getCatalog().getLayerGroupByName(name);
            if(other != null && (layerGroupId == null || !other.getId().equals(layerGroupId))) {
                error(validatable, "duplicateGroupNameError", Collections.singletonMap("name", name));
            }
        }
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

        @SuppressWarnings("unused")
        MvcResult result = mvc.perform(req)
            .andExpect(status().isOk())
            .andReturn();

        LayerGroupInfo m = geoServer.getCatalog().getLayerGroupByName("map");
        assertNotNull(m);
       
        assertEquals( "one", m.getLayers().get(0).getName() );
        assertEquals( "two", m.getLayers().get(1).getName() );

        assertEquals( "one.ysld", m.getStyles().get(0).getFilename() );
        assertEquals( "two.ysld", m.getStyles().get(1).getFilename() );
    }
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

        assertTrue(it.hasNext());
        assertEquals("one", it.next().id);
    }

    LayerGroupInfo map(String id) {
        LayerGroupInfo map = mock(LayerGroupInfo.class);
        when(map.getId()).thenReturn(id);
        return map;
    }
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

        }
        return s;
    }

    protected LayerGroupInfo findMap(String wsName, String name, Catalog cat) {
        LayerGroupInfo m = cat.getLayerGroupByName(wsName, name);
        if (m == null) {
            throw new NotFoundException(String.format("No such map %s:%s", wsName, name));
        }
        return m;
    }
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

        }

        Date mod = new Date();
        Metadata.modified(l, mod);

        LayerGroupInfo map = null;
        if (mapName != null) {
            map = findMap(wsName, mapName, cat);
        }

        cat.save(l);
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

        if (!obj.has("layers")) {
            throw new BadRequestException("Map object requires layers array");
        }

        LayerGroupInfo map = cat.getFactory().createLayerGroup();
        map.setName( name );
        map.setAbstract( description );
        map.setTitle( title );
        map.setMode( Mode.SINGLE );
        map.setWorkspace(ws);

        for (Object o : obj.array("layers")) {
            JSONObj l = (JSONObj) o;

            LayerInfo layer = findLayer(wsName, l.str("name"), cat);
            map.getLayers().add(layer);
            map.getStyles().add(null);

            if (updateBounds) {
                try {
                    updateBounds(bounds, layer);
                } catch (Exception e) {
                    throw new RuntimeException("Error calculating map bounds ", e);
                }
            }

        }

        map.setBounds( bounds );

        Metadata.created(map, created);
        Metadata.modified(map, created);
        Metadata.modified(ws, created);
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

    @RequestMapping(value = "/{wsName}/{name}", method = RequestMethod.DELETE)
    public @ResponseBody
    JSONArr delete(@PathVariable String wsName, @PathVariable String name) {
        Catalog cat = catalog();

        LayerGroupInfo map = findMap(wsName,name, cat);
        cat.remove(map);

        recent.remove(LayerGroupInfo.class, map);
        return list(wsName);
    }
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

   
    @RequestMapping(value="/{wsName}/{name}", method = RequestMethod.GET)
    public @ResponseBody JSONObj get(@PathVariable String wsName,
                                     @PathVariable String name, HttpServletRequest req) {
        Catalog cat = catalog();
        LayerGroupInfo map = findMap(wsName, name, cat);
        return mapDetails(new JSONObj(), map, wsName, req);
    }
View Full Code Here

Examples of org.geoserver.catalog.LayerGroupInfo

                                     @PathVariable String name,
                                     @RequestBody JSONObj obj,
                                     HttpServletRequest req) {
        Catalog cat = geoServer.getCatalog();

        LayerGroupInfo map = findMap(wsName, name, cat);
        WorkspaceInfo ws = map.getWorkspace();

        if(obj.has("name")){
            map.setName( obj.str("name"));
        }
        if(obj.has("title")){
            map.setTitle(obj.str("title"));
        }
        if(obj.has("abstract")){
            map.setAbstract(obj.str("abstract"));
        }
        if(obj.has("proj")&&obj.has("bbox")){
            CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84;
            if( obj.has("proj")){
                String srs = obj.str("proj");
                try {
                    crs = CRS.decode(srs);
                } catch (FactoryException e) {
                    LOG.log(Level.FINE, wsName+"."+name+" unrecorgnized proj:"+srs,e);
                }
            }
            Envelope envelope = IO.bounds(obj.object("bbox"));
            ReferencedEnvelope bounds = new ReferencedEnvelope( envelope, crs );
            map.setBounds(bounds);
        }
        if(obj.has("layers")){
            List<LayerInfo> layers = new ArrayList<LayerInfo>();
            for(Iterator<Object> i = obj.array("layers").iterator();i.hasNext();){
                JSONObj l = (JSONObj) i.next();
                String n = l.str("workspace")+":"+l.str("name");
                LayerInfo layer = cat.getLayerByName(n);
                layers.add(layer);
            }
            map.layers().clear();
            map.layers().addAll(layers);
        }
        // update configuration history
        String user = SecurityContextHolder.getContext().getAuthentication().getName();
        map.getMetadata().put("user", user );

        Date modified = new Date();
        Metadata.modified(map, modified);
        Metadata.modified(ws, modified);

        if(obj.has("change")){
            map.getMetadata().put("change", obj.str("change") );
        }
        else {
            map.getMetadata().put("change", "modified "+obj.keys() );
        }
        cat.save(map);
        cat.save(ws);

        recent.add(LayerGroupInfo.class, map);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.