Package org.geotools.xml

Examples of org.geotools.xml.Encoder$SingleIterator


    @Test
    public void testGML3() throws Exception {
        final Geometry geometry = GeomFormat.WKT.parse("Polygon((482200.0 63000.0,835700.0 63000.0,835700.0 301000.0,482200.0 301000.0," +
                                                       "482200.0 63000.0))");
        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        final Encoder encoder = new Encoder(GeomFormat.gml3Config);
        encoder.setIndenting(false);
        encoder.setOmitXMLDeclaration(true);
        encoder.setNamespaceAware(true);

        encoder.encode(geometry, org.geotools.gml3.GML.geometryMember, outputStream);
        String gmlString = outputStream.toString();

        assertNotNull(GeomFormat.GML3.parse(gmlString));
        assertNotNull(GeomFormat.GML3.parse(URLEncoder.encode(gmlString, "UTF-8")));
    }
View Full Code Here


    @Test
    public void testGML32() throws Exception {
        final Geometry geometry = GeomFormat.WKT.parse("Polygon((482200.0 63000.0,835700.0 63000.0,835700.0 301000.0,482200.0 301000.0," +
                                                       "482200.0 63000.0))");
        final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        final Encoder encoder = new Encoder(GeomFormat.gml32Config);
        encoder.setIndenting(false);
        encoder.setOmitXMLDeclaration(true);
        encoder.setNamespaceAware(true);

        encoder.encode(geometry, org.geotools.gml3.v3_2.GML.geometryMember, outputStream);
        String gmlString = outputStream.toString();

        assertNotNull(GeomFormat.GML32.parse(gmlString));
        assertNotNull(GeomFormat.GML32.parse(URLEncoder.encode(gmlString, "UTF-8")));
    }
View Full Code Here

      Log.error(Geonet.CSW, "Error parsing CQL or during conversion into Filter");
      throw new NoApplicableCodeEx("Error during CQL to Filter conversion : "+ e);
    }

    final Configuration filter110Config = new OGCConfiguration();
    final Encoder encoder = new Encoder(filter110Config);
   
    final Charset charset = Charset.forName("UTF-16");
    encoder.setEncoding(charset);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
   
    String xml;
    try {
      encoder.encode(filter, OGC.Filter, out);
      xml = new String(out.toByteArray(), charset.toString());
    } catch (IOException e) {
      Log.error(Geonet.CSW, e.getMessage());
      throw new NoApplicableCodeEx("Error transforming Filter to XML" + e);
    }
View Full Code Here

    {
        Element parentElement = element.getParentElement();
        int index = parentElement.indexOf(element);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Encoder encoder = new Encoder(_configuration);
        encoder.setOmitXMLDeclaration(true);
        encoder.setNamespaceAware(true);

        encoder.encode(SpatialIndexWriter.toMultiPolygon(fullGeom), org.geotools.gml3.GML.MultiPolygon, out);
        Element geomElem = org.fao.geonet.csw.common.util.Xml.loadString(out.toString(Constants.ENCODING), false);
        parentElement.setContent(index, geomElem);
    }
View Full Code Here

        org.geotools.xml.Encoder encoder;
        QName qname;
        if (version.equalsIgnoreCase("1.1")) {
            qname = org.geotools.filter.v1_1.OGC.getInstance().Filter;
            org.geotools.filter.v1_1.OGCConfiguration config = new org.geotools.filter.v1_1.OGCConfiguration();
            encoder = new Encoder(config);
        } else {
            qname = org.geotools.filter.v1_0.OGC.getInstance().Filter;
            org.geotools.filter.v1_0.OGCConfiguration config = new org.geotools.filter.v1_0.OGCConfiguration();
            encoder = new Encoder(config);
        }
        encoder.setIndenting(pretty);
        encoder.setOmitXMLDeclaration(true);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        encoder.encode(this.filter, qname, out);
View Full Code Here

    super(resultPropertyName);
 

  @Override 
  protected GeoPipeFlow process(GeoPipeFlow flow) {
    Encoder encoder = new Encoder(new KMLConfiguration());
    encoder.setIndenting(true);
    try {
      setProperty(flow, encoder.encodeAsString(flow.getGeometry(), KML.Geometry));
    } catch (IOException e) {
      setProperty(flow, e.getMessage());
    }   
    return flow;
 
View Full Code Here

            metas.add(meta);
        }

        GeoServerInfo global = wfs.getGeoServer().getGlobal();
        Encoder encoder = new Encoder(configuration, configuration.schema());
        encoder.setEncoding(Charset.forName( global.getCharset() ));

        // declare wfs schema location
        BaseRequestType gft = (BaseRequestType) getFeature.getParameters()[0];

        encoder.setSchemaLocation(org.geoserver.wfsv.xml.v1_1_0.WFSV.NAMESPACE,
                buildSchemaURL(gft.getBaseUrl(), "wfs/1.1.0/wfs.xsd"));

        // declare application schema namespaces
        for (Iterator i = ns2metas.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();

            String namespaceURI = (String) entry.getKey();
            Set metas = (Set) entry.getValue();

            StringBuffer typeNames = new StringBuffer();

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

                if (m.hasNext()) {
                    typeNames.append(",");
                }
            }

            // set the schema location
            Map<String, String> params = params("service", "WFS",
                    "version", "1.1.0",
                    "request", "DescribeFeatureType",
                    "typeName", typeNames.toString());
            encoder.setSchemaLocation(namespaceURI, buildURL(gft.getBaseUrl(), "wfs", params, URLType.SERVICE));
        }

        encoder.encode(results,
                    org.geoserver.wfs.xml.v1_1_0.WFS.FEATURECOLLECTION, output);
      
    }
View Full Code Here

        assertNotNull(fc);

        XSDSchema schema = TEST.getInstance().getSchema();
        assertNotNull(schema);

        Encoder encoder = new Encoder(configuration, schema);
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        encoder.write(fc, TEST.TestFeatureCollection, output);

        validate(output.toByteArray(), configuration);
    }
View Full Code Here

        assertNotNull(fc);

        XSDSchema schema = TEST.getInstance().getSchema();
        assertNotNull(schema);

        Encoder encoder = new Encoder(configuration, schema);

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        encoder.write(fc, TEST.TestFeatureCollection, output);

        validate(output.toByteArray(), configuration);
    }
View Full Code Here

    public void testEncodeFeatureWithBounds() throws Exception {
        SimpleFeature feature = GML3MockData.feature();
        TestConfiguration configuration  = new TestConfiguration();
        //configuration.getProperties().add( org.geotools.gml2.GMLConfiguration.NO_FEATURE_BOUNDS );
   
        Encoder encoder = new Encoder( configuration );
        Document dom = encoder.encodeAsDOM(feature, TEST.TestFeature );
       
        assertEquals( 1, dom.getElementsByTagName("gml:boundedBy").getLength());
    }
View Full Code Here

TOP

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

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.