|
| Geometry column data format & OGC's WKTs |
 |
Tue, 05 Jun 2007 04:31:49 EDT |
Hi David and others!
I'm trying to read db2 spatial data by geotools and get the exception
org.geotools.data.DataSourceException: Could not parse WKT
at
org.geotools.data.jdbc.attributeio.WKTAttributeIO.read(WKTAttributeIO.java:82)
at org.geotools.data.jdbc.QueryData.read(QueryData.java:191)
at
org.geotools.data.jdbc.JDBCFeatureReader.readFeature(JDBCFeatureReader.java:107)
at org.geotools.data.jdbc.JDBCFeatureReader.next(JDBCFeatureReader.java:88)
As I understand, geotools could not parse data from spatial column.
Why?
I imported data from shape (http://mappinghacks.com/data/world_borders.zip)
by typing db2se import_shape TEST -userId rov -pw *** -fileName
world_borders.shp -srsName "WGS84_SRS_1003" -tableName wb1
-createTableFlag 1 -spatialColumn the_geom
I see it from David's DB2FeatureSourceTest.java that FeatureSource should
iterrate Features properly
..
featureSource = dataStore.getFeatureSource(featureName);
features = featureSource.getFeatures();
it = features.iterator();
while (it.hasNext()) {
Feature f = (Feature) it.next();
...
}
David would you please give a hint as what to do abouit it?
|
| Post Reply
|
| Re: Geometry column data format & OGC's WKTs |
 |
Tue, 05 Jun 2007 04:46:21 EDT |
exception occurs here
->return getWKTReader().read(wkt);
and wkt is
|
| Post Reply
|
| Re: Geometry column data format & OGC's WKTs |
 |
Tue, 05 Jun 2007 07:04:51 -040 |
I will take a look.
You could also try importing the shapefile as ST_Polygon instead of
ST_MultiPolygon which is the default for shapefiles as the shapefile
does not distinguish between single and multi-part geometries. In most
but not all cases, the shapefile is actually single-part geometries.
After the spatial column name in the import_shape command add the
parameters:
-typeSchema db2gse
-typeName st_polygon
David
rov@mail.ru wrote:
> Hi David and others!
> I'm trying to read db2 spatial data by geotools and get the exception
> org.geotools.data.DataSourceException: Could not parse WKT
> at
org.geotools.data.jdbc.attributeio.WKTAttributeIO.read(WKTAttributeIO.java:82)
> at org.geotools.data.jdbc.QueryData.read(QueryData.java:191)
> at
org.geotools.data.jdbc.JDBCFeatureReader.readFeature(JDBCFeatureReader.java:107)
> at
org.geotools.data.jdbc.JDBCFeatureReader.next(JDBCFeatureReader.java:88)
>
> As I understand, geotools could not parse data from spatial column.
> Why?
>
> I imported data from shape
(http://mappinghacks.com/data/world_borders.zip)
> by typing db2se import_shape TEST -userId rov -pw *** -fileName
world_borders.shp -srsName "WGS84_SRS_1003" -tableName wb1
-createTableFlag 1 -spatialColumn the_geom
>
> I see it from David's DB2FeatureSourceTest.java that FeatureSource should
> iterrate Features properly
> ..
> featureSource = dataStore.getFeatureSource(featureName);
> features = featureSource.getFeatures();
> it = features.iterator();
> while (it.hasNext()) {
> Feature f = (Feature) it.next();
> ...
> }
>
>
> David would you please give a hint as what to do abouit it?
>
|
| Post Reply
|
| Re: Geometry column data format & OGC's WKTs |
 |
Tue, 05 Jun 2007 07:40:49 EDT |
wkt parser doesnt like ',' instead of '.' it seems
bad wkt : MULTIPOLYGON (((-69,8822331 12,4111101, -69,8761140 12,4116650,
-69,8733370 12,4158329, ...
good wkt: MULTIPOLYGON (((-69.8822331 12.4111101, -69.8761140 12.4116650,
-69.8733370 12.4158329, ...
I made some patch work at org.geotools.data.jdbc.attributeio.WKTAttributeIO so
it works
public Object read(ResultSet rs, int position) throws IOException {
try {
String wkt = rs.getString(position);
if (wkt == null || wkt.equals("")) {
return null;
}
//ROV APPENDS
wkt = make_good_wkt(wkt);
//============
return getWKTReader().read(wkt);
} catch (SQLException e) {
throw new DataSourceException("Sql reading problem", e);
} catch (ParseException e) {
throw new DataSourceException("Could not parse WKT", e);
}
}
|
| Post Reply
|
| Re: Geometry column data format & OGC's WKTs |
 |
Wed, 06 Jun 2007 09:12:07 -040 |
This looks like a locale problem if the numbers in the WKT are using ','
as the decimal delimiter and ',' is also the coordinate pair delimiter.
I thought we had fixed this but will take another look.
Oleg R wrote:
> wkt parser doesnt like ',' instead of '.' it seems
> bad wkt : MULTIPOLYGON (((-69,8822331 12,4111101, -69,8761140 12,4116650,
-69,8733370 12,4158329, ...
> good wkt: MULTIPOLYGON (((-69.8822331 12.4111101, -69.8761140 12.4116650,
-69.8733370 12.4158329, ...
>
> I made some patch work at org.geotools.data.jdbc.attributeio.WKTAttributeIO
so it works
>
> public Object read(ResultSet rs, int position) throws IOException {
> try {
> String wkt = rs.getString(position);
> if (wkt == null || wkt.equals("")) {
> return null;
> }
> //ROV APPENDS
> wkt = make_good_wkt(wkt);
> //============
> return getWKTReader().read(wkt);
> } catch (SQLException e) {
> throw new DataSourceException("Sql reading problem",
e);
> } catch (ParseException e) {
> throw new DataSourceException("Could not parse WKT",
e);
> }
> }
>
|
| Post Reply
|
|
|
|
|
|
|
|
|
|