<commit_before>define(function(require) {
  'use strict';
  var flight = require('flight');
  var _  = require('lodash');
  var $ = require('jquery');

  return flight.component(function search() {
    this.defaultAttrs({
      searchUrl: '//nominatim.openstreetmap.org/search'
    });
    this.configureSearch = function(ev, config) {
      if (config.search && config.search.geosearch) {
        this.maxBounds = config.map.maxBounds;
      } else {
        this.teardown();
      }
    };

    this.onSearch = function(ev, options) {
      ev.preventDefault();
      var parameters = {
        // addressdetails: 1,
        format: "json",
        q: options.query,
        bounded: 1
      };
      if (this.maxBounds) {
        parameters.viewbox = [
          this.maxBounds[1][1], this.maxBounds[1][0],
          this.maxBounds[0][1], this.maxBounds[0][0]
        ].join(',');
      }
      $.getJSON(this.attr.searchUrl,
                parameters,
                this.searchResults.bind(this));
    };

    this.searchResults = function(results) {
      if (results.length) {
        var location = results[0],
            displayName = location.display_name;
        this.trigger('dataSearchResult', {
          name: displayName,
          lat: location.lat,
          lng: location.lon
        });
      }
    };

    this.after('initialize', function() {
      this.on(document, 'config', this.configureSearch);<commit_msg>Use ESRI world geocoder for location search<commit_after>define(function(require) {
  'use strict';
  var flight = require('flight');
  var _  = require('lodash');
  var $ = require('jquery');

  return flight.component(function search() {
    this.defaultAttrs({
      searchUrl: 'http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates'
    });
    this.configureSearch = function(ev, config) {
      if (config.search && config.search.geosearch) {
        this.maxBounds = config.map.maxBounds;
      } else {
        this.teardown();
      }
    };

    this.onSearch = function(ev, options) {
      ev.preventDefault();
      var parameters = {
        f: 'json',
        singleLine: options.query,
        maxLocations: 1
      };
      if (this.maxBounds) {
        parameters.searchExtent = [
          this.maxBounds[1][1], this.maxBounds[0][0],
          this.maxBounds[0][1], this.maxBounds[1][0]
        ].join(',');
      }
      $.getJSON(this.attr.searchUrl,
                parameters,
                this.searchResults.bind(this));
    };

    this.searchResults = function(result) {
      if (result.candidates.length) {
        var candidate = result.candidates[0],
            displayName = candidate.address;
        this.trigger('dataSearchResult', {
          name: displayName,
          lat: candidate.location.y,
          lng: candidate.location.x
        });
      }
    };

    this.after('initialize', function() {
      this.on(document, 'config', this.configureSearch);
{'fraction_non_alphanumeric': 0.14199192462987886, 'fraction_numerical': 0.0070659488559892325, 'mean_word_length': 2.214054054054054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1956212', 'n_tokens_mistral': 901, 'n_tokens_neox': 879, 'n_words': 147}