osm_pois.lua 683 B

123456789101112131415161718192021222324252627282930313233
  1. local schema = os.getenv("PGSCHEMA") or "public"
  2. local tables = {}
  3. tables.pois = osm2pgsql.define_node_table(
  4. 'osm_pois',
  5. {
  6. { column = 'name', type = 'text' },
  7. { column = 'type', type = 'text' },
  8. { column = 'tags', type = 'jsonb' },
  9. { column = 'geom', type = 'point', not_null = true }
  10. },
  11. {
  12. schema = schema,
  13. proj = 3301
  14. }
  15. )
  16. function osm2pgsql.process_node(object)
  17. local tags = object.tags
  18. local poi_type = tags.amenity or tags.shop or tags.tourism or tags.office or tags.leisure
  19. if not poi_type then
  20. return
  21. end
  22. tables.pois:insert({
  23. name = tags.name,
  24. type = poi_type,
  25. tags = tags,
  26. geom = object:as_point()
  27. })
  28. end