view schema/updates/1316/01.search_for_bottleneck_id.sql @ 5082:c4ebb6ccc588 time-sliding

client: start a request for the last changed time on time slider * initiate a refresh layers request when the time for the finished request differs from the selected time on time slider
author Fadi Abbud <fadi.abbud@intevation.de>
date Wed, 18 Mar 2020 14:11:44 +0100
parents 7cbe5d32a614
children
line wrap: on
line source

CREATE OR REPLACE FUNCTION search_bottlenecks(search_string text) RETURNS jsonb
  LANGUAGE plpgsql STABLE PARALLEL SAFE
  AS $$
DECLARE
  _result jsonb;
BEGIN
  SELECT COALESCE(json_agg(r),'[]')
    INTO _result
    FROM (SELECT objnam AS name,
                 ST_AsGeoJSON(ST_Envelope(area::geometry))::json AS geom,
                 'bottleneck' AS type,
                 bottleneck_id AS location
            FROM waterway.bottlenecks
            WHERE (objnam ILIKE '%' || search_string || '%'
                   OR bottleneck_id ILIKE '%' || search_string || '%')
              AND validity @> now()
          ORDER BY name) r;
  RETURN _result;
END;
$$;