Martin,
I call your GMLReader as follows:
STRUCT res = SC4O.ST_GeomFromGML("<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml/3.2\" gml:id=\"bp1\" srsName=\"EPSG:4326\" srsDimension=\"2\"> <gml:exterior> <gml:LinearRing><gml:posList>115.25 4.5 115.25 4.25 115.5 4.25 115.5 4.5 115.25 4.5</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>");
public static STRUCT ST_GeomFromGML(String _gml)
throws SQLException
{
...
GMLReader gr = new GMLReader();
try
{
Geometry geom = gr.read(_gml,gf);
And I get this:
java.lang.NullPointerException
at com.vividsolutions.jts.io.gml2.GMLHandler$Handler.create(GMLHandler.java:121)
at com.vividsolutions.jts.io.gml2.GMLHandler.endElement(GMLHandler.java:217)
at oracle.xml.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1306)
at oracle.xml.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:324)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:291)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:207)
at oracle.xml.jaxp.JXSAXParser.parse(JXSAXParser.java:292)
at com.vividsolutions.jts.io.gml2.GMLReader.read(GMLReader.java:127)
at com.vividsolutions.jts.io.gml2.GMLReader.read(GMLReader.java:101)
at com.spatialdbadvisor.dbutils.ora.SC4O.ST_GeomFromGML(SC4O.java:1896)
The NullPointerException is here:
/**
* @param gf GeometryFactory
* @return Parsed Object
* @throws SAXException
*/
public Object create(GeometryFactory gf) throws SAXException {
return strategy.parse(this, gf);
}
And is because strategy (protected ParseStrategy strategy) is null.
Now, it took a while but I finally realised that this way probably because I was passing in GML3.2 and not GML2. If so, why would it not give a better exception than the impossibly opaque NullPointerException?
Is there a better place to get GML etc conversion open source Java?
regards
SImon
On Mon, 03 Dec 2012 14:55:10 +1100, Martin Davis <mtnclimb@...> wrote:
> This was fixed in JTS 1.13, as of August 2011.
>
> On Sun, Dec 2, 2012 at 7:20 PM, Simon Greener <simon@...> wrote:
>
>> Just compiled JTS 1.12 source under Java 1.4 and I got this breakage in GeometryMapper:
>>
>>
>>
>> Error(74,19): for-each loops are not supported in -source 1.4
>>
>>
>>
>> public static Collection map(Collection geoms, MapOp op)
>>
>> {
>>
>> List mapped = new ArrayList();
>>
>> for (Object o : geoms) {
>>
>> Geometry g = (Geometry) o;
>>
>> Geometry gr = op.map(g);
>>
>> if (gr != null)
>>
>> mapped.add(gr);
>>
>> }
>>
>> return mapped;
>>
>> }
>>
>>
>>
>> Only one that I can see.
>>
>>
>>
>> regards
>>
>> Simon
>>
>> --
>>
>> Holder of "2011 Oracle Spatial Excellence Award for Education and Research."
>>
>> SpatialDB Advice and Design, Solutions Architecture and Programming,
>>
>> Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
>>
>> Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio >>Specialist.
>>
>> 39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
>>
>> Website: http://www.spatialdbadvisor.com
>>
>> Email: simon@...
>>
>> Voice: +61 362 396397
>>
>> Mobile: +61 418 396391
>>
>> Skype: sggreener
>>
>> Longitude: 147.20515 (147° 12' 18" E)
>>
>> Latitude: -43.01530 (43° 00' 55" S)
>>
>> GeoHash: r22em9r98wg
>>
>> NAC:W80CK 7SWP3
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> Keep yourself connected to Go Parallel:
>>
>> BUILD Helping you discover the best ways to construct your parallel projects.
>>
>> http://goparallel.sourceforge.net
>>
>> _______________________________________________
>>
>> Jts-topo-suite-user mailing list
>>
>> Jts-topo-suite-user@...
>>
>> https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
>>
>
>
--
Holder of "2011 Oracle Spatial Excellence Award for Education and Research."
SpatialDB Advice and Design, Solutions Architecture and Programming,
Oracle Database 10g Administrator Certified Associate; Oracle Database 10g SQL Certified Professional
Oracle Spatial, SQL Server, PostGIS, MySQL, ArcSDE, Manifold GIS, FME, Radius Topology and Studio Specialist.
39 Cliff View Drive, Allens Rivulet, 7150, Tasmania, Australia.
Website: http://www.spatialdbadvisor.com
Email: simon@...
Voice: +61 362 396397
Mobile: +61 418 396391
Skype: sggreener
Longitude: 147.20515 (147° 12' 18" E)
Latitude: -43.01530 (43° 00' 55" S)
GeoHash: r22em9r98wg
NAC:W80CK 7SWP3
|