[tracker/gst-geolocation: 1/2] tracker-extract: Add geolocation to GStreamer extractor
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gst-geolocation: 1/2] tracker-extract: Add geolocation to GStreamer extractor
- Date: Tue, 16 Aug 2011 12:17:26 +0000 (UTC)
commit 05b1caa1b1e186bd9bfe0db828c058fe7122f993
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jun 13 15:58:19 2011 +0200
tracker-extract: Add geolocation to GStreamer extractor
src/tracker-extract/tracker-extract-gstreamer.c | 82 +++++++++++++++++++++++
1 files changed, 82 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 219bd3e..f509f9a 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -406,6 +406,87 @@ get_embedded_album_art (MetadataExtractor *extractor)
}
static void
+add_geolocation_tags (TrackerSparqlBuilder *metadata,
+ TrackerSparqlBuilder *preupdate,
+ GstTagList *tag_list)
+{
+ gchar *country, *city, *sublocation;
+ gdouble lat, lon, alt;
+ gboolean has_coords;
+
+ country = city = sublocation = NULL;
+ has_coords = (gst_tag_list_get_double (tag_list, GST_TAG_GEO_LOCATION_LATITUDE, &lat) &&
+ gst_tag_list_get_double (tag_list, GST_TAG_GEO_LOCATION_LONGITUDE, &lon) &&
+ gst_tag_list_get_double (tag_list, GST_TAG_GEO_LOCATION_ELEVATION, &alt));
+
+ gst_tag_list_get_string (tag_list, GST_TAG_GEO_LOCATION_CITY, &city);
+ gst_tag_list_get_string (tag_list, GST_TAG_GEO_LOCATION_COUNTRY, &country);
+ gst_tag_list_get_string (tag_list, GST_TAG_GEO_LOCATION_SUBLOCATION, &sublocation);
+
+ if (city || country || sublocation || has_coords) {
+ gchar *address_uri = NULL;
+
+ /* Create postal address */
+ if (city || country || sublocation) {
+ address_uri = tracker_sparql_get_uuid_urn ();
+
+ tracker_sparql_builder_insert_open (preupdate, NULL);
+ tracker_sparql_builder_subject_iri (preupdate, address_uri);
+
+ tracker_sparql_builder_predicate (preupdate, "a");
+ tracker_sparql_builder_object (preupdate, "nco:PostalAddress");
+
+ if (sublocation) {
+ tracker_sparql_builder_predicate (preupdate, "nco:region");
+ tracker_sparql_builder_object_unvalidated (preupdate, sublocation);
+ }
+
+ if (city) {
+ tracker_sparql_builder_predicate (preupdate, "nco:locality");
+ tracker_sparql_builder_object_unvalidated (preupdate, city);
+ }
+
+ if (country) {
+ tracker_sparql_builder_predicate (preupdate, "nco:country");
+ tracker_sparql_builder_object_unvalidated (preupdate, country);
+ }
+
+ tracker_sparql_builder_insert_close (preupdate);
+ }
+
+ /* Create geolocation */
+ tracker_sparql_builder_predicate (metadata, "slo:location");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "slo:GeoLocation");
+
+ if (address_uri) {
+ tracker_sparql_builder_predicate (metadata, "slo:postalAddress");
+ tracker_sparql_builder_object_iri (metadata, address_uri);
+ }
+
+ if (has_coords) {
+ tracker_sparql_builder_predicate (metadata, "slo:latitude");
+ tracker_sparql_builder_object_double (metadata, lat);
+
+ tracker_sparql_builder_predicate (metadata, "slo:longitude");
+ tracker_sparql_builder_object_double (metadata, lon);
+
+ tracker_sparql_builder_predicate (metadata, "slo:altitude");
+ tracker_sparql_builder_object_double (metadata, alt);
+ }
+
+ tracker_sparql_builder_object_blank_close (metadata);
+ g_free (address_uri);
+ }
+
+ g_free (city);
+ g_free (country);
+ g_free (sublocation);
+}
+
+static void
extract_metadata (MetadataExtractor *extractor,
const gchar *uri,
TrackerSparqlBuilder *preupdate,
@@ -518,6 +599,7 @@ extract_metadata (MetadataExtractor *extractor,
g_free (composer);
}
+ add_geolocation_tags (metadata, preupdate, extractor->tagcache);
}
/* Audio */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]