This follows on from my recent entry where I showed how I made it easier to map a large circular feature by generating a .osm
file from a script.
A short while ago, I mapped a cluster of houses based on measurements made on the ground. Getting them all lined up correctly and positioned right was quite fiddly and it took a fair bit of time to do it. Once it was rendered in mapnik, I realised that JOSM's angles, measurements and orthogonalise tool, while giving me nice rectangular shapes on the screen in the default JOSM projection, were all wrong - I should have selected Mercator in the JOSM preferences.
So to generalise my earlier method of producing a .osm
file, I needed a really quick and simple way to describe nodes and ways in a script. For this, I decided to use the old turtle graphics method. I could have implemented a few functions for this in python or stuck with the zsh script I already had but it seemed more fun to use logo - the definitive language for turtle graphics. It also turned out to be a fairly easy language to implement it in. And an advantage of using logo is that I can simply comment out the line which says load mapturtle and the same script will draw the house outlines in a graphics window.
Now to map an 6½ by 12 metre house, I can do:
repeat 2 [ forward 6.5 right 90 forward 12 right 90 ]
It's easy to offset it at a strange angle and then place the next house at an exact distance from the first. I was able to remap the cluster of houses much more quickly than when originally putting them in using JOSM.
The source is a little too long to quote here so mail me if you'd like a copy or know of a suitable place to host it. I used ucblogo on Linux but it should work with other logo interpreters. If other people are interested we could perhaps look at making a JOSM plugin.
… 查看完整日记文章