So we are definately ending up with a GeometryCollection. The goal is to convert GML into a shapefile. How do I keep the GML from loading the geometry as a GeometryCollection? Am I going to have to reformat the GML before reading it?
Segment of the gml: 8 <gml:featureMember> 9 <ms:coreexport> 10 <gml:boundedBy> 11 <gml:Box srsName="EPSG:4326"> 12 <gml:coordinates>-61.133333,77.166667 -61.133333,77.166667</gml:coordinates> 13 </gml:Box> 14 </gml:boundedBy> 15 <ms:msGeometry> 16 17 <gml:MultiGeometry> 18 19 <gml:geometryMember><gml:Point srsName="EPSG:4326"> 20 <gml:coordinates>-61.133333,77.166667</gml:coordinates> 21 </gml:Point></gml:geometryMember></gml:MultiGeometry></ms:msGeometry> 22 <ms:OGR_FID>8</ms:OGR_FID> 23 <ms:TUBESININVENTORY>142</ms:TUBESININVENTORY> 24 <ms:BOTTOMOFCOREM>237.95</ms:BOTTOMOFCOREM> 25 <ms:COREDIAMETERCM>12.4</ms:COREDIAMETERCM> 26 <ms:COREID>CC 62</ms:COREID> 27 <ms:CORENAME>CAMP CENTURY</ms:CORENAME> 28 <ms:DATEMODIFIED>8/18/2006</ms:DATEMODIFIED> 29 <ms:DRILLFLUID>diesel/ trichloroethylene</ms:DRILLFLUID> 30 <ms:DRILLERS>USA CRREL</ms:DRILLERS> 31 <ms:LATITUDE>77.16666667</ms:LATITUDE> 32 <ms:LOCATION>Greenland</ms:LOCATION> 33 <ms:LONGITUDE>-61.13333333</ms:LONGITUDE> 34 <ms:METHOD>Thermal</ms:METHOD> 35 <ms:NOTES>MARKED FOR DEACCESSION</ms:NOTES> 36 <ms:NUMBEROFSAMPLES /> 37 <ms:ORIGINALPI>Chester Langway</ms:ORIGINALPI> 38 <ms:SITEELEVATIONM>1885</ms:SITEELEVATIONM> 39 <ms:TOPOFCOREM>10.53</ms:TOPOFCOREM> 40 <ms:TUBEDIAMETER>5.5</ms:TUBEDIAMETER> 41 <ms:TUBESDRILLED>1.5</ms:TUBESDRILLED> 42 <ms:UNIVERSITYORAFFILIATE>161</ms:UNIVERSITYORAFFILIATE> 43 <ms:YEARSDRILLED>CRREL</ms:YEARSDRILLED> 44 </ms:coreexport> 45 </gml:featureMember> Thanks, Yolan ************************************************* * Yolan (Aaron Jackson) [EMAIL PROTECTED] * * http://mlug.missouri.edu/~yolan/ * * AIM: YolanLINUX, YolanOTHER, YolanLAPTOP * * ICQ: 74624109 * ************************************************* * Doubling Technologies * ************************** On Thu, 24 Aug 2006, Jesse Eichar wrote: > Looking at the exception (as I should have done better the first > time). It looks like the Geometry is a GeometryCollection or > something like that. The valid types are: Polygon, MultiPolygon, > Point, MultiPoint, Line and MultiLine. > > Make sure that the objects you are inserting are all of the same type > and are one of those choices. > > > Jesse > On 24-Aug-06, at 1:34 PM, Aaron Jackson wrote: > >> I'm pretty sure the features in the FeatureCollection are all the >> same type as those in the FeatureStore. The features being added >> are created from the following function: >> >> ------- BEGIN CODE -------- >> public Feature CreateFeatureInstance(Element rootElement, >> FeatureType featureType) >> throws ConversionException { >> Feature featureInstance; >> ArrayList attributesOfRoot = new ArrayList(); >> ArrayList attributesNeeded = new ArrayList(); >> List children = rootElement.getChildren(); >> ListIterator attributeIterator; >> Object[] attributesObject; >> >> if (children.size() > 0) // check to see that it's not >> empty >> { >> >> // get the attributes needed in a vector format >> for (int i = 0; i < featureType.getAttributeCount(); i+ >> +) { >> attributesNeeded.add(featureType.getAttributeType(i)); >> } >> >> try { >> attributesOfRoot = GetAttributes((Element) >> children.get(0), >> >> attributesNeeded); // should only be one, so this is OK >> } catch (Exception e) { >> throw new ConversionException(e.getMessage()); >> } >> >> // Throw an exception we come up empty on attributes >> if (attributesOfRoot.size() < 1) { >> throw new ConversionException( >> "Feature instance creation error: no " >> + featureType.getTypeName() + " found"); >> } >> >> // If there's some attributes left, fill it in with blanks >> attributeIterator = attributesNeeded.listIterator(); >> >> while (attributeIterator.hasNext()) { >> attributeIterator.next(); >> attributesOfRoot.add(""); >> } >> >> // load up the Object[] for creationg of a feature >> instance >> attributesObject = (Object[]) attributesOfRoot.toArray(); >> >> try { >> featureInstance = featureType.create >> (attributesObject); >> } catch (IllegalAttributeException iae) { >> throw new ConversionException( >> "Feature instance creation error: " + >> iae.getMessage()); >> } >> >> return featureInstance; >> } else { >> throw new ConversionException( >> "Element passed is empty! Feature instance creation >> failed..."); >> } >> } >> ------- END CODE ------- >> >> The data store is created using the same featureType object (as >> seen below). >> dataStore = new ShapefileDataStore(anURL); >> dataStore.createSchema(finalFeatureType); >> featureStore = (FeatureStore) dataStore.getFeatureSource( >> finalFeatureType.getTypeName()); >> >> Yolan >> >> ************************************************* >> * Yolan (Aaron Jackson) [EMAIL PROTECTED] * >> * http://mlug.missouri.edu/~yolan/ * >> * AIM: YolanLINUX, YolanOTHER, YolanLAPTOP * >> * ICQ: 74624109 * >> ************************************************* >> * Doubling Technologies * >> ************************** >> >> On Thu, 24 Aug 2006, Jesse Eichar wrote: >> >>> The features in the Geometry collection have to be the same type as >>> the features in the FeatureStore. >>> >>> Jesse >>> >>> On 24-Aug-06, at 9:53 AM, Aaron Jackson wrote: >>> >>>> Hi, I'm trying to add features from a FeatureCollection to a >>>> FeatureStore. >>>> When I do the add, I get the following exception: >>>> >>>> org.geotools.data.shapefile.shp.ShapefileException: Cannot handle >>>> geometry type : com.vividsolutions.jts.geom.GeometryCollection >>>> at >>>> org.geotools.data.shapefile.shp.JTSUtilities.getShapeType >>>> (JTSUtilities.java:332) >>>> at org.geotools.data.shapefile.ShapefileDataStore >>>> $Writer.write(ShapefileDataStore.java:1514) >>>> ... >>>> >>>> >>>> Any suggestions? >>>> >>>> Yolan >>>> >>>> ************************************************* >>>> * Yolan (Aaron Jackson) [EMAIL PROTECTED] * >>>> * http://mlug.missouri.edu/~yolan/ * >>>> * AIM: YolanLINUX, YolanOTHER, YolanLAPTOP * >>>> * ICQ: 74624109 * >>>> ************************************************* >>>> * Doubling Technologies * >>>> ************************** >>>> >>>> -------------------------------------------------------------------- >>>> -- >>>> --- >>>> Using Tomcat but need to do more? Need to support web services, >>>> security? >>>> Get stuff done quickly with pre-integrated technology to make your >>>> job easier >>>> Download IBM WebSphere Application Server v.1.0.1 based on Apache >>>> Geronimo >>>> http://sel.as-us.falkag.net/sel? >>>> cmd=lnk&kid=120709&bid=263057&dat=121642 >>>> _______________________________________________ >>>> Geotools-gt2-users mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >>> >>> --------------------------------------------------------------------- >>> ---- >>> Using Tomcat but need to do more? Need to support web services, >>> security? >>> Get stuff done quickly with pre-integrated technology to make your >>> job easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache >>> Geronimo >>> http://sel.as-us.falkag.net/sel? >>> cmd=lnk&kid=120709&bid=263057&dat=121642 >>> _______________________________________________ >>> Geotools-gt2-users mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
