add logging when we make a network request for geocoding through OSM
This commit is contained in:
parent
7d72c2e8c1
commit
83ce3afe58
1 changed files with 4 additions and 0 deletions
|
|
@ -4,6 +4,8 @@ const GeoCache = @import("GeoCache.zig");
|
||||||
const Airports = @import("Airports.zig");
|
const Airports = @import("Airports.zig");
|
||||||
const Coordinates = @import("../Coordinates.zig");
|
const Coordinates = @import("../Coordinates.zig");
|
||||||
|
|
||||||
|
const log = std.log.scoped(.resolver);
|
||||||
|
|
||||||
pub const Location = struct {
|
pub const Location = struct {
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
coords: Coordinates,
|
coords: Coordinates,
|
||||||
|
|
@ -92,6 +94,7 @@ pub const Resolver = struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("Calling nominatim (OpenStreetMap) to resolve place name {s} to coordinates", .{name});
|
||||||
// Call Nominatim API
|
// Call Nominatim API
|
||||||
const url = try std.fmt.allocPrint(
|
const url = try std.fmt.allocPrint(
|
||||||
self.allocator,
|
self.allocator,
|
||||||
|
|
@ -142,6 +145,7 @@ pub const Resolver = struct {
|
||||||
const display_name = first.object.get("display_name").?.string;
|
const display_name = first.object.get("display_name").?.string;
|
||||||
const lat = try std.fmt.parseFloat(f64, first.object.get("lat").?.string);
|
const lat = try std.fmt.parseFloat(f64, first.object.get("lat").?.string);
|
||||||
const lon = try std.fmt.parseFloat(f64, first.object.get("lon").?.string);
|
const lon = try std.fmt.parseFloat(f64, first.object.get("lon").?.string);
|
||||||
|
log.info("nominatim resolved place name {s} to {}, {}", .{ name, lat, lon });
|
||||||
|
|
||||||
// Cache the result
|
// Cache the result
|
||||||
try self.geocache.put(name, .{
|
try self.geocache.put(name, .{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue