[Talk-ca] [OSM-talk] Addr:streetnumber:first;last:left;right
Marcus Wolschon
Marcus at Wolschon.biz
Tue Apr 7 19:30:12 BST 2009
On Tue, Apr 7, 2009 at 8:25 PM, andrzej zaborowski <balrogg at gmail.com> wrote:
>> createInterpolationWay(way w, int offset) {
>>
>> Node startInterpNode = new Node(w.getNode(0).location +
>> offset * w.getNode(0).getNextSegment().vectorNormalLeft());
>>
>> foreach (Node n in w.nodes except 0 and last) {
>> Vector last = w.getNode(0).getLastSegment().vectorNormalLeft();
>> Vector next = w.getNode(0).getNextSegment().vectorNormalLeft();
>> Vector normalVector =
>> new Vector((last[0] + next[0]) / 2,
>> (last[1] + next[1]) / 2).normalize()
>> Node interpNode = new Node(w.getNode(0).location +
>> offset * normalVector );
>
> If you just add the normal vectors it won't look very natural because
> the angle will determine the offset between the interpolation way and
> the road.
That is why I normalized the resulting vector, thus giving it
a length of 1. The offset will thus stay constant.
>> }
>>
>> Node endInterpNode = new Node(w.getNode(last).location +
>> offset * w.getNode(last).getLastSegment().vectorNormalLeft());
>>
>> }
>>
>> Not as difficult as andrzej thought it would be.
>
> This isn't the difficult part, ump2osm implements this too. The
> difficult part is the reverse mapping, if you wanted to convert OSM
> data back into a Garmin compatible format.
> (difficult but doable, ofcourse)
That is where associatedStreet and the trivial distance betwen a point
(node with addr:housenumber) and line (segment of the ways of the nearest
nodes) comes into play.
I implemented it. It was easy to do and is much more reliable then
I would have thought when we specified the Karlsruhe Schema
at the Geofabrik last year.
Marcus
More information about the Talk-ca
mailing list