/***************************************
- $Header: /home/amb/routino/src/RCS/tagmodifier.c,v 1.5 2010/05/30 18:18:54 amb Exp $
+ $Header: /home/amb/routino/src/RCS/tagmodifier.c,v 1.8 2010/11/13 14:22:28 amb Exp $
Test application for OSM XML file parser / tagging rule testing.
#include <ctype.h>
#include <errno.h>
-#include "functions.h"
+#include "files.h"
+#include "logging.h"
#include "xmlparse.h"
#include "tagging.h"
nnodes++;
if(!(nnodes%1000))
- fprintf(stderr,"\rReading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
+ fprintf_middle(stderr,"Reading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
current_tags=NewTagList();
}
nways++;
if(!(nways%1000))
- fprintf(stderr,"\rReading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
+ fprintf_middle(stderr,"Reading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
current_tags=NewTagList();
}
nrelations++;
if(!(nrelations%1000))
- fprintf(stderr,"\rReading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
+ fprintf_middle(stderr,"Reading: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
current_tags=NewTagList();
}
{
if(!strcmp(argv[arg],"--help"))
print_usage(1);
+ else if(!strcmp(argv[arg],"--loggable"))
+ option_loggable=1;
else if(!strncmp(argv[arg],"--tagging=",10))
tagging=&argv[arg][10];
else if(argv[arg][0]=='-' && argv[arg][1]=='-')
/* Check the specified command line options */
- if(tagging && ExistsFile(tagging))
- ;
- else if(!tagging && ExistsFile("tagging.xml"))
- tagging="tagging.xml";
-
- if(tagging && ParseXMLTaggingRules(tagging))
+ if(tagging)
{
- fprintf(stderr,"Error: Cannot read the tagging rules in the file '%s'.\n",tagging);
- return(1);
+ if(!ExistsFile(tagging))
+ {
+ fprintf(stderr,"Error: The '--tagging' option specifies a file that does not exist.\n");
+ return(1);
+ }
+ }
+ else
+ {
+ if(ExistsFile("tagging.xml"))
+ tagging="tagging.xml";
+ else
+ {
+ fprintf(stderr,"Error: The '--tagging' option was not used and the default 'tagging.xml' does not exist.\n");
+ return(1);
+ }
}
- if(!tagging)
+ if(ParseXMLTaggingRules(tagging))
{
- fprintf(stderr,"Error: Cannot run without reading some tagging rules.\n");
+ fprintf(stderr,"Error: Cannot read the tagging rules in the file '%s'.\n",tagging);
return(1);
}
+ /* Open the input file */
+
if(filename)
{
file=fopen(filename,"rb");
/* Parse the file */
- fprintf(stderr,"\rReading: Lines=0 Nodes=0 Ways=0 Relations=0");
+ fprintf_first(stderr,"Reading: Lines=0 Nodes=0 Ways=0 Relations=0");
retval=ParseXML(file,xml_toplevel_tags,XMLPARSE_UNKNOWN_ATTR_IGNORE);
- fprintf(stderr,"\rRead: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld \n",ParseXML_LineNumber(),nnodes,nways,nrelations);
+ fprintf_last(stderr,"Read: Lines=%ld Nodes=%ld Ways=%ld Relations=%ld",ParseXML_LineNumber(),nnodes,nways,nrelations);
/* Tidy up */
{
fprintf(stderr,
"Usage: tagmodifier [--help]\n"
+ " [--loggable]\n"
" [--tagging=<filename>]\n"
" [<filename.osm>]\n");
"\n"
"--help Prints this information.\n"
"\n"
+ "--loggable Print progress messages suitable for logging to file.\n"
+ "\n"
"--tagging=<filename> The name of the XML file containing the tagging rules\n"
" (defaults to 'tagging.xml' in current directory).\n"
"\n"