OffsetCenterPostProcessor implements PostProcessor { @Override public void postProcess( Map<String, KlvDataElement> dataElements, Map<String, KlvHandler> handlers) { if (!(isCornerLatitude(handlers) && isCornerLongitude(handlers))) { return; } if (isFrameCenter(dataElements) && isOffsetCornerLatitude(dataElements) && isOffsetCornerLongitude(dataElements)) { doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LATITUDE_1, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_1, Stanag4609TransportStreamParser.FRAME_CENTER_LATITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LONGITUDE_1, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_1, Stanag4609TransportStreamParser.FRAME_CENTER_LONGITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LATITUDE_2, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_2, Stanag4609TransportStreamParser.FRAME_CENTER_LATITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LONGITUDE_2, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_2, Stanag4609TransportStreamParser.FRAME_CENTER_LONGITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LATITUDE_3, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_3, Stanag4609TransportStreamParser.FRAME_CENTER_LATITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LONGITUDE_3, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_3, Stanag4609TransportStreamParser.FRAME_CENTER_LONGITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LATITUDE_4, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_4, Stanag4609TransportStreamParser.FRAME_CENTER_LATITUDE); doField( dataElements, handlers, Stanag4609TransportStreamParser.CORNER_LONGITUDE_4, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_4, Stanag4609TransportStreamParser.FRAME_CENTER_LONGITUDE); } }  @Override void postProcess(
      Map<String, KlvDataElement> dataElements, Map<String, KlvHandler> handlers);  }
@Test public void test() throws KlvDecodingException { OffsetCenterPostProcessor offsetCenterPostProcessor = new OffsetCenterPostProcessor(); Map<String, KlvHandler> handlers = new HashMap<>(); GeoBoxHandler cornerHandler = mock(GeoBoxHandler.class); GeoBoxHandler offsetHandler = mock(GeoBoxHandler.class); LatitudeLongitudeHandler centerHandler = mock(LatitudeLongitudeHandler.class); handlers.put(Stanag4609TransportStreamParser.CORNER_LATITUDE_1, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LATITUDE_2, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LATITUDE_3, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LATITUDE_4, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LONGITUDE_1, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LONGITUDE_2, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LONGITUDE_3, cornerHandler); handlers.put(Stanag4609TransportStreamParser.CORNER_LONGITUDE_4, cornerHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_1, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_2, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_3, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_4, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_1, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_2, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_3, offsetHandler); handlers.put(Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_4, offsetHandler); handlers.put(Stanag4609TransportStreamParser.FRAME_CENTER_LATITUDE, centerHandler); handlers.put(Stanag4609TransportStreamParser.FRAME_CENTER_LONGITUDE, centerHandler); Map<String, KlvDataElement> dataElements = new HashMap<>(); double lat1 = 1; double lat2 = 2; double lat3 = 3; double lat4 = 4; double lon1 = 5; double lon2 = 6; double lon3 = 7; double lon4 = 8; double lat = 30; double lon = 50; add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_1, lat1); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_2, lat2); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_3, lat3); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LATITUDE_4, lat4); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_1, lon1); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_2, lon2); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_3, lon3); add(dataElements, Stanag4609TransportStreamParser.OFFSET_CORNER_LONGITUDE_4, lon4); add(dataElements, Stanag4609TransportStreamParser.FRAME_CENTER_LATITUDE, lat); add(dataElements, Stanag4609TransportStreamParser.FRAME_CENTER_LONGITUDE, lon); offsetCenterPostProcessor.postProcess(dataElements, handlers); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LATITUDE_1, lat1 + lat); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LATITUDE_2, lat2 + lat); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LATITUDE_3, lat3 + lat); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LATITUDE_4, lat4 + lat); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LONGITUDE_1, lon1 + lon); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LONGITUDE_2, lon2 + lon); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LONGITUDE_3, lon3 + lon); verifyThat(cornerHandler, Stanag4609TransportStreamParser.CORNER_LONGITUDE_4, lon4 + lon); }