Loading...
Searching...
No Matches
xyz_export.h
Go to the documentation of this file.
94 const auto source = processor.renderWindow(static_cast<std::size_t>(left), static_cast<std::size_t>(top),
108 const std::size_t taps[] = {offset, offset + 1, offset + windowWidth, offset + windowWidth + 1};
123 result.bgra[i * 4 + c] = static_cast<unsigned char>(std::clamp(std::lround(colour[c]), 0L, 255L));
180 * @throws std::runtime_error If a saved batch has mismatched dimensions/hash or rendering fails.
182static pangea_survey::XyzPixels xyzBatch(pangea_survey::Orthorectifier& processor, const pangea_survey::MapConfig& working,
183 const pangea_survey::OrthoLayout& layout, int zoom, std::uint64_t x, std::uint64_t y, int width, int height) {
184 const auto path = working.workingDirectory / "batches" / (std::to_string(x) + "_" + std::to_string(y));
191 savedWidth != width || savedHeight != height || pangea_survey::fileDigest(path, isStopping) != digest ||
199 input.read(reinterpret_cast<char*>(plane->data()), static_cast<std::streamsize>(plane->size()));
204 auto pixels = pangea_survey::renderXyzPixels(processor, working, layout, zoom, x, y, width, height, isStopping);
207 pangea_survey::storageHeadroom(path.parent_path(), static_cast<std::uint64_t>(width) * height * 5);
211 output.write(reinterpret_cast<const char*>(plane->data()), static_cast<std::streamsize>(plane->size()));
215 pangea_survey::saveWorkingText(recordPath, std::to_string(width) + " " + std::to_string(height) + " " + pangea_survey::fileDigest(path, isStopping) + "\n");
240 pangea_survey::publishWorkingFile(workDirectory / "dataset.json", workDirectory / "dataset.previous.json");
250 << "Ground pixel at area centre: " << pangea_survey::XyzTiles::groundPixel(plan.base.zoom, latitude)
252 << config.mosaicThreads << (config.lowMemory ? "; byte-bounded disk cache; " : "; 32-block LRU; ")
254 << "Output: " << config.output.u8string() << "\nExport report: " << workDirectory.u8string() << '\n';
255 if (working.mapPixelSize > pangea_survey::XyzTiles::groundPixel(plan.base.zoom, latitude) * 1.05)
258 const auto manifestPath = workDirectory / (config.lowMemory ? "tiles.csv.partial" : "tiles.csv");
264 progress.stage(diagnostic ? "Rendering XYZ diagnostic tiles" : "Rendering and publishing XYZ tiles",
318 const auto jpeg = encoder.encode(data, 256, 256, pixels.width * 4, static_cast<int>(config.quality));
320 if (pangea_survey::fileDigest(path, isStopping) != pangea_survey::dataDigest(jpeg.data, jpeg.size))
352 if (!manifest || published + omitted != plan.size()) throw std::runtime_error("XYZ tile manifest is incomplete");
354 throw std::runtime_error("No XYZ tile has complete colour coverage; report remains incomplete");
355 if (config.lowMemory) pangea_survey::publishWorkingFile(manifestPath, workDirectory / "tiles.csv");
359 metadata << "{\"complete\":" << (diagnostic || omitted || config.incrementalPreview ? "false" : "true")
362 << pangea_survey::PhotoExif::jsonString(config.xyzCompleteOnly ? "complete_tiles_only" : "require_all")
375 << ",\"ground_pixel_size_at_centre_m\":" << pangea_survey::XyzTiles::groundPixel(plan.base.zoom, latitude)
378 << ",\"runtime_profile\":" << pangea_survey::PhotoExif::jsonString(config.lowMemory ? "low_memory" : "desktop")
385 << ",\"gap_fill_method\":" << pangea_survey::PhotoExif::jsonString(config.mosaicFillGaps ? "global_source_push_pull" : "none")
388 << ",\"observed_coverage_complete\":" << (omitted || reconstructed || reconstructionBlend ? "false" : "true")
391 << ",\"original_source_csv\":" << pangea_survey::PhotoExif::jsonString(config.originalSourceCsv.u8string())
392 << ",\"photo_directory\":" << pangea_survey::PhotoExif::jsonString(config.photoDirectory.u8string())
393 << ",\"camera_geometry\":" << pangea_survey::PhotoExif::jsonString(config.photoDirectory.empty() ?
394 "confirmed_survey_nadir" : config.allowRecordedPose ? "usher_recorded_exif_pose_perspective_unverified_timing" :
396 << ",\"optics_calibration\":" << pangea_survey::PhotoExif::jsonString(config.photoDirectory.empty() ?
398 << ",\"camera_profile\":" << pangea_survey::PhotoExif::jsonString(config.cameraProfile.u8string())
399 << ",\"admission_max_pose_uncertainty_m\":" << (config.allowRecordedPose ? "null" : std::to_string(config.maxPoseUncertainty))
void saveBinary(const fs::path &path, const void *data, std::size_t size)
Write bytes to a new path and publish them by same-directory rename.
Definition binary_output.h:41
static void save(const Image &image, const std::filesystem::path &path, const unsigned char *exif=nullptr, std::size_t exifSize=0, bool durable=false)
Publish encoded JPEG bytes, optionally adding one EXIF APP1 segment.
Definition jpeg_encoder.h:192
Thread-safe progress reporter for staged map work.
Definition map_progress.h:49
void stage(const std::string &name, double first, double last, double estimateSeconds=0)
Begin a monotonic percentage range for one named stage.
Definition map_progress.h:152
void finish()
Mark the entire operation complete and permit 100 percent output.
Definition map_progress.h:186
void update(double fraction, const std::string &detail={})
Advance the current stage without allowing its fraction to regress.
Definition map_progress.h:173
Forward and inverse WGS-84 Transverse Mercator conversion for one UTM zone.
Definition map_projection.h:46
std::pair< double, double > forward(double latitude, double longitude) const
Project a geographic position into UTM easting and northing.
Definition map_projection.h:101
Load a fixed-session source set and render its projected tiles/windows.
Definition ortho_map.h:98
void prepareSources(const std::function< bool()> &stopped)
Prepare shared source rasters/mosaic state before repeated rendering.
Definition ortho_map.cpp:640
OrthoImage renderWindow(std::size_t originX, std::size_t originY, int width, int height, const std::function< bool()> &stopped, const std::function< void(double)> &progress={})
Render an arbitrary bounded window of the configured map grid.
Definition ortho_map.cpp:1301
static std::string jsonString(const std::string &text)
Escape a string as a JSON string literal.
Definition photo_exif.h:456
static double groundPixel(int zoom, double latitude)
Ground metres per pixel at a latitude after Mercator scale correction.
Definition xyz_tiles.h:71
static std::filesystem::path path(const std::filesystem::path &root, int zoom, std::uint32_t x, std::uint32_t y)
Build the canonical zoom/x/y.jpeg path after range validation.
Definition xyz_tiles.h:105
static std::pair< double, double > pixel(std::uint64_t x, std::uint64_t y, int zoom)
Return the geographic centre of one global pixel address.
Definition xyz_tiles.h:100
static int record(const union dc_shot_union *shot)
Retrieve a point and admit a new observation only when its credit is free.
Definition dipla_camera_backend.c:206
static bool publish(const char *path, const uint8_t *frame, size_t bytes, unsigned width, unsigned height, bool synthetic, bool raw, const struct lwir_evidence *evidence, const struct lwir_render_options *render)
Durably publish a JPEG or raw companion under a new name.
Definition lwir_image.c:422
Definition camera_optics.h:32
bool xyzCompleteCoverage(std::size_t valid)
Require every one of the tile's 256 x 256 output pixels to be supported.
Definition xyz_export.h:40
OrthoLayout orthoLayout(const MapConfig &config)
Compute a north-up, non-overlapping image grid for the requested bounds.
Definition ortho_map.cpp:334
void storageHeadroom(const std::filesystem::path &directory, std::uint64_t bytes)
Require requested free space plus a fixed safety reserve.
Definition map_storage.h:121
void parallelRows(int rows, Function function, unsigned requested=4)
Apply a row operation in parallel without creating nested teams.
Definition parallel_rows.h:48
std::string fileDigest(const std::filesystem::path &path, const std::function< bool()> &stopped={})
Hash a file in bounded chunks, optionally honoring cancellation.
Definition map_storage.h:89
XyzPixels xyzOverview(const XyzPixels &input, unsigned workers, const std::function< bool()> &stopped)
Build one lower-zoom level from aligned 2 x 2 child pixels.
Definition xyz_export.h:138
void publishWorkingFile(const std::filesystem::path &temporary, const std::filesystem::path &target, bool replace=true)
Fsync a completed working file, rename it, then sync its directory.
Definition map_storage.h:135
std::string dataDigest(const void *data, std::size_t size)
Compute a lowercase SHA-256 digest for an in-memory byte range.
Definition map_storage.h:77
void saveWorkingText(const std::filesystem::path &target, const std::string &text)
Save checkpoint text through the durable working-file publisher.
Definition map_storage.h:158
XyzPixels renderXyzPixels(Orthorectifier &processor, const MapConfig &config, const OrthoLayout &layout, int zoom, std::uint64_t originX, std::uint64_t originY, int width, int height, const std::function< bool()> &stopped)
Resample an orthomosaic window onto one Web-Mercator pixel grid.
Definition xyz_export.h:59
bool mosaicMode(const std::string &mode)
Return whether a supported processing mode uses the Great mosaic.
Definition map_config.h:80
Run independent row work with a bounded native thread team.
Fully parsed settings shared by orthomap and XYZ export.
Definition map_config.h:41
std::filesystem::path workingDirectory
Definition map_config.h:57
std::filesystem::path originalSourceCsv
Definition map_config.h:71
std::filesystem::path cameraProfile
Definition map_config.h:60
std::filesystem::path photoDirectory
Definition map_config.h:60
int mosaicOverviewSourceMaxSide
Definition map_config.h:53
UTM-aligned extent and tile count for one requested map area.
Definition ortho_map.h:38
Colour and confidence planes for one aligned XYZ working batch.
Definition xyz_export.h:34
std::vector< unsigned char > confidence
Definition xyz_export.h:36
Derive requested XYZ bounds, map grid, and per-zoom tile ranges.
Definition xyz_tiles.h:119
static bool isStopping()
Check cancellation at a cooperative mapping boundary.
Definition survey.cpp:68
static double seconds(Clock::duration duration)
Convert a monotonic interval without truncating fractional seconds.
Definition survey.cpp:100
static int exportXyzTiles(const pangea_survey::MapConfig &config, const fs::path &csv, const fs::path &workDirectory, bool diagnostic=false)
Render and publish the planned XYZ pyramid, optionally as diagnostics.
Definition xyz_export.h:230
static pangea_survey::XyzPixels xyzBatch(pangea_survey::Orthorectifier &processor, const pangea_survey::MapConfig &working, const pangea_survey::OrthoLayout &layout, int zoom, std::uint64_t x, std::uint64_t y, int width, int height)
Render or reuse one identity-checked XYZ batch for low-memory resume.
Definition xyz_export.h:182
Plan interoperable XYZ tile ranges in Web Mercator.