NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi

I would like to fix simple mistakes in the opening_hours tag based on regular expressions but only if it is clear what they mean … One example (second example on the key page) is opening_hours=0600-1800 → opening_hours=06:00-18:00.

An example Python script looks like this:

#!/usr/bin/env python
# encoding: utf-8

import re

wrong = '1200-2300'

regex = re.compile(r'\A(?P<start_hour>[0-1][0-9]|2[0-4])(?P<start_min>[:1-5][0-9]|0[0-9])\s*(?P<sep>-)\s*(?P<end_hour>[0-1][0-9]|2[0-4])(?P<end_min>[:1-5][0-9]|0[0-9])\Z')

re_object = re.search(regex, wrong)
bot_right_val = '%s:%s%s%s:%s' % (
        re_object.group('start_hour'), re_object.group('start_min'),
        re_object.group('sep'),
        re_object.group('end_hour'), re_object.group('end_min')
        )
print '%s -> %s' % (wrong, bot_right_val)

I would like to automate this task a little bit more to avoid chancing this by hand. How can I integrate this script to JOSM? I can already load all wrong values matching this regex with regex_search.py in JOSM.

asked 02 Mar '14, 15:11

ypid's gravatar image

ypid
106237
accept rate: 0%

3

Just in case you do not know it yet: Automated Edits code of conduct. Your idea sounds like this applies.

(02 Mar '14, 15:45) aseerel4c26 ♦

@aseerel4c26 I already read this page. Thanks for the hint. The problem is that I did not really find a description about how to do it. I thought about writing a Xybot rule file but I wanted to test this first in a simple way.

(02 Mar '14, 15:53) ypid

The only 'simple' way I came up with is to download all occurrences of a tag in JOSM, save the .osm file, parse and change the file, load the file back to JOSM, upload the file.

(02 Mar '14, 15:55) ypid
2

Okay, fine. So, before you are doing large scale edits, please discuss them (not on this help site).

(02 Mar '14, 15:56) aseerel4c26 ♦

JOSM has a scripting plugin which supports scripts of various languages. The quality assurance script is a great example for this interface.

permanent link

answered 02 Mar '14, 16:36

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

edited 02 Mar '14, 16:43

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

this sounds like the better way. ;-)

(02 Mar '14, 16:40) aseerel4c26 ♦

Thanks. I might check that out in detail later. For now I will go with the .osm file script variant because I feel more confident in this area.

(02 Mar '14, 16:48) ypid

if you want to use JOSM, my newbie and basic idea (this may be the worst possible way) would be to edit a .osm/JOSM file:

  1. Download the data into a .osm file
  2. change the file with your script (just look into a .osm file which contains changes made by JOSM to see how JOSM saves changes - or see the format description, link above)
  3. open and upload with JOSM
permanent link

answered 02 Mar '14, 15:53

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554
accept rate: 18%

edited 02 Mar '14, 16:04

I guess this is the way to go.

(02 Mar '14, 15:57) ypid
2

Started to write the script: https://github.com/ypid/opening_hours_bot

(02 Mar '14, 16:48) ypid
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×622
×78
×10
×6

question asked: 02 Mar '14, 15:11

question was seen: 4,256 times

last updated: 02 Mar '14, 16:48

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum