PocketTopoTxtImporter extends Importer { public static Set<PathDetail> parsePolylines(String text, Coord2D offset) { Set<PathDetail> paths = new HashSet<>(); boolean inPolyline = false; Colour currentPathColour = null; PathDetail currentPathDetail = null; for (String line : TextTools.toArrayOfLines(text)) { if (line.startsWith("POLYLINE")) { if (inPolyline) { paths.add(currentPathDetail); currentPathDetail = null; } String colourText = line.substring("POLYLINE ".length()); currentPathColour = interpretColour(colourText); inPolyline = true; continue; } if (!inPolyline) { continue; } String[] coords = line.split("\t"); double x = Double.parseDouble(coords[0]) - offset.x; double y = Double.parseDouble(coords[1]) - offset.y; Coord2D coord = new Coord2D(x, -y); if (currentPathDetail == null) { currentPathDetail = new PathDetail(coord, currentPathColour); } else { currentPathDetail.lineTo(coord); } } if (currentPathDetail != null) { paths.add(currentPathDetail); } return paths; }  Survey toSurvey(File file); boolean canHandleFile(File file); static String getSection(String text, String header); static Coord2D extractOffset(
            Survey survey, String text, Space<Coord2D> projection); static Coord2D getOffsetForNamedStation(String[] lines, Station station); static String getNamedSubSection(String text, String header, String sectionHeader); static String getNamedSubSection(String text, String header); static Set<PathDetail> parsePolylines(String text, Coord2D offset); static Colour interpretColour(String colourText);  }
@Test public void testParsePolylines() { String section = PocketTopoTxtImporter.getSection(FAKE_TEXT, "PLAN"); Set<PathDetail> paths = PocketTopoTxtImporter.parsePolylines(section, Coord2D.ORIGIN); PathDetail brownPath = null; for (PathDetail path : paths) { if (path.getColour() == Colour.BROWN) { brownPath = path; } } Assert.assertEquals(4.980, brownPath.getPath().get(0).x, 0.01); Assert.assertEquals(55.180, brownPath.getPath().get(0).y, 0.01); }