[postgis-users] Distance constraints on spatial points

fork forkandwait at gmail.com
Tue May 3 16:18:13 PDT 2011


Sairam Krishnamurthy <kmsram420 <at> gmail.com> writes:

> 
> Thanks. But how do I specify the code to raise an error if the distance is 
> not met ? 

You probably want to write a PLPGSQL function with a SELECT statement that
returns the min(st_distance(NEW.the_geom, a.the_geom)), and raise an exception
if it is below a certain amount.  You might need to multiply by constants to get
the return value into your prefered units. Then you need to set up a trigger to
call it on an insert.

If you don't know how to write PLPGSQL, you need to learn ;)... or maybe
somebody else can help with example code, but even more or less knowing how to
do it, it would take me an hour to write working code, and I cant spare the time
(tho it would be fun).

Or you need to ask a more specific question after posting the code you have
tried -- that would be best.





More information about the postgis-users mailing list