Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
map.c File Reference
#include "common/collection.h"
#include "common/darktable.h"
#include "common/debug.h"
#include "common/gpx.h"
#include "common/geo.h"
#include "common/image_cache.h"
#include "common/mipmap_cache.h"
#include "common/undo.h"
#include "control/conf.h"
#include "control/control.h"
#include "dtgtk/thumbtable.h"
#include "gui/drag_and_drop.h"
#include "gui/draw.h"
#include "libs/lib.h"
#include "views/view.h"
#include "views/view_api.h"
#include <gdk/gdkkeysyms.h>
#include <osm-gps-map.h>
+ Include dependency graph for map.c:

Data Structures

struct  dt_geo_position_t
 
struct  dt_map_image_t
 
struct  dt_map_t
 

Macros

#define UNCLASSIFIED   -1
 
#define NOISE   -2
 
#define CORE_POINT   1
 
#define NOT_CORE_POINT   0
 
#define LOG2(x)   ((int)floor(log2(abs(x))))
 
#define TILESIZE   256
 
#define R   6371
 

Typedefs

typedef struct dt_geo_position_t dt_geo_position_t
 
typedef struct dt_map_image_t dt_map_image_t
 
typedef struct dt_map_t dt_map_t
 
typedef enum dt_map_thumb_t dt_map_thumb_t
 

Enumerations

enum  dt_map_thumb_t {
  DT_MAP_THUMB_THUMB = 0 ,
  DT_MAP_THUMB_COUNT ,
  DT_MAP_THUMB_NONE
}
 

Functions

static void _view_map_center_on_location (const dt_view_t *view, gdouble lon, gdouble lat, gdouble zoom)
 
static void _view_map_center_on_bbox (const dt_view_t *view, gdouble lon1, gdouble lat1, gdouble lon2, gdouble lat2)
 
static void _view_map_show_osd (const dt_view_t *view)
 
static void _view_map_set_map_source (const dt_view_t *view, OsmGpsMapSource_t map_source)
 
static void _view_map_set_map_source_g_object (const dt_view_t *view, OsmGpsMapSource_t map_source)
 
static void _view_map_check_preference_changed (gpointer instance, gpointer user_data)
 
static GObject * _view_map_add_marker (const dt_view_t *view, dt_geo_map_display_t type, GList *points)
 
static gboolean _view_map_remove_marker (const dt_view_t *view, dt_geo_map_display_t type, GObject *marker)
 
static void _view_map_add_location (const dt_view_t *view, dt_map_location_data_t *g, const guint locid)
 
static void _view_map_location_action (const dt_view_t *view, const int action)
 
static void _view_map_drag_set_icon (const dt_view_t *self, GdkDragContext *context, const int32_t imgid, const int count)
 
static void _view_map_collection_changed (gpointer instance, dt_collection_change_t query_change, dt_collection_properties_t changed_property, gpointer imgs, int next, gpointer user_data)
 
static void _view_map_selection_changed (gpointer instance, gpointer user_data)
 
static void _view_map_geotag_changed (gpointer instance, GList *imgs, const int locid, gpointer user_data)
 
static void _view_map_update_location_geotag (dt_view_t *self)
 
static void _view_map_filmstrip_activate_callback (gpointer instance, int32_t imgid, gpointer user_data)
 
static void _drag_and_drop_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint target_type, guint time, gpointer data)
 
static void _view_map_dnd_get_callback (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint target_type, guint time, dt_view_t *self)
 
static void _view_map_changed_callback (OsmGpsMap *map, dt_view_t *self)
 
static gboolean _view_map_scroll_event (GtkWidget *w, GdkEventScroll *event, dt_view_t *self)
 
static gboolean _view_map_button_press_callback (GtkWidget *w, GdkEventButton *e, dt_view_t *self)
 
static gboolean _view_map_button_release_callback (GtkWidget *w, GdkEventButton *e, dt_view_t *self)
 
static gboolean _view_map_motion_notify_callback (GtkWidget *w, GdkEventMotion *e, dt_view_t *self)
 
static gboolean _view_map_drag_motion_callback (GtkWidget *widget, GdkDragContext *dc, gint x, gint y, guint time, dt_view_t *self)
 
static gboolean _view_map_dnd_failed_callback (GtkWidget *widget, GdkDragContext *drag_context, GtkDragResult result, dt_view_t *self)
 
static void _dbscan (dt_geo_position_t *points, unsigned int num_points, double epsilon, unsigned int minpts)
 
static gboolean _view_map_prefs_changed (dt_map_t *lib)
 
static void _view_map_build_main_query (dt_map_t *lib)
 
static gboolean _view_map_center_on_image_list (dt_view_t *self, const char *table)
 
static void _view_map_center_on_image (dt_view_t *self, const int32_t imgid)
 
static OsmGpsMapPolygon * _view_map_add_polygon_location (dt_map_t *lib, dt_location_draw_t *ld)
 
static gboolean _view_map_remove_polygon (const dt_view_t *view, OsmGpsMapPolygon *polygon)
 
static OsmGpsMapImage * _view_map_draw_location (dt_map_t *lib, dt_location_draw_t *ld, const gboolean main)
 
static void _view_map_remove_location (dt_map_t *lib, dt_location_draw_t *ld)
 
const char * name (const dt_view_t *self)
 
uint32_t view (const dt_view_t *self)
 
static float deg2rad (float deg)
 
static int latlon2zoom (int pix_height, int pix_width, float lat1, float lat2, float lon1, float lon2)
 
static void osm_gps_map_zoom_fit_bbox (OsmGpsMap *map, float latitude1, float latitude2, float longitude1, float longitude2)
 
static void _toast_log_lat_lon (const float lat, const float lon)
 
static GdkPixbuf * _view_map_images_count (const int nb_images, const gboolean same_loc, double *count_width, double *count_height)
 
static GdkPixbuf * _init_image_pin ()
 
static GdkPixbuf * _init_place_pin ()
 
static GdkPixbuf * _draw_ellipse (const float dlongitude, const float dlatitude, const gboolean main)
 
static GdkPixbuf * _draw_rectangle (const float dlongitude, const float dlatitude, const gboolean main)
 
void expose (dt_view_t *self, cairo_t *cri, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
 
static void _view_changed (gpointer instance, dt_view_t *old_view, dt_view_t *new_view, dt_view_t *self)
 
void init (dt_view_t *self)
 
void cleanup (dt_view_t *self)
 
void configure (dt_view_t *self, int wd, int ht)
 
int try_enter (dt_view_t *self)
 
static void _view_map_signal_change_raise (gpointer user_data)
 
static gboolean _view_map_signal_change_delayed (gpointer user_data)
 
static void _view_map_signal_change_wait (dt_view_t *self, const int time_out)
 
static gboolean _view_map_redraw (gpointer user_data)
 
static void _view_map_angles (dt_map_t *lib, const gint pixels, const float lat, const float lon, float *dlat_min, float *dlon_min)
 
static void _view_map_thumb_angles (dt_map_t *lib, const float lat, const float lon, float *dlat_min, float *dlon_min)
 
static float _view_map_angles_to_pixels (const dt_map_t *lib, const float lat0, const float lon0, const float angle)
 
static double _view_map_get_angles_ratio (const dt_map_t *lib, const float lat0, const float lon0)
 
static GdkPixbuf * _draw_location (dt_map_t *lib, int *width, int *height, dt_map_location_data_t *data, const gboolean main)
 
dt_location_draw_t_others_location_draw (dt_map_t *lib, const int locid)
 
GList * _others_location (GList *others, const int locid)
 
static void _view_map_delete_other_location (dt_map_t *lib, GList *other)
 
static void _view_map_draw_main_location (dt_map_t *lib, dt_location_draw_t *ld)
 
static void _view_map_draw_other_locations (dt_map_t *lib, dt_map_box_t *bbox)
 
static GdkPixbuf * _draw_image (const int32_t imgid, int *width, int *height, const int group_count, const gboolean group_same_loc, const uint32_t frame, const gboolean blocking, const int thumbnail, dt_view_t *self)
 
static gboolean _view_map_draw_image (dt_map_image_t *entry, const gboolean blocking, const int thumbnail, dt_view_t *self)
 
static gboolean _view_map_draw_images (gpointer user_data)
 
static void _view_map_get_bounding_box (dt_map_t *lib, dt_map_box_t *bbox)
 
static void _view_map_changed_callback_delayed (gpointer user_data)
 
static gboolean _view_map_changed_callback_wait (gpointer user_data)
 
static dt_map_image_t_view_map_get_entry_at_pos (dt_view_t *self, const double x, const double y)
 
static GList * _view_map_get_imgs_at_pos (dt_view_t *self, const float x, const float y, int *offset_x, int *offset_y, const gboolean first_on)
 
gint _find_image_in_images (gconstpointer a, gconstpointer b)
 
static gboolean _display_next_image (dt_view_t *self, dt_map_image_t *entry, const gboolean next)
 
static gboolean _zoom_and_center (const gint x, const gint y, const int direction, dt_view_t *self)
 
static gboolean _view_map_display_selected (gpointer user_data)
 
void enter (dt_view_t *self)
 
void leave (dt_view_t *self)
 
static OsmGpsMapImage * _view_map_add_pin (const dt_view_t *view, GList *points)
 
static gboolean _view_map_remove_pin (const dt_view_t *view, OsmGpsMapImage *pin)
 
static void _track_add_point (OsmGpsMapTrack *track, OsmGpsMapPoint *point, OsmGpsMapPoint *prev_point)
 
static OsmGpsMapTrack * _view_map_add_track (const dt_view_t *view, GList *points)
 
static gboolean _view_map_remove_track (const dt_view_t *view, OsmGpsMapTrack *track)
 
static OsmGpsMapImage * _view_map_draw_single_image (const dt_view_t *view, GList *points)
 

Variables

static const int thumb_size = 128
 
static const int thumb_border = 2
 
static const int image_pin_size = 13
 
static const int place_pin_size = 72
 
static const int cross_size = 16
 
static const int max_size = 1024
 
static const uint32_t thumb_frame_color = 0x000000aa
 
static const uint32_t thumb_frame_sel_color = 0xffffffee
 
static const uint32_t thumb_frame_gpx_color = 0xff000099
 
static const uint32_t pin_outer_color = 0x0000aaaa
 
static const uint32_t pin_inner_color = 0xffffffee
 
static const uint32_t pin_line_color = 0x000000ff
 
static int first_times = 3
 

Macro Definition Documentation

◆ CORE_POINT

#define CORE_POINT   1

◆ LOG2

#define LOG2 (   x)    ((int)floor(log2(abs(x))))

◆ NOISE

#define NOISE   -2

◆ NOT_CORE_POINT

#define NOT_CORE_POINT   0

◆ R

#define R   6371

◆ TILESIZE

#define TILESIZE   256

◆ UNCLASSIFIED

#define UNCLASSIFIED   -1

Typedef Documentation

◆ dt_geo_position_t

◆ dt_map_image_t

◆ dt_map_t

typedef struct dt_map_t dt_map_t

◆ dt_map_thumb_t

Enumeration Type Documentation

◆ dt_map_thumb_t

Enumerator
DT_MAP_THUMB_THUMB 
DT_MAP_THUMB_COUNT 
DT_MAP_THUMB_NONE 

Function Documentation

◆ _dbscan()

static void _dbscan ( dt_geo_position_t points,
unsigned int  num_points,
double  epsilon,
unsigned int  minpts 
)
static

◆ _display_next_image()

◆ _drag_and_drop_received()

◆ _draw_ellipse()

static GdkPixbuf * _draw_ellipse ( const float  dlongitude,
const float  dlatitude,
const gboolean  main 
)
static

◆ _draw_image()

static GdkPixbuf * _draw_image ( const int32_t  imgid,
int *  width,
int *  height,
const int  group_count,
const gboolean  group_same_loc,
const uint32_t  frame,
const gboolean  blocking,
const int  thumbnail,
dt_view_t self 
)
static

◆ _draw_location()

◆ _draw_rectangle()

static GdkPixbuf * _draw_rectangle ( const float  dlongitude,
const float  dlatitude,
const gboolean  main 
)
static

◆ _find_image_in_images()

gint _find_image_in_images ( gconstpointer  a,
gconstpointer  b 
)

References dt_map_image_t::imgid.

◆ _init_image_pin()

static GdkPixbuf * _init_image_pin ( )
static

◆ _init_place_pin()

static GdkPixbuf * _init_place_pin ( )
static

◆ _others_location()

GList * _others_location ( GList *  others,
const int  locid 
)

◆ _others_location_draw()

dt_location_draw_t * _others_location_draw ( dt_map_t lib,
const int  locid 
)

◆ _toast_log_lat_lon()

static void _toast_log_lat_lon ( const float  lat,
const float  lon 
)
static

◆ _track_add_point()

static void _track_add_point ( OsmGpsMapTrack *  track,
OsmGpsMapPoint *  point,
OsmGpsMapPoint *  prev_point 
)
static

◆ _view_changed()

static void _view_changed ( gpointer  instance,
dt_view_t old_view,
dt_view_t new_view,
dt_view_t self 
)
static

◆ _view_map_add_location()

◆ _view_map_add_marker()

static GObject * _view_map_add_marker ( const dt_view_t view,
dt_geo_map_display_t  type,
GList *  points 
)
static

◆ _view_map_add_pin()

static OsmGpsMapImage * _view_map_add_pin ( const dt_view_t view,
GList *  points 
)
static

◆ _view_map_add_polygon_location()

static OsmGpsMapPolygon * _view_map_add_polygon_location ( dt_map_t lib,
dt_location_draw_t ld 
)
static

Referenced by _view_map_draw_location().

◆ _view_map_add_track()

static OsmGpsMapTrack * _view_map_add_track ( const dt_view_t view,
GList *  points 
)
static

◆ _view_map_angles()

static void _view_map_angles ( dt_map_t lib,
const gint  pixels,
const float  lat,
const float  lon,
float *  dlat_min,
float *  dlon_min 
)
static

References lat, lon, and dt_map_t::map.

Referenced by _view_map_thumb_angles().

◆ _view_map_angles_to_pixels()

static float _view_map_angles_to_pixels ( const dt_map_t lib,
const float  lat0,
const float  lon0,
const float  angle 
)
static

References dt_map_t::map.

Referenced by _draw_location().

◆ _view_map_build_main_query()

static void _view_map_build_main_query ( dt_map_t lib)
static

◆ _view_map_button_press_callback()

◆ _view_map_button_release_callback()

static gboolean _view_map_button_release_callback ( GtkWidget *  w,
GdkEventButton *  e,
dt_view_t self 
)
static

◆ _view_map_center_on_bbox()

static void _view_map_center_on_bbox ( const dt_view_t view,
gdouble  lon1,
gdouble  lat1,
gdouble  lon2,
gdouble  lat2 
)
static

◆ _view_map_center_on_image()

◆ _view_map_center_on_image_list()

◆ _view_map_center_on_location()

static void _view_map_center_on_location ( const dt_view_t view,
gdouble  lon,
gdouble  lat,
gdouble  zoom 
)
static

◆ _view_map_changed_callback()

static void _view_map_changed_callback ( OsmGpsMap *  map,
dt_view_t self 
)
static

◆ _view_map_changed_callback_delayed()

◆ _view_map_changed_callback_wait()

static gboolean _view_map_changed_callback_wait ( gpointer  user_data)
static

◆ _view_map_check_preference_changed()

static void _view_map_check_preference_changed ( gpointer  instance,
gpointer  user_data 
)
static

References _view_map_prefs_changed(), dt_map_t::map, and view().

Referenced by cleanup(), and init().

◆ _view_map_collection_changed()

◆ _view_map_delete_other_location()

static void _view_map_delete_other_location ( dt_map_t lib,
GList *  other 
)
static

◆ _view_map_display_selected()

static gboolean _view_map_display_selected ( gpointer  user_data)
static

◆ _view_map_dnd_failed_callback()

static gboolean _view_map_dnd_failed_callback ( GtkWidget *  widget,
GdkDragContext *  drag_context,
GtkDragResult  result,
dt_view_t self 
)
static

Referenced by init().

◆ _view_map_dnd_get_callback()

static void _view_map_dnd_get_callback ( GtkWidget *  widget,
GdkDragContext *  context,
GtkSelectionData *  selection_data,
guint  target_type,
guint  time,
dt_view_t self 
)
static

◆ _view_map_drag_motion_callback()

static gboolean _view_map_drag_motion_callback ( GtkWidget *  widget,
GdkDragContext *  dc,
gint  x,
gint  y,
guint  time,
dt_view_t self 
)
static

References _toast_log_lat_lon(), dt_view_t::data, FALSE, lat, lon, and dt_map_t::map.

Referenced by init().

◆ _view_map_drag_set_icon()

static void _view_map_drag_set_icon ( const dt_view_t self,
GdkDragContext *  context,
const int32_t  imgid,
const int  count 
)
static

◆ _view_map_draw_image()

◆ _view_map_draw_images()

◆ _view_map_draw_location()

◆ _view_map_draw_main_location()

◆ _view_map_draw_other_locations()

◆ _view_map_draw_single_image()

static OsmGpsMapImage * _view_map_draw_single_image ( const dt_view_t view,
GList *  points 
)
static

◆ _view_map_filmstrip_activate_callback()

static void _view_map_filmstrip_activate_callback ( gpointer  instance,
int32_t  imgid,
gpointer  user_data 
)
static

References _view_map_center_on_image().

Referenced by enter(), and leave().

◆ _view_map_geotag_changed()

static void _view_map_geotag_changed ( gpointer  instance,
GList *  imgs,
const int  locid,
gpointer  user_data 
)
static

◆ _view_map_get_angles_ratio()

static double _view_map_get_angles_ratio ( const dt_map_t lib,
const float  lat0,
const float  lon0 
)
static

◆ _view_map_get_bounding_box()

static void _view_map_get_bounding_box ( dt_map_t lib,
dt_map_box_t bbox 
)
static

◆ _view_map_get_entry_at_pos()

◆ _view_map_get_imgs_at_pos()

static GList * _view_map_get_imgs_at_pos ( dt_view_t self,
const float  x,
const float  y,
int *  offset_x,
int *  offset_y,
const gboolean  first_on 
)
static

◆ _view_map_images_count()

static GdkPixbuf * _view_map_images_count ( const int  nb_images,
const gboolean  same_loc,
double count_width,
double count_height 
)
static

◆ _view_map_location_action()

◆ _view_map_motion_notify_callback()

◆ _view_map_prefs_changed()

static gboolean _view_map_prefs_changed ( dt_map_t lib)
static

◆ _view_map_redraw()

static gboolean _view_map_redraw ( gpointer  user_data)
static

References dt_view_t::data, FALSE, and dt_map_t::map.

Referenced by enter().

◆ _view_map_remove_location()

◆ _view_map_remove_marker()

static gboolean _view_map_remove_marker ( const dt_view_t view,
dt_geo_map_display_t  type,
GObject *  marker 
)
static

◆ _view_map_remove_pin()

static gboolean _view_map_remove_pin ( const dt_view_t view,
OsmGpsMapImage *  pin 
)
static

References dt_map_t::map, and view().

Referenced by _view_map_remove_marker().

◆ _view_map_remove_polygon()

static gboolean _view_map_remove_polygon ( const dt_view_t view,
OsmGpsMapPolygon *  polygon 
)
static

Referenced by _view_map_remove_marker().

◆ _view_map_remove_track()

static gboolean _view_map_remove_track ( const dt_view_t view,
OsmGpsMapTrack *  track 
)
static

References dt_map_t::map, and view().

Referenced by _view_map_remove_marker().

◆ _view_map_scroll_event()

◆ _view_map_selection_changed()

static void _view_map_selection_changed ( gpointer  instance,
gpointer  user_data 
)
static

◆ _view_map_set_map_source()

static void _view_map_set_map_source ( const dt_view_t view,
OsmGpsMapSource_t  map_source 
)
static

◆ _view_map_set_map_source_g_object()

static void _view_map_set_map_source_g_object ( const dt_view_t view,
OsmGpsMapSource_t  map_source 
)
static

References dt_map_t::map, and view().

Referenced by _view_map_set_map_source(), enter(), and leave().

◆ _view_map_show_osd()

static void _view_map_show_osd ( const dt_view_t view)
static

References dt_conf_get_bool(), dt_map_t::map, dt_map_t::osd, and view().

Referenced by enter().

◆ _view_map_signal_change_delayed()

static gboolean _view_map_signal_change_delayed ( gpointer  user_data)
static

◆ _view_map_signal_change_raise()

◆ _view_map_signal_change_wait()

static void _view_map_signal_change_wait ( dt_view_t self,
const int  time_out 
)
static

◆ _view_map_thumb_angles()

static void _view_map_thumb_angles ( dt_map_t lib,
const float  lat,
const float  lon,
float *  dlat_min,
float *  dlon_min 
)
static

◆ _view_map_update_location_geotag()

◆ _zoom_and_center()

static gboolean _zoom_and_center ( const gint  x,
const gint  y,
const int  direction,
dt_view_t self 
)
static

◆ cleanup()

◆ configure()

void configure ( dt_view_t self,
int  wd,
int  ht 
)

◆ deg2rad()

static float deg2rad ( float  deg)
static

References M_PI.

Referenced by osm_gps_map_zoom_fit_bbox().

◆ enter()

◆ expose()

void expose ( dt_view_t self,
cairo_t *  cri,
int32_t  width,
int32_t  height,
int32_t  pointerx,
int32_t  pointery 
)

◆ init()

void init ( dt_view_t self)

◆ latlon2zoom()

static int latlon2zoom ( int  pix_height,
int  pix_width,
float  lat1,
float  lat2,
float  lon1,
float  lon2 
)
static

References LOG2, M_PI, MIN, and TILESIZE.

Referenced by osm_gps_map_zoom_fit_bbox().

◆ leave()

◆ name()

const char * name ( const dt_view_t self)

◆ osm_gps_map_zoom_fit_bbox()

static void osm_gps_map_zoom_fit_bbox ( OsmGpsMap *  map,
float  latitude1,
float  latitude2,
float  longitude1,
float  longitude2 
)
static

References deg2rad(), and latlon2zoom().

Referenced by _view_map_center_on_bbox().

◆ try_enter()

int try_enter ( dt_view_t self)

◆ view()

Variable Documentation

◆ cross_size

const int cross_size = 16
static

Referenced by _draw_ellipse(), and _draw_rectangle().

◆ first_times

int first_times = 3
static

◆ image_pin_size

◆ max_size

const int max_size = 1024
static

◆ pin_inner_color

const uint32_t pin_inner_color = 0xffffffee
static

Referenced by _init_place_pin().

◆ pin_line_color

const uint32_t pin_line_color = 0x000000ff
static

Referenced by _init_place_pin().

◆ pin_outer_color

const uint32_t pin_outer_color = 0x0000aaaa
static

Referenced by _init_place_pin().

◆ place_pin_size

const int place_pin_size = 72
static

Referenced by _init_place_pin().

◆ thumb_border

const int thumb_border = 2
static

◆ thumb_frame_color

const uint32_t thumb_frame_color = 0x000000aa
static

◆ thumb_frame_gpx_color

const uint32_t thumb_frame_gpx_color = 0xff000099
static

◆ thumb_frame_sel_color

const uint32_t thumb_frame_sel_color = 0xffffffee
static

◆ thumb_size