[postgis-users] massive snap of points of one geometry to points of another geometry

Jose C. Martinez-Llario jomarlla at cgf.upv.es
Tue Nov 16 04:18:12 PST 2010

Hi all,
JASPA has a ST_SNAP function using JTS function. I guess with GEOS 
should be similar.
You can snap the segments and vertex of a geometry to the vertex of 
anotther one.


Anyways, in my opinion this algorithm should be modified a little bit to 
use in a spatial database using real cartography.
Some interesting comments from Martin Davis to my question  in the jts list.


In JASPA 0.2 (maybe around march) a new system with topology rules and I 
think a tolerance system will be introduced.
Hope it helps,

public static Geometry ST_Snap(Geometry geom0, Geometry geom1, double 
tolerance) throws JASPAJTSException, JASPAGeomMismatchException {
         if (GeomProperties.errorIfDifferentSRIDorCoorDim (geom0, 
geom1)) return null;

         GeometrySnapper snapper = new GeometrySnapper(geom0);
         Geometry res = null;
         try {
             res = snapper.snapTo(geom1, tolerance);
             Geometry[] snapped = GeometrySnapper.snap(geom0, geom1, 
             if (snapped == null || snapped.length < 2) return null;

             Geometry res = snapped[0];
         } catch (RuntimeException e) {
             //Catch the runtime JTS Exceptions

         return res;

El 16/11/2010 13:04, Jan Hartmann escribió:
> On 11/15/10 18:03, strk wrote:
>> The function exists within GEOS, which is a library used by PostGIS.
>> But the specific functionality (snapping) isn't exposed in SQL yet.
>> What you could do is implement or fund implementation of
>> the missing bit (the wrapper).
> I've always found snapping a very important function in all kinds of 
> (carto)graphic environments. Could you give an indication how much 
> time it would cost to write the PostGIS wrappers? If the algorithm 
> already exists in GEOS, exposing it in PostGIS doesn't look like a 
> major problem to me.
> Jan
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

More information about the postgis-users mailing list