[tracker/miner-rss: 2/3] tracker-miner-rss: Added support for GeoRss



commit 5212d56241903b38a617a4ce40e3ab819a734de9
Author: Michele Tameni <michele tameni it>
Date:   Thu Mar 4 13:03:50 2010 +0100

    tracker-miner-rss: Added support for GeoRss

 configure.ac                              |    4 +-
 src/tracker-miner-rss/tracker-miner-rss.c |   37 ++++++++++++++++++++++++----
 2 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index bc15295..f0b264a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,7 +157,7 @@ EDS_REQUIRED=2.25.5
 LIBSTREAMANALYZER_REQUIRED=0.7.0
 GEE_REQUIRED=0.3
 ID3LIB_REQUIRED=3.8.3
-LIBGRSS_REQUIRED=0.2
+LIBGRSS_REQUIRED=0.3
 
 # Library Checks
 PKG_CHECK_MODULES(GLIB2, [glib-2.0 >= $GLIB_REQUIRED])
@@ -808,7 +808,7 @@ if test "x$enable_miner_rss" != "xno" ; then
 
    if test "x$enable_miner_rss" = "xyes"; then
       if test "x$have_libgrss" != "xyes"; then
-         AC_MSG_ERROR([Couldn't find libgrss >= $LIBGRSS_REQUIRED. and miner rss requeste])
+         AC_MSG_ERROR([Couldn't find libgrss >= $LIBGRSS_REQUIRED. and miner rss requested])
       fi
    fi
 else
diff --git a/src/tracker-miner-rss/tracker-miner-rss.c b/src/tracker-miner-rss/tracker-miner-rss.c
index 3c175b5..d15b9b8 100644
--- a/src/tracker-miner-rss/tracker-miner-rss.c
+++ b/src/tracker-miner-rss/tracker-miner-rss.c
@@ -191,6 +191,8 @@ item_verify_reply_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 	gchar *uri;
 	gchar *subject;
 	gchar **values;
+	gdouble latitude;
+	gdouble longitude;
 	const gchar *tmp_string;
 	const GPtrArray *response;
 	GError *error;
@@ -198,6 +200,7 @@ item_verify_reply_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 	FeedItem *item;
 	FeedChannel *feed;
 	TrackerMinerRSS *miner;
+	gboolean has_geopoint;
 
 	miner = TRACKER_MINER_RSS (source_object);
 	response = tracker_miner_execute_sparql_finish (TRACKER_MINER (source_object), res, &error);
@@ -217,13 +220,36 @@ item_verify_reply_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 	subject = get_message_subject (item);
 
 	sparql = tracker_sparql_builder_new_update ();
+
+	has_geopoint = feed_item_get_geo_point (item, &latitude, &longitude);
 	tracker_sparql_builder_insert_open (sparql, subject);
+
+	if (has_geopoint) {
+		tracker_sparql_builder_subject (sparql, "_:location");
+		tracker_sparql_builder_predicate (sparql, "a");
+		tracker_sparql_builder_object (sparql, "mlo:GeoLocation");
+		tracker_sparql_builder_predicate (sparql, "mlo:asGeoPoint");
+		tracker_sparql_builder_object_blank_open (sparql);
+		tracker_sparql_builder_predicate (sparql, "a");
+		tracker_sparql_builder_object (sparql, "mlo:GeoPoint");
+		tracker_sparql_builder_predicate (sparql, "mlo:latitude");
+		tracker_sparql_builder_object_double (sparql, latitude);
+		tracker_sparql_builder_predicate (sparql, "mlo:longitude");
+		tracker_sparql_builder_object_double (sparql, longitude);
+		tracker_sparql_builder_object_blank_close (sparql);
+	}
+
 	tracker_sparql_builder_subject (sparql, "_:message");
 	tracker_sparql_builder_predicate (sparql, "a");
 	tracker_sparql_builder_object (sparql, "mfo:FeedMessage");
 	tracker_sparql_builder_predicate (sparql, "a");
 	tracker_sparql_builder_object (sparql, "nfo:RemoteDataObject");
 
+	if (has_geopoint == TRUE) {
+		tracker_sparql_builder_predicate (sparql, "mlo:location");
+		tracker_sparql_builder_object (sparql, "_:location");
+	}
+
 	tmp_string = feed_item_get_title (item);
 	if (tmp_string != NULL) {
 		tracker_sparql_builder_predicate (sparql, "nie:title");
@@ -248,7 +274,6 @@ item_verify_reply_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 
 	t = time (NULL);
 
-	g_print ("%s\n", feed_item_get_author (item));
 	tracker_sparql_builder_predicate (sparql, "nmo:receivedDate");
 	tracker_sparql_builder_object_date (sparql, &t);
 
@@ -350,7 +375,7 @@ feeds_retrieve_cb (GObject *source_object, GAsyncResult *res, gpointer data)
 		values = (gchar**) g_ptr_array_index (response, i);
 
 		chan = feed_channel_new ();
-		g_object_set_data_full (G_OBJECT (chan), "subject", g_strdup (values [0]), g_free);
+		g_object_set_data_full (G_OBJECT (chan), "subject", g_strdup (values [2]), g_free);
 		feed_channel_set_source (chan, values [0]);
 
 		/*
@@ -374,10 +399,10 @@ retrieve_and_schedule_feeds (TrackerMinerRSS *miner)
 {
 	gchar *sparql;
 
-	sparql = g_strdup_printf ("SELECT ?chanUrl ?interval WHERE		\
-	                           { ?chan a mfo:FeedChannel .			\
-	                             ?chan mfo:feedSettings ?settings .		\
-	                             ?chan nie:url ?chanUrl .			\
+	sparql = g_strdup_printf ("SELECT ?chanUrl ?interval ?chanUrn WHERE		\
+	                           { ?chanUrn a mfo:FeedChannel .			\
+	                             ?chanUrn mfo:feedSettings ?settings .		\
+	                             ?chanUrn nie:url ?chanUrl .			\
 	                             ?settings mfo:updateInterval ?interval }");
 
 	tracker_miner_execute_sparql (TRACKER_MINER (miner), sparql, NULL, feeds_retrieve_cb, NULL);



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