Permalink
Browse files

yahoo geocoder + tests fixed

  • Loading branch information...
xavijam committed Dec 26, 2012
1 parent b9437eb commit 96b16da4659f35ae139c0c629f2ce35dcfdd2748
Showing with 10 additions and 10 deletions.
  1. +4 −4 src/geo/geocoder.js
  2. +6 −6 test/spec/geo/geocoder.spec.js
View
@@ -31,15 +31,15 @@ cdb.geo.geocoder.YAHOO = {
$.getJSON(protocol + '//query.yahooapis.com/v1/public/yql?q='+encodeURIComponent('SELECT * FROM json WHERE url="http://where.yahooapis.com/geocode?q=' + address + '&appid=' + this.keys.app_id + '&flags=JX"') + '&format=json&callback=?', function(data) {
var coordinates = [];
- if (data && data.query && data.query.results && data.query.results.ResultSet && data.query.results.ResultSet.Found != "0") {
+ if (data && data.query && data.query.results && data.query.results.json && data.query.results.json.ResultSet && data.query.results.json.ResultSet.Found != "0") {
// Could be an array or an object |arg!
var res;
- if (_.isArray(data.query.results.ResultSet.Results)) {
- res = data.query.results.ResultSet.Results;
+ if (_.isArray(data.query.results.json.ResultSet.Results)) {
+ res = data.query.results.json.ResultSet.Results;
} else {
- res = [data.query.results.ResultSet.Results];
+ res = [data.query.results.json.ResultSet.Results];
}
for(var i in res) {
@@ -6,8 +6,8 @@ describe('Geocoder', function() {
it('we should get a direction that exists using YAHOO', function() {
cdb.geo.geocoder.YAHOO.geocode('Madrid, Spain', function(data) {
expect(data.length).toEqual(1);
- expect(data[0].lat).toEqual('40.420300');
- expect(data[0].lon).toEqual('-3.705774');
+ expect(data[0].lat).toEqual('40.4203');
+ expect(data[0].lon).toEqual('-3.70577');
expect(data[0].boundingbox).toBeTruthy();
});
});
@@ -21,17 +21,17 @@ describe('Geocoder', function() {
it('we should get a direction that exists using NOKIA', function() {
cdb.geo.geocoder.NOKIA.geocode('Madrid, Spain', function(data) {
expect(data.length).toEqual(1);
- expect(data[0].lat).toEqual(parseFloat('40.4203'));
- expect(data[0].lon).toEqual(parseFloat('-3.70577'));
+ expect(data[0].lat).toEqual(40.420300);
+ expect(data[0].lon).toEqual(-3.70577);
expect(data[0].boundingbox).toBeTruthy();
});
});
it('we should get a direction with # character using NOKIA', function() {
cdb.geo.geocoder.NOKIA.geocode('# Mexico', function(data) {
expect(data.length).toEqual(1);
- expect(data[0].lat).toEqual('19.4321');
- expect(data[0].lon).toEqual('-99.1331');
+ expect(data[0].lat).toEqual(19.4321);
+ expect(data[0].lon).toEqual(-99.1331);
});
});

0 comments on commit 96b16da

Please sign in to comment.