Opened 3 years ago

Closed 3 years ago

#17680 closed defect (fixed)

Suspicious code in Geometry.addIntersections()

Reported by: GerdP Owned by: team
Priority: minor Milestone: 19.05
Component: Core Version:
Keywords: javadoc Cc:


The javadoc says

     * Will find all intersection and add nodes there for list of given ways.
     * Handles self-intersections too.
     * And makes commands to add the intersection points to ways.
     * Prerequisite: no two nodes have the same coordinates.
     * @param ways  a list of ways to test
     * @param test  if false, do not build list of Commands, just return nodes
     * @param cmds  list of commands, typically empty when handed to this method.
     *              Will be filled with commands that add intersection nodes to
     *              the ways.
     * @return list of new nodes

I tried to use this method with a list of multipolygon ways like this
Set<Node> selfIntersections = Geometry.addIntersections(ways, false, null);

I got a NPE because in line 218 there is no check if test is set or not:

if (intNode == newNode) {
    cmds.add(new AddCommand(dataset, intNode));

I wonder if JoinAreasAction needs this or if it sometimes fails because of this. It uses the method like this:

    Set<Node> nodes = Geometry.addIntersections(allStartingWays, false, cmds);

Attachments (1)

17680.patch (988 bytes) - added by GerdP 3 years ago.

Download all attachments as: .zip

Change History (5)

Changed 3 years ago by GerdP

Attachment: 17680.patch added

comment:1 Changed 3 years ago by GerdP

Milestone: 19.05

Seems that only the javadoc is wrong. The attached patch fixes this.

If I hear no complains I'll commit this tomorrow.

comment:2 Changed 3 years ago by Don-vip

Yep, the javadoc looks wrong, you're right.

comment:3 Changed 3 years ago by Don-vip

Keywords: javadoc added
Priority: normalminor

comment:4 Changed 3 years ago by GerdP

Resolution: fixed
Status: newclosed

In 15055/josm:

fix #17680: correct misleading javadoc

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.