[tracker/writeback-miner-interaction: 18/19] libtracker-extract, tracker-extract: Add extraction of image compass direction



commit b5fb2d931e66b934ccf67d29493990c33f942d58
Author: Mikael Ottela <mikael ottela ixonos com>
Date:   Fri Jun 10 04:11:50 2011 +0300

    libtracker-extract, tracker-extract: Add extraction of image compass direction

 data/ontologies/38-nmm.ontology            |    8 +++++++-
 src/libtracker-extract/tracker-exif.c      |    4 ++++
 src/libtracker-extract/tracker-exif.h      |    1 +
 src/libtracker-extract/tracker-xmp.c       |    8 ++++++++
 src/libtracker-extract/tracker-xmp.h       |    1 +
 src/tracker-extract/tracker-extract-gif.c  |    5 +++++
 src/tracker-extract/tracker-extract-jpeg.c |    7 +++++++
 src/tracker-extract/tracker-extract-png.c  |    6 ++++++
 src/tracker-extract/tracker-extract-tiff.c |    8 +++++++-
 9 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index 55aa3e8..a098f74 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -13,7 +13,7 @@
 
 nmm: a tracker:Namespace, tracker:Ontology ;
 	tracker:prefix "nmm" ;
-	nao:lastModified "2011-01-25T13:30:00Z" .
+	nao:lastModified "2011-06-10T01:12:00Z" .
 
 nmm:MusicPiece a rdfs:Class ;
 	rdfs:label "Music" ;
@@ -432,6 +432,12 @@ nmm:isColorCorrected a rdf:Property ;
 	rdfs:domain nmm:Photo ;
 	rdfs:range xsd:boolean .
 
+nmm:direction ;
+	rdfs:comment "The direction the image is taken (angle wrt true north)" ;
+	nrl:maxCardinality 1 ;
+	rdfs:domain nmm:Photo ;
+	rdfs:range xsd:double .
+
 # Radio (IE part)
 nmm:RadioStation a rdfs:Class ;
 	rdfs:label "Radio station" ;
diff --git a/src/libtracker-extract/tracker-exif.c b/src/libtracker-extract/tracker-exif.c
index b9fdcec..fccd71d 100644
--- a/src/libtracker-extract/tracker-exif.c
+++ b/src/libtracker-extract/tracker-exif.c
@@ -473,6 +473,9 @@ parse_exif (const unsigned char *buffer,
 	if(!data->gps_longitude)
 		data->gps_longitude = get_gps_coordinate (exif, EXIF_TAG_GPS_LONGITUDE, EXIF_TAG_GPS_LONGITUDE_REF);
 
+	if(!data->gps_direction)
+		data->gps_direction = get_value (exif, EXIF_TAG_GPS_IMG_DIRECTION);	
+
 	exif_data_free (exif);
 #endif /* HAVE_LIBEXIF */
 
@@ -590,6 +593,7 @@ tracker_exif_free (TrackerExifData *data)
 	g_free (data->gps_altitude);
 	g_free (data->gps_latitude);
 	g_free (data->gps_longitude);
+	g_free (data->gps_direction);
 
 	g_free (data);
 }
diff --git a/src/libtracker-extract/tracker-exif.h b/src/libtracker-extract/tracker-exif.h
index eec879c..2d3af07 100644
--- a/src/libtracker-extract/tracker-exif.h
+++ b/src/libtracker-extract/tracker-exif.h
@@ -58,6 +58,7 @@ typedef struct {
 	gchar *gps_altitude;
 	gchar *gps_latitude;
 	gchar *gps_longitude;
+	gchar *gps_direction;
 } TrackerExifData;
 
 TrackerExifData * tracker_exif_new   (const guchar *buffer,
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index bbac8e4..c0f2a5d 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -369,6 +369,8 @@ iterate_simple (const gchar    *uri,
 			data->gps_latitude = gps_coordinate_dup (value);
 		} else if (!data->gps_longitude && g_ascii_strcasecmp (name, "GPSLongitude") == 0) {
 			data->gps_longitude = gps_coordinate_dup (value);
+		} else if (!data->gps_direction && g_ascii_strcasecmp (name, "GPSImgDirection") == 0) {
+			data->gps_direction = div_str_dup (value);
 		}
 		/* PDF*/
 	} else if (g_ascii_strcasecmp (schema, NS_PDF) == 0) {
@@ -686,6 +688,7 @@ tracker_xmp_free (TrackerXmpData *data)
 	g_free (data->gps_altitude_ref);
 	g_free (data->gps_latitude);
 	g_free (data->gps_longitude);
+	g_free (data->gps_direction);
 
 	g_free (data);
 }
@@ -1002,5 +1005,10 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
 		tracker_sparql_builder_object_blank_close (metadata); /* GeoLocation */
 	}
 
+	if (data->gps_direction) {
+		tracker_sparql_builder_predicate (metadata, "nmm:direction");
+		tracker_sparql_builder_object_unvalidated (metadata, data->gps_direction);
+	}
+
 	return TRUE;
 }
diff --git a/src/libtracker-extract/tracker-xmp.h b/src/libtracker-extract/tracker-xmp.h
index b1b939e..1aa2c57 100644
--- a/src/libtracker-extract/tracker-xmp.h
+++ b/src/libtracker-extract/tracker-xmp.h
@@ -88,6 +88,7 @@ typedef struct {
 	gchar *gps_altitude_ref;
 	gchar *gps_latitude;
 	gchar *gps_longitude;
+	gchar *gps_direction;
 
 } TrackerXmpData;
 
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index a34c62d..f486fdc 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -487,6 +487,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
 		tracker_sparql_builder_object_blank_close (metadata); /* GeoLocation */
 	}
 
+	if (xd->gps_direction) {
+		tracker_sparql_builder_predicate (metadata, "nmm:direction");
+		tracker_sparql_builder_object_unvalidated (metadata, xd->gps_direction);
+	}
+
 	if (gd.width) {
 		tracker_sparql_builder_predicate (metadata, "nfo:width");
 		tracker_sparql_builder_object_unvalidated (metadata, gd.width);
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index bf271f1..41775c8 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -78,6 +78,7 @@ typedef struct {
 	const gchar *gps_altitude;
 	const gchar *gps_latitude;
 	const gchar *gps_longitude;
+	const gchar *gps_direction;
 } MergeData;
 
 struct tej_error_mgr {
@@ -254,6 +255,7 @@ tracker_extract_get_metadata (const gchar          *uri,
 	md.gps_altitude = tracker_coalesce_strip (2, xd->gps_altitude, ed->gps_altitude);
 	md.gps_latitude = tracker_coalesce_strip (2, xd->gps_latitude, ed->gps_latitude);
 	md.gps_longitude = tracker_coalesce_strip (2, xd->gps_longitude, ed->gps_longitude);
+	md.gps_direction = tracker_coalesce_strip (2, xd->gps_direction, ed->gps_direction);
 	md.creator = tracker_coalesce_strip (3, xd->creator, id->byline, id->credit);
 	md.comment = tracker_coalesce_strip (2, comment, ed->user_comment);
 	md.make = tracker_coalesce_strip (2, xd->make, ed->make);
@@ -617,6 +619,11 @@ tracker_extract_get_metadata (const gchar          *uri,
 		tracker_sparql_builder_object_blank_close (metadata); /* GeoLocation */
 	}
 
+	if (md.gps_direction) {
+		tracker_sparql_builder_predicate (metadata, "nmm:direction");
+		tracker_sparql_builder_object_unvalidated (metadata, md.gps_direction);
+	}
+
 	if (cinfo.density_unit != 0 || ed->x_resolution) {
 		gdouble value;
 
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index b0e1e09..43585f1 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -56,6 +56,7 @@ typedef struct {
 	const gchar *state;
 	const gchar *address;
 	const gchar *country;
+	const gchar *gps_direction;
 } MergeData;
 
 typedef struct {
@@ -476,6 +477,11 @@ read_metadata (TrackerSparqlBuilder *preupdate,
 		tracker_sparql_builder_object_blank_close (metadata); /* GeoLocation */
 	}
 
+	if (xd->gps_direction) {
+		tracker_sparql_builder_predicate (metadata, "nmm:direction");
+		tracker_sparql_builder_object_unvalidated (metadata, xd->gps_direction);
+	}
+
 	if (ed->x_resolution) {
 		gdouble value;
 
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index e33cbda..71bcb73 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -62,7 +62,8 @@ typedef struct {
 	const gchar *country;
         const gchar *gps_altitude;
         const gchar *gps_latitude;
-        const gchar *gps_longitude;       
+        const gchar *gps_longitude;
+	const gchar *gps_direction;
 } MergeData;
 
 typedef struct {
@@ -373,6 +374,7 @@ tracker_extract_get_metadata (const gchar          *uri,
 	md.gps_altitude = tracker_coalesce_strip (2, xd->gps_altitude, ed->gps_altitude);
 	md.gps_latitude = tracker_coalesce_strip (2, xd->gps_latitude, ed->gps_latitude);
 	md.gps_longitude = tracker_coalesce_strip (2, xd->gps_longitude, ed->gps_longitude);
+	md.gps_direction = tracker_coalesce_strip (2, xd->gps_direction, ed->gps_direction);
 	md.creator = tracker_coalesce_strip (3, xd->creator, id->byline, id->credit);
 	md.x_dimension = tracker_coalesce_strip (2, td.width, ed->x_dimension);
 	md.y_dimension = tracker_coalesce_strip (2, td.length, ed->y_dimension);
@@ -535,6 +537,10 @@ tracker_extract_get_metadata (const gchar          *uri,
 		tracker_sparql_builder_object_blank_close (metadata); /* GeoLocation */
 	}
 
+	if (md.gps_direction) {
+		tracker_sparql_builder_predicate (metadata, "nmm:direction");
+		tracker_sparql_builder_object_unvalidated (metadata, md.gps_direction);
+	}
 
 	if (id->contact) {
 		gchar *uri = tracker_sparql_escape_uri_printf ("urn:contact:%s", id->contact);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]