X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6ad397d4a971820e06ea4117e8fe8372e8bba17f..5b02cd22b9d9bdf9d3cd32d9e4cfcb971a92c606:/lib-sql/functions/utils.sql diff --git a/lib-sql/functions/utils.sql b/lib-sql/functions/utils.sql index ff2f037d..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. @@ -416,6 +436,20 @@ END; $$ LANGUAGE plpgsql IMMUTABLE; +CREATE OR REPLACE FUNCTION simplify_large_polygons(geometry GEOMETRY) + RETURNS GEOMETRY + AS $$ +BEGIN + IF ST_GeometryType(geometry) in ('ST_Polygon','ST_MultiPolygon') + and ST_MemSize(geometry) > 3000000 + THEN + geometry := ST_SimplifyPreserveTopology(geometry, 0.0001); + END IF; + RETURN geometry; +END; +$$ +LANGUAGE plpgsql IMMUTABLE; + CREATE OR REPLACE FUNCTION place_force_delete(placeid BIGINT) RETURNS BOOLEAN