write method

Future<void> write(
  1. double maxDeviationPixel,
  2. int instanceCount
)

Writes the complete map file structure to the file sink.

maxDeviationPixel is the maximum allowed deviation in pixels when simplifying way geometries. This is used to prevent polygons from having more than 32767 points, which is a limitation of the format. instanceCount is the number of parallel instances to use for tile processing.

Implementation

///
  /// [maxDeviationPixel] is the maximum allowed deviation in pixels when simplifying
  /// way geometries. This is used to prevent polygons from having more than 32767
  /// points, which is a limitation of the format.
  /// [instanceCount] is the number of parallel instances to use for tile processing.
  Future<void> write(double maxDeviationPixel, int instanceCount) async {
//createSubfiles();

assert(subfileCreators.isNotEmpty);
//    assert(poiTags.isNotEmpty || wayTags.isNotEmpty);

Writebuffer writebuffer = Writebuffer();
for (SubfileCreator subfileCreator in subfileCreators) {
  subfileCreator.analyze(poiTags, wayTags, mapHeaderInfo.languagesPreference);
}
_writeTags(writebuffer, poiTags);
_writeTags(writebuffer, wayTags);

MapfileHeaderWriter mapfileHeaderWriter = MapfileHeaderWriter(mapHeaderInfo);
Writebuffer writebufferHeader = mapfileHeaderWriter.write(writebuffer.length + 1 + 19 * subfileCreators.length);

for (SubfileCreator subfileCreator in subfileCreators) {
  await subfileCreator.prepareTiles(mapHeaderInfo.debugFile, maxDeviationPixel, instanceCount);
}
// amount of zoom intervals
writebuffer.appendInt1(subfileCreators.length);
await _writeZoomIntervalConfiguration(writebuffer, writebufferHeader.length + writebuffer.length + 19 * subfileCreators.length);

writebufferHeader.appendWritebuffer(writebuffer);
writebufferHeader.writeToSink(_sink);

for (SubfileCreator subfileCreator in subfileCreators) {
  // for each subfile, write the tile index header and entries
  Writebuffer writebuffer = subfileCreator.writeTileIndex(mapHeaderInfo.debugFile);
  writebuffer.writeToSink(_sink);
  await subfileCreator.writeTiles(mapHeaderInfo.debugFile, _sink);
  subfileCreator.dispose();
}
  }