[josm-dev] function to find nodes next to a way

Jo winfixit at gmail.com
Tue Feb 19 06:40:33 GMT 2013


2013/2/18 Dirk Stöcker <openstreetmap at dstoecker.de>

> On Mon, 18 Feb 2013, Jo wrote:
>
>  I would like to be able to find nodes with certain tags next to a way,
>> within a few meters (configurable).
>> I was thinking to draw a 'virtual' rectangle to one side of the way, but I
>> don't know what function to use for this.
>>
>
> See http://josm.openstreetmap.de/**doc/<http://josm.openstreetmap.de/doc/>
>
> Have a look at DataSet class (e.g. searchNodes() function).
>

searchNodes seems to work with a bbox if I understand correctly. That's not
what I need to do.

I want to create a rectangle, given 2 nodes and a width, to one side of the
way I'm 'following'. Or maybe I simply want the edge nodes of such a
rectangle.

Then I want to detect nodes with specific properties which are inside this
rectangle. Then I go on with those nodes and drop the rectangle.

I think I can use this function for that purpose:

https://josm.openstreetmap.de/browser/josm/trunk/src/org/openstreetmap/josm/tools/Geometry.java
public static boolean nodeInsidePolygon(Node point, List<Node> polygonNodes)
 {

Then I still have to figure out a way to get a list of candidate nodes to
test with. That part can be done with a search in a bbox.
But my main problem is the list of nodes which form the rectangle polygon.
The distance from the way should be configurable and it would be nice if it
could 'overshoot' the line by a few meters, for the situation where the
road bends to the left and the bus stop happens to be on the outside corner
to the right.

Those rectangles can be oriented in all directions, whereas a bbox always
seems to be oriented north/east.

I hope it's clear what I want to achieve. If not, maybe it's better I draw
a picture.

Jo


More information about the josm-dev mailing list