OpenMap-java/openmap

Bug in DMSLatLonPoint.equals

jflecomte opened this issue · 1 comments

Method equals is:

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DMSLatLonPoint pt = (DMSLatLonPoint) obj;
        return (pt.lat_isnegative == lat_isnegative
                && pt.lat_degrees == lat_degrees
                && pt.lat_minutes == lat_degrees
                && pt.lat_seconds == lat_seconds
                && pt.lon_isnegative == lon_isnegative
                && pt.lon_degrees == lon_degrees
                && pt.lon_minutes == lon_minutes
                && pt.lon_seconds == lon_seconds);
    }

The comparison for lat_minutes is wrong, should be:

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final DMSLatLonPoint pt = (DMSLatLonPoint) obj;
        return (pt.lat_isnegative == lat_isnegative
                && pt.lat_degrees == lat_degrees
                && pt.lat_minutes == lat_minutes
                && pt.lat_seconds == lat_seconds
                && pt.lon_isnegative == lon_isnegative
                && pt.lon_degrees == lon_degrees
                && pt.lon_minutes == lon_minutes
                && pt.lon_seconds == lon_seconds);
    }

Thanks for the fix!

  • Don

On Dec 21, 2015, at 12:41 PM, JFLecomte notifications@github.com wrote:

Method equals is:

public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (getClass() != objgetClass()) {
        return false;
    }
    final DMSLatLonPoint pt = (DMSLatLonPoint) obj;
    return (ptlat_isnegative == lat_isnegative
            && ptlat_degrees == lat_degrees
            && ptlat_minutes == lat_degrees
            && ptlat_seconds == lat_seconds
            && ptlon_isnegative == lon_isnegative
            && ptlon_degrees == lon_degrees
            && ptlon_minutes == lon_minutes
            && ptlon_seconds == lon_seconds);
}

The comparison for lat_minutes is wrong, should be:

public boolean equals(Object obj) {
    if (obj == null) {
        return false;
    }
    if (getClass() != objgetClass()) {
        return false;
    }
    final DMSLatLonPoint pt = (DMSLatLonPoint) obj;
    return (ptlat_isnegative == lat_isnegative
            && ptlat_degrees == lat_degrees
            && ptlat_minutes == lat_minutes
            && ptlat_seconds == lat_seconds
            && ptlon_isnegative == lon_isnegative
            && ptlon_degrees == lon_degrees
            && ptlon_minutes == lon_minutes
            && ptlon_seconds == lon_seconds);
}


Reply to this email directly or view it on GitHub #16.