Package org.opengis.feature

Examples of org.opengis.feature.Attribute


        // verify the non modified properties stay the same
        final List<Attribute> originalValues = (List<Attribute>) originalFeature.getValue();
        final List<Attribute> actualValues = (List<Attribute>) modifiedFeature.getValue();
        for (int i = 0; i < originalValues.size(); i++) {
            Attribute originalAtt = originalValues.get(i);
            Attribute actualAtt = actualValues.get(i);
            Name name = originalAtt.getName();
            // bah, date equals does not work, I don't care for this test
            String localName = name.getLocalPart();
            if (!"INT32_COL".equals(localName) && !"SHAPE".equals(localName)
                    && !"DATE_COL".equals(localName)) {
                assertEquals(name + " does not match", originalAtt.getValue(), actualAtt.getValue());
            }
        }
    }
View Full Code Here


                Object phenomNameVal = phenomName.evaluate(feature, String.class);
                assertNotNull(phenomNamePath + " evaluated to null", phenomNameVal);
            }
            {
                PropertyName sampledFeatureName = ffac.property("sa:sampledFeature");
                Attribute sampledFeatureVal = (Attribute) sampledFeatureName.evaluate(feature);
                assertNotNull("sa:sampledFeature evaluated to null", sampledFeatureVal);
                assertEquals(0, ((Collection) sampledFeatureVal.getValue()).size());
                Map attributes = (Map) sampledFeatureVal.getUserData().get(Attributes.class);
                assertNotNull(attributes);
                Name xlinkTitle = name(XLINK.NAMESPACE, "title");
                assertTrue(attributes.containsKey(xlinkTitle));
                assertNotNull(attributes.get(xlinkTitle));

                Name xlinkHref = name(XLINK.NAMESPACE, "href");
                assertTrue(attributes.containsKey(xlinkHref));
                assertNotNull(attributes.get(xlinkHref));
            }

            {
                final String elementPath = "aw:relatedObservation/aw:PhenomenonTimeSeries/om:result/cv:CompactDiscreteTimeCoverage";
                PropertyName elementName = ffac.property(elementPath);
                Object timeCovVal = elementName.evaluate(feature);
                assertNotNull(elementPath, timeCovVal);
                assertTrue(timeCovVal instanceof Feature);
                final List elements = (List) ((Feature) timeCovVal).getValue();
                assertEquals(1, elements.size());
            }

        }
        it.close();

        count = 0;
        FeatureIterator<? extends Feature> simpleIterator = ((AbstractMappingFeatureIterator) features.features()).getSourceFeatureIterator();
        for (; simpleIterator.hasNext();) {
            feature = (Feature) simpleIterator.next();
            count++;

            if (count == 22) {
                String compactTimeValuePairName = "result";
                String geomName = "sample_time_position";

                Collection compactTimes = feature.getProperties(compactTimeValuePairName);
                assertNotNull(compactTimes);
                assertEquals(1, compactTimes.size());

                Attribute value = (Attribute) compactTimes.iterator().next();
                assertNotNull(value.getValue());

                Collection geomProperties = feature.getProperties(geomName);
                assertNotNull(geomProperties);
                assertEquals(1, geomProperties.size());

                Attribute geom = (Attribute) geomProperties.iterator().next();
                assertNotNull(geom.getValue());

                Object valueContent = geom.getValue();
                Date sampleTimePosition = (Date) valueContent;
                Calendar cal = Calendar.getInstance();
                // property file dates appear to be parsed as being in UTC
                cal.setTimeZone(TimeZone.getTimeZone("UTC"));
                cal.setTime(sampleTimePosition);
View Full Code Here

    public Object evaluate(Object obj) {
        if (!(obj instanceof Attribute)) {
            return null;
        }
        Attribute att = (Attribute) obj;
        org.opengis.filter.expression.Expression arg = (Expression) getParameters()
                .get(0);
        Object value = arg.evaluate(att);

        if (value != null) {
View Full Code Here

            } else {
                descriptor = new AttributeDescriptorImpl(type, name, minOccurs, maxOccurs,
                        nillable, defaultValue);
            }
        }
        Attribute attribute;
        if (descriptor != null && descriptor.getType() instanceof NonFeatureTypeProxy) {
            // we don't want a feature. NonFeatureTypeProxy is used to make non feature types
            // a fake feature type, so it can be created as top level feature in app-schema
            // mapping file. When created inside other features, it should be encoded as
            // complex features though.
View Full Code Here

        super("getID");
    }

    public Object evaluate(Object obj) {
        if (obj instanceof Attribute) {
            Attribute att = (Attribute) obj;
            return att.getIdentifier();
        }
        return null;
    }
View Full Code Here

     * Test that normal Attribute shouldn't be affected by the converter.
     */
    public void testAttribute() {
        AttributeDescriptor descriptor = new AttributeDescriptorImpl(XSSchema.STRING_TYPE,
                ComplexFeatureConstants.SIMPLE_CONTENT, 1, 1, true, (Object) null);
        Attribute att = new AttributeImpl("rini", descriptor, null);
        Set<ConverterFactory> factories = Converters.getConverterFactories(att.getClass(), String.class);
        for (ConverterFactory factory : factories) {
            assertFalse(factory instanceof ComplexAttributeConverterFactory);
        }
    }
View Full Code Here

            // Test an attribute with constant value (as opposed to an xpath)
            // ***************************************************************************************
            List<Attribute> attPurposeList = getAttributesForProperty(f, "purpose");
            assertEquals(1, attPurposeList.size());

            Attribute at = attPurposeList.get(0);
            assertEquals("CONSTANT", getValueForAttribute(at));
            assertFalse(at.getUserData().containsKey(Attributes.class));
           
            // ***************************************************************************************
            // Test an attribute with null value (ie unset) but User data is an xpath
            // ***************************************************************************************
            List<Attribute> attGUTypeList = getAttributesForProperty(f, "rank");
            assertEquals(1, attGUTypeList.size());

            at = attGUTypeList.get(0);
            assertEquals("", getValueForAttribute(at));
            assertEquals(1, ((Map<Object, Object>) at.getUserData().get(Attributes.class)).size());
            assertEquals("urn:cgi:classifier:GSV:LithostratigraphicUnitRank:formation",
                    getUserDataForAttribute(at, new NameImpl("http://www.w3.org/1999/xlink", "href")));
           
            // ***************************************************************************************
            // Test that a nested complex type is created correctly
            // ***************************************************************************************
            List<Attribute> attObMethList = getAttributesForProperty(f, "observationMethod");
            assertEquals(1, attObMethList.size());
            at = attObMethList.get(0);

            assertEquals(null, at.getIdentifier());
            assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "observationMethod"), at.getName());
            assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "CGI_TermValuePropertyType"), at.getDescriptor()
                    .getType().getName());

            ComplexAttribute ob = getNestedComplexValueForAttribute(at);
            assertEquals(null, ob.getIdentifier());
            assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "CGI_TermValue"), ob.getName());
            assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "CGI_TermValueType"), ob.getDescriptor().getType()
                    .getName());

            ComplexAttribute ob2 = getNestedComplexValueForAttribute(ob);
            assertEquals(null, ob2.getIdentifier());
            assertEquals(new NameImpl(FeatureChainingTest.GSMLNS, "value"), ob2.getName());
            assertEquals(new NameImpl(CGINS, "CodeWithAuthorityType"), ob2
                    .getDescriptor().getType().getName());
            assertEquals("CONSTANT", getValueForAttribute(ob2));
            assertEquals("gsv:NameSpace", getUserDataForAttribute(ob2, new NameImpl("codeSpace")));
        }

        Feature feature = results.get(0);

        // ***************************************************************************************
        // Test an attribute that occurs once, set via xpaths. Also has no userData
        // ***************************************************************************************
        List<Attribute> attDescList = getAttributesForProperty(feature, "description");
        assertEquals(1, attDescList.size());
        Attribute at = attDescList.get(0);
        assertEquals("Test description 1", getValueForAttribute(at));
        assertFalse(at.getUserData().containsKey(Attributes.class));

        // ***************************************************************************************
        // Test an attribute with two values. Also has userData, set with constants instead of
        // xpaths
        // ***************************************************************************************
        List<Attribute> attNameList = getAttributesForProperty(feature, "name");
        assertEquals(2, attNameList.size());

        // First one has a value and a single attribute--codeSpace
        at = attNameList.get(0);
        assertEquals("Unit Name1248396531312 UC1248396531312 description name",
                getValueForAttribute(at));
        assertEquals(1, ((Map) at.getUserData().get(Attributes.class)).size());
        assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));

        // Second one has a value and a single attribute--codeSpace
        at = attNameList.get(1);
        assertEquals("urn:cgi:feature:GSV:1679161021439131319", getValueForAttribute(at));
        assertTrue(at.getUserData() != null && ((Map) at.getUserData().get(Attributes.class)).size() == 1);
        assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
       
        // second feature
        feature = results.get(1);
        attDescList = getAttributesForProperty(feature, "description");
        assertEquals(1, attDescList.size());
        at = attDescList.get(0);
        assertEquals("Test description 1", getValueForAttribute(at));
        assertFalse(at.getUserData().containsKey(Attributes.class));

        attNameList = getAttributesForProperty(feature, "name");
        assertEquals(2, attNameList.size());
       
        at = attNameList.get(0);
        assertEquals("Unit Name1233811724109 UC1233811724109 description name",
                getValueForAttribute(at));
        assertEquals(1, ((Map) at.getUserData().get(Attributes.class)).size());
        assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));

        at = attNameList.get(1);
        assertEquals("urn:cgi:feature:GSV:1679161041155866313", getValueForAttribute(at));
        assertTrue(at.getUserData() != null && ((Map) at.getUserData().get(Attributes.class)).size() == 1);
        assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
               
        // third feature
        feature = results.get(2);
        attDescList = getAttributesForProperty(feature, "description");
        assertEquals(1, attDescList.size());
        at = attDescList.get(0);
        assertEquals("Test description 2", getValueForAttribute(at));
        assertFalse(at.getUserData().containsKey(Attributes.class));

        attNameList = getAttributesForProperty(feature, "name");
        assertEquals(2, attNameList.size());
       
        at = attNameList.get(0);
        assertEquals("Unit Name1248396020281 UC1248396020281 description name 2",
                getValueForAttribute(at));
        assertEquals(1, ((Map) at.getUserData().get(Attributes.class)).size());
        assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));

        at = attNameList.get(1);
        assertEquals("urn:cgi:feature:GSV:1679161021439938381", getValueForAttribute(at));
        assertTrue(at.getUserData() != null && ((Map) at.getUserData().get(Attributes.class)).size() == 1);
        assertEquals("gsv:NameSpace", getUserDataForAttribute(at, new NameImpl("codeSpace")));
    }
View Full Code Here

    private List<Attribute> getAttributesForProperty(Feature feature, String propertyName) {
        List<Attribute> returnValues = new ArrayList<Attribute>();
        Collection cs = feature.getProperties(propertyName);
        Iterator it = cs.iterator();
        while (it.hasNext()) {
            Attribute sv = (Attribute) it.next();
            returnValues.add(sv);
        }
        return returnValues;
    }
View Full Code Here

        Object value;
        value = f.getValue();
        if (f instanceof ComplexAttribute) {
            Collection values = (Collection) value;
            for (Iterator it = values.iterator(); it.hasNext();) {
                Attribute att = (Attribute) it.next();
                assertNotNull(att);
                traverse(att);
            }
        }
    }
View Full Code Here

                        mapping.put(label + XPATH_PROPERTY_SEPARATOR + "gml:id", ff
                            .property(xpath));
                       
                        StepList sl = attMapping.getTargetXPath();
                        setPathIndex(j, sl);
                        Attribute subFeature = null;
                        elements.put(attMapping.getLabel(), countXpath + bracketIndex, subFeature);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.opengis.feature.Attribute

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.