DROP TABLE IF EXISTS links;

CREATE UNLOGGED TABLE links AS
SELECT
  h.id,
  h.source,
  h.target,
  h.hwtype AS highway,
  h.surface,
  h.oneway,
  h.maxspeed,
  ST_Length(h.geom) AS length,
  COALESCE(NULLIF(h.name, ''), NULLIF(h.hwtype, ''), 'Unnamed road') AS name,
  h.geom AS geometry
FROM ardok_highways h;

CREATE INDEX links_geom_idx ON links USING GIST (geometry);
