開放街圖標誌 OpenStreetMap 開放街圖

Opk 的日記

最近的日記項目

Using turtle graphics to map buildings

於 2010年八月23日 由 OpkEnglish發表。

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.

查看完整日記項目

Mapping large circular features

於 2010年八月10日 由 OpkEnglish發表。 上一次更新在 2010年八月23日。

I recently looked at improving the very basic map data for the Waldfriedhof in Darmstadt - a large circular cemetery.

When creating a circle using JOSM, you get an octagon. This is fine for roundabouts but for anything larger the wiki tells you to to put a few extra nodes in and then select align nodes in circle. This isn't very precise - start with a 600 metre line, turn it into an octagonal "circle", add another 8 nodes, align in a circle and then measure the diameter. It comes out as about 578 metres. I needed it to be precise because there are paths closely following both sides of the perimeter fence.

So to get a much better circle, I first created an octagon, did a copy and paste to get a second octagon. I placed this exactly over the first octagon and rotated it. Adding lines across the octagon can help with accurate positioning. I then repeated the process again, copying both octagons together to get 32 nodes total. It is then possible to draw a 32 sided "circle" manually through these nodes and delete the four octagons.

At this point, I discovered that the cemetery is actually very slightly egg shaped. This is hard to spot because the lower half tapers into a rectangle. I was about to start on some calculations to work out how much I would need to move each node down by to massage my circle into an egg shape when it occurred to me that it might be easier to simply write a script to draw me the appropriate shape and save it to a .osm file that I could load with josm. This approach also made it easy to accurately map the path along the perimeter.

查看完整日記項目

位置: Waldkolonie, Darmstadt-Nord, Darmstadt, Hesse, Germany