MATLAB Answers

How retrieving geagraphical coordinates through Yahoo as the service retired sonce 2019???

1 view (last 30 days)
Sébastien MAILFERT
Sébastien MAILFERT on 25 Jan 2019
Hi all,
I was using this thread to get the coordinates of locations:
% Uses YQL to query the geo.places database for the latitude and longitude
% of a city, given the city name and country code.
function [latDegs, lonDegs] = getLatLonViaYql(city,countryCode)
% build the YQL query
yqlQuery = sprintf(['select centroid.latitude,centroid.longitude ' ...
'from geo.places ' ...
'where text="%s" and country.code="%s" and ' ...
'placeTypeName.code="7"'], ...
city, countryCode);
% build the URL
yqlUrl = ['' yqlQuery];
% replace blank spaces with %20
yqlUrl = strrep(yqlUrl,' ','%20');
% retrieve the data
xmlData = urlread(yqlUrl);
% get the latitude and longitude (here we assume that the latitude is
% within <latitude>XYZ</latitude> and the longitude within
% <longitude>UVW</longitude> tags)
posData = regexp(xmlData,'>[0-9.-]+<','match');
% if exactly two tags match the above regexp then parse the latitude
% and longitude data
if length(posData)==2
latDegs = str2double(char(posData{1}(2:end-1)));
lonDegs = str2double(char(posData{2}(2:end-1)));
latDegs = 0;
lonDegs = 0;
But, since 2019, the "" site does not work anymore since few days.
Do you have an idea to bypass this yahoo queries?
Best regards.


Sign in to comment.

Answers (0)