- int latidx = (int)lat;
- diff = lat - (double)latidx;
- if ( (lat < 0.0) && (fabs(diff) > SG_EPSILON) ) {
- latidx -= 1;
- }
- double latfrac = lat - (double)latidx;
- latidx += 90;
-
- int master_index = lonidx * 1000 + latidx;
- // cout << "lonidx = " << lonidx << " latidx = " << latidx << " ";
- // cout << "Master index = " << master_index << endl;
-
- // add to the actual bucket
- real_add( navmap, master_index, n );
-
- // if we are close to the edge, add to adjacent buckets so we only
- // have to search one bucket at run time
-
- // there are 8 cases since there are 8 adjacent tiles
-
- if ( lonfrac < 0.2 ) {
- real_add( navmap, master_index - 1000, n );
- if ( latfrac < 0.2 ) {
- real_add( navmap, master_index - 1000 - 1, n );
- } else if ( latfrac > 0.8 ) {
- real_add( navmap, master_index - 1000 + 1, n );
- }
- } else if ( lonfrac > 0.8 ) {
- real_add( navmap, master_index + 1000, n );
- if ( latfrac < 0.2 ) {
- real_add( navmap, master_index + 1000 - 1, n );
- } else if ( latfrac > 0.8 ) {
- real_add( navmap, master_index + 1000 + 1, n );
- }
- } else if ( latfrac < 0.2 ) {
- real_add( navmap, master_index - 1, n );
- } else if ( latfrac > 0.8 ) {
- real_add( navmap, master_index + 1, n );
- }