Skip to content

Fix Bounds.toBounds collector #110

@jenetics

Description

@jenetics

The initialization of the toBounds collector is invalid.

public static <P extends Point> Collector<P, ?, Bounds> toBounds() {
    return Collector.of(
        () -> {
            final double[] a = new double[4];
            a[0] = Double.MAX_VALUE;
            a[1] = Double.MAX_VALUE;
            a[2] = Double.MIN_VALUE;
            a[3] = Double.MIN_VALUE;
            return a;
        },
        ...
}

The correct initialization is

public static <P extends Point> Collector<P, ?, Bounds> toBounds() {
    return Collector.of(
        () -> {
            final double[] a = new double[4];
            a[0] = Double.MAX_VALUE;
            a[1] = Double.MAX_VALUE;
            a[2] = -Double.MAX_VALUE;
            a[3] = -Double.MAX_VALUE;
            return a;
        },
        ...
}

This leads to erroneous bounds for negative latitude and longitude values.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions