Package org.opengis.feature.type

Examples of org.opengis.feature.type.FeatureType


        FeatureLayer featureLayer = (FeatureLayer) layer;
        List<Rule> rules = (List<Rule>) featureLayer.getUserData().get(LayerFactory.USERDATA_KEY_STYLE_RULES);
        for (Rule rule : rules) {
          if (!isTextOnly(rule)) {
            FeatureSource<?, ?> source = featureLayer.getFeatureSource();
            FeatureType schema = source.getSchema();
            if (schema instanceof SimpleFeatureType) {
              builder.addVectorLayer((SimpleFeatureType) schema, rule.getDescription().getTitle()
                  .toString(), rule, font);
            }
          }
View Full Code Here


        FeatureSource<SimpleFeatureType,SimpleFeature> source =
                layer.getResource(FeatureSource.class, new SubProgressMonitor(monitor,10));

        FeatureCollection<SimpleFeatureType, SimpleFeature> features = source.getFeatures( filter );
       
        FeatureType schema = features.getSchema();
        Class<?> binding = schema.getGeometryDescriptor().getType().getBinding();
        Graph graph = null;
        if( MultiLineString.class.isAssignableFrom( binding )){
            graph = buildFromMultiLineString( features, new SubProgressMonitor(monitor, 90) );
        }       
        if( graph == null ){
View Full Code Here

        // check that all required properties have a specified value
        UpdateElementType update = (UpdateElementType) element;

        try {
            FeatureTypeInfo meta = (FeatureTypeInfo) typeInfos.values().iterator().next();
            FeatureType featureType = meta.getFeatureType();

            for (Iterator prop = update.getProperty().iterator(); prop.hasNext();) {
                PropertyType property = (PropertyType) prop.next();

                //check that valus that are non-nillable exist
                if (property.getValue() == null) {
                    String propertyName = property.getName().getLocalPart();
                    AttributeDescriptor attributeType = null;
                    PropertyDescriptor pd = featureType.getDescriptor(propertyName);
                    if(pd instanceof AttributeDescriptor) {
                        attributeType = (AttributeDescriptor) pd;
                    }
                    if ((attributeType != null) && (attributeType.getMinOccurs() > 0)) {
                        String msg = "Property '" + attributeType.getLocalName()
View Full Code Here

            if ( !meta.enabled() ) {
                continue;
            }

           
            FeatureType featureType =  null;
            try {
                featureType = meta.getFeatureType();
            } catch(Exception e) {
                LOGGER.log(Level.WARNING, "Could not load underlying feature type for type "
                        + meta.getName(), e);
View Full Code Here

            mli = new MapLayerInfo(layerInfo);

            try {
                if (layerInfo.getType() == Type.VECTOR) {
                    FeatureType featureType = mli.getFeature().getFeatureType();
                    request.setLayer(featureType);
                } else if (layerInfo.getType() == Type.RASTER) {
                    CoverageInfo coverageInfo = mli.getCoverage();

                    // it much safer to wrap a reader rather than a coverage in most cases, OOM can
View Full Code Here

    @Override
    protected String checkAttribute(FeatureTypeInfo cfg){
        String attribute = MapLayerInfo.getRegionateAttribute(cfg);
        try{
            FeatureType ft = cfg.getFeatureType();
            if ((attribute != null) && (ft.getDescriptor(attribute) != null))
                return attribute;

            return ft.getGeometryDescriptor().getLocalName();
        } catch (Exception e) {
            LOGGER.severe("Couldn't get attribute name due to " + e);
            return null;
        }
    }
View Full Code Here

                            nameSpaceinfo.getURI());
                }
            }
            // would result in 1 xsd:include if schema location is specified
            try {
                FeatureType featureType = featureTypeInfos[0].getFeatureType();
                Object schemaUri = featureType.getUserData().get("schemaURI");
                if (schemaUri != null) {
                    // should always be a string.. set in AppSchemaDataAccessConfigurator
                    assert schemaUri instanceof String;
                    // schema is supplied by the user.. just include the top level schema instead of
                    // building the type
                    if (!findTypeInSchema(featureTypeInfos[0], schema, factory)) {
                        addInclude(schema, factory, targetNamespace, (String) schemaUri);
                    }
                    return schema;
                }
            } catch (IOException e) {
                logger.warning("Unable to get schema location for feature type '"
                        + featureTypeInfos[0].getPrefixedName() + "'. Reason: '" + e.getMessage()
                        + "'. Building the schema manually instead.");
            }

            // user didn't define schema location
            // import gml schema
            XSDImport imprt = factory.createXSDImport();
            imprt.setNamespace(gmlNamespace);

            imprt.setSchemaLocation(ResponseUtils.buildSchemaURL(baseUrl, gmlSchemaLocation));

            XSDSchema gmlSchema = gmlSchema();
            imprt.setResolvedSchema(gmlSchema);

            schema.getContents().add(imprt);
            schema.getQNamePrefixToNamespaceMap().put(gmlPrefix, gmlNamespace);
            schema.getQNamePrefixToNamespaceMap().put("gml", "http://www.opengis.net/gml");
            // then manually build schema
            for (int i = 0; i < featureTypeInfos.length; i++) {
                try {
                    buildSchemaContent(featureTypeInfos[i], schema, factory, baseUrl);
                } catch (Exception e) {
                    logger.log(Level.WARNING, "Could not build xml schema for type: "
                            + featureTypeInfos[i].getName(), e);
                }
            }
        } else {
            //different namespaces, write out import statements
            ArrayList<String> importedNamespaces = new ArrayList<String>(
                    ns2featureTypeInfos.size() + 1);
            for (Iterator i = ns2featureTypeInfos.entrySet().iterator(); i.hasNext();) {
                Map.Entry entry = (Map.Entry) i.next();
                String prefix = (String) entry.getKey();
                List types = (List) entry.getValue();

                StringBuffer typeNames = new StringBuffer();
                String namespaceURI;
                for (Iterator t = types.iterator(); t.hasNext();) {
                    FeatureTypeInfo info = (FeatureTypeInfo) t.next();
                    FeatureType featureType = info.getFeatureType();
                    Object schemaUri = featureType.getUserData().get("schemaURI");
                    if (schemaUri != null) {
                        // should always be a string.. set in AppSchemaDataAccessConfigurator
                        assert schemaUri instanceof String;
                        // schema is supplied by the user.. just import the top level schema instead of
                        // building
                        // the type
                        namespaceURI = featureType.getName().getNamespaceURI();

                        addImport(schema, factory, namespaceURI,
                                (String) schemaUri, importedNamespaces);

                        // ensure there's only 1 import per namespace
View Full Code Here

        return atts;
    }
   
    public List<AttributeTypeInfo> loadAttributes(FeatureTypeInfo info) throws IOException {
        List<AttributeTypeInfo> attributes = new ArrayList();
        FeatureType ft = getFeatureType(info);
       
        for (PropertyDescriptor pd : ft.getDescriptors()) {
            AttributeTypeInfo att = catalog.getFactory().createAttribute();
            att.setFeatureType(info);
            att.setName(pd.getName().getLocalPart());
            att.setMinOccurs(pd.getMinOccurs());
            att.setMaxOccurs(pd.getMaxOccurs());
View Full Code Here

     *
     * @throws IOException Any errors that occure while loading the resource.
     */
    public FeatureType getFeatureType( FeatureTypeInfo info ) throws IOException {
       
        FeatureType ft = (FeatureType) featureTypeCache.get( info );
        if ( ft == null ) {
            synchronized ( featureTypeCache ) {
                ft = (FeatureType) featureTypeCache.get( info );
                if ( ft == null ) {
                   
                    //grab the underlying feature type
                    DataAccess<? extends FeatureType, ? extends Feature> dataAccess = getDataStore(info.getStore());
                    ft = dataAccess.getSchema(info.getQualifiedNativeName());
                   
                    // TODO: support reprojection for non-simple FeatureType
                    if (ft instanceof SimpleFeatureType) {
                        SimpleFeatureType sft = (SimpleFeatureType) ft;
                        //create the feature type so it lines up with the "declared" schema
                        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
                        tb.setName( info.getName() );
                        tb.setNamespaceURI( info.getNamespace().getURI() );

                        if ( info.getAttributes() == null || info.getAttributes().isEmpty() ) {
                            //take this to mean just load all native
                            for ( PropertyDescriptor pd : ft.getDescriptors() ) {
                                if ( !( pd instanceof AttributeDescriptor ) ) {
                                    continue;
                                }
                               
                                AttributeDescriptor ad = (AttributeDescriptor) pd;
                                ad = handleDescriptor(ad, info);
                                tb.add( ad );
                            }
                        }
                        else {
                            //only load native attributes configured
                            for ( AttributeTypeInfo att : info.getAttributes() ) {
                                String attName = att.getName();
                               
                                //load the actual underlying attribute type
                                PropertyDescriptor pd = ft.getDescriptor( attName );
                                if ( pd == null || !( pd instanceof AttributeDescriptor) ) {
                                    throw new IOException("the SimpleFeatureType " + info.getPrefixedName()
                                            + " does not contains the configured attribute " + attName
                                            + ". Check your schema configuration");
                                }
View Full Code Here

     * </p>
     */
    public AttributeDescriptor getAttributeDescriptor( FeatureTypeInfo ftInfo, AttributeTypeInfo atInfo )
        throws Exception {
   
        FeatureType featureType = getFeatureType( ftInfo );
        if ( featureType != null ) {
            for ( PropertyDescriptor pd : featureType.getDescriptors() ) {
                if (pd instanceof AttributeDescriptor) {
                    AttributeDescriptor ad = (AttributeDescriptor) pd;
                    if (atInfo.getName().equals(ad.getLocalName())) {
                        return ad;
                    }
View Full Code Here

TOP

Related Classes of org.opengis.feature.type.FeatureType

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.