#ifndef WEATHER_APP_H
#define WEATHER_APP_H

#include <cairo.h>
#include <stdbool.h>
#include <stdint.h>

/* radar.c: weathersnail's radar maps (the NWS's radars put together),
 * in web-map projection, with place names over them */
struct radar_map {
	char *region; // "national", "mosaic-ak", …
	cairo_surface_t *map; // the radar on the light base map
	cairo_surface_t *labels; // place names, the map's size, may be NULL
	double west, south, east, north;
	int width, height, zoom;
	int64_t time; // when the radar saw it
};
struct radar_stop {
	double dbz;
	uint32_t color;
};
struct radar_ramp {
	char *label; // "Rain"
	struct radar_stop *stops;
	int count;
};
typedef void (*radar_fn)(void *data);
/* fn runs when a map came (or a newer one did); family draws the names */
void radar_init(radar_fn fn, void *data, const char *family);
/* The map a place is on, or NULL while it comes (asking starts it, and
 * the list of maps is read again when it's a few minutes old) */
const struct radar_map *radar_for(double lat, double lon);
/* Where a place is on the map, in its pixels */
void radar_project(const struct radar_map *m, double lat, double lon,
	double *x, double *y);
/* The colour ramps of the legend */
const struct radar_ramp *radar_ramps(int *count);
void radar_refresh(void);
/* Couldn't be read (the place is off every map, or no network) */
bool radar_failed(double lat, double lon);

#endif
