Loading...
Searching...
No Matches
great_session.h
Go to the documentation of this file.
45 const int descriptor = open(paths[index].c_str(), O_CREAT | O_RDWR | O_NOFOLLOW | O_CLOEXEC, 0600);
80 if (fstat(descriptor, &status) != 0 || !S_ISREG(status.st_mode) || status.st_size > 4 * 1024 * 1024) {
114 if (record.size() < 65 || record[64] != '\n') throw std::runtime_error("Invalid AI Camera admission record");
118 if (!std::getline(lines, name) || name != "USHER_AICAM_V1") throw std::runtime_error("Invalid AI Camera snapshot schema");
124 if (name.empty() || name.front() != 'a' || entry.path().extension() != ".jpg" || admitted.count(name)) continue;
173static bool updateGreatSession(const MapConfig& settings, const fs::path& ini, bool final, bool render = true) {
176 throw std::runtime_error("Incremental GREAT requires low_memory GREAT XYZ and CSV or AI Camera photos");
178 const auto sourceDirectory = settings.photoDirectory.empty() ? fs::canonical(settings.sourceCsv).parent_path() :
182 const auto profileIdentity = settings.photoDirectory.empty() ? std::string() : fileDigest(settings.cameraProfile);
184 (settings.photoDirectory.empty() ? fs::canonical(settings.sourceCsv) : sourceDirectory).generic_string() + "\n" +
229 const auto revisionIdentity = "PANGEA_GREAT_REVISION_V1\n" + identity + fingerprint + "\n" + photoIdentity + "\n";
233 if (target.parent_path() != fs::path("revisions") || !greatRevisionName(target.filename().string()))
239 const cv::FileStorage status((root / "latest" / "status.json").string(), cv::FileStorage::READ);
244 if (fs::exists(revision / "identity") && sessionText(revision / "identity") != revisionIdentity)
245 throw std::runtime_error("Committed source photo changed; originals and previous revision retained");
256 if (entry.is_symlink() || !entry.is_directory() || !greatRevisionName(entry.path().filename().string()) ||
263 if (!fs::exists(revision / "identity")) saveWorkingText(revision / "identity", revisionIdentity);
281 saveWorkingText(root / "status.json", "{\"schema\":\"pangea_great_session_v1\",\"state\":\"prepared\","
289 const cv::FileStorage report((config.workingDirectory / "dataset.json").string(), cv::FileStorage::READ);
293 status << "{\"schema\":\"pangea_great_session_v1\",\"provisional\":" << (final ? "false" : "true")
294 << ",\"finalized\":" << (final ? "true" : "false") << ",\"source_count\":" << input.sourceCount()
295 << ",\"tile_count\":" << tiles << ",\"revision\":" << PhotoExif::jsonString(revisionName) << "}";
299 std::cout << "GREAT " << (final ? "final" : "provisional") << " revision: " << input.sourceCount()
static void report(const struct capture_intent *intent, unsigned camera_id, uint32_t outcome)
Record a terminal outcome without allowing telemetry backlog to block camera release.
Definition capture_arbiter.c:129
~GreatSessionLease()
Release both locks without removing the lock paths.
Definition great_session.h:63
GreatSessionLease(const GreatSessionLease &)=delete
Noncopyable: both descriptors have a single lifetime owner.
GreatSessionLease()
Acquire both nonblocking locks or fail without disturbing the owner.
Definition great_session.h:40
GreatSessionLease & operator=(const GreatSessionLease &)=delete
Nonassignable: an active lease cannot be replaced by copying.
std::array< int, 2 > descriptors_
Definition great_session.h:37
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
std::size_t sourceCount() const
Return the validated source count without decoding pixels.
Definition ortho_map.cpp:470
std::string sourceFingerprint(const std::function< bool()> &stopped) const
Hash canonical source paths and current JPEG contents in source order.
Definition ortho_map.cpp:471
static std::string jsonString(const std::string &text)
Escape a string as a JSON string literal.
Definition photo_exif.h:456
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
Definition camera_optics.h:32
static bool updateGreatSession(const MapConfig &settings, const fs::path &ini, bool final, bool render=true)
Admit new photos and optionally publish a GREAT preview/final revision.
Definition great_session.h:173
bool greatRevisionName(const std::string &name)
Validate a digest-based revision name and its preview/final suffix.
Definition great_session.h:155
std::string sessionText(const fs::path &path)
Read a bounded regular session file without following symlinks.
Definition great_session.h:76
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
std::string greatInputText(const MapConfig &config)
Snapshot the current accepted photo list for one GREAT revision.
Definition great_session.h:108
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 publishGreatLatest(const fs::path &root, const std::string &revision)
Atomically point latest at a completed, owned revision.
Definition great_session.h:139
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
Fully parsed settings shared by orthomap and XYZ export.
Definition map_config.h:41
std::filesystem::path cameraProfile
Definition map_config.h:60
std::filesystem::path sourceDirectory
Definition map_config.h:59
std::filesystem::path photoDirectory
Definition map_config.h:60
std::filesystem::path captureManifest
Definition map_config.h:71
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 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