{"size": 1367, "ext": "js", "max_stars_repo_path": "lib/geocoder/abstractgeocoder.js", "max_stars_repo_name": "cloudnapps/mlop-geo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/geocoder/abstractgeocoder.js", "max_issues_repo_name": "cloudnapps/mlop-geo", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lib/geocoder/abstractgeocoder.js", "max_forks_repo_name": "cloudnapps/mlop-geo", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.4107142857, "max_line_length": 77, "alphanum_fraction": 0.6686174104}
'use strict';

var net = require('net');
var ValueError = require('../error/valueerror.js');

function formatGeocoderName(name) {
  return name.toLowerCase().replace(/geocoder$/, '');
}

/**
 * AbstractGeocoder Constructor
 * @param <object> httpAdapter Http Adapter
 * @param <object> options     Options
 */
var AbstractGeocoder = function(httpAdapter, options) {
  if (!this.constructor.name) {
    throw new Error('The Constructor must be named');
  }

  this.name = formatGeocoderName(this.constructor.name);

  if (!httpAdapter || httpAdapter == 'undefined') {
    throw new Error(this.constructor.name + ' need an httpAdapter');
  }
  this.httpAdapter = httpAdapter;

  if (!options || options == 'undefined') {
    options = {};
  }

  if (this.options) {
    this.options.forEach(function(option) {
      if (!options[option] || options[option] == 'undefined') {
        options[option] = null;
      }
    });
  }

  this.options = options;
};

/**
* Reverse geocoding
* @param {lat:<number>,lon:<number>}  lat: Latitude, lon: Longitude
* @param <function> callback Callback method
*/
AbstractGeocoder.prototype.reverse = function(query, callback) {
  if (typeof this._reverse != 'function') {
    throw new Error(this.constructor.name + ' no support reverse geocoding');
  }

  return this._reverse(query, callback);
};

module.exports = AbstractGeocoder;
