Package org.opengis.feature.type

Examples of org.opengis.feature.type.AttributeType


  @Test
  public void testLayerBeanstoSimpleFeatureType() throws LayerException {
    SimpleFeatureType type = service.toSimpleFeatureType(layer.getLayerInfo());
    Assert.assertEquals("org.geomajas.layer.bean.FeatureBean", type.getName().getLocalPart());
    AttributeType doubleType = type.getType("doubleAttr");
    Assert.assertEquals(Double.class, doubleType.getBinding());
    Assert.assertEquals("doubleAttr", doubleType.getName().getLocalPart());
  }
View Full Code Here


        Object defaultValue = descriptor.getDefaultValue();
        if (defaultValue != null) {
            options.add(String.valueOf(defaultValue));
        }
        AttributeType type = descriptor.getType();
        if (Number.class.isAssignableFrom(type.getBinding())) {
            options.add("0");
            options.add("1");
            options.add("2");
            options.add("3");
            options.add("4");
View Full Code Here

            if( binding == null ){
                Object value = expression.evaluate(sample);
                if( value == null){
                    ifexpression instanceof PropertyName){
                        String path = ((PropertyName)expression).getPropertyName();
                        AttributeType attributeType = sample.getFeatureType().getType(path);
                        if( attributeType == null ){
                            String msg = Messages.ReshapeOperation_4;
                            throw new ReshapeException(format(msg, name, path));
                        }
                        binding = attributeType.getClass();
                    }
                } else {
                    binding = value.getClass();
                }
                if( binding ==null ){
                    String msg = Messages.ReshapeOperation_5;
                    throw new ReshapeException(format(msg, name));
                }
            }
            if( Geometry.class.isAssignableFrom( binding )){
                CoordinateReferenceSystem crs;
                AttributeType originalAttributeType = originalFeatureType.getType(name);
                if( originalAttributeType == null && originalAttributeType instanceof GeometryType ) {
                    crs = ((GeometryType)originalAttributeType).getCoordinateReferenceSystem();
                } else {
                    crs = originalFeatureType.getCoordinateReferenceSystem();
                }
View Full Code Here

     */
    public List<String> toPropertyList(Class<?> binding){
        if( schema != null && binding != null ){
            List<String> names = new ArrayList<String>();
            for( AttributeDescriptor descriptor : schema.getAttributeDescriptors() ){
                AttributeType type = descriptor.getType();
                if( binding.isAssignableFrom( type.getBinding() ) ){
                    names.add( descriptor.getLocalName() );
                }
            }
            return names;
        }
View Full Code Here

        for (Iterator p = profiles.iterator(); p.hasNext(); ) {
            ProfileImpl profile = (ProfileImpl) p.next();
           
            for (Iterator i = profile.values().iterator(); i.hasNext();) {
                AttributeType type = (AttributeType) i.next();
   
                if (type.getBinding().isAssignableFrom(clazz)) {
                    assignable.add(type);
                }
   
                if (clazz.equals(type.getBinding())) {
                    return type;
                }
            }
        }

        if (assignable.isEmpty()) {
            return null;
        }

        if (assignable.size() == 1) {
            return (AttributeType) assignable.get(0);
        } else {
            //sort
            Comparator comparator = new Comparator() {
                    public int compare(Object o1, Object o2) {
                        AttributeType a1 = (AttributeType) o1;
                        AttributeType a2 = (AttributeType) o2;

                        Class c1 = a1.getBinding();
                        Class c2 = a2.getBinding();
                       
                        if (c1.equals(c2)) {
                            return 0;
                        }
View Full Code Here

        for (Iterator p = profiles.iterator(); p.hasNext(); ) {
            ProfileImpl profile = (ProfileImpl) p.next();
           
            for (Iterator i = profile.entrySet().iterator(); i.hasNext();) {
                Map.Entry entry = (Map.Entry) i.next();
                AttributeType type = (AttributeType) entry.getValue();
               
                if (type.getBinding().isAssignableFrom(clazz)) {
                    assignable.add(entry);
                }
       
                if (clazz.equals(type.getBinding())) {
                    return (Name) entry.getKey();
                }
            }
        }

        if (assignable.isEmpty()) {
            return null;
        }

        if (assignable.size() == 1) {
            return (Name) ((Map.Entry) assignable.get(0)).getKey();
        } else {
            //sort
            Comparator comparator = new Comparator() {
                    public int compare(Object o1, Object o2) {
                        Map.Entry e1 = (Map.Entry) o1;
                        Map.Entry e2 = (Map.Entry) o2;

                        AttributeType a1 = (AttributeType) e1.getValue();
                        AttributeType a2 = (AttributeType) e2.getValue();

                        Class c1 = a1.getBinding();
                        Class c2 = a2.getBinding();
                       
                        if (c1.equals(c2)) {
                            return 0;
                        }

                        if (c1.isAssignableFrom(c2)) {
                            return 1;
                        }

                        return -1;
                    }
                };

            Collections.sort(assignable, comparator);

            Map.Entry e1 = (Map.Entry) assignable.get(0);
            Map.Entry e2 = (Map.Entry) assignable.get(1);
            AttributeType a1 = (AttributeType) e1.getValue();
            AttributeType a2 = (AttributeType) e2.getValue();

            if (!a1.equals(a2)) {
                return (Name) e1.getKey();
            }
        }
View Full Code Here

            attribute = MapLayerInfo.getRegionateAttribute( featureType );
        if (attribute == null)
            throw new WmsException("Regionating attribute has not been specified");

        // Make sure the attribute is actually there
        AttributeType attributeType = type.getType(attribute);
        if (attributeType == null) {
            throw new WmsException("Could not find regionating attribute "
                    + attribute + " in layer " + featureType.getName());
        }
       
View Full Code Here

            LOGGER.log(Level.FINER, "No attribute specified, falling "
                    + "back on geometry attribute");
            attribute = ft.getGeometryDescriptor().getLocalName();
        } else {
            // Make sure the attribute is actually there
            AttributeType attributeType = ft.getType(attribute);
            if (attributeType == null) {
                throw new WmsException("Could not find regionating attribute "
                        + attribute + " in layer " + featureType.getName());
            }
        }
View Full Code Here

            FeatureTypeFactory typeFactory) throws IOException {
        final Name name = readName(in);
        final boolean nillable = in.readBoolean();
        final int minOccurs = in.readInt();
        final int maxOccurs = in.readInt();
        final AttributeType type = readAttributeType(in, typeFactory);
        if (type instanceof GeometryType)
            return typeFactory.createGeometryDescriptor((GeometryType) type, name, minOccurs,
                    maxOccurs, nillable, null);
        else
            return typeFactory.createAttributeDescriptor(type, name, minOccurs, maxOccurs,
View Full Code Here

            FeatureTypeFactory typeFactory) throws IOException {
        final Name name = readName(in);
        final boolean nillable = in.readBoolean();
        final int minOccurs = in.readInt();
        final int maxOccurs = in.readInt();
        final AttributeType type = readAttributeType(in, typeFactory);
        if (type instanceof GeometryType)
            return typeFactory.createGeometryDescriptor((GeometryType) type, name, minOccurs,
                    maxOccurs, nillable, null);
        else
            return typeFactory.createAttributeDescriptor(type, name, minOccurs, maxOccurs,
View Full Code Here

TOP

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

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.