Hi Rico:

I have created a Jira so we can continue this discussion (and fix the docs). If 
you get a code example showing how to use Encoder it would be a great help.

https://jira.codehaus.org/browse/GEOT-3605

-- 
Jody Garnett

On Wednesday, 25 May 2011 at 12:32 AM, Rico Lelina wrote: 
> I'll try these suggestions as soon as I can and report back. Thanks.
> 
> Rico
> 
> On Tue, May 24, 2011 at 9:15 AM, Justin Deoliveira <[email protected]> 
> wrote:
> > Hi Rico,
> > 
> > On Thu, May 19, 2011 at 9:55 AM, Rico Lelina <[email protected]> wrote:
> > >  Hello,
> > > 
> > > I have a SimpleFeatureCollection whose SimpleFeatures have been created 
> > > from a custom GeoJSON decoder. Then I try to encode the collection into 
> > > GML using the following code:
> > > 
> > > GML encoder = new GML(GML.Version.WFS1_1);
> > >  encoder.encode(outputStream, featureCollection);
> > > 
> > I don't really recommend using these classes... Jody are these classes 
> > really tested at all? I have no idea what the point of them is. All the 
> > code that uses the encoder does it explicitly. I recommend users do that 
> > rather than give them another option that does not really work. 
> > 
> > > First, I found that if I do not set the namespace URI on the 
> > > SimpleFeatureTypeBuilder in my GeoJSON decoder to 
> > > http://www.opengis.net/wfs, the namespace on the properties in the 
> > > encoded GML is null, e.g. (see last 2 line lines):
> > > 
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <wfs:FeatureCollection
> > >  xmlns:ogc="http://www.opengis.net/ogc";
> > >  xmlns:gml="http://www.opengis.net/gml";
> > >  xmlns:xlink="http://www.w3.org/1999/xlink";
> > >  xmlns:ows="http://www.opengis.net/ows";
> > >  xmlns:wfs="http://www.opengis.net/wfs";>
> > > <gml:boundedBy>
> > > <gml:Envelope>
> > > <gml:lowerCorner>-124.1633 -34.3667</gml:lowerCorner>
> > > <gml:upperCorner>57.7144 47.7528</gml:upperCorner>
> > > </gml:Envelope>
> > > </gml:boundedBy>
> > > <gml:featureMember>
> > > <wfs:MultiPoint gml:id="9c068ab0-b56c-40bb-8e33-b4507ed3547c">
> > > <gml:name>Cape Town</gml:name>
> > > <gml:boundedBy>
> > > <gml:Envelope>
> > > <gml:lowerCorner>18.4167 -33.9167</gml:lowerCorner>
> > > <gml:upperCorner>18.4167 -33.9167</gml:upperCorner>
> > > </gml:Envelope>
> > > </gml:boundedBy>
> > > <null:fillColor>#ee9900</null:fillColor>
> > > <null:strokeColor>#000000<null:strokeColor>
> > > etc.
> > > 
> > > So I changed my GeoJSON decoder to set the namespace URI on the builder 
> > > to the URI above. Now the properties are encoding with wfs:fillColor, 
> > > wfs:strokeColor, etc.
> > > 
> > An alternative that I think will work is to modify the encoder and populate 
> > the namespace context with a default namespace mapping. Something like:
> > 
> > encoder.getNamespaces().put("", "<yourNamespaceURI>"); 
> > 
> > While your solution works keep in mind that it is producing an invalid 
> > document by reusing the well known wfs schema. Those elements are unknown 
> > in the wfs schema and meant for a feature application schema. Generally we 
> > use some sort of custom schema uri for our feature attributes. So in your 
> > geojson code you can set the feature namespace uri to something like 
> > "http://geotools.org";. And then register it on the encoder: 
> > 
> > encoder.getNamespaces().put("feature", "http://geotools.org";)
> > 
> > Then your GML document will contain those attributes with a "feature" 
> > prefix. 
> > 
> > > 
> > > Second, I noticed that each gml:featureMember element has a gml:boundedBy 
> > > element even though there is only a single point geometry. Is this 
> > > because the geometry is actually a MultiPoint?
> > > 
> > All feature members may have a boundedBy element, regardless of the 
> > geometry type. You can turn this off with an encoder property:
> > 
> > encoder.getProperties().add(GMLConfiguration.NO_FEATURE_BOUNDS); 
> > 
> > > 
> > > Third, during encoding I get these warning messages on the log. It may be 
> > > affecting performance when I'm encoding a huge number of features, and 
> > > also I think it should read "Could not find type..." Is there something I 
> > > can do in building the features to avoid these warning messages?
> > > 
> > > May 19, 2011 10:23:45 AM org.geotools.gml2.bindings.GMLEncodingUtils 
> > > AbstractFeatureType_getProperties
> > > WARNING: Could find type for Polygon in the schema, generating type from 
> > > feature.
> > > May 19, 2011 10:23:45 AM org.geotools.gml2.bindings.GMLEncodingUtils 
> > > AbstractFeatureType_getProperties
> > > WARNING: Could find type for MultiPoint in the schema, generating type 
> > > from feature.
> > > 
> > Yeah, this leads me to believe that whatever code you are using (that GML 
> > class) is not setting up the schema properly. What I would suggest you do 
> > instead is: 
> > 
> > Encoder e = new Encoder(new org.geotools.wfs.v1_1.WFSConfiguration()); 
> > 
> > And indeed that is a typo. Will fix. 
> > 
> > >  Thanks.
> > 
> > Hope that helps. 
> > > 
> > > -- 
> > > Rico
> > > 
> > > ------------------------------------------------------------------------------
> > >  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
> > > 
> > 
> > 
> > 
> > -- 
> > Justin Deoliveira
> > OpenGeo - http://opengeo.org
> > Enterprise support for open source geospatial.
> > 
> > 
> 
> 
> -- 
> Rico
> ------------------------------------------------------------------------------
> vRanger cuts backup time in half-while increasing security.
> With the market-leading solution for virtual backup and recovery, 
> you get blazing-fast, flexible, and affordable data protection.
> Download your free trial now. 
> http://p.sf.net/sfu/quest-d2dcopy1
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> 
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery, 
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now. 
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to