Hi Jon:

You will need to send email to the user list; the company I work for actually 
offers developer support (allowing me to respond promptly by email). If you are 
interested you can visit http://lisasoft.com/ for the details.

That is really good you are getting the parser to work.

I did not actually find the exception message helpful and would need to look at 
that section of code. I recommend putting a breakpoint in there and stepping 
through with the debugger to see if you can determine why the error is 
occurring.

-- 
Jody Garnett


On Wednesday, 15 June 2011 at 12:14 AM, Jon Britton wrote:

> Hi Jody,
> 
> I saw some code using GMLConfiguration and Parser, which I've tried to adapt 
> to my problem (code below). However, it fails at 
> newDataStore.createSchema(fc.getSchema()) and produces a java.io.IOException 
> (shown in full below). It seems to have read in the GML ok, which is a start. 
> Any help would be appreciated. Cheers, Jon. 
> 
> CODE:
> 
> URL url = new URL(dataUrl);
> InputStream in = url.openStream();
> 
> GMLConfiguration config = new GMLConfiguration();
> Parser parser = new Parser(config);
> DefaultFeatureCollection fc = (DefaultFeatureCollection) parser
> .parse(in);
> 
> // Create random name
> Random rand = new Random();
> String fileName = Long.toString(Math.abs(rand.nextLong()), 36);
> 
> File file = new File(getServletContext().getRealPath("WEB-INF")
> + ""/tempfiles/" + fileName + ".shp");
> 
> ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
> Map<String, Serializable> params = new HashMap<String, Serializable>();
> params.put("url", file.toURI().toURL());
> params.put("create spatial index", Boolean.TRUE);
> 
> ShapefileDataStore newDataStore = (ShapefileDataStore) dataStoreFactory
> .createNewDataStore(params);
> newDataStore.createSchema(fc.getSchema());
> 
> /*
> * Write the features to the shapefile
> */
> Transaction transaction = new DefaultTransaction("create");
> 
> String typeName = newDataStore.getTypeNames()[0];
> FeatureSource featureSource = newDataStore
> .getFeatureSource(typeName);
> 
> if (featureSource instanceof FeatureStore) {
> FeatureStore featureStore = (FeatureStore) featureSource;
> 
> featureStore.setTransaction(transaction); 
> try {
> featureStore.addFeatures(fc);
> transaction.commit();
> 
> } catch (Exception problem) {
> problem.printStackTrace();
> transaction.rollback();
> } finally {
> transaction.close();
> }
> } else {
> LOGGER.info (http://LOGGER.info)(typeName + " does not support read/write 
> access");
> }
> 
> 
> 
> EXCEPTION: 
> 
> java.io.IOException: Unable to write : java.lang.Object
> at 
> org.geotools.data.shapefile.ShapefileDataStore.createDbaseHeader(ShapefileDataStore.java:1061)
> at 
> org.geotools.data.shapefile.ShapefileDataStore.createSchema(ShapefileDataStore.java:855)
> at 
> uk.ac.glam.smartwps.server.OWSRequestServiceImpl.gmlToShapefile(OWSRequestServiceImpl.java:286)
> at 
> uk.ac.glam.smartwps.server.OWSRequestServiceImpl.testSomething(OWSRequestServiceImpl.java:748)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
> at 
> com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
> at 
> com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
> at 
> com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
> at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
> at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
> at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
> at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
> at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at 
> org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
> at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> at org.mortbay.jetty.Server.handle(Server.java:324)
> at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
> at 
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
> at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
> at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
> at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
> at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
> at 
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
> 
> 
> On 14 June 2011 13:28, Jody Garnett <[email protected] 
> (mailto:[email protected])> wrote:
> > Here is the trouble; especially with GML from a WPS service - what schema 
> > does the GML match? We need the schema in order to do a good job parsing 
> > it. GML without a schema is like charging off into the wilderness; it may 
> > be a fun ride but you are not going to be sure where you will end up. 
> > 
> > However if your GML output references a schema at the top of the file you 
> > may be okay? I added some code the the GML utility class that would process 
> > the output of parsing GML without a schema (ends up as raw data in 
> > java.util.Map data structures) and convert it into "features" for normal 
> > use. 
> > 
> > You can backport that code if you like; if not I recommend using the GML 
> > Configuration + Parser and sorting things out yourself.
> > 
> > -- 
> > Jody Garnett
> > 
> > 
> > On Tuesday, 14 June 2011 at 10:11 PM, Jon Britton wrote:
> > 
> > 
> > 
> > > Hi,
> > > 
> > > I need to convert the output of a WPS process (GML) to Shapefile so I can 
> > > upload it into GeoServer. I've done some searching and found quite a few 
> > > different examples, many of which seem out of date (or even too in-date, 
> > > I'm using GeoTools 2.6.1). All I've got is a URL to the GML process 
> > > output to work with. 
> > > 
> > > Any help would be appreciated.
> > > 
> > > Thanks,
> > > 
> > > Jon 
> > > ------------------------------------------------------------------------------
> > > EditLive Enterprise is the world's most technically advanced content
> > > authoring tool. Experience the power of Track Changes, Inline Image
> > >  Editing and ensure content is compliant with Accessibility Checking.
> > > http://p.sf.net/sfu/ephox-dev2dev
> > > _______________________________________________
> > >  Geotools-gt2-users mailing list
> > > [email protected] 
> > > (mailto:[email protected])
> > > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> > 
> > 
> > ------------------------------------------------------------------------------
> >  EditLive Enterprise is the world's most technically advanced content
> >  authoring tool. Experience the power of Track Changes, Inline Image
> >  Editing and ensure content is compliant with Accessibility Checking.
> > http://p.sf.net/sfu/ephox-dev2dev
> > _______________________________________________
> >  Geotools-gt2-users mailing list
> > [email protected] 
> > (mailto:[email protected])
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> > 
> 

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to