lib/enrichment_db/geo/region.rb in enrichment_db-0.1.10 vs lib/enrichment_db/geo/region.rb in enrichment_db-0.1.11

- old
+ new

@@ -30,16 +30,24 @@ puts "Finding #{object_type} intersecting with some geohash" field_names = fields table = make_table_name query = "SELECT #{field_names} FROM #{DATABASE_NAME}.#{table} where ST_Within(ST_SetSRID(ST_GeomFromGeoHash($1), 4283), boundary)" - result = EnrichmentDb.request(DATABASE_NAME, query, values) - if result.ntuples == 1 - puts "Found #{object_type}" - result[0] - else - puts "Nothing found" - nil + begin + result = EnrichmentDb.request(DATABASE_NAME, query, values) + + if result.ntuples == 1 + puts "Found #{object_type}" + result[0] + else + puts "Nothing found" + nil + end + rescue PG::InternalError => e + # This usually is GEOSContains: TopologyException: side location conflict at #{lat} #{long} + LexerAPI.error e.class + LexerAPI.error e.message + return nil end end private