#include "common.hh" #include "geo_json.hh" #include "timezone.hh" #include "tz_info.hh" namespace { class TimezoneImpl : public Timezone { public: TimezoneImpl(std::shared_ptr logger, std::filesystem::path geojsondb, std::filesystem::path tzinfo_dir) : geojson_(GeoJson::create(logger, std::move(geojsondb))), tzinfo_(TzInfo::create(logger, std::move(tzinfo_dir))) { } std::optional get_local_time(double lat, double lng, time_t utc_time) const override { auto tzid = geojson_->get_data(lat, lng, "tzid"); if (tzid.has_value()) return tzinfo_->get_local_time(tzid.value(), utc_time); return std::nullopt; } private: std::unique_ptr geojson_; std::unique_ptr tzinfo_; }; } // namespace std::unique_ptr Timezone::create(std::shared_ptr logger, std::filesystem::path geojsondb, std::filesystem::path tzinfo_dir) { return std::make_unique(std::move(logger), std::move(geojsondb), std::move(tzinfo_dir)); }