[tracker] Added missing location fields
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Added missing location fields
- Date: Mon, 21 Dec 2009 11:23:59 +0000 (UTC)
commit 1c5289e31f29a0924f655dcc7a61dd6c93f7fb20
Author: Philip Van Hoof <philip codeminded be>
Date: Mon Dec 21 12:22:10 2009 +0100
Added missing location fields
This can be adapted later, in case certain of these added fields aren't the
we finally want them.
data/ontologies/40-mlo.ontology | 21 ++++++
src/tracker-extract/tracker-extract-jpeg.c | 34 ++++++++++
src/tracker-extract/tracker-extract-pdf.c | 34 ++++++++++
src/tracker-extract/tracker-extract-png.c | 34 ++++++++++
src/tracker-extract/tracker-extract-tiff.c | 34 ++++++++++
src/tracker-extract/tracker-xmp.c | 93 +++++++++++++++++++++-------
src/tracker-extract/tracker-xmp.h | 2 +-
7 files changed, 228 insertions(+), 24 deletions(-)
---
diff --git a/data/ontologies/40-mlo.ontology b/data/ontologies/40-mlo.ontology
index f8daf77..a124b7f 100644
--- a/data/ontologies/40-mlo.ontology
+++ b/data/ontologies/40-mlo.ontology
@@ -99,3 +99,24 @@ mlo:location a rdf:Property ;
rdfs:comment "This can be subclassed to add semantics" ;
rdfs:domain nie:InformationElement ;
rdfs:range mlo:GeoPoint .
+
+# TODO: These are ad-hoc added by Philip to support writeback of locations
+mlo:city a rdf:Property ;
+ rdfs:label "City" ;
+ rdfs:domain mlo:GeoPoint ;
+ rdfs:range xsd:string .
+
+mlo:country a rdf:Property ;
+ rdfs:label "Country" ;
+ rdfs:domain mlo:GeoPoint ;
+ rdfs:range xsd:string .
+
+mlo:state a rdf:Property ;
+ rdfs:label "State" ;
+ rdfs:domain mlo:GeoPoint ;
+ rdfs:range xsd:string .
+
+mlo:address a rdf:Property ;
+ rdfs:label "Address" ;
+ rdfs:domain mlo:GeoPoint ;
+ rdfs:range xsd:string .
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 7580c6b..4ae3a50 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -511,6 +511,40 @@ extract_jpeg (const gchar *uri,
g_free (md.comment);
}
+ if (xd.Address || xd.Country || xd.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:location");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "mlo:GeoPoint");
+
+ if (xd.Address) {
+ tracker_sparql_builder_predicate (metadata, "mlo:address");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.Address);
+ g_free (xd.Address);
+ }
+
+ if (xd.State) {
+ tracker_sparql_builder_predicate (metadata, "mlo:state");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.State);
+ g_free (xd.State);
+ }
+
+ if (xd.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:city");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.City);
+ g_free (xd.City);
+ }
+
+ if (xd.Country) {
+ tracker_sparql_builder_predicate (metadata, "mlo:country");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.Country);
+ g_free (xd.Country);
+ }
+
+ tracker_sparql_builder_object_blank_close (metadata);
+ }
+
jpeg_destroy_decompress (&cinfo);
fail:
tracker_file_close (f, FALSE);
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index 307c21e..bf025f4 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -397,6 +397,40 @@ extract_pdf (const gchar *uri,
tracker_sparql_builder_object (metadata, xd.MeteringMode);
g_free (xd.MeteringMode);
}
+
+ if (xd.Address || xd.Country || xd.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:location");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "mlo:GeoPoint");
+
+ if (xd.Address) {
+ tracker_sparql_builder_predicate (metadata, "mlo:address");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.Address);
+ g_free (xd.Address);
+ }
+
+ if (xd.State) {
+ tracker_sparql_builder_predicate (metadata, "mlo:state");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.State);
+ g_free (xd.State);
+ }
+
+ if (xd.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:city");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.City);
+ g_free (xd.City);
+ }
+
+ if (xd.Country) {
+ tracker_sparql_builder_predicate (metadata, "mlo:country");
+ tracker_sparql_builder_object_unvalidated (metadata, xd.Country);
+ g_free (xd.Country);
+ }
+
+ tracker_sparql_builder_object_blank_close (metadata);
+ }
} else {
/* So if we are here we have NO XMP data and we just
* write what we know from Poppler.
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index f2ce9c9..482ec27 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -396,6 +396,40 @@ read_metadata (png_structp png_ptr, png_infop info_ptr, const gchar *uri, Tracke
tracker_sparql_builder_object_unvalidated (metadata, xmp_data.MeteringMode);
g_free (xmp_data.MeteringMode);
}
+
+ if (xmp_data.Address || xmp_data.Country || xmp_data.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:location");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "mlo:GeoPoint");
+
+ if (xmp_data.Address) {
+ tracker_sparql_builder_predicate (metadata, "mlo:address");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.Address);
+ g_free (xmp_data.Address);
+ }
+
+ if (xmp_data.State) {
+ tracker_sparql_builder_predicate (metadata, "mlo:state");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.State);
+ g_free (xmp_data.State);
+ }
+
+ if (xmp_data.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:city");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.City);
+ g_free (xmp_data.City);
+ }
+
+ if (xmp_data.Country) {
+ tracker_sparql_builder_predicate (metadata, "mlo:country");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.Country);
+ g_free (xmp_data.Country);
+ }
+
+ tracker_sparql_builder_object_blank_close (metadata);
+ }
}
}
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 4cf9429..8148eb8 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -530,6 +530,40 @@ extract_tiff (const gchar *uri, TrackerSparqlBuilder *metadata)
g_free (xmp_data.license);
}
+ if (xmp_data.Address || xmp_data.Country || xmp_data.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:location");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "mlo:GeoPoint");
+
+ if (xmp_data.Address) {
+ tracker_sparql_builder_predicate (metadata, "mlo:address");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.Address);
+ g_free (xmp_data.Address);
+ }
+
+ if (xmp_data.State) {
+ tracker_sparql_builder_predicate (metadata, "mlo:state");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.State);
+ g_free (xmp_data.State);
+ }
+
+ if (xmp_data.City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:city");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.City);
+ g_free (xmp_data.City);
+ }
+
+ if (xmp_data.Country) {
+ tracker_sparql_builder_predicate (metadata, "mlo:country");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data.Country);
+ g_free (xmp_data.Country);
+ }
+
+ tracker_sparql_builder_object_blank_close (metadata);
+ }
+
if (iptc_data.keywords) {
insert_keywords (metadata, uri, iptc_data.keywords);
g_free (iptc_data.keywords);
diff --git a/src/tracker-extract/tracker-xmp.c b/src/tracker-extract/tracker-xmp.c
index 4d1b917..d5d9474 100644
--- a/src/tracker-extract/tracker-xmp.c
+++ b/src/tracker-extract/tracker-xmp.c
@@ -372,7 +372,41 @@ tracker_xmp_iter_simple (const gchar *uri,
if (!data->license && g_ascii_strcasecmp (name, "license") == 0) {
data->license = g_strdup (value);
}
- } /* else
+ } else
+ /* Photoshop */
+ if (g_ascii_strcasecmp (schema, NS_PHOTOSHOP) == 0) {
+ if (data->City && g_ascii_strcasecmp (name, "City") == 0) {
+ data->City = g_strdup (value);
+ } else
+ if (!data->Country && g_ascii_strcasecmp (name, "Country") == 0) {
+ data->Country = g_strdup (value);
+ } else
+ if (!data->State && g_ascii_strcasecmp (name, "State") == 0) {
+ data->State = g_strdup (value);
+ } else
+ if (!data->Address && g_ascii_strcasecmp (name, "Location") == 0) {
+ data->Address = g_strdup (value);
+ }
+ } else
+ /* IPTC4XMP scheme - GeoClue / location stuff, TODO */
+ if (g_ascii_strcasecmp (schema, NS_IPTC4XMP) == 0) {
+ if (!data->City && g_ascii_strcasecmp (name, "City") == 0) {
+ data->City = g_strdup (value);
+ } else
+ if (!data->Country && g_ascii_strcasecmp (name, "Country") == 0) {
+ data->Country = g_strdup (value);
+ } else
+ if (!data->Country && g_ascii_strcasecmp (name, "PrimaryLocationName") == 0) {
+ data->Country = g_strdup (value);
+ } else
+ if (!data->State && g_ascii_strcasecmp (name, "Province") == 0) {
+ data->State = g_strdup (value);
+ } else
+ if (!data->Address && g_ascii_strcasecmp (name, "Sublocation") == 0) {
+ data->Address = g_strdup (value);
+ }
+ }
+ /* else
* XAP (XMP)scheme *
if (g_ascii_strcasecmp (schema, NS_XAP) == 0) {
if (g_ascii_strcasecmp (name, "Rating") == 0) {
@@ -384,29 +418,7 @@ tracker_xmp_iter_simple (const gchar *uri,
"Image:Date", value);
}
} else
- * IPTC4XMP scheme - GeoClue / location stuff, TODO *
- if (g_ascii_strcasecmp (schema, NS_IPTC4XMP) == 0) {
- if (g_ascii_strcasecmp (name, "Location") == 0) {
- tracker_statement_list_insert (metadata, uri,
- "Image:Location", value);
- } else
- if (g_ascii_strcasecmp (name, "Sublocation") == 0) {
- tracker_statement_list_insert (metadata, uri,
- "Image:Sublocation", value);
- }
- } else
- if (g_ascii_strcasecmp (schema, NS_PHOTOSHOP) == 0) {
- if (g_ascii_strcasecmp (name, "City") == 0) {
- tracker_statement_list_insert (metadata, uri,
- "Image:City", value);
- } else
- if (g_ascii_strcasecmp (name, "Country") == 0) {
- tracker_statement_list_insert (metadata, uri,
- "Image:Country", value);
- }
- }
*/
-
g_free (name);
}
@@ -702,4 +714,39 @@ tracker_apply_xmp (TrackerSparqlBuilder *metadata, const gchar *uri, TrackerXmpD
tracker_sparql_builder_object_blank_close (metadata);
g_free (xmp_data->creator);
}
+
+ if (xmp_data->Address || xmp_data->Country || xmp_data->City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:location");
+
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "mlo:GeoPoint");
+
+ if (xmp_data->Address) {
+ tracker_sparql_builder_predicate (metadata, "mlo:address");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data->Address);
+ g_free (xmp_data->Address);
+ }
+
+ if (xmp_data->State) {
+ tracker_sparql_builder_predicate (metadata, "mlo:state");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data->State);
+ g_free (xmp_data->State);
+ }
+
+ if (xmp_data->City) {
+ tracker_sparql_builder_predicate (metadata, "mlo:city");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data->City);
+ g_free (xmp_data->City);
+ }
+
+ if (xmp_data->Country) {
+ tracker_sparql_builder_predicate (metadata, "mlo:country");
+ tracker_sparql_builder_object_unvalidated (metadata, xmp_data->Country);
+ g_free (xmp_data->Country);
+ }
+
+ tracker_sparql_builder_object_blank_close (metadata);
+ }
+
}
diff --git a/src/tracker-extract/tracker-xmp.h b/src/tracker-extract/tracker-xmp.h
index 9522642..b525e83 100644
--- a/src/tracker-extract/tracker-xmp.h
+++ b/src/tracker-extract/tracker-xmp.h
@@ -39,7 +39,7 @@ typedef struct {
/* TODO NS_XAP*/
/* TODO NS_IPTC4XMP */
/* TODO NS_PHOTOSHOP */
-
+ gchar *Address, *Country, *State, *City;
} TrackerXmpData;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]