<commit_before>define([
    'app/config',
    'app/map/MapController',

    'dojo/Deferred',
    'dojo/topic',
    'dojo/_base/declare',

    'esri/config',
    'esri/tasks/BufferParameters',
    'esri/tasks/GeometryService'
], function (
    config,
    mapController,

    Deferred,
    topic,
    declare,

    esriConfig,
    BufferParameters,
    GeometryService
) {
    return declare(null, {
        // summary:
        //      mixin for searchs that have buffers

        // noBufferMsg: String
        //      shown when the user draws a line or point without defining a buffer radius
        noBufferMsg: 'You must enter a buffer radius greater than zero!',

        // geoService: GeometryService
        //      used to buffer points and lines
        geoService: null,

        // getGeometryDef: Deferred
        //      the deferred returned from getGeometry
        getGeometryDef: null,

        getGeometry() {
            // summary:
            //      gets the geometry to send to the search service
            // returns: Promise
            console.log('app/search/_BufferMixin:getGeometry', arguments);

            this.getGeometryDef = new Deferred();

            if (!this.geometry && mapController.selectedGraphic) {
                this.geometry = mapController.selectedGraphic.geometry;
            }

            if (this.geometry) {
                if (this.bufferNum.value > 0) {
                    // start spinner
                    topic.publish(config.topics.appSearch.searchStarted);
                    if (!this.geoService) {
                        this.initGeoService();
                    }
                    this.bufferParams.distances = [this.bufferNum.value];
                    this.bufferParams.geometries = [this.geometry];
                    this.geoService.buffer(this.bufferParams);
                } else if (this.geometry.type === 'polygon') {
                    this.getGeometryDef.resolve(this.geometry);
                } else {
                    this.getGeometryDef.reject(this.noBufferMsg);
                }
            } else {
                this.getGeometryDef.reject(this.noGeoMsg);
            }

            return this.getGeometryDef.promise;
        },
        initGeoService() {
            // summary:
            //      sets up the geometry service
            console.log('app/search/_BufferMixin:initGeoService', arguments);

            var that = this;
            this.geoService = esriConfig.defaults.geometryService;
            this.geoService.on('buffer-complete', function (result) {
                that.getGeometryDef.resolve(result.geometries[0]);
                topic.publish(config.topics.appMapMapController.zoomToSearchGraphic, result.geometries[0]);
            });
            this.geoService.on('error', function () {
                that.getGeometryDef.reject('There was an error with the buffer');
            });

            this.bufferParams = new BufferParameters();
            this.bufferParams.spatialReference = config.spatialReference;
            this.bufferParams.unit = GeometryService.UNIT_STATUTE_MILE;
        },
        clear() {
            // summary:
            //      clears the buffer text box
            console.log('app/search/_BufferMixin:clear', arguments);

            topic.publish(config.topics.appMapMapController.clearGraphics);

            this.bufferNum.value = '';
        }
    });
});
<commit_msg>fix bug causing incorrect buffer lengths<commit_after>define([
    'app/config',
    'app/map/MapController',

    'dojo/Deferred',
    'dojo/topic',
    'dojo/_base/declare',

    'esri/config',
    'esri/tasks/BufferParameters',
    'esri/tasks/GeometryService'
], function (
    config,
    mapController,

    Deferred,
    topic,
    declare,

    esriConfig,
    BufferParameters,
    GeometryService
) {
    return declare(null, {
        // summary:
        //      mixin for searchs that have buffers

        // noBufferMsg: String
        //      shown when the user draws a line or point without defining a buffer radius
        noBufferMsg: 'You must enter a buffer radius greater than zero!',

        // geoService: GeometryService
        //      used to buffer points and lines
        geoService: null,

        // getGeometryDef: Deferred
        //      the deferred returned from getGeometry
        getGeometryDef: null,

        getGeometry() {
            // summary:
            //      gets the geometry to send to the search service
            // returns: Promise
            console.log('app/search/_BufferMixin:getGeometry', arguments);

            this.getGeometryDef = new Deferred();

            if (!this.geometry && mapController.selectedGraphic) {
                this.geometry = mapController.selectedGraphic.geometry;
            }

            if (this.geometry) {
                if (this.bufferNum.value > 0) {
                    // start spinner
                    topic.publish(config.topics.appSearch.searchStarted);
                    if (!this.geoService) {
                        this.initGeoService();
                    }
                    this.bufferParams.distances = [this.bufferNum.value];
                    this.bufferParams.geometries = [this.geometry];
                    this.geoService.buffer(this.bufferParams);
                } else if (this.geometry.type === 'polygon') {
                    this.getGeometryDef.resolve(this.geometry);
                } else {
                    this.getGeometryDef.reject(this.noBufferMsg);
                }
            } else {
                this.getGeometryDef.reject(this.noGeoMsg);
            }

            return this.getGeometryDef.promise;
        },
        initGeoService() {
            // summary:
            //      sets up the geometry service
            console.log('app/search/_BufferMixin:initGeoService', arguments);

            var that = this;
            this.geoService = esriConfig.defaults.geometryService;
            this.geoService.on('buffer-complete', function (result) {
                that.getGeometryDef.resolve(result.geometries[0]);
                topic.publish(config.topics.appMapMapController.zoomToSearchGraphic, result.geometries[0]);
            });
            this.geoService.on('error', function () {
                that.getGeometryDef.reject('There was an error with the buffer');
            });

            this.bufferParams = new BufferParameters();
            this.bufferParams.spatialReference = config.spatialReference;
            this.bufferParams.unit = GeometryService.UNIT_STATUTE_MILE;
            this.bufferParams.geodesic = true;
        },
        clear() {
            // summary:
            //      clears the buffer text box
            console.log('app/search/_BufferMixin:clear', arguments);

            topic.publish(config.topics.appMapMapController.clearGraphics);

            this.bufferNum.value = '';
        }
    });
});

{'fraction_non_alphanumeric': 0.0996553704767375, 'fraction_numerical': 0.0008615738081562321, 'mean_word_length': 1.6634799235181645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7367385', 'n_tokens_mistral': 1815, 'n_tokens_neox': 1724, 'n_words': 345}