Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Using ST_Contains in where clause sometimes gives me error messages like

ERROR: GEOSContains: TopologyException: side location conflict at 37.3706 55.7882

For now I can't guarantee validity for every geometry in DB, using third-party import tools, so I just catch every exception:

CREATE OR REPLACE FUNCTION safe_st_contains(geom1 geometry, geom2 geometry)
  RETURNS BOOL AS
  $$
  BEGIN
    RETURN ST_Contains($1, $2);
    EXCEPTION WHEN others THEN
      RAISE NOTICE 'TopologyException'; -- this is a guess
      RETURN FALSE;
  END;
  $$
LANGUAGE plpgsql;

I'd like to know where exceptions like TopologyException really belong and which exception conditions should I use instead of OTHERS ?

share|improve this question

1 Answer 1

Best I could find by briefly looking at the PostGIS code was, that these kind of exceptions are raised by GEOS. So I would recommend you to look at their wiki, sources etc. like http://trac.osgeo.org/geos/wiki/TopologyExceptions

share|improve this answer
    
Here's how you can search the source for "TopologyException" –  Mike T Aug 31 at 21:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.