Package org.geoserver.catalog

Examples of org.geoserver.catalog.FeatureTypeInfo


                summary.newLayer(layerName);

                LayerInfo layer = null;
                try {
                    builder.setStore(storeInfo);
                    FeatureTypeInfo featureType = builder.buildFeatureType(name);
                    builder.lookupSRS(featureType, true);
                    builder.setupBounds(featureType);
                    layer = builder.buildLayer(featureType);
                    layer.setDefaultStyle(styles.getStyle(featureType));
                    ImportStatus status = SUCCESS;
View Full Code Here


                // workaround bogus collection implementation that won't return the crs
                if(env != null &&  env.getCoordinateReferenceSystem() == null) {
                    CoordinateReferenceSystem crs = fc.getSchema().getCoordinateReferenceSystem();
                    if ( crs == null ) {
                        //fall back on catalog
                        FeatureTypeInfo info = catalog.getFeatureTypeByName(fc.getSchema().getName());
                        if ( info != null ) {
                            crs = info.getCRS();
                        }
                    }
                    env = new ReferencedEnvelope(env, crs);
                }
               
View Full Code Here

               
                List featureTypes = new ArrayList(catalog.getFeatureTypes());
               
                // filter out disabled feature types
                for (Iterator it = featureTypes.iterator(); it.hasNext();) {
                    FeatureTypeInfo ft = (FeatureTypeInfo) it.next();
                    if(!ft.enabled())
                        it.remove();
                }
               
                // filter the layers if a namespace filter has been set
                if(request.getNamespace() != null) {
                    String namespace = request.getNamespace();
                    for (Iterator it = featureTypes.iterator(); it.hasNext();) {
                        FeatureTypeInfo ft = (FeatureTypeInfo) it.next();
                        if(!namespace.equals(ft.getNamespace().getPrefix()))
                            it.remove();
                    }
                }
               
                Collections.sort(featureTypes, new FeatureTypeInfoTitleComparator());
                for (Iterator i = featureTypes.iterator(); i.hasNext();) {
                    FeatureTypeInfo featureType = (FeatureTypeInfo) i.next();
                    if(featureType.enabled())
                        featureType(featureType);
                }

                end("FeatureTypeList");
            }
View Full Code Here

    public ResourceReference getSpecificLayerIcon(LayerInfo info) {
        if (info.getType() == Type.RASTER) {
            return RASTER_ICON;
        } else if(info.getType() == Type.VECTOR) {
            try {
                FeatureTypeInfo fti = (FeatureTypeInfo) info.getResource();
                GeometryDescriptor gd = fti.getFeatureType().getGeometryDescriptor();
                return getVectoryIcon(gd);
            } catch(Exception e) {
                return GEOMETRY_ICON;
            }
        } else {
View Full Code Here

            FeatureCollection<SimpleFeatureType, SimpleFeature> features = (FeatureCollection) fc.next();
            SimpleFeatureType featureType = features.getSchema();

            //load the metadata for the feature type
            String namespaceURI = featureType.getName().getNamespaceURI();
            FeatureTypeInfo meta = catalog.getFeatureTypeByName( namespaceURI, featureType.getTypeName() );
            if(meta == null)
                throw new WFSException("Could not find feature type " + namespaceURI + ":" + featureType.getTypeName() + " in the GeoServer catalog");

            NamespaceInfo ns = catalog.getNamespaceByURI( namespaceURI );
            ns2metas.put( ns, meta );
        }

        Collection<FeatureTypeInfo> featureTypes = ns2metas.values();
       
        //create the encoder
        ApplicationSchemaXSD xsd = new ApplicationSchemaXSD( null, catalog, gft.getBaseUrl(),
            org.geotools.wfs.v1_0.WFS.getInstance(), featureTypes );
        Configuration configuration = new ApplicationSchemaConfiguration( xsd, new org.geotools.wfs.v1_0.WFSConfiguration() );
       
        Encoder encoder = new Encoder(configuration);
        //encoder.setEncoding(wfs.getCharSet());
       
       encoder.setSchemaLocation(org.geoserver.wfs.xml.v1_1_0.WFS.NAMESPACE,
               buildSchemaURL(gft.getBaseUrl(), "wfs/1.0.0/WFS-basic.xsd"));

        //declare application schema namespaces
        Map<String, String> params = params("service", "WFS", "version", "1.0.0", "request", "DescribeFeatureType");
        for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();

            NamespaceInfo ns = (NamespaceInfo) entry.getKey();
            String namespaceURI = ns.getURI();
           
            Collection metas = (Collection) entry.getValue();

            StringBuffer typeNames = new StringBuffer();

            for (Iterator m = metas.iterator(); m.hasNext();) {
                FeatureTypeInfo meta = (FeatureTypeInfo) m.next();
                typeNames.append(meta.getPrefixedName());

                if (m.hasNext()) {
                    typeNames.append(",");
                }
            }
View Full Code Here

O:
            for (Iterator t = names.iterator(); t.hasNext();) {
                QName name = (QName) t.next();

                for (Iterator h = infos.iterator(); h.hasNext();) {
                    FeatureTypeInfo meta = (FeatureTypeInfo) h.next();
                    if(!meta.enabled())
                        continue;
                   
                    String namespace = meta.getNamespace().getURI();
                    String local = meta.getName();

                    if (namespace.equals(name.getNamespaceURI())
                            && local.equals(name.getLocalPart())) {
                        //found, continue on and keep this handle in list
                        requested.add(meta);

                        continue O;
                    }
                }

                //not found
                String msg = "Could not find type: " + name;
                if (citeConformance) {
                    msg += ". \nStrict WFS protocol conformance is being applied.\n"
                            + "Make sure the type name is correctly qualified";
                }
                throw new WFSException(msg);
            }
        } else {
            //if there are no specific requested types then get all the ones that
            //are enabled
            for (Iterator it = infos.iterator(); it.hasNext();) {
                FeatureTypeInfo ftInfo = (FeatureTypeInfo) it.next();
                if(ftInfo.enabled())
                    requested.add(ftInfo);
            }
        }

        return (FeatureTypeInfo[]) requested.toArray(new FeatureTypeInfo[requested.size()]);
View Full Code Here

            //FeatureResults features = (FeatureResults) f.next();
            FeatureCollection<SimpleFeatureType, SimpleFeature> features;
            features = (FeatureCollection) results.getFeature().get(i);
            SimpleFeatureType featureType = features.getSchema();

            FeatureTypeInfo meta = catalog.getFeatureTypeByName(featureType.getName());

            String prefix = meta.getNamespace().getPrefix();
            String uri = meta.getNamespace().getURI();

            ftNames.declareNamespace(features.getSchema(), prefix, uri);

            if (ftNamespaces.containsKey(uri)) {
                String location = (String) ftNamespaces.get(uri);
                ftNamespaces.put(uri, location + "," + meta.getName());
            } else {
                String location = typeSchemaLocation(geoServer.getGlobal(), meta, request.getBaseUrl());
                ftNamespaces.put(uri, location);
            }

            //JD: wfs reprojection: should not set srs form metadata but from
            // the request
            //srs = Integer.parseInt(meta.getSRS());
            QueryType query = (QueryType) request.getQuery().get(i);
            try {
                String srsName = query.getSrsName() != null ? query.getSrsName().toString() : null;
                if ( srsName == null ) {
                    //no SRS in query...asking for the default?
                    srsName = meta.getSRS();
                }
                if ( srsName != null ) {
                    CoordinateReferenceSystem crs = CRS.decode(srsName);
                    String epsgCode = GML2EncodingUtils.epsgCode(crs);
                    srs = Integer.parseInt(epsgCode);
                }
            }
            catch( Exception e ) {
                LOGGER.log(Level.WARNING, "Problem encoding:" + query.getSrsName(), e);
               
            }
           
            //track num decimals, in cases where the query has multiple types we choose the max
            // of all the values
            if (meta.getNumDecimals() > 0) {
                numDecimals = numDecimals == -1 ? meta.getNumDecimals()
                    : Math.max(numDecimals,meta.getNumDecimals());
            }
        }

        GeoServerInfo global = geoServer.getGlobal();
       
View Full Code Here

        builder.calculateLayerGroupBounds(lg);
        catalog.add(lg);
    }
   
    public void setNativeBox(Catalog catalog, String name) throws Exception {
        FeatureTypeInfo fti = catalog.getFeatureTypeByName(name);
        fti.setNativeBoundingBox(fti.getFeatureSource(null, null).getBounds());
        fti.setLatLonBoundingBox(new ReferencedEnvelope(fti.getNativeBoundingBox(), DefaultGeographicCRS.WGS84));
        catalog.save(fti);
    }
View Full Code Here

        XpathEngine xpath = XMLUnit.newXpathEngine();

        final List<FeatureTypeInfo> enabledTypes = getCatalog().getFeatureTypes();
        for (Iterator<FeatureTypeInfo> it = enabledTypes.iterator(); it.hasNext();) {
            FeatureTypeInfo ft = it.next();
            if (!ft.isEnabled()) {
                it.remove();
            }
        }
        final int enabledCount = enabledTypes.size();
View Full Code Here

        Element e = doc.getDocumentElement();
        assertEquals("WFS_Capabilities", e.getLocalName());

        final List<FeatureTypeInfo> enabledTypes = getCatalog().getFeatureTypes();
        for (Iterator<FeatureTypeInfo> it = enabledTypes.iterator(); it.hasNext();) {
            FeatureTypeInfo ft = it.next();
            if (ft.isEnabled()) {
                String prefixedName = ft.getPrefixedName();

                String xpathExpr = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/"
                        + "wfs:FeatureType/wfs:Name[text()=\"" + prefixedName + "\"]";

                XMLAssert.assertXpathExists(xpathExpr, doc);
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.FeatureTypeInfo

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.