/**
* @fileoverview bu.street.Services is an abstract class for Servicess
* that show street 360 panoramas and data.
* Created 23/03/2017.
* @author josea.hernandez@blom.no (Jose Antonio Hernandez)
* @author rafael.delaviuda@blom.no (Rafael de la Viuda)
* @author raul.sangil@blom.no (Raul Sangil)
* @copyright Blom Data S.L. 2017
*/
goog.provide('bu.street.Services');
goog.require('ol');
goog.require('ol.Object');
//goog.require('bu.street.Image');
/**
* @classdesc
* Utility class to simplify calls to BlomURBEX Street services.
*
* @constructor
* @extends {ol.Object}
* @param {bu.street.ServicesOptions} options
* @api stable
*/
bu.street.Services = function(options) {
ol.Object.call(this);
this.usertoken_ = options.usertoken;
};
ol.inherits(bu.street.Services, ol.Object);
/**
* Execute a request to the GetStreetImageMetadata service.
* @param {string} imageId ID of the 360 image.
* @callback {Function} load Function to execute if response is loaded.
* @callback {Function} error Function to execute if response has an error.
* @api
*/
bu.street.Services.prototype.getStreetMetadata = function(imageId, load, error){
var client = new XMLHttpRequest();
client.addEventListener('load', load);
client.addEventListener('error', error);
client.open('GET', bu.GETSTREETIMAGEMETADATA_SERVICE + "?" +
"usertoken=" + this.usertoken_ + "&" +
"id=" + imageId + "&" +
"format=json");
client.send();
};
/**
* Execute a request to the FindStreetImagesByExtent service.
* @param {bu.Extent} extent Extent to be searched. Coordinates must be in EPSG:4326 latlon.
* @callback {Function} load Function to execute if response is loaded.
* @callback {Function} error Function to execute if response has an error.
* @api
*/
bu.street.Services.prototype.findStreetImagesByExtent = function(extent, load, error){
var client = new XMLHttpRequest();
client.addEventListener('load', load);
client.addEventListener('error', error);
client.open('GET', bu.FINDSTREETIMAGESBYEXTENT_SERVICE + "?" +
"usertoken=" + this.usertoken_ + "&" +
"bbox=" + extent.join(',') + "&" +
"srs=EPSG:4326&" +
"format=json");
client.send();
};