Hi,
this is probably caused by the fact that JTS uses double-precision floating
point.
You can test that, reducing precision with ST_SnapToGrid in your postgis
table.
Fred.
On Wed, Jan 4, 2012 at 10: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.3862893*8* 5608697.43804972, -4931658.38628938
> 5608697.43804972)), ((-4947166.3816637*4* 5555710.74141808,
> -4947166.38166466 5555710.74141493, -4947166.38166467 5555710.74141491,
> -4947166.38166467 5555710.74141491, -4947166.3816637*4*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 thank you in advance for your help,
>
> Regards,
> Emmanuel
>
>
>
>
>
> ------------------------------------------------------------------------------
> 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
>
>
------------------------------------------------------------------------------
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