Agreed on making the parser more lax. I can think of a different couple of ways to patch it though. One would be to have a fallback like:
final String code = null; try { code = element.pullString("code"); } catch( ParseException e ) { code = element.pullInteger("code") } However to make the parser consistent we would have to probably patch it multiple places to follow this behavior, which is potentially a lot of work. A more consice fix (although a bit more hacky) would be to patch pullString() to do a second pass, and check for the case of a single element, and just return its string representation: public String pullString(final String key) throws ParseException { final Iterator iterator = list.iterator(); while (iterator.hasNext()) { final Object object = iterator.next(); if (object instanceof String) { iterator.remove(); return (String)object; } } //check for case of a single child and just return it as // a string if ( list.size() == 1 ) { return list.get(0).toString(); } throw missingParameter(key); } Regardless Frank, yeah open a jira issue and we can throw some patches around. Martin/Andrea: what are your thoughts? Frank Gasdorf wrote: > Hello Martin > > sounds good in to accept the two different "coding" styles for the authority > parameter. Would you change the Parser code or should i create an issue an > attach a patch? Thanks so far, > > Frank > >> Frank Gasdorf a écrit : >>> But I got a ParseExcpetion for the AUTHORITY Parameter: >>> >>> java.text.ParseException: Error in "AUTHORITY": Parameter "code" is missing. >>> at org.geotools.referencing.wkt.Element.pullString(Element.java:419) >>> at org.geotools.referencing.wkt.Parser.parseAuthority(Parser.java:338) >>> at org.geotools.referencing.wkt.Parser.parseProjCS(Parser.java:883) >>> at >>> org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:222) >>> at >>> org.geotools.referencing.wkt.Parser.parseCoordinateReferenceSystem(Parser.java:201) >>> >>> within the wkt-string the AUTHORITY section looks like : >>> >>> AUTHORITY["ESRI",102018] >> The code must be between quote, like: >> >> AUTHORITY["ESRI","102018"] >> >> However I realize that the error message was confusing. We could change the >> WKT >> parser so that it accepts unquoted integers as well. >> >> Martin >> > > > > ------------------------------------------------------------------------------ > _______________________________________________ > Geotools-devel mailing list > Geotools-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-devel -- Justin Deoliveira OpenGeo - http://opengeo.org Enterprise support for open source geospatial. ------------------------------------------------------------------------------ _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel