On Wed, Jan 4, 2012 at 11:43 AM, Emmanuel Blondel
<[email protected]> wrote:
> Dear all,
>
> I am facing an issue with geometry validation.
>
> I have a PostGIS table for which I tested geometry validity with GEOS
> st_isValid(), all geometries are valid. I published this PostGIS table in
> Geoserver and I use this layer in a model based on Geotools/JTS, retrieving
> the features using WFS Datastore plugin.
>
> - I retrieved the features from WFSDatastore, and before applying any
> geo-process, I set a control of geometry validity using the JTS method
> isValid(). According to JTS, some geometries are not valid, while they are
> valid according to GEOS st_isValid() in PostGIS. I tried to focus on the
> issue, and tested one geometry using WKT:
>
> String wkt = "MULTIPOLYGON(((-4931658.38628938
> 5608697.43804972,-4931658.38629031 5608697.43804656,-4931658.38628939
> 5608697.43804972,-4931658.38628938 5608697.43804972)),((-4947166.38166375
> 5555710.74141808,-4947166.38166466 5555710.74141493,-4947166.38166467
> 5555710.74141491,-4947166.38166467 5555710.74141491,-4947166.38166375
> 5555710.74141808)))";
>
> GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null
> );
> WKTReader reader = new WKTReader( geometryFactory );
> Geometry geom = reader.read(wkt);
> System.out.println(geom.isValid());
>
> Getting a geometry from WKT, I can see that both GEOS and JTS return true,
> so it seems the issue is related to GeoTools WFSdatastore.
>
> - Hereafter the wkt string of the geometry retrieved from WFS, which indeed
> is a bit different.
>
> MULTIPOLYGON (((-4931658.38628938 5608697.43804972, -4931658.38629031
> 5608697.43804656, -4931658.38628938 5608697.43804972, -4931658.38628938
> 5608697.43804972)), ((-4947166.38166374 5555710.74141808, -4947166.38166466
> 5555710.74141493, -4947166.38166467 5555710.74141491, -4947166.38166467
> 5555710.74141491, -4947166.38166374 5555710.74141808)))
>
> This small difference makes the geometry invalid.
>
> I know that to make valid a geometry, I can apply a buffer, but I would like
> to avoid this and know if such issue could be solved in WFSdatastore, so to
> ensure that the geometry retrieved from WFS  is exactly the same as in the
> initial geometry in PostGIS.
>
> ==================
> Here the versions I am using:
> - select postgis_full_version(): "POSTGIS="1.5.3" GEOS="3.3.1-CAPI-1.7.1"
> PROJ="Rel. 4.6.1, 21 August 2008" LIBXML="2.7.8" USE_STATS"
> - Geoserver 2.1.3
> - Geotools library / WFS datastore plugin - version 8.0-M4

I'm wondering where the loss of procision is happening. There could be several
places:
- as the geometry is read from the database in wkb form
- as the geometry is turned into GML
- as the gml is read by the wfs datastore

Did you try manually checking the GML produced by GeoServer?
Also, have you tried changing the number of decimals generated by
Geoserver? It's part of the global settings, equal to 8 by default

Cheers
Andrea


-- 
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:      +39 0584 962313
mob:    +39 339 8844549

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to