Skip to content

Loop validate() fails to adequately detect duplicate vertices #108

Open
@missinglink

Description

@missinglink

The current code only checks for duplicate adjacent vertices:

geo/s2/loop.go

Lines 251 to 260 in 6adc566

// Loops are not allowed to have any duplicate vertices or edge crossings.
// We split this check into two parts. First we check that no edge is
// degenerate (identical endpoints). Then we check that there are no
// intersections between non-adjacent edges (including at vertices). The
// second check needs the ShapeIndex, so it does not fall within the scope
// of this method.
for i, v := range l.vertices {
if v == l.Vertex(i+1) {
return fmt.Errorf("edge %d is degenerate (duplicate vertex)", i)
}

While the comments say:

Loops are not allowed to have any duplicate vertices (whether adjacent or not)

geo/s2/loop.go

Lines 34 to 35 in 6adc566

// Loops are not allowed to have any duplicate vertices (whether adjacent or
// not). Non-adjacent edges are not allowed to intersect, and furthermore edges

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions