X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/56201feb28d8393f26d683e65a42b4daaea8f895..8e5a19b39209f20f41b7bd10ff7dbcdb8a3dcb9c:/lib-sql/functions/utils.sql diff --git a/lib-sql/functions/utils.sql b/lib-sql/functions/utils.sql index 75e83e7f..f8b365c5 100644 --- a/lib-sql/functions/utils.sql +++ b/lib-sql/functions/utils.sql @@ -73,6 +73,26 @@ END; $$ LANGUAGE plpgsql IMMUTABLE; + +CREATE OR REPLACE FUNCTION get_rel_node_members(members JSONB, memberLabels TEXT[]) + RETURNS SETOF BIGINT + AS $$ +DECLARE + member JSONB; +BEGIN + FOR member IN SELECT * FROM jsonb_array_elements(members) + LOOP + IF member->>'type' = 'N' and member->>'role' = ANY(memberLabels) THEN + RETURN NEXT (member->>'ref')::bigint; + END IF; + END LOOP; + + RETURN; +END; +$$ +LANGUAGE plpgsql IMMUTABLE; + + -- Copy 'name' to or from the default language. -- -- \param country_code Country code of the object being named.