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

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.