make output of empty json (if no features are hit) on by default, and rename parameter from 'only-nonempty' to 'output-empty'
This commit is contained in:
parent
50147ab509
commit
a7e9cc7e87
3 changed files with 9 additions and 9 deletions
|
@ -64,9 +64,9 @@ public:
|
|||
/** Get output stream. */
|
||||
std::ostream *get_stream() const { return f_; }
|
||||
/** Only write header/footer to file with one or more features. */
|
||||
void set_only_nonempty(bool only_nonempty) { only_nonempty_ = only_nonempty; }
|
||||
/** See set_only_nonempty(). */
|
||||
bool get_only_nonempty() { return only_nonempty_; }
|
||||
void set_output_empty(bool output_empty) { output_empty_ = output_empty; }
|
||||
/** See set_output_empty(). */
|
||||
bool get_output_empty() { return output_empty_; }
|
||||
virtual void set_map_srs(projection const& proj);
|
||||
protected:
|
||||
enum {
|
||||
|
@ -76,7 +76,7 @@ protected:
|
|||
};
|
||||
/** Features written. */
|
||||
int count_;
|
||||
bool only_nonempty_;
|
||||
bool output_empty_;
|
||||
/** Transformation from map srs to output srs. */
|
||||
proj_transform *trans_;
|
||||
projection output_srs_;
|
||||
|
|
|
@ -376,9 +376,9 @@ void map_parser::parse_metawriter(Map & map, ptree const & pt)
|
|||
string file = get_attr<string>(pt, "file");
|
||||
optional<string> properties = get_opt_attr<string>(pt, "default-output");
|
||||
metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file)));
|
||||
optional<boolean> only_nonempty = get_opt_attr<boolean>(pt, "only-nonempty");
|
||||
if (only_nonempty) {
|
||||
json->set_only_nonempty(*only_nonempty);
|
||||
optional<boolean> output_empty = get_opt_attr<boolean>(pt, "output-empty");
|
||||
if (output_empty) {
|
||||
json->set_output_empty(*output_empty);
|
||||
}
|
||||
writer = json;
|
||||
} else {
|
||||
|
|
|
@ -60,7 +60,7 @@ std::string metawriter_properties::to_string() const
|
|||
void metawriter_json_stream::start(metawriter_property_map const& properties)
|
||||
{
|
||||
assert(trans_);
|
||||
if (!only_nonempty_) {
|
||||
if (output_empty_) {
|
||||
write_header();
|
||||
} else {
|
||||
count_ = HEADER_NOT_WRITTEN;
|
||||
|
@ -95,7 +95,7 @@ metawriter_json_stream::~metawriter_json_stream()
|
|||
|
||||
|
||||
metawriter_json_stream::metawriter_json_stream(metawriter_properties dflt_properties)
|
||||
: metawriter(dflt_properties), count_(-1), only_nonempty_(true),
|
||||
: metawriter(dflt_properties), count_(-1), output_empty_(true),
|
||||
trans_(0), output_srs_("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), f_(0)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue