All files / engine/Source/Core GeocoderService.js

85.71% Statements 6/7
100% Branches 2/2
50% Functions 1/2
85.71% Lines 6/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                  1x                                   1x 47x 2x     45x                   1x    
import Credit from "./Credit.js";
import defined from "./defined.js";
import DeveloperError from "./DeveloperError.js";
 
/**
 * @typedef {object} GeocoderService.Result
 * @property {string} displayName The display name for a location
 * @property {Rectangle|Cartesian3} destination The bounding box for a location
 * @property {object[]} [attributions]
 */
 
/**
 * Provides geocoding through an external service. This type describes an interface and
 * is not intended to be used.
 * @alias GeocoderService
 * @constructor
 *
 * @see BingMapsGeocoderService
 * @see PeliasGeocoderService
 * @see OpenCageGeocoderService
 */
function GeocoderService() {
  DeveloperError.throwInstantiationError();
}
 
Object.defineProperties(GeocoderService.prototype, {
  /**
   * Gets the credit to display after a geocode is performed. Typically this is used to credit
   * the geocoder service.
   * @memberof GeocoderService.prototype
   * @type {Credit|undefined}
   * @readonly
   */
  credit: {
    get: DeveloperError.throwInstantiationError,
  },
});
 
/**
 * Parses credits from the geocoder result attributions, if present.
 * @param {GeocoderService.Result} geocoderResult The geocoder result
 * @returns {Credit[]|undefined} A list of credits if present in the result, otherwise undefined
 */
GeocoderService.getCreditsFromResult = function (geocoderResult) {
  if (defined(geocoderResult.attributions)) {
    return geocoderResult.attributions.map(Credit.getIonCredit);
  }
 
  return undefined;
};
 
/**
 * @function
 *
 * @param {string} query The query to be sent to the geocoder service
 * @param {GeocodeType} [type=GeocodeType.SEARCH] The type of geocode to perform.
 * @returns {Promise<GeocoderService.Result[]>}
 */
GeocoderService.prototype.geocode = DeveloperError.throwInstantiationError;
export default GeocoderService;