I have been trying to figure out, is it possible to produce KML polygons from OSM areas with the OSMLib ruby? I have already made quite a few modifications to the ruby source to fit my needs, but I still can't get this part to work.. In the osmlib-base-0.1.4/lib folder, in objects.rb, I added: ** Updated code below
Replacing what was previously just:
That didn't seem to do the trick (there is already some geometry polygon code in the KML output, but obviously not enough! I don't know much at all about Ruby (this project is the first time I have used ruby at all!). Anyone have some tips/want to help implement this? I am sure this could get implemented properly and would be of use to people. asked 22 Feb '11, 06:35 wbski |
Firstly, your approach will mistakenly put many objects in the polygon category, e.g. a highway roundabout; these are not, as your code seems to assume, tagged "area=no". To do this right you would have to look at the specific tags (i.e. closed way tagged as forest => polygon; closed way tagged as fence => linestring etc.) Secondly, are you sure that the areas you hope to see on output are closed ways at all - or are they maybe multipolygon relation, in which case you would need a totally different approach? You might want to look at Osmium/Osmjs, by the same author, a program that lets you execute arbitrary Javascript code for OSM objects (you would still have to write the KML output part though). This program has good support for multipolygons. answered 22 Feb '11, 07:40 Frederik Ramm ♦ ... thirdly, you need to refactor your code, since even if the if condition matches, the function will return the results of the last computation, which as written above is always linestring.
(22 Feb '11, 09:47)
Andy Allan
I see what you mean Frederik about not handling all the polygons properly.. However, in my application (ski runs), determining the areas is pretty simple, I will change tagging to area==yes. Anyways, I can tweak the logic to select forests etc later. I changed my code above, but still not working.. Now getting: geo_ruby/simple_features/polygon.rb:17:in Its a mystery to me..
(22 Feb '11, 16:05)
wbski
|