GML3 ClassCastException when parsing Polygon with Ring as exterior
------------------------------------------------------------------

                 Key: GEOT-1754
                 URL: http://jira.codehaus.org/browse/GEOT-1754
             Project: GeoTools
          Issue Type: Bug
    Affects Versions: 2.4.1
         Environment: Sun JDK 1.5.0.15
            Reporter: Michael Rudolf


Hi,

I get a ClassCastException, the stack trace of which is shown below, when 
parsing the following GML3 string:

<gml:Polygon 
xmlns:gml="http://www.opengis.net/gml";><gml:exterior><gml:Ring><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:pos
 srsName="urn:adv:crs:DE_DHDN_3GK3">3353124.446 5533265.243</gml:pos><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353137.958 
5533276.370</gml:pos></gml:LineStringSegment><gml:LineStringSegment><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353137.958 5533276.370</gml:pos><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353158.333 
5533251.626</gml:pos></gml:LineStringSegment><gml:LineStringSegment><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353158.333 5533251.626</gml:pos><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353145.043 
5533240.230</gml:pos></gml:LineStringSegment><gml:LineStringSegment><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353145.043 5533240.230</gml:pos><gml:pos 
srsName="urn:adv:crs:DE_DHDN_3GK3">3353124.446 
5533265.243</gml:pos></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:Ring></gml:exteri
 or></gml:Polygon>

Caused by: java.lang.ClassCastException: java.lang.String
    at 
org.geotools.gml3.bindings.PolygonTypeBinding.parse(PolygonTypeBinding.java:90)
    at org.geotools.xml.impl.ParseExecutor.visit(ParseExecutor.java:130)
    ... 36 more

The code I am using for parsing the above XML fragment is the following 
(exception handling omitted):

import org.geotools.xml.Configuration;
import org.geotools.xml.Parser;
import org.geotools.gml3.GMLConfiguration;
...
Configuration configuration = new GMLConfiguration();
Parser parser = new Parser(configuration);
geometry = (Geometry)parser.parse(new StringReader(geometryString));
...

When looking at the source code of the class causing the exception, 
org.geotools.gml3.bindings.PolygonTypeBinding, I can spot the following:

    public Object parse(ElementInstance instance, Node node, Object value)
        throws Exception {
        //TODO: schema allows no exterior ring, but what the heck is that all 
about ?
        LinearRing exterior = (LinearRing) node.getChildValue("exterior");
        LinearRing[] interior = null;

        if (node.hasChild("interior")) {
            List list = node.getChildValues("interior");
            interior = (LinearRing[]) list.toArray(new LinearRing[list.size()]);
        }

        return gFactory.createPolygon(exterior, interior);
    }

It seems to me as if Rings in Polygons are not supported, only LinearRings are 
expected. However, there are lots of Rings inside Polygons in the data I get 
and also in the data one can find on the internet - what shall I do? Is this a 
bug in GeoTools or in the data I get?

Thanks very much in advance for the help!
Best regards,
Michael

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to