CREATE OR REPLACE FUNCTION osm_set_speedlimit(varchar) RETURNS smallint AS $$
DECLARE
	highway ALIAS FOR $1;
BEGIN
	IF highway = 'access' THEN
		RETURN 0;
	ELSIF highway = 'bridleway' THEN
		RETURN 10;
	ELSIF highway = 'construction' THEN
		RETURN 0;
	ELSIF highway = 'conveyor' THEN
		RETURN 0;
	ELSIF highway = 'cycleway' THEN
		RETURN 0;
	ELSIF highway = 'footway' THEN
		RETURN 0;
	ELSIF highway = 'living_street' THEN
		RETURN 30;
	ELSIF highway = 'motorway' THEN
		RETURN 110;
	ELSIF highway = 'motorway_link' THEN
		RETURN 90;
	ELSIF highway = 'none' THEN
		RETURN 0;
	ELSIF highway = 'path' THEN
		RETURN 0;
	ELSIF highway = 'pedestrian' THEN
		RETURN 0;
	ELSIF highway = 'primary' THEN
		RETURN 90;
	ELSIF highway = 'primary_link' THEN
		RETURN 70;
	ELSIF highway = 'proposed' THEN
		RETURN 0;
	ELSIF highway = 'raceway' THEN
		RETURN 0;
	ELSIF highway = 'residential' THEN
		RETURN 30;
	ELSIF highway = 'road' THEN
		RETURN 60;
	ELSIF highway = 'secondary' THEN
		RETURN 50;
	ELSIF highway = 'secondary_link' THEN
		RETURN 50;
	ELSIF highway = 'service' THEN
		RETURN 0;
	ELSIF highway = 'steps' THEN
		RETURN 0;
	ELSIF highway = 'tertiary' THEN
		RETURN 50;
	ELSIF highway = 'tertiary_link' THEN
		RETURN 50;
	ELSIF highway = 'track' THEN
		RETURN 0;
	ELSIF highway = 'trunk' THEN
		RETURN 30;
	ELSIF highway = 'trunk_link' THEN
		RETURN 30;
	ELSIF highway = 'unclassified' THEN
		RETURN 0;
	ELSIF highway = 'unsurfaced' THEN
		RETURN 0;
	END IF;
	RETURN NULL;
END;
$$ LANGUAGE plpgsql;
