QString OsmPgCsvWriter::toString(const ConstOsmMapPtr& map) { OsmPgCsvWriter writer; array<QString, FileType::MaxFileType> buffers; for (int i = 0; i < FileType::MaxFileType; ++i) writer._streams[i].setString(&buffers[i]); // Initialize the file headers writer._initFiles(); // Write the map to the string writer.write(map); // Flush the streams to the buffers writer.close(); // Everything is written to the buffers for (int i = 1; i < FileType::MaxFileType; ++i) writer._streams[0] << writer._endl + buffers[i]; return buffers[0]; }
void runBasic() { OsmXmlReader reader; OsmMapPtr map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ScoreMatchRef1.osm", map); OsmPgCsvWriter writer; writer.open("test-output/io/PgCsvWriter/runBasic.pgcsv"); writer.write(map); writer.close(); // Check the results HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-nodes.pgcsv"), QString("test-output/io/PgCsvWriter/runBasic-nodes.pgcsv")); HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-ways.pgcsv"), QString("test-output/io/PgCsvWriter/runBasic-ways.pgcsv")); HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-waynodes.pgcsv"), QString("test-output/io/PgCsvWriter/runBasic-waynodes.pgcsv")); HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-relations.pgcsv"), QString("test-output/io/PgCsvWriter/runBasic-relations.pgcsv")); HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-relationmembers.pgcsv"), QString("test-output/io/PgCsvWriter/runBasic-relationmembers.pgcsv")); }