[tracker/gst-geolocation: 2/2] tracker-extract: Add geolocation to gupnp-dlna extractor
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gst-geolocation: 2/2] tracker-extract: Add geolocation to gupnp-dlna extractor
- Date: Tue, 16 Aug 2011 12:17:31 +0000 (UTC)
commit 593a269105e02b1231ee7431506bda01de15986a
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jun 13 15:58:35 2011 +0200
tracker-extract: Add geolocation to gupnp-dlna extractor
src/tracker-extract/tracker-extract-gupnp-dlna.c | 88 +++++++++++++++++++++-
1 files changed, 87 insertions(+), 1 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-gupnp-dlna.c b/src/tracker-extract/tracker-extract-gupnp-dlna.c
index 65fcbe3..8d03c4d 100644
--- a/src/tracker-extract/tracker-extract-gupnp-dlna.c
+++ b/src/tracker-extract/tracker-extract-gupnp-dlna.c
@@ -253,6 +253,87 @@ add_keywords_gst_tag (TrackerSparqlBuilder *metadata,
}
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,
@@ -334,7 +415,6 @@ extract_metadata (MetadataExtractor *extractor,
g_free (composer);
}
-
}
/* Audio */
@@ -679,6 +759,12 @@ extract_metadata (MetadataExtractor *extractor,
tracker_sparql_builder_predicate (metadata, "nfo:aspectRatio");
tracker_sparql_builder_object_double (metadata, extractor->aspect_ratio);
}
+
+ }
+
+ if (extractor->content == CONTENT_IMAGE ||
+ extractor->content == CONTENT_VIDEO) {
+ add_geolocation_tags (metadata, preupdate, extractor->tags);
}
if (extractor->dlna_profile) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]