Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete undesired tags with Lua transform #268

Closed
pnorman opened this issue Jan 27, 2015 · 5 comments
Closed

Delete undesired tags with Lua transform #268

pnorman opened this issue Jan 27, 2015 · 5 comments

Comments

@pnorman
Copy link
Collaborator

pnorman commented Jan 27, 2015

The C tag transform can drop tags like created_by, odbl, note, source, tiger:* and others specified in the style file. The sample Lua transform, style.lua, should do the same.

The following Lua might be helpful

delete_tags = {'INT-*', 'note', 'note:*', 'source', 'source_ref', 'source:*',
               'attribution', 'comment', 'fixme', 'created_by', 'odbl',
               'odbl:note', 'SK53_bulk:load', 'tiger:*', 'NHD:*', 'nhd:*',
               'gnis:*', 'geobase:*', 'accuracy:meters', 'sub_sea:type',
               'waterway:type', 'KSJ2:*', 'yh:*', 'osak:*', 'kms:*', 'ngbe:*',
               'naptan:*', 'CLC:*', '3dshapes:ggmodelk', 'AND_nosr_r',
               'import', 'it:fvg:*'}
function preprocess_tags (kv)
  tags = {}
  for k, v in pairs (kv) do
    match = false
    for _, d in ipairs(delete_tags) do
      match = match or string.find(k, d)
    end
    if not match then
      tags[k] = v
    end
  end
end

It takes num tags * num deletes iterations through the loop, but does short-circuit the string.find call if it's already matched a delete.

@lonvia
Copy link
Collaborator

lonvia commented Jan 27, 2015

Isn't that done here already?

@pnorman
Copy link
Collaborator Author

pnorman commented Jan 27, 2015

Isn't that done here already?

Ah, I had missed that.

Kind of - there are two differences from the C transforms. The first is it uses a different list, which is easily fixed. The second is that the method used (setting specific keys to nil) doesn't work for wildcards.

@lonvia
Copy link
Collaborator

lonvia commented Jan 27, 2015

Indeed, I overlooked those wildcards. I always wonder if we shouldn't compile a huge reqex for such a case. Anyways, as you have only two cases, fullmatch and startswith, I'd probably split that in two steps, first deleting the full matches as done in the current style and then check for a match as the beginning with the double loop (although with an early break as soon as a match is found). But that might all be overoptimising, it might not really matter because the lua execution is insignificant compared to everything else that happens.

@pnorman
Copy link
Collaborator Author

pnorman commented Jan 27, 2015

it might not really matter because the lua execution is insignificant compared to everything else that happens

yes - provided you don't go the tag delete code for untagged nodes.

My code snippet doesn't quite work - I screwed up the patterns.

@joto
Copy link
Collaborator

joto commented May 27, 2021

This is outdated, we will not do any larger changes on the pgsql output. The flex output has provisions for dropping tags.

@joto joto closed this as completed May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants