class SurvexImporter extends Importer {

    public static Leg[] parseAnyPromotedLegs(String instructions) {
        try {
            List<Leg> legs = new ArrayList<>();

            instructions = instructions.replace("{", "");
            instructions = instructions.replace("}", "");
            if (instructions.contains("from:")) {
                instructions = instructions.replace("from:", "");
            } else {
                throw new Exception("Not an instruction we understand");
            }

            String[] legStrings = instructions.split(",");

            for (String legString : legStrings) {
                legString = legString.trim();
                String[] fieldStrings = legString.split(" ");
                double distance = Double.parseDouble(fieldStrings[0].trim());
                double azimuth = Double.parseDouble(fieldStrings[1].trim());
                double inclination = Double.parseDouble(fieldStrings[2].trim());
                legs.add(new Leg(distance, azimuth, inclination));
            }

            return legs.toArray(new Leg[]{});
        } catch (Exception exception) {
            Log.e("Error parsing promoted leg (ignoring and carrying on): " + exception);
            return new Leg[]{}; // seems to be corrupted... feature not mission-critical so bail
        }
    }

}