Skip to content

Commit 483c0a1

Browse files
committed
2 parents 70b8704 + 45ecafd commit 483c0a1

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

  • generator/src/main/java/de/westnordost/countryboundaries

generator/src/main/java/de/westnordost/countryboundaries/Main.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,13 @@ public class Main
2525
{
2626
public static void main(String[] args) throws Exception {
2727

28-
if(args.length < 3) {
29-
System.err.println("Missing parameters. F.e. 'boundaries.osm 360 180' ");
28+
if(args.length != 3 && args.length != 2) {
29+
System.err.println("Missing parameters. F.e. 'boundaries.osm 360 180' or 'boundaries.osm boundaries.json' ");
3030
return;
3131
}
3232

3333
String filename = args[0];
34-
int width = Integer.parseInt(args[1]);
35-
int height = Integer.parseInt(args[2]);
36-
3734
FileInputStream is = new FileInputStream(filename);
38-
3935
GeometryCollection geometries;
4036
if(filename.endsWith(".json") || filename.endsWith(".geojson"))
4137
{
@@ -58,11 +54,13 @@ else if(filename.endsWith(".osm"))
5854
return;
5955
}
6056

61-
//String geojson = new GeoJsonWriter().write(geometries);
62-
//try(Writer writer = new OutputStreamWriter(new FileOutputStream("boundaries.json"), "UTF-8"))
63-
//{
64-
// writer.write(geojson);
65-
//}
57+
if(args.length == 2) {
58+
String geojson = new GeoJsonWriter().write(geometries);
59+
try(Writer writer = new OutputStreamWriter(new FileOutputStream(args[1]), "UTF-8")) {
60+
writer.write(geojson);
61+
}
62+
return;
63+
}
6664

6765
Set<String> excludeCountries = new HashSet<>();
6866
excludeCountries.add("FX");
@@ -96,6 +94,8 @@ else if(filename.endsWith(".osm"))
9694
}
9795
});
9896

97+
int width = Integer.parseInt(args[1]);
98+
int height = Integer.parseInt(args[2]);
9999
CountryBoundaries boundaries = generator.generate(width, height, geometryList);
100100
try(FileOutputStream fos = new FileOutputStream("boundaries.ser"))
101101
{

0 commit comments

Comments
 (0)