Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
location_repository.h File Reference

data.locations: the geometry of a geotagging location. More...

#include "metadata/map_locations.h"
#include <glib.h>
#include <stdint.h>
+ Include dependency graph for location_repository.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dt_location_candidate_t
 One row of a geo query: an id with the position that matched. More...
 

Typedefs

typedef G_BEGIN_DECLS struct dt_location_candidate_t dt_location_candidate_t
 One row of a geo query: an id with the position that matched.
 

Functions

void dt_location_repository_delete (const guint locid)
 Drop the geometry row of locid. The tag itself is the tag repository's.
 
GListdt_location_repository_get_in_bbox (const dt_map_box_t *const bbox)
 Locations whose extent overlaps bbox.
 
dt_map_location_data_tdt_location_repository_get_data (const guint locid, const char *name_prefix)
 The geometry of locid, if it is a real location.
 
void dt_location_repository_set_data (const guint locid, const dt_map_location_data_t *g)
 Insert or replace the geometry of locid, polygon blob included.
 
gboolean dt_location_repository_get_polygon (const guint locid, void **blob, gint *bytes)
 The raw polygon blob of locid.
 
GListdt_location_repository_find_locations_for_image (const int32_t imgid)
 Locations whose shape contains imgid's coordinates.
 
GListdt_location_repository_find_images_for_location (const guint locid, const int shape)
 Images whose coordinates fall inside location locid.
 
GListdt_location_repository_get_image_locations (const int32_t imgid)
 Location (tag) ids currently attached to imgid. GINT_TO_POINTER list.
 

Detailed Description

data.locations: the geometry of a geotagging location.

A location is a tag under darktable|locations| plus one row here giving its shape and extent, keyed by that tag's id. So common/map_locations.c deals with two repositories, this one and tag_repository, and the tag half is the identity: the name, the rename, the attach-to-image.

Note
Several queries here join main.images on longitude/latitude to answer "which images fall inside this shape". They return candidates, not answers: a polygon location is bounded by its box in SQL and the point-in-polygon test is done by the caller, exactly as before. The test is geometry, not storage.

Definition in file location_repository.h.

Typedef Documentation

◆ dt_location_candidate_t

One row of a geo query: an id with the position that matched.

Used for both directions. Looking for an image's locations, ::id is a location (tag) id; looking for a location's images, it is an image id. lon and lat are the IMAGE's coordinates either way, because they are what a point-in-polygon test needs.

Function Documentation

◆ dt_location_repository_delete()

void dt_location_repository_delete ( const guint  locid)

Drop the geometry row of locid. The tag itself is the tag repository's.

Definition at line 28 of file location_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by dt_map_location_delete().

◆ dt_location_repository_find_images_for_location()

GList * dt_location_repository_find_images_for_location ( const guint  locid,
const int  shape 
)

Images whose coordinates fall inside location locid.

Parameters
shapethe location's shape, which selects the query. MAP_LOCATION_SHAPE_POLYGONS returns box-bounded candidates with their coordinates filled in.

Definition at line 227 of file location_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, L, MAP_LOCATION_SHAPE_ELLIPSE, and MAP_LOCATION_SHAPE_RECTANGLE.

Referenced by _map_location_find_images().

◆ dt_location_repository_find_locations_for_image()

GList * dt_location_repository_find_locations_for_image ( const int32_t  imgid)

Locations whose shape contains imgid's coordinates.

Returns
dt_location_candidate_t list; polygon entries are box-bounded candidates the caller must still test. Free with g_list_free_full(l, g_free).

Definition at line 183 of file location_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, L, MAP_LOCATION_SHAPE_ELLIPSE, MAP_LOCATION_SHAPE_POLYGONS, and MAP_LOCATION_SHAPE_RECTANGLE.

Referenced by dt_map_location_find_locations().

◆ dt_location_repository_get_data()

dt_map_location_data_t * dt_location_repository_get_data ( const guint  locid,
const char *  name_prefix 
)

The geometry of locid, if it is a real location.

Parameters
name_prefixthe darktable|locations| prefix a location's tag name must have. Passed in rather than known here: which tags count as locations is common/map_locations.c's definition, not the database's.
Returns
newly allocated, or NULL when there is no such location, its longitude is NULL, or its tag is not under name_prefix.

Definition at line 83 of file location_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_BIND_TEXT, DT_DEBUG_SQLITE3_PREPARE_V2, g, L, and dt_map_location_data_t::shape.

Referenced by dt_map_location_get_data().

◆ dt_location_repository_get_image_locations()

GList * dt_location_repository_get_image_locations ( const int32_t  imgid)

Location (tag) ids currently attached to imgid. GINT_TO_POINTER list.

Definition at line 301 of file location_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by dt_map_location_update_locations().

◆ dt_location_repository_get_in_bbox()

GList * dt_location_repository_get_in_bbox ( const dt_map_box_t *const  bbox)

Locations whose extent overlaps bbox.

Returns
a GList of newly allocated dt_location_draw_t, without their polygons – fetch those with dt_location_repository_get_polygon(). Free with g_list_free_full(l, g_free).

Definition at line 40 of file location_repository.c.

References bbox, dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_DOUBLE, DT_DEBUG_SQLITE3_PREPARE_V2, L, dt_map_box_t::lat1, dt_map_box_t::lat2, dt_map_box_t::lon1, dt_map_box_t::lon2, and t.

Referenced by dt_map_location_get_locations_on_map().

◆ dt_location_repository_get_polygon()

gboolean dt_location_repository_get_polygon ( const guint  locid,
void **  blob,
gint *  bytes 
)

The raw polygon blob of locid.

Parameters
blobreceives a newly allocated copy, or NULL. Free with dt_free().
bytesreceives its size in bytes.
Returns
TRUE when a blob was found. The caller divides by sizeof(dt_geo_map_display_point_t) to get the point count – this function does not, because it hands back bytes.

Definition at line 143 of file location_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, FALSE, IS_NULL_PTR, L, n, and TRUE.

Referenced by dt_map_location_find_locations(), and dt_map_location_get_polygons().

◆ dt_location_repository_set_data()

void dt_location_repository_set_data ( const guint  locid,
const dt_map_location_data_t g 
)