OpenStreetMap

M!dgard's Diary

Recent diary entries

Multiple user accounts in JOSM

Posted by M!dgard on 5 July 2023 in English. Last updated on 6 July 2023.

I started taking on mapping commissions and I want to do those with a different user account. JOSM doesn’t have built-in support for multiple user accounts, so I created a script for it that lets me switch without pain. It works on a typical Linux setup or other *NIXes such as macOS, not on Windows.

It modifies JOSM’s preferences.xml file to change your credentials, and then launches JOSM. You create one copy of this script for each OSM user account, and run those instead of launching JOSM the normal way.

I created two files with this script in a directory in my PATH and made them executable: once as ~/.local/bin/josm and once as ~/.local/bin/josm_commissioned. For Linux desktops: If you want, you can also create .desktop files in ~/.local/share/applications so you can run these scripts easily from your main menu or launcher. Feel free to share those in the comments!

Find the OAuth key and secret in JOSM’s preferences XML file, and fill them in in the script. Especially for macOS, you may need to change the JOSM_PREFS and JOSM_EXECUTABLE paths.

#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
IFS=$'\n'

OAUTH_KEY=changeme3G45hi67Jkl8mn901op2qR3st4U5vw8X
OAUTH_SECRET=changeme3G45hi67Jkl8mn901op2qR3st4U5vw8X
JOSM_PREFS="$HOME/.josm/preferences.xml"
JOSM_EXECUTABLE="/usr/bin/josm"

notify() {
	echo "$1" >&2
	if which wl-overlay >/dev/null 2>&1; then
		# https://git.sr.ht/~midgard/wl-overlay/
		wl-overlay --time=1000 "" "$1"
	elif which notify-send >/dev/null 2>&1; then
		# freedesktop.org
		notify-send -t 1000 "$1"
	elif which osascript >/dev/null 2>&1; then
		# macOS
		osascript -e "display alert \"$1\""
	fi
}

if ps ax | grep -i '[j]ava -jar .*josm'; then
	notify "JOSM still running"
	exit 1
fi

sed "
	s+<tag key='oauth\\.access-token\\.key' value='[0-9a-zA-Z]*'/>+<tag key='oauth.access-token.key' value='$OAUTH_KEY'/>+
	s+<tag key='oauth\\.access-token\\.secret' value='[0-9a-zA-Z]*'/>+<tag key='oauth.access-token.secret' value='$OAUTH_SECRET'/>+
	" "$JOSM_PREFS" > "${JOSM_PREFS}.new" && mv "${JOSM_PREFS}.new" "$JOSM_PREFS"

"$JOSM_EXECUTABLE" "$@"

A fast workflow for taking and processing personal survey notes

Posted by M!dgard on 31 December 2019 in English. Last updated on 2 August 2023.

Taking private notes on a survey with OsmAnd and processing them with JOSM is a breeze. Here’s how.

With this workflow you’re able to enter geo-referenced text while surveying and copy-paste it in JOSM. I do this to i.a. enter opening hours on the go.

tl;dr: Create quick actions in OsmAnd to create notes. Don’t upload, but export the notes as GPX. Open in JOSM, convert to data layer. Remove a note node when it’s done. Remove all notes in OsmAnd.

Personal notes?

If you don’t choose to upload your notes, they stay private.

Setting up OsmAnd

  1. Enable the OSM editing plugin. (main menu → Plugins → tap the icon for OSM editing, it turns orange)
  2. Enable quick actions. (main menu → Configure screen → switch Quick action to on)
  3. Add a quick action for “add note”. (quick action → Add actionAdd OSM note → switch Show interim dialog to on, leave message empty)

To save typing on things you add a lot, also add one-click quick actions for them. (Create a quick action like before, but switch interim dialog to off, and fill in a message.) I have those set up for bicycle parkings with the standard capacities that can be found all around Ghent: 5, 10 and 15. For non-standard parkings I can still create a manual note.

After surveying

On the device with OsmAnd

  1. Export your notes as GPX. (main menu → My placesOSM edits → share icon → All dataGPX file)
  2. A “share” menu will pop up to send the result somewhere. Get the file to your computer somehow. Some suggestions:

On your computer

  1. Open the GPX file in JOSM. Your notes will appear as pink markers with the text written next to them. (FileOpen… → locate and double-click the file)
  2. Discard the GPX layer but not the markers layer. (sidepanel Layers → right-click the .gpx layer → Delete)
  3. Convert the markers layer to an OSM data layer. (sidepanel Layers → right-click the markers layer → Convert to data layer → acknowledge the “don’t upload raw traces to OSM” warning → Proceed without simplifying)
  4. Create a new data layer. (FileNew Layer) Download data into it to start editing.
  5. Activate the layer with your todos to copy text, and the one with the OSM data to edit. Switch back and forth between these as needed. Delete a node from the todo layer when you’ve done it.

When you download data, make sure to do it in the data layer, and not in the todo layer!

Removing the notes in OsmAnd

It’s fast and easy: main menu → My placesOSM edits → trash icon → check the checkbox at the top. All notes are now selected. If you confirm the deletion, your map is clean again.

Alternative: favourites

You can do the exact same workflow using favourites instead of notes. This has certain advantages:

  • you can’t accidentally upload them and
  • you can categorize your todos.

For me those are outweighed by the disadvantages:

  • OsmAnd will complain about “favourite name already in use”,
  • favourite lists get long, such as when picking a destination from your favourites and
  • the favourite creation screen auto-fills the address, which takes some time to compute.

So I use the notes approach, though I do keep my “to survey if nearby” notes in a dedicated favourite category.


Shout out to Pieter whose diary post inspired the first part of this one! Thanks to s8evq for pointing out the alternative with favourites.

Removing phone booths in Belgium

Posted by M!dgard on 28 July 2015 in English. Last updated on 6 January 2019.

Update: The mechanical edit described in this diary entry has been discussed on the Belgian mailing list. You should never do an edit like this without prior consultation with and consent of the relevant community/communities. Also make sure to read the Automated Edits code of conduct if you plan on making an automated edit. OpenStreetMap is generally not welcoming those, even when they follow all rules.

All Belgacom/Proximus telephone booths in Belgium are removed from the streets. With changeset #32926155 those that had operator=Belgacom or Proximus have also been removed from OSM.

The remaining phone booths before their removal. Most of them are near Brussels.

I used the following Overpass query:

/* Find all Belgacom/Proximus phone booths in bbox */
(
  node[amenity=telephone][operator~"[Bb]elgacom|[Pp]roximus"]({{bbox}});
  <;
  >;
);

out meta qt;

This fetched all phone booths and also any ways they are connected to. No relations were matched, which was good. Then, in JOSM, I did the following searches to obtain phone booths that are member of a way:

  • type:way (no phone booths were tagged as ways)
  • amenity=telephone child selected

I removed all tags on those 4 nodes.

Then I searched all remaining amenity=telephones and removed the nodes.

Some stats:

  • There were 320 Belgacom/Proximus phone booths left in OSM in Belgium.
  • 316 had operator=Belgacom, 2 belgacom and 2 Belgacom NV
  • 3 phone booths had covered=yes, 1 had covered=no.

Note that at the time of writing there are still 320 other amenity=telephones left in Belgium. (Exactly the same number as I removed!) They haven’t been tagged with operator=Belgacom and should be manually surveyed and removed if necessary.

You are invited to add a note like verified that this phone still exists 2015-07-28 to any phones that you have surveyed, to prevent mappers from armchair-mapping them away. (They shouldn’t, but just to be sure.) An operator tag is appreciated as well.

Search for amenity=telephones in Belgium

/* Find all phone booths in Belgium */
area["name:en"="Belgium"]->.belgium;
(
  node(area.belgium)[amenity=telephone];
);

out qt;

Public transport

Posted by M!dgard on 30 November 2013 in English.

How should bus lines be mapped?

In 2011, this scheme was approved and according to the proposal page it is active. I took the time to learn it and I tried it out, but as far as I can tell, it is not supported well.

Apparently the wiki proposal page has not been cleaned up and not all of the information on it has been put on the page about public transport. I find this situation to be confusing.

If you know more about how to tag public transport or want to share thoughts, please contact me on my wiki talk page.

Location: 8000, West Flanders, Flanders, 8000, Belgium