I'm using GeoTools v2.7.0.1 and having issues with GML encoding. I have
tried both the gml2.GMLConfiguration with the org.geotools.xml.Encoder class
and also the org.geotools.GML utility class.

 

1. Could you please point out what may be wrong with the following GML2
encoding example. Also, does the structure of the SimpleFeatureCollection
(how the simple feature types are created) impact the ability to encode with
a particular schema?

 

   public void encode(SimpleFeatureCollection fc, OutputStream os) throws
IOException

   {

       org.geotools.xml.XSD xsd = new org.geotools.xml.XSD() {

           public String getNamespaceURI() {

               return "http://ogr.maptools.org/";;

           }

           public String getSchemaLocation()

           {

               return "file:///C:/Projects/GeoTools/schema/results.xsd";

           }

           protected void addDependencies(Set dependencies) {

               dependencies.add(org.geotools.gml2.GML.getInstance());

           }            

       };

       org.eclipse.xsd.XSDSchema schema = xsd.getSchema();

       QName fcName = new QName("http://ogr.maptools.org/";,
"FeatureCollection");

 

       org.geotools.gml2.GMLConfiguration config = new
org.geotools.gml2.GMLConfiguration();

       org.geotools.xml.Encoder encoder = new
org.geotools.xml.Encoder(config, schema);

       //encoder.setSchemaLocation("http://ogr.maptools.org/";,
"file:///C:/Projects/GeoTools/schema/results.xsd");

       encoder.setIndentSize(2);

 

       encoder.encode(featureCollection, fcName, os);

       System.out.println("Encoded " + featureCollection.size() + "
features");

    }

 

There are a total of 11 features in the feature collection with mixed
geometry types (MultiPoint, Polygon, LineString, GeometryCollection,  etc.).
The encoded output is below and the results.xsd file is attached. There are
no warning or error messages.

 

<?xml version="1.0" encoding="UTF-8"?>

<ogr:FeatureCollection xmlns:ogr="http://ogr.maptools.org/";
xmlns:gml="http://www.opengis.net/gml"/>

 

 

Below is some output from the feature.getType() method.

=======================================================

 

SimpleFeatureTypeImpl http://ogr.maptools.org/:MultiPoint identified extends
Feature(groupedFeatureAttributes:groupedFeatureAttributes,graphicWidth:graph
icWidth,fillColor:fillColor,olTool:olTool,name:name,

display:disp
lay,graphicHeight:graphicHeight,bufferM:bufferM,type:type,strokeColor:stroke
Color,fillOpacity:fillOpacity,geometry:geometry)

 

SimpleFeatureTypeImpl http://ogr.maptools.org/:Polygon identified extends
Feature(groupedFeatureAttributes:groupedFeatureAttributes,graphicWidth:graph
icWidth,fillColor:fillColor,olTool:olTool,name:name,

display:disp
lay,graphicHeight:graphicHeight,bufferM:bufferM,type:type,strokeColor:stroke
Color,fillOpacity:fillOpacity,geometry:geometry)

 

SimpleFeatureTypeImpl http://ogr.maptools.org/:MultiLineString identified
extends
Feature(groupedFeatureAttributes:groupedFeatureAttributes,graphicWidth:graph
icWidth,fillColor:fillColor,olTool:olTool,name:name,

display:disp
lay,graphicHeight:graphicHeight,bufferM:bufferM,type:type,strokeColor:stroke
Color,fillOpacity:fillOpacity,geometry:geometry)

 

SimpleFeatureTypeImpl http://ogr.maptools.org/:GeometryCollection identified
extends
Feature(groupedFeatureAttributes:groupedFeatureAttributes,graphicWidth:graph
icWidth,fillColor:fillColor,olTool:olTool,name:name,

display:disp
lay,graphicHeight:graphicHeight,bufferM:bufferM,type:type,strokeColor:stroke
Color,fillOpacity:fillOpacity,geometry:geometry)

 

 

Below is output from one of the features.

=========================================

SimpleFeatureImpl:MultiPoint=[SimpleFeatureImpl.Attribute:
groupedFeatureAttributes<groupedFeatureAttributes
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=, SimpleFeatureImpl.Attribute:
graphicWidth<graphicWidth  id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=null,
SimpleFeatureImpl.Attribute: fillColor<fillColor
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=#ee9900,
SimpleFeatureImpl.Attribute: olTool<olTool
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=1,  SimpleFeatureImpl.Attribute:
name<name id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=Point1,
SimpleFeatureImpl.Attribute: display<display
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=, SimpleFeatureImpl.Attribute:
graphicHeight<graphicHeight  id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=null,
SimpleFeatureImpl.Attribute: bufferM<bufferM
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=0.0,  SimpleFeatureImpl.Attribute:
type<type id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=Point,
SimpleFeatureImpl.Attribute: strokeColor<strokeColor
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=#000000,
SimpleFeatureImpl.Attribute: fillOpacity<fillOpacity
id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=1, SimpleFeatureImpl.Attribute:
geometry<geometry  id=5b6124a5-0c42-47a6-ae9f-26189d81fbad>=MULTIPOINT
((85.140225 61.273128))]

 

 

2. Since I am trying to represent a feature collection using GML that can
contain mixed types and the features will have some custom
attributes/properties (like GeoJSON), is there an exising defacto "standard"
feature collection GML-based schema that can be leveraged (like  some WFS
feature collection schema)?

 

 

3. I do not see any encoding examples in
http://svn.osgeo.org/geotools/trunk/modules/extension/xsd/xsd-gml2/src/test/
java/org/geotools/gml2/GMLApplicationSchemaParsingTest.java nor  in any of
the other test files inside that package.

 

Thanks,

Ken

Attachment: results.xsd
Description: Binary data

------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to