<commit_before>goog.provide('layerorder');

goog.require('ngeo.DecorateLayer');
goog.require('ngeo.mapDirective');
goog.require('ngeo.sortableDirective');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.source.MapQuest');
goog.require('ol.source.TileWMS');


/** @const **/
var app = {};


/** @type {!angular.Module} **/
app.module = angular.module('app', ['ngeo']);



/**
 * @param {angular.Scope} $scope Scope.
 * @param {ngeo.DecorateLayer} ngeoDecorateLayer Decorate layer service.
 * @constructor
 * @ngInject
 */
app.MainController = function($scope, ngeoDecorateLayer) {

  /** @type {ol.layer.Tile} */
  var boundaries = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_state_boundaries'},
      serverType: 'geoserver'
    }),
    name: 'Boundaries'
  });

  /** @type {ol.layer.Tile} */
  var roads = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_roads'},
      serverType: 'geoserver'
    }),
    name: 'Roads'
  });

  /** @type {ol.layer.Tile} */
  var waterBodies = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_water_bodies'},
      serverType: 'geoserver'
    }),
    name: 'Water bodies'
  });

  /** @type {ol.layer.Tile} */
  var cities = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_cities'},
      serverType: 'geoserver'
    }),
    name: 'Cities'
  });


  /** @type {ol.Map} */
  this['map'] = new ol.Map({
    layers: [
      new ol.layer.Tile({
        source: new ol.source.MapQuest({layer: 'sat'}),
        name: 'MapQuest'
      }),
      boundaries,
      roads,
      waterBodies,
      cities
    ],
    view: new ol.View({
      center: [16339075, -5194965],
      zoom: 7
    })
  });

  // watch any change on layers array to refresh the map
  $scope.layers = this['map'].getLayers().getArray();
  $scope.$watchCollection('layers', goog.bind(function() {
    this['map'].render();
  }, this));
};


app.module.controller('MainController', app.MainController);<commit_msg>Simplify how layers collection is watched<commit_after>goog.provide('layerorder');

goog.require('ngeo.DecorateLayer');
goog.require('ngeo.mapDirective');
goog.require('ngeo.sortableDirective');
goog.require('ol.Map');
goog.require('ol.View');
goog.require('ol.layer.Tile');
goog.require('ol.source.MapQuest');
goog.require('ol.source.TileWMS');


/** @const **/
var app = {};


/** @type {!angular.Module} **/
app.module = angular.module('app', ['ngeo']);



/**
 * @param {angular.Scope} $scope Scope.
 * @param {ngeo.DecorateLayer} ngeoDecorateLayer Decorate layer service.
 * @constructor
 * @ngInject
 */
app.MainController = function($scope, ngeoDecorateLayer) {

  /** @type {ol.layer.Tile} */
  var boundaries = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_state_boundaries'},
      serverType: 'geoserver'
    }),
    name: 'Boundaries'
  });

  /** @type {ol.layer.Tile} */
  var roads = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_roads'},
      serverType: 'geoserver'
    }),
    name: 'Roads'
  });

  /** @type {ol.layer.Tile} */
  var waterBodies = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_water_bodies'},
      serverType: 'geoserver'
    }),
    name: 'Water bodies'
  });

  /** @type {ol.layer.Tile} */
  var cities = new ol.layer.Tile({
    source: new ol.source.TileWMS({
      url: 'http://demo.opengeo.org/geoserver/wms',
      params: {'LAYERS': 'topp:tasmania_cities'},
      serverType: 'geoserver'
    }),
    name: 'Cities'
  });


  /** @type {ol.Map} */
  this['map'] = new ol.Map({
    layers: [
      new ol.layer.Tile({
        source: new ol.source.MapQuest({layer: 'sat'}),
        name: 'MapQuest'
      }),
      boundaries,
      roads,
      waterBodies,
      cities
    ],
    view: new ol.View({
      center: [16339075, -5194965],
      zoom: 7
    })
  });

  // watch any change on layers array to refresh the map
  var map = this['map'];
  $scope.$watchCollection(function() {
    return map.getLayers().getArray();
  }, function() {
    map.render();
  });
};


app.module.controller('MainController', app.MainController);
{'fraction_non_alphanumeric': 0.19106804297451022, 'fraction_numerical': 0.0067410996418790815, 'mean_word_length': 3.1072664359861593, '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': '5287423', 'n_tokens_mistral': 1745, 'n_tokens_neox': 1672, 'n_words': 304}