private static int calculateTriggerDistance(int primaryInstructionDist, boolean isExitRamp, 
            int timeToStartAhead, float speedMPS, int speedLimitKmh) {
        
        int triggerDistance = primaryInstructionDist;
        
        if(LOG.isDebug()) {
            LOG.debug("NavigationSoundHandler.calculateTriggerDistance()", "dist=" + 
                    primaryInstructionDist + " timeahead=" + 
                    timeToStartAhead + " speed=" + speedMPS);
        }
        
        //FIXME: hack to avoid starting the sound to early because of the incorrect
        //limit the speed using segment maximum allowed speed
        if (speedLimitKmh <= 0) {
            speedLimitKmh = 130;
        };
        
        //check if speed is over the segment limit plus 20kmh
        //from test the speed when is wrong is actually over 100mps 
        if (speedMPS > ((speedLimitKmh + 20)/3.6)) {
            if(LOG.isWarn()) {
                LOG.warn("NavigationSoundHandler.calculateTriggerDistance()", 
                        "limit speed " + speedMPS + "mps to " + speedLimitKmh/5); 
            }            
            //reduce even more the speed as the driver will probably reduce 
            //the speed close to the turn where it's matters 
            speedMPS = ((float)speedLimitKmh)/5;

        }

        // Make the "Turn here" sound play 10 meters earlier to compensate
        // for the sound coming to late
        if (primaryInstructionDist == 0) {
            triggerDistance += 10;
        }
        
        if (isExitRamp) {
            // we are presumably on a freeway
            // add a hundred meters
            triggerDistance += 100; 
        }
        
        // Add 1 second worth of distance to cope with positioning delay
        triggerDistance += 1*speedMPS;//was (int) (10 + 1 * speedMPS);
       
         
        //finally add the extra time from soundbatch
        triggerDistance += (timeToStartAhead * speedMPS/1000);
        
        if(LOG.isDebug()) {
            LOG.debug("NavigationSoundHandler.calculateTriggerDistance()",  "triggerDistance=" + triggerDistance);
        }
        
        return triggerDistance;
    }