 	FROM roadsnodesinorder
 	GROUP BY node_id
 	/* bool_or is needed, because we are interested in nodes that are endpoints in *at least one* road */
+	/* RKM: Only 1 road_id, so IS the bool_or really needed?? Should be just one node. */
 	HAVING COUNT(road_id) = 1 AND bool_or(is_endpoint) IS TRUE
 
 	UNION

	Append items from the 'planet_osm_point' table with the 'bus_stop' value in the highway field.
*/ 

INSERT INTO poimplist
	SELECT
		planet_osm_point.osm_id as node_id, planet_osm_point.way as geom

  USING gist
  (the_geom);

/* RKM: Why not add the region_id column when creating the table? */

ALTER TABLE tmppoimp2 ADD COLUMN region_id integer;

/*	At first, the function has a top-down step, in which regions are formed.
	Each region includes POImps that all of them are isolated from other regions (distance > radius) but can form clusters.
	Thus, calculations are performed for items of the same region only.
*/

DROP TABLE IF EXISTS poimpregions;

/* RKM: This is where we stopped 26.2.2015. */

CREATE TEMPORARY TABLE poimpregions AS
	SELECT ST_Dump(ST_UNION(ST_Buffer(tmppoimp2.the_geom,radius))) as dump
