@@ -0,0 +1,2170 @@
+package au.gov.amsa.geo.adhoc;%0A%0Aimport java.io.File;%0Aimport java.util.List;%0Aimport java.util.TreeSet;%0Aimport java.util.concurrent.ConcurrentHashMap;%0Aimport java.util.regex.Pattern;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport com.github.davidmoten.grumpy.core.Position;%0A%0Aimport au.gov.amsa.risky.format.BinaryFixes;%0Aimport au.gov.amsa.util.Files;%0Aimport rx.Observable;%0A%0Apublic class HeadingCourseDiffMain %7B%0A%0A    private static final Logger log = LoggerFactory.getLogger(CountCrossingsIntoRegionMain.class);%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        Pattern pattern = Pattern.compile(%22.*%5C%5C.track%22);%0A        List%3CFile%3E files = Files.find(new File(%22/media/an/binary-fixes-5-minute/2014%22), pattern);%0A        // files.addAll(Files.find(new%0A        // File(%22/media/an/binary-fixes-5-minute/2013%22), pattern));%0A        // files.addAll(Files.find(new%0A        // File(%22/media/an/binary-fixes-5-minute/2014%22), pattern));%0A        // files.addAll(Files.find(new%0A        // File(%22/media/an/binary-fixes-5-minute/2015%22), pattern));%0A        log.info(%22files=%22 + files.size());%0A%0A        ConcurrentHashMap%3CInteger, Long%3E map = new ConcurrentHashMap%3C%3E();%0A        int count = Observable.from(files) //%0A                // .doOnNext(System.out::println) //%0A                // .doOnNext(System.out::println)%0A                .concatMap(file -%3E BinaryFixes.from(file)%0A                        .filter(f -%3E f.courseOverGroundDegrees().isPresent()%0A                                && f.headingDegrees().isPresent())%0A                        .map(f -%3E Math.abs(Position.getBearingDifferenceDegrees(%0A                                f.courseOverGroundDegrees().get(), f.headingDegrees().get()))) //%0A                        .doOnNext(x -%3E %7B%0A                            int bucket = (int) Math.round(x);%0A                            map.compute(bucket, (n, num) -%3E num == null ? 1 : num + 1);%0A                        %7D)//%0A        ) //%0A                .count().toBlocking().single();%0A%0A        System.out.println(%22count=%22 + count);%0A        for (Integer key : new TreeSet%3CInteger%3E(map.keySet())) %7B%0A            System.out.println(key + %22%5Ct%22 + map.get(key));%0A        %7D%0A    %7D%0A%0A%7D%0A

add heading course adhoc main