Package org.geotools.xml

Examples of org.geotools.xml.Encoder$NullIterator


    // Wrap style as an SLD
    StyleFactory factory = CommonFactoryFinder.getStyleFactory();
    StyledLayerDescriptor sld = factory.createStyledLayerDescriptor();

    org.geotools.sld.v1_1.SLDConfiguration configuration = new org.geotools.sld.v1_1.SLDConfiguration();
    Encoder encoder = new org.geotools.xml.Encoder(configuration);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    try {
      encoder.encode(style,
          org.geotools.sld.bindings.SLD.STYLEDLAYERDESCRIPTOR,
          outputStream);
      String document = outputStream.toString("UTF-8");

      display(document, SLD_1_1);
View Full Code Here


                throw new IllegalStateException(
                        "Cannot encode a feature collection using GML2 (only WFS)");
            }
        }
        if (version == Version.WFS1_0) {
            Encoder e = new Encoder(new org.geotools.wfs.v1_0.WFSConfiguration());
            e.getNamespaces().declarePrefix(prefix, namespace);
            e.setIndenting(true);

            FeatureCollectionType featureCollectionType = WfsFactory.eINSTANCE
                    .createFeatureCollectionType();
            featureCollectionType.getFeature().add(collection);

            e.encode(featureCollectionType, org.geotools.wfs.WFS.FeatureCollection, out);
        }
        if (version == Version.WFS1_1) {
            Encoder e = new Encoder(new org.geotools.wfs.v1_1.WFSConfiguration());
            e.getNamespaces().declarePrefix(prefix, namespace);
            e.setIndenting(true);

            FeatureCollectionType featureCollectionType = WfsFactory.eINSTANCE
                    .createFeatureCollectionType();
            featureCollectionType.getFeature().add(collection);

            e.encode(featureCollectionType, org.geotools.wfs.WFS.FeatureCollection, out);
        }
    }
View Full Code Here

       
        fc.getFeature().add( features );
    }
   
    public void testEncodeFeatureCollection10() throws Exception {
        Encoder e = new Encoder( new org.geotools.wfs.v1_0.WFSConfiguration() );
        e.getNamespaces().declarePrefix( "geotools", "http://geotools.org");
        e.setIndenting(true);

        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
           
        assertEquals( 2, d.getElementsByTagName( "gml:Point" ).getLength() );
        assertTrue( d.getElementsByTagName( "gml:coord" ).getLength() > 2 );
        assertEquals( 0, d.getElementsByTagName( "gml:pos" ).getLength() );
       
View Full Code Here

        assertNotNull( ((Element)d.getElementsByTagName( "geotools:feature").item( 0 )).getAttribute("fid") );
               
    }
   
    public void testEncodeFeatureCollection11() throws Exception {
        Encoder e = new Encoder( new org.geotools.wfs.v1_1.WFSConfiguration() );
        e.getNamespaces().declarePrefix( "geotools", "http://geotools.org");
        e.setIndenting(true);
       
        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        assertEquals( 2, d.getElementsByTagName( "gml:Point" ).getLength() );
        assertEquals( 2, d.getElementsByTagName( "gml:pos" ).getLength() );
        assertEquals( 0, d.getElementsByTagName( "gml:coord" ).getLength() );
       
        assertEquals( 2, d.getElementsByTagName( "geotools:feature" ).getLength() );
View Full Code Here

        b.add( 1 );
        features.add( b.buildFeature( "one" ) );
       
        fc.getFeature().add( features );
       
        Encoder e = new Encoder( new org.geotools.wfs.v1_1.WFSConfiguration() );
        e.getNamespaces().declarePrefix( "geotools", "http://geotools.org");
        e.getNamespaces().declarePrefix( "geotools2", "http://geotools.org/geotools2");
        e.setIndenting(true);
       
        Document d = e.encodeAsDOM( fc, WFS.FeatureCollection );
        assertEquals( 2, d.getElementsByTagName( "geotools:feature").getLength());
        assertEquals( 2, d.getElementsByTagName( "geotools2:feature2").getLength());
    }
View Full Code Here

        update.setFilter(filterfac.id( filterfac.featureId("someid")));
       
        //try with string
        propertyType.setValue("myvalue");
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        Document doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("mn:mytypename", "//wfs:Update/@typeName", doc);
        XMLAssert.assertXpathEvaluatesTo("mn:myproperty", "//wfs:Update/wfs:Property/wfs:Name", doc);
        XMLAssert.assertXpathEvaluatesTo("myvalue", "//wfs:Update/wfs:Property/wfs:Value", doc);
        XMLAssert.assertXpathEvaluatesTo("someid", "//wfs:Update/ogc:Filter/ogc:FeatureId/@fid", doc);
       
        //try with numeric value
        propertyType.setValue(100.25);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("100.25", "//wfs:Update/wfs:Property/wfs:Value", doc);
               
        //try with geometry
        Coordinate insideCoord = new Coordinate(5.2, 7.5);
        Point myPoint = geomfac.createPoint(insideCoord);
       
        propertyType.setValue(myPoint);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("5.2", "//wfs:Update/wfs:Property/wfs:Value/gml:Point/gml:coord/gml:X", doc);
        XMLAssert.assertXpathEvaluatesTo("7.5", "//wfs:Update/wfs:Property/wfs:Value/gml:Point/gml:coord/gml:Y", doc);
               
    }
View Full Code Here

        SimpleFeature feature = ff.createSimpleFeature(new Object[] {"dummyValue"}, ft, "dummyId");
       
        InsertElementType insert = wfsfac.createInsertElementType();
        insert.getFeature().add(feature);       
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(insert, WFS.Insert));
        Document doc = encoder.encodeAsDOM(insert, WFS.Insert);
        XMLAssert.assertXpathEvaluatesTo("dummyId", "//wfs:Insert/wfs:dummyFeatureType/@fid", doc);
        XMLAssert.assertXpathEvaluatesTo("dummyValue", "//wfs:Insert/wfs:dummyFeatureType/wfs:dummyAttribute", doc);
       
    }
View Full Code Here

        FilterFactory2 filterfac = CommonFactoryFinder.getFilterFactory2();
               
        DeleteElementType delete = wfsfac.createDeleteElementType();
        delete.setFilter(filterfac.id( filterfac.featureId("someid")));
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(delete, WFS.Delete));
        Document doc = encoder.encodeAsDOM(delete, WFS.Delete);
        XMLAssert.assertXpathEvaluatesTo("someid", "//wfs:Delete/ogc:Filter/ogc:FeatureId/@fid", doc);       
       
    }
View Full Code Here

        ExceptionReportType report = Ows20Factory.eINSTANCE.createExceptionReportType();
        report.setVersion("2.0");
        report.getException().add(e);

        Encoder encoder = new Encoder(new OWSConfiguration());
        encoder.setIndenting(true);
        encoder.setIndentSize(2);
       
        // used to throw an exception here
        encoder.encodeAsString(report, OWS.ExceptionReport);
    }
View Full Code Here

        update.setFilter(filterfac.id( filterfac.featureId("someid")));
       
        //try with string
        propertyType.setValue("myvalue");
       
        Encoder encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        Document doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("mn:mytypename", "//wfs:Update/@typeName", doc);
        XMLAssert.assertXpathEvaluatesTo("mn:myproperty", "//wfs:Update/wfs:Property/wfs:Name", doc);
        XMLAssert.assertXpathEvaluatesTo("myvalue", "//wfs:Update/wfs:Property/wfs:Value", doc);
        XMLAssert.assertXpathEvaluatesTo("someid", "//wfs:Update/ogc:Filter/ogc:FeatureId/@fid", doc);
       
        //try with numeric value
        propertyType.setValue(100.25);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("100.25", "//wfs:Update/wfs:Property/wfs:Value", doc);
               
        //try with geometry
        Coordinate insideCoord = new Coordinate(5.2, 7.5);
        Point myPoint = geomfac.createPoint(insideCoord);
       
        propertyType.setValue(myPoint);
       
        encoder = new Encoder(new WFSConfiguration());
        //System.out.println(encoder.encodeAsString(update, WFS.Update));
        doc = encoder.encodeAsDOM(update, WFS.Update);
        XMLAssert.assertXpathEvaluatesTo("5.2", "//wfs:Update/wfs:Property/wfs:Value/gml:Point/gml:coord/gml:X", doc);
        XMLAssert.assertXpathEvaluatesTo("7.5", "//wfs:Update/wfs:Property/wfs:Value/gml:Point/gml:coord/gml:Y", doc);
               
    }
View Full Code Here

TOP

Related Classes of org.geotools.xml.Encoder$NullIterator

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.