OpenMap-java / openmap

OpenMap is an Open Source JavaBeans-based programmer's toolkit. Using OpenMap, you can quickly build applications and applets that access data from legacy databases and applications.
http://openmap-java.org
Other
73 stars 43 forks source link

Bug in DMSLatLonPoint.equals #16

Closed jflecomte closed 8 years ago

jflecomte commented 8 years ago

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);
    }
dfdietrick commented 8 years ago

Thanks for the fix!

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 https://github.com/OpenMap-java/openmap/issues/16.