local schema = os.getenv("PGSCHEMA") or "public"

local tables = {}

tables.pois = osm2pgsql.define_node_table(
  'osm_pois',
  {
    { column = 'name', type = 'text' },
    { column = 'type', type = 'text' },
    { column = 'tags', type = 'jsonb' },
    { column = 'geom', type = 'point', not_null = true }
  },
  {
    schema = schema,
    proj = 3301
  }
)

function osm2pgsql.process_node(object)
  local tags = object.tags
  local poi_type = tags.amenity or tags.shop or tags.tourism or tags.office or tags.leisure

  if not poi_type then
    return
  end

  tables.pois:insert({
    name = tags.name,
    type = poi_type,
    tags = tags,
    geom = object:as_point()
  })
end
