Changeset 34966 in osm for applications/editors/josm/plugins/poly/src
- Timestamp:
- 2019-04-07T07:14:21+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/poly/src/poly/PolyExporter.java
r34860 r34966 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedWriter;7 6 import java.io.File; 8 7 import java.io.IOException; 8 import java.io.PrintWriter; 9 9 import java.nio.charset.StandardCharsets; 10 10 import java.nio.file.Files; … … 43 43 throw new IOException(tr("Data contains unclosed ways.")); 44 44 } 45 try ( BufferedWriter writer = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) {45 try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8))) { 46 46 DataSet ds = ((OsmDataLayer) layer).getDataSet(); 47 47 HashSet<Way> written = new HashSet<>(); … … 56 56 if (rel.isMultipolygon()) { 57 57 if (!firstFile) { 58 writer. newLine();58 writer.println(); 59 59 } 60 60 writeRelation(writer, fileName, rel, written); … … 64 64 65 65 if (firstFile) { 66 writer. write(fileName);66 writer.println(fileName); 67 67 } 68 68 int counter = 1; … … 72 72 } 73 73 } 74 writer.write("END"); 75 writer.newLine(); 74 writer.println("END"); 76 75 } 77 76 } 78 77 } 79 78 80 private static void writeRelation( BufferedWriter writer, String fileName, Relation rel, Set<Way> written) throws IOException{79 private static void writeRelation(PrintWriter writer, String fileName, Relation rel, Set<Way> written) { 81 80 String polygonName = fileName; 82 81 if (rel.getName() != null) 83 82 polygonName = rel.getName(); 84 writer.write(polygonName); 85 writer.newLine(); 83 writer.println(polygonName); 86 84 int counter = 1; 87 85 for (RelationMember rm: rel.getMembers()) { … … 96 94 } 97 95 98 private static int writeWay( BufferedWriter writer, Way w, int counter) throws IOException{96 private static int writeWay(PrintWriter writer, Way w, int counter) { 99 97 String name = w.getName(); 100 98 if (name == null) { 101 99 name = String.valueOf(counter++); 102 100 } 103 writer.write(name); 104 writer.newLine(); 101 writer.println(name); 105 102 106 103 for (Node n : w.getNodes()) { 107 writer.write(String.format(Locale.ENGLISH, " %f %f", n.getCoor().lon(), n.getCoor().lat())); 108 writer.newLine(); 104 writer.println(String.format(Locale.ENGLISH, " %f %f", n.getCoor().lon(), n.getCoor().lat())); 109 105 } 110 writer.write("END"); 111 writer.newLine(); 106 writer.println("END"); 112 107 return counter; 113 108 }
Note:
See TracChangeset
for help on using the changeset viewer.