class MetadataCombiner implements Comparator<PlatformMetadata>, Serializable {

    public List<PlatformMetadata> combineData(List<PlatformMetadata> locations, List<PlatformMetadata> platformOrientations,
            List<PlatformMetadata> gimbalOrientation)
    {
        locations.sort(this);
        platformOrientations.sort(this);
        gimbalOrientation.sort(this);

        List<PlatformMetadata> combined = New.list();

        int index = 0;
        for (PlatformMetadata gimbal : gimbalOrientation)
        {
            PlatformMetadata location = findNearest(gimbal, locations);
            PlatformMetadata platformOrientation = findNearest(gimbal, platformOrientations);

            PlatformMetadata aCombined = new PlatformMetadata();
            aCombined.setCameraPitchAngle(gimbal.getCameraPitchAngle());
            aCombined.setCameraRollAngle(gimbal.getCameraRollAngle());
            aCombined.setCameraYawAngle(gimbal.getCameraYawAngle());

            aCombined.setPitchAngle(platformOrientation.getPitchAngle());
            aCombined.setRollAngle(platformOrientation.getRollAngle());
            aCombined.setYawAngle(platformOrientation.getYawAngle());

            double groundAltitude = locations.get(0).getLocation().getAltM();
            if (index >= gimbalOrientation.size() / 2)
            {
                groundAltitude = locations.get(locations.size() - 1).getLocation().getAltM();
            }

            double normalizedAltitude = location.getLocation().getAltM() - groundAltitude;
            LatLonAlt normalizedLocation = LatLonAlt.createFromDegreesMeters(location.getLocation().getLatD(),
                    location.getLocation().getLonD(), normalizedAltitude, ReferenceLevel.TERRAIN);
            aCombined.setLocation(normalizedLocation);
            aCombined.setTime(gimbal.getTime());

            combined.add(aCombined);

            index++;
        }

        return combined;
    }

}