OpenStreetMap 标志 OpenStreetMap

Using turtle graphics to map buildings

Opk 于 2010年八月23日 以 English 发布

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.

I'm now tempted to invest in one of these laser distance measuring devices that they have in DIY stores so that I don't have to go round counting paving stones. Does anyone have any experience in using them to map buildings?

电子邮件图标 Bluesky图标 Facebook图标 LinkedIn图标 Mastodon图标 Telegram图标 X图标

讨论

knarF2010年08月23日 18:28 的评论

I would like a copy, I could also host a tarball or zip for you - if you wish.

Andy Allan2010年08月24日 13:12 的评论

You should remember that a square house in real life won't necessarily appear as square in either latlong (epsg:4326, the josm default) nor spherical mercator (epsg:900913/3857, rendering default). So worry more about getting the corners in the right real places!

seav2010年08月26日 16:15 的评论

@Andy, at very large scales and at latitudes far from the poles, I doubt that the difference between spherical mercator and true mercator would be noticeable.

登录以留下评论