Permalink
Browse files

POI writer: add progress-logs option (#1072)

  • Loading branch information...
Gustl22 authored and devemux86 committed Jun 24, 2018
1 parent 52769b9 commit 3eabdd71be5a72cf2f71fea101cdb7f2e2c3f79a
View
@@ -41,6 +41,7 @@ The `--poi-writer`, or short `--pw` task indicates that the POI writer plugin sh
|`all-tags`|Export all tags. If false only the name will be exported.|true/false|true|
|`preferred-language`|If not specified, only the default language with no tag will be written to the file. If a language is specified, it will be written if its tag is found, otherwise the default language will be written. *Redundant if all-tags is true.*|language code as defined in ISO 639-1 or ISO 639-2 if an ISO 639-1 code doesn't exist|(blank)|
|`comment`|Writes a comment to the file.||(blank)|
|`progress-logs`|Enable progress logs|true/false|true|
#### Advanced Options (only use when you know what you are doing)
@@ -1,5 +1,5 @@
/*
* Copyright 2017 Gustl22
* Copyright 2017-2018 Gustl22
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -173,25 +173,27 @@ void filterBoundaries(Relation relation) {
void processBoundaries() {
int nPostalBounds = 0;
for (Relation postalBoundary : postalBoundaries) {
if (nPostalBounds % 10 == 0) {
System.out.printf("Progress: PostalBounds " + nPostalBounds + "/"
+ postalBoundaries.size() + " \r");
if (writer.configuration.isProgressLogs()) {
if (++nPostalBounds % 10 == 0) {
System.out.print("Progress: PostalBounds " + nPostalBounds + "/"
+ postalBoundaries.size() + " \r");
}
}
processBoundary(postalBoundary, true);
nPostalBounds++;
}
commit();
for (int i = administrativeBoundaries.size() - 1; i >= 0; i--) {
int nAdminBounds = 0;
List<Relation> administrativeBoundary = administrativeBoundaries.get(i);
for (Relation relation : administrativeBoundary) {
if (nAdminBounds % 10 == 0) {
System.out.printf("Progress: AdminLevel " + i + ": " + nAdminBounds + "/"
+ administrativeBoundary.size() + " \r");
if (writer.configuration.isProgressLogs()) {
if (++nAdminBounds % 10 == 0) {
System.out.print("Progress: AdminLevel " + i + ": " + nAdminBounds + "/"
+ administrativeBoundary.size() + " \r");
}
}
processBoundary(relation, false);
nAdminBounds++;
}
commit();
}
@@ -89,7 +89,7 @@ public static PoiWriter newInstance(PoiWriterConfiguration configuration, Progre
private static final Pattern NAME_LANGUAGE_PATTERN = Pattern.compile("(name)(:)([a-zA-Z]{1,3}(?:[-_][a-zA-Z0-9]{1,8})*)");
private final PoiWriterConfiguration configuration;
final PoiWriterConfiguration configuration;
private final ProgressManager progressManager;
private final NumberFormat nfCounts = NumberFormat.getInstance();
@@ -387,8 +387,10 @@ public void process(EntityContainer entityContainer) {
if (this.nNodes == 0) {
LOGGER.info("Processing nodes...");
}
if (nNodes % 100000 == 0) {
System.out.printf("Progress: Nodes " + nfCounts.format(nNodes) + " \r");
if (this.configuration.isProgressLogs()) {
if (nNodes % 100000 == 0) {
System.out.print("Progress: Nodes " + nfCounts.format(nNodes) + " \r");
}
}
++this.nNodes;
if (this.configuration.isWays()) {
@@ -409,8 +411,10 @@ public void process(EntityContainer entityContainer) {
e.printStackTrace();
}
}
if (nWays % 10000 == 0) {
System.out.printf("Progress: Ways " + nfCounts.format(nWays) + " \r");
if (this.configuration.isProgressLogs()) {
if (nWays % 10000 == 0) {
System.out.print("Progress: Ways " + nfCounts.format(nWays) + " \r");
}
}
++this.nWays;
processWay(way);
@@ -424,8 +428,10 @@ public void process(EntityContainer entityContainer) {
this.geoTagger.commit();
}
this.geoTagger.filterBoundaries(relation);
if (nRelations % 10000 == 0) {
System.out.printf("Progress: Relations " + nfCounts.format(nRelations) + " \r");
if (this.configuration.isProgressLogs()) {
if (nRelations % 10000 == 0) {
System.out.print("Progress: Relations " + nfCounts.format(nRelations) + " \r");
}
}
++this.nRelations;
}
@@ -1,6 +1,6 @@
/*
* Copyright 2015-2017 devemux86
* Copyright 2017 Gustl22
* Copyright 2017-2018 Gustl22
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -35,6 +35,7 @@
private boolean names;
private File outputFile;
private String preferredLanguage;
private boolean progressLogs;
private URL tagMapping;
private boolean ways;
private String writerVersion;
@@ -147,6 +148,13 @@ public boolean isNames() {
return names;
}
/**
* @return the progressLogs
*/
public boolean isProgressLogs() {
return this.progressLogs;
}
/**
* @return the ways
*/
@@ -249,6 +257,13 @@ public void setPreferredLanguage(String preferredLanguage) {
}
}
/**
* @param progressLogs the progressLogs to set
*/
public void setProgressLogs(boolean progressLogs) {
this.progressLogs = progressLogs;
}
/**
* @param ways the ways to set
*/
@@ -2,7 +2,7 @@
* Copyright 2010, 2011 mapsforge.org
* Copyright 2010, 2011 Karsten Groll
* Copyright 2015-2017 devemux86
* Copyright 2017 Gustl22
* Copyright 2017-2018 Gustl22
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -40,6 +40,7 @@
private static final String PARAM_NAMES = "names";
private static final String PARAM_OUTFILE = "file";
private static final String PARAM_PREFERRED_LANGUAGE = "preferred-language";
private static final String PARAM_PROGRESS_LOGS = "progress-logs";
private static final String PARAM_TAG_MAPPING_FILE = "tag-conf-file";
private static final String PARAM_WAYS = "ways";
@@ -54,6 +55,7 @@ protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
configuration.setNames(getBooleanArgument(taskConfig, PARAM_NAMES, true));
configuration.addOutputFile(getStringArgument(taskConfig, PARAM_OUTFILE, Constants.DEFAULT_PARAM_OUTFILE));
configuration.setPreferredLanguage(getStringArgument(taskConfig, PARAM_PREFERRED_LANGUAGE, null));
configuration.setProgressLogs(getBooleanArgument(taskConfig, PARAM_PROGRESS_LOGS, true));
configuration.loadTagMappingFile(getStringArgument(taskConfig, PARAM_TAG_MAPPING_FILE, null));
configuration.setWays(getBooleanArgument(taskConfig, PARAM_WAYS, true));

0 comments on commit 3eabdd7

Please sign in to comment.