Hi list,
I'm using geotools2.1 and working on a servlet wich convert a GML to a
shape-File, it works well when all the features in the GML has the same
attributes, but when a feature misses an attribute it won't be added to
the shape-file and an error will be logged.
The FeatureStore "newFeatureStore" has 15 types:
[0]= DefaultAttributeType$Textual (id=224)
[1]= DefaultAttributeType$Textual (id=226)
[2]= DefaultAttributeType$Textual (id=227)
[3]= DefaultAttributeType$Textual (id=228)
[4]= DefaultAttributeType$Textual (id=229)
[5]= DefaultAttributeType$Textual (id=230)
[6]= DefaultAttributeType$Textual (id=231)
[7]= DefaultAttributeType$Textual (id=232)
[8]= DefaultAttributeType$Numeric (id=233)
[9]= DefaultAttributeType$Numeric (id=235)
[10]= DefaultAttributeType$Numeric (id=236)
[11]= DefaultAttributeType$Textual (id=237)
[12]= DefaultAttributeType$Textual (id=238)
[13]= DefaultAttributeType$Numeric (id=239)
[14]= DefaultAttributeType$Geometric (id=211)
An object in the
FeatureReader "reader" has only 14 types (schema):
[0]= DefaultAttributeType$Textual (id=330)
[1]= DefaultAttributeType$Textual (id=331)
[2]= DefaultAttributeType$Textual (id=332)
[3]= DefaultAttributeType$Textual (id=333)
[4]= DefaultAttributeType$Textual (id=334)
[5]= DefaultAttributeType$Textual (id=335)
[6]= DefaultAttributeType$Textual (id=336)
[7]= DefaultAttributeType$Numeric (id=337)
[8]= DefaultAttributeType$Numeric (id=338)
[9]= DefaultAttributeType$Numeric (id=339)
[10]= DefaultAttributeType$Textual (id=340)
[11]= DefaultAttributeType$Textual (id=341)
[12]= DefaultAttributeType$Numeric (id=342)
[13]= DefaultAttributeType$Geometric (id=307)
==> in the GML an attribut of this Feature is not set (null)
_*
My question: *_
Where and what can I do to get all Features to the GML-file, also this
Feature with null-attributes ?
Regards,
Greq
*_Source:_*
public void writeShape(DataSource dataSource)
throws Exception
{
FeatureType type = dataSource.getSchema();
String typeName = type.getTypeName();
NullFilter filter =
FilterFactory.createFilterFactory().createNullFilter();
try {
filter.nullCheckValue(FilterFactory.createFilterFactory().createAttributeExpression(type));
org.geotools.data.FeatureReader reader =
DataUtilities.reader(dataSource.getFeatures(filter));
// org.geotools.data.FeatureReader reader =
DataUtilities.reader(dataSource.getFeatures());
// now print out the feature contents (including geometric
attribute)
// create new shapefile data store
ShapefileDataStore newShapefileDataStore = new
ShapefileDataStore(shapefile.toURL());
// create the schema using from the original shapefile
newShapefileDataStore.createSchema(type);
// grab the data source from the new shapefile data store
FeatureSource newFeatureSource =
newShapefileDataStore.getFeatureSource(typeName);
// downcast FeatureSource to specific implementation of
FeatureStore
FeatureStore newFeatureStore = (FeatureStore)newFeatureSource;
// accquire a transaction to create the shapefile from
FeatureStore
Transaction t = newFeatureStore.getTransaction();
// add features got from the query (FeatureReader)
newFeatureStore.addFeatures(reader);
// filteredReader is now exhausted and closed, commit the
changes
t.commit();
t.close();
System.out.println("Successfully create new shapefile ");
} catch (Exception e) {
e.printStackTrace();
}
}
_*Error:*_
org.geotools.data.DataSourceException: Could not create bundeslaender
out of provided feature: bundeslaender.9
at
org.geotools.data.AbstractFeatureStore.addFeatures(AbstractFeatureStore.java:217)
at
net.dmapper.service.shapefile.ShapefileServlet.writeShape(ShapefileServlet.java:124)
at
net.dmapper.service.shapefile.ShapefileServlet.doGet(ShapefileServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: org.geotools.feature.IllegalAttributeException: Wrong number
of attributes expected 15 got 14
at
org.geotools.feature.DefaultFeature.setAttributes(DefaultFeature.java:226)
at
org.geotools.data.AbstractFeatureStore.addFeatures(AbstractFeatureStore.java:215)
... 18 more
*_GML:_*
...
<gml:featureMember>
<topp:bundeslaender fid="bundeslaender.2">
<topp:fips_admin>GM02</topp:fips_admin>
<topp:gmi_admin>DEU-BYR</topp:gmi_admin>
*<topp:admin_name>Bayern</topp:admin_name>*
<topp:fips_cntry>GM</topp:fips_cntry>
<topp:gmi_cntry>DEU</topp:gmi_cntry>
<topp:cntry_name>Germany</topp:cntry_name>
<topp:region>Western Europe</topp:region>
<topp:continent>Europe</topp:continent>
<topp:pop_admin>11750370</topp:pop_admin>
<topp:sqkm_admin>70092.961</topp:sqkm_admin>
<topp:sqmi_admin>27062.891</topp:sqmi_admin>
<topp:type_eng>State</topp:type_eng>
<topp:type_loc>Land</topp:type_loc>
<topp:color_map>6</topp:color_map>
<topp:the_geom>
..........
</topp:the_geom>
</topp:bundeslaender>
</gml:featureMember>
<gml:featureMember>
<topp:bundeslaender fid="bundeslaender.9">
<topp:fips_admin>GM09</topp:fips_admin>
<topp:gmi_admin>DEU-SRL</topp:gmi_admin>
<topp:fips_cntry>GM</topp:fips_cntry>
<topp:gmi_cntry>DEU</topp:gmi_cntry>
<topp:cntry_name>Germany</topp:cntry_name>
<topp:region>Western Europe</topp:region>
<topp:continent>Europe</topp:continent>
<topp:pop_admin>1090716</topp:pop_admin>
<topp:sqkm_admin>2536.979</topp:sqkm_admin>
<topp:sqmi_admin>979.528</topp:sqmi_admin>
<topp:type_eng>State</topp:type_eng>
<topp:type_loc>Land</topp:type_loc>
<topp:color_map>3</topp:color_map>
<topp:the_geom>
.....................
</topp:the_geom>
</topp:bundeslaender>
</gml:featureMember>
...
<mailto:[email protected]>
--
---------------------------------------
WhereGroup GmbH & Co. KG
Siemensstraße 8
53121 Bonn
-------------------------------
Fon: +49 (0)228 / 90 90 38 - 25
Fax: +49 (0)228 / 90 90 38 - 11
-------------------------------
Dipl. Ing. (FH) Gregor Fikoczek
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
http://www.wheregroup.com
-------------------------------
Komplementärin:
WhereGroup Verwaltungs GmbH
vertreten durch:
Arnulf Christl, Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRA 6788
---------------------------------------
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users