diff --git a/tests/tests.js b/tests/tests.js index 9a4e7736..ee080d63 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -341,7 +341,7 @@ define(function(require) { }); asyncTest("check articles found nearby London", function() { - expect(3); + expect(5); var callbackTitlesNearbyLondonFound = function(titleList) { ok(titleList !== null, "Some titles should be found"); equal(titleList.length, 1, "1 title should be found"); @@ -353,6 +353,12 @@ define(function(require) { } } ok(titleLondon !== null, "The title 'London' should be found"); + + // Check coordinates of London + var x = titleLondon._geolocation.x; + var y = titleLondon._geolocation.y; + equal(x, 51.50777816772461, "London should be at latitude 51.50777816772461"); + equal(y, -0.12805555760860443, "London should be at longitude -0.12805555760860443"); start(); }; diff --git a/www/js/lib/archive.js b/www/js/lib/archive.js index e05070cd..70fed4b1 100644 --- a/www/js/lib/archive.js +++ b/www/js/lib/archive.js @@ -27,6 +27,7 @@ define(function(require) { var util = require('util'); var geometry = require('geometry'); var jQuery = require('jquery'); + var evopediaTitle = require('title'); var titleIterators = require('titleIterators'); // Declare the webworker that can uncompress with bzip2 algorithm @@ -698,10 +699,13 @@ define(function(require) { * @param {type} callbackFunction */ LocalArchive.readTitlesFromTitleCoordsInTitleFile = function (localArchive, titlePositionsFound, i, titlesFound, maxTitles, callbackFunction) { - var titleOffset = titlePositionsFound[i]; + var titleOffset = titlePositionsFound[i]._titleOffset; + var geolocation = titlePositionsFound[i]._geolocation; localArchive.getTitlesStartingAtOffset(titleOffset, 1, function(titleList) { if (titleList && titleList.length === 1) { - titlesFound.push(titleList[0]); + var title = titleList[0]; + title._geolocation = geolocation; + titlesFound.push(title); i++; if (i= 0 && titlePositionsFound.length < maxTitles) { - titlePositionsFound.push(title_pos); + var title = new evopediaTitle.Title(); + title._titleOffset = title_pos; + title._geolocation = articleCoordinates; + titlePositionsFound.push(title); } } } diff --git a/www/js/lib/title.js b/www/js/lib/title.js index 0c0f19fb..4604fb6f 100644 --- a/www/js/lib/title.js +++ b/www/js/lib/title.js @@ -37,6 +37,7 @@ define(function(require) { this._archive = null; this._titleOffset = null; this._titleEntryLength = null; + this._geolocation = null; }; Title.prototype.getReadableName = function() { @@ -137,7 +138,7 @@ define(function(require) { * Serialize the title in a readable way */ Title.prototype.toString = function() { - return "title.id = " + this.toStringId() + "title.name = " + this._name + " title.fileNr = " + this._fileNr + " title.blockStart = " + this._blockStart + " title.blockOffset = " + this._blockOffset + " title.articleLength = " + this._articleLength; + return "title.id = " + this.toStringId() + " title.name = " + this._name + " title.fileNr = " + this._fileNr + " title.blockStart = " + this._blockStart + " title.blockOffset = " + this._blockOffset + " title.articleLength = " + this._articleLength; }; /**