-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #439 from mmd-osm/patch/csjsonformat
Rework changeset json output according to Rails implementation
- Loading branch information
Showing
19 changed files
with
249 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* SPDX-License-Identifier: GPL-2.0-only | ||
* | ||
* This file is part of openstreetmap-cgimap (https://github.com/zerebubuth/openstreetmap-cgimap/). | ||
* | ||
* Copyright (C) 2009-2023 by the CGImap developer community. | ||
* For a full list of authors see the git log. | ||
*/ | ||
|
||
#ifndef OSM_CHANGESET_RESPONDER_HPP | ||
#define OSM_CHANGESET_RESPONDER_HPP | ||
|
||
#include "cgimap/osm_responder.hpp" | ||
|
||
#include <chrono> | ||
|
||
|
||
class osm_changeset_responder : public osm_responder { | ||
public: | ||
// construct, passing the mime type down to the responder. | ||
// multi_selection flag can be set if we plan to fetch and print multiple changesets | ||
osm_changeset_responder(mime::type, | ||
data_selection &s, | ||
bool multi_selection); | ||
|
||
// writes whatever is in the selection to the formatter | ||
void write(output_formatter& f, | ||
const std::string &generator, | ||
const std::chrono::system_clock::time_point &now) override; | ||
|
||
protected: | ||
// current selection of elements to be written out | ||
data_selection& sel; | ||
// do we want to select and print multiple changesets? | ||
bool multi_selection{false}; | ||
}; | ||
|
||
#endif /* OSM_CHANGESET_RESPONDER_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* SPDX-License-Identifier: GPL-2.0-only | ||
* | ||
* This file is part of openstreetmap-cgimap (https://github.com/zerebubuth/openstreetmap-cgimap/). | ||
* | ||
* Copyright (C) 2009-2023 by the CGImap developer community. | ||
* For a full list of authors see the git log. | ||
*/ | ||
|
||
#include "cgimap/logger.hpp" | ||
#include "cgimap/osm_changeset_responder.hpp" | ||
|
||
#include <fmt/core.h> | ||
|
||
#include <optional> | ||
|
||
using std::list; | ||
|
||
osm_changeset_responder::osm_changeset_responder(mime::type mt, | ||
data_selection &s, | ||
bool multi_selection) | ||
: osm_responder(mt), | ||
sel(s), | ||
multi_selection(multi_selection){} | ||
|
||
|
||
void osm_changeset_responder::write(output_formatter& fmt, | ||
const std::string &generator, | ||
const std::chrono::system_clock::time_point &now) { | ||
|
||
try { | ||
fmt.start_document(generator, "osm"); | ||
|
||
fmt.start_changeset(multi_selection); | ||
|
||
// write changeset | ||
sel.write_changesets(fmt, now); | ||
|
||
fmt.end_changeset(multi_selection); | ||
|
||
} catch (const std::exception &e) { | ||
logger::message(fmt::format("Caught error in osm_changeset_responder: {}", | ||
e.what())); | ||
fmt.error(e); | ||
} | ||
|
||
fmt.end_document(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.