Package org.geoserver.catalog

Examples of org.geoserver.catalog.CatalogFactory


    }

    void importCatalog(File catalogFile) throws FileNotFoundException,
            IOException, Exception {
        CatalogFactory factory = catalog.getFactory();
       
        LegacyCatalogReader reader = new LegacyCatalogReader();
        reader.read(catalogFile);

        // build all the catalog objects that can be read from the catalog.xml file
View Full Code Here


     * @param ftInfoReader
     * @return
     * @throws Exception
     */
    FeatureTypeInfo readFeatureType(LegacyFeatureTypeInfoReader ftInfoReader, File ftDirectory) throws Exception {
        CatalogFactory factory = catalog.getFactory();
        FeatureTypeInfo featureType = factory.createFeatureType();
       
        featureType.setNativeName(ftInfoReader.name());
        if ( ftInfoReader.alias() != null ) {
            featureType.setName( ftInfoReader.alias() );   
        }
        else {
            featureType.setName( ftInfoReader.name() );
        }
       
        featureType.setSRS("EPSG:" + ftInfoReader.srs());
       
        ProjectionPolicy pp = ProjectionPolicy.get( ftInfoReader.srsHandling() );
        featureType.setProjectionPolicy(pp);
       
        featureType.setTitle(ftInfoReader.title());
        featureType.setAbstract(ftInfoReader.abstrct());
        featureType.getKeywords().addAll(ftInfoReader.keywords());
       
        for ( Map m : ftInfoReader.metadataLinks() ) {
            MetadataLinkInfo link = factory.createMetadataLink();
            link.setContent( (String) m.get( null ) );
            link.setMetadataType( (String) m.get( "metadataType" ) );
            link.setType( (String) m.get( "type" ) );
            featureType.getMetadataLinks().add( link );
        }
View Full Code Here

       
        return featureType;
    }
   
    CoverageInfo readCoverage(LegacyCoverageInfoReader cInfoReader) throws Exception {
        CatalogFactory factory = catalog.getFactory();
       
        // link to coverage store
        String coverageStoreName = cInfoReader.format();
        CoverageStoreInfo coverageStore = catalog.getCoverageStoreByName(coverageStoreName);
       
        if ( coverageStore == null ) {
            LOGGER.warning( "Ignoring coverage: '" + cInfoReader.parentDirectoryName()
                + "', coverage store '" + coverageStoreName + "'  not found");
            return null;
        }
       
        if ( !coverageStore.isEnabled() ) {
            LOGGER.info( "Ignoring coverage: '" + cInfoReader.parentDirectoryName()
                    + "', coverage store is disabled");
            return null;
        }
       
        CoverageInfo coverage = factory.createCoverage();
        coverage.setStore(coverageStore);
       
        coverage.setName(cInfoReader.name());
        coverage.setNativeName(cInfoReader.name());
        coverage.setTitle(cInfoReader.label());
        coverage.setDescription(cInfoReader.description());
        coverage.getKeywords().addAll( cInfoReader.keywords() );
       
        Map<String,Object> envelope = cInfoReader.envelope();
        String userDefinedCrsIdentifier = (String)envelope.get( "srsName" );
        String nativeCrsWkt = (String)envelope.get("crs");

        coverage.setSRS(userDefinedCrsIdentifier);
        CoordinateReferenceSystem crs = CRS.parseWKT(nativeCrsWkt);
        coverage.setNativeCRS( crs );
       
        ReferencedEnvelope bounds = new ReferencedEnvelope(
            (Double) envelope.get( "x1" ), (Double) envelope.get( "x2" ),
            (Double) envelope.get( "y1" ), (Double) envelope.get( "y2" ),
            crs
        );
        coverage.setNativeBoundingBox(bounds);
       
        GeneralEnvelope boundsLatLon =
            CoverageStoreUtils.getWGS84LonLatEnvelope(new GeneralEnvelope( bounds ) );
        coverage.setLatLonBoundingBox(new ReferencedEnvelope( boundsLatLon ) );
       
        GeneralEnvelope gridEnvelope = new GeneralEnvelope( bounds );
        Map grid = cInfoReader.grid();
        if ( grid != null ) {
            int[] low = (int[]) grid.get( "low" );
            int[] high = (int[]) grid.get( "high" );
           
            GeneralGridEnvelope range = new GeneralGridEnvelope(low, high);
           
            Map<String,Double> tx = (Map<String, Double>) grid.get( "geoTransform" );
            if ( tx != null ) {
                double[] matrix = new double[3 * 3];
                matrix[0] = tx.get( "scaleX") != null ? tx.get( "scaleX") : matrix[0];
                matrix[1] = tx.get( "shearX") != null ? tx.get( "shearX") : matrix[1];
                matrix[2] = tx.get( "translateX") != null ? tx.get( "translateX") : matrix[2];
                matrix[3] = tx.get( "shearY") != null ? tx.get( "shearY") : matrix[3];
                matrix[4] = tx.get( "scaleY") != null ? tx.get( "scaleY") : matrix[4];
                matrix[5] = tx.get( "translateY") != null ? tx.get( "translateY") : matrix[5];
                matrix[8] = 1.0;
               
                MathTransform gridToCRS = new DefaultMathTransformFactory()
                    .createAffineTransform( new GeneralMatrix(3,3,matrix));
                coverage.setGrid( new GridGeometry2D(range,gridToCRS,crs) );
            }
            else {
                coverage.setGrid( new GridGeometry2D( range, gridEnvelope ) );
            }
        }
        else {
            // new grid range
            GeneralGridEnvelope range = new GeneralGridEnvelope(new int[] { 0,
                    0 }, new int[] { 1, 1 });
            coverage.setGrid( new GridGeometry2D(range, gridEnvelope) );
        }
       
        for ( Iterator x = cInfoReader.coverageDimensions().iterator(); x   .hasNext(); ) {
            Map map = (Map) x.next();
            CoverageDimensionInfo cd = factory.createCoverageDimension();
            cd.setName((String)map.get("name"));
            cd.setDescription((String)map.get("description"));
            cd.setRange(
               new NumberRange((Double)map.get("min"),(Double)map.get("max"))
            );
View Full Code Here

        Catalog catalog = geoServer.getCatalog();
        // ... we need access to the actual catalog, not a filtered out view of the
        // layers accessible to the current user
        if(catalog instanceof Wrapper)
            catalog = ((Wrapper) catalog).unwrap(Catalog.class);
        CatalogFactory factory = catalog.getFactory();
       
        List<Map> baseMaps = (List<Map>) props.get( "BaseMapGroups");
        if ( baseMaps != null ) {
         O:  for ( Map baseMap : baseMaps ) {
                LayerGroupInfo bm = factory.createLayerGroup();
                bm.setName( (String) baseMap.get( "baseMapTitle" ) );
               
                //process base map layers
                List<String> layerNames = (List) baseMap.get( "baseMapLayers");
                for ( String layerName : layerNames ) {
View Full Code Here

    LayerInfo createLayerFromLayer(JSONObj from, WorkspaceInfo ws, Catalog cat) {
        LayerInfo orig = findLayer(ws.getName(), from.str("name"), cat);
        ResourceInfo origResource = orig.getResource();

        CatalogFactory factory = cat.getFactory();

        CatalogBuilder builder = new CatalogBuilder(cat);
        builder.setWorkspace(ws);

        LayerInfo l = factory.createLayer();
        if (origResource instanceof FeatureTypeInfo){
            FeatureTypeInfo resource = (FeatureTypeInfo) origResource;
            FeatureTypeInfo data = factory.createFeatureType();
            builder.updateFeatureType(data, resource);
            l.setResource(data);
        }
        else if (origResource instanceof CoverageInfo){
            CoverageInfo resource = (CoverageInfo) origResource;
            CoverageInfo data = factory.createCoverage();
            builder.updateCoverage( data,  resource);
            l.setResource(data);
        }
        else if (origResource instanceof WMSLayerInfo){
            WMSLayerInfo resource = (WMSLayerInfo) origResource;
            WMSLayerInfo data = factory.createWMSLayer();
            builder.updateWMSLayer( data,  resource);
            l.setResource(data);
        }
        else {
            throw new BadRequestException("Unable to copy layer from " + origResource.getClass().getSimpleName());
View Full Code Here

    @SuppressWarnings({ "rawtypes", "unchecked" })
    @RequestMapping(value = "/{wsName}/{name}", method = RequestMethod.POST)
    public @ResponseBody
    JSONObj create(@PathVariable String wsName, @PathVariable String name, @RequestBody JSONObj obj, HttpServletRequest req) throws IOException {
        Catalog cat = geoServer.getCatalog();
        CatalogFactory factory = cat.getFactory();
       
        WorkspaceInfo workspace = findWorkspace(wsName);
        StoreInfo store = null;
       
        JSONObj params = obj.object("connection");
        if( params == null ){
            throw new IllegalArgumentException("connection parameters required");
        }
        if( params.has("raster")){
            String url = params.str("raster");           
            CoverageStoreInfo info = factory.createCoverageStore();
            info.setWorkspace(workspace);
            info.setType(name);
           
            // connect and defaults
            info.setURL(url);
            info.setType(obj.str("type"));
            try {
                GridCoverageReader reader = info.getGridCoverageReader(null, null);
                Format format = reader.getFormat();
                info.setDescription( format.getDescription() );
                info.setEnabled(true);
            } catch (IOException e) {
                info.setError(e);
                info.setEnabled(false);
            }
            store = info;
        }
        else if ( params.has("url") &&
                params.str("url").toLowerCase().contains("Service=WMS") &&
                params.str("url").startsWith("http")){
            WMSStoreInfo info = factory.createWebMapServer();
            info.setWorkspace(workspace);
            info.setType(name);
           
            // connect and defaults
            info.setCapabilitiesURL(params.str("url"));
            try {
                WebMapServer service = info.getWebMapServer(new NullProgressListener());
                info.setDescription( service.getInfo().getDescription() );
                info.setEnabled(true);
            } catch (Throwable e) {
                info.setError(e);
                info.setEnabled(false);
            }
            store = info;
        }
        else {
            HashMap map = new HashMap(params.raw());
            Map resolved = ResourcePool.getParams(map, cat.getResourceLoader() );
            DataAccess dataStore = DataAccessFinder.getDataStore(resolved);           
            if( dataStore == null ){
                throw new IllegalArgumentException("Connection parameters incomplete (does not match an available data store, coverage store or wms store).");
            }
            DataStoreInfo info = factory.createDataStore();
            info.setWorkspace(workspace);
            info.setType(name);
            info.getConnectionParameters().putAll(map);
            try {
                info.setDescription( dataStore.getInfo().getDescription());
View Full Code Here

    @Override
    protected void oneTimeSetUp() throws Exception {
        super.oneTimeSetUp();

        CatalogFactory cf = getCatalog().getFactory();
        CatalogBuilder cb = new CatalogBuilder(getCatalog());
        LayerGroupInfo gi = cf.createLayerGroup();
        gi.setName("testGroup");
        gi.getLayers().add(getCatalog().getLayerByName(MockData.BASIC_POLYGONS.getLocalPart()));
        gi.getStyles().add(getCatalog().getStyleByName("polygon"));
        cb.calculateLayerGroupBounds(gi);
        getCatalog().add(gi);
View Full Code Here

            super(ready, done);
            this.idx = idx;
        }

        protected void runInternal() throws Exception {
            CatalogFactory factory = catalog.getFactory();
            for (int i = 0; i < GET_LAYER_BY_ID_WITH_CONCURRENT_ADD_TEST_COUNT; i++) {
                LayerInfo layer = factory.createLayer();
                layer.setResource(ft);
                layer.setName("LAYER-" + i + "-" + idx);
                catalog.add(layer);
            }
        }
View Full Code Here

    Catalog readCatalog( XStreamPersister xp ) throws Exception {
        Catalog catalog = new CatalogImpl();
        catalog.setResourceLoader(resourceLoader);
        xp.setCatalog( catalog );
       
        CatalogFactory factory = catalog.getFactory();
      
        //styles
        File styles = resourceLoader.find( "styles" );
        for ( File sf : list(styles,new SuffixFileFilter(".xml") ) ) {
            try {
View Full Code Here

        assertEquals( "ms", dom.getDocumentElement().getNodeName() );
    }
   
    public void testDataStore() throws Exception {
        Catalog catalog = new CatalogImpl();
        CatalogFactory cFactory = catalog.getFactory();
       
        WorkspaceInfo ws = cFactory.createWorkspace();
        ws.setName( "foo" );
       
        DataStoreInfo ds1 = cFactory.createDataStore();
        ds1.setName( "bar" );
        ds1.setWorkspace( ws );
       
        ByteArrayOutputStream out = out();
        persister.save( ds1 , out );
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.CatalogFactory

Copyright © 2018 www.massapicom. 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.