private int distToInt ( double distance ) { if ( distance < 0 ) throw new IllegalArgumentException ( "Distance cannot be negative: " + distance ) ; if ( distance > MAX_DIST ) { distance = MAX_DIST ; } int integ = ( int ) Math . round ( distance * INT_DIST_FACTOR ) ; assert integ >= 0 : "distance out of range" ; return integ ; }
Translates double distance to integer in order to save it in a DataAccess object