Update and index the last added and deleted layers (num_layers) in WorldMap service.
339207
def update_last_wm_layers(self, service_id, num_layers=10):
    
    from hypermap.aggregator.models import Service

    LOGGER.debug(
        'Updating the index the last %s added and %s deleted layers in WorldMap service'
        % (num_layers, num_layers)
                )
    service = Service.objects.get(id=service_id)
    # TODO raise error if service type is not WM type
    if service.type == 'Hypermap:WorldMapLegacy':
        from hypermap.aggregator.models import update_layers_wm_legacy as update_layers_wm
    if service.type == 'Hypermap:WorldMap':
        from hypermap.aggregator.models import update_layers_geonode_wm as update_layers_wm

    update_layers_wm(service, num_layers)

    # Remove in search engine last num_layers that were deleted
    LOGGER.debug('Removing the index for the last %s deleted layers' % num_layers)
    layer_to_unindex = service.layer_set.filter(was_deleted=True).order_by('-last_updated')[0:num_layers]
    for layer in layer_to_unindex:
        if not settings.REGISTRY_SKIP_CELERY:
            unindex_layer(layer.id, use_cache=True)
        else:
            unindex_layer(layer.id)

    # Add/Update in search engine last num_layers that were added
    LOGGER.debug('Adding/Updating the index for the last %s added layers' % num_layers)
    layer_to_index = service.layer_set.filter(was_deleted=False).order_by('-last_updated')[0:num_layers]
    for layer in layer_to_index:
        if not settings.REGISTRY_SKIP_CELERY:
            index_layer(layer.id, use_cache=True)
        else:
            index_layer(layer.id)
164755
def reset(self):
        ""
        self.hidden = [next(self.parameters()).data.new(0) for i in range(self.n_layers+1)]
165186
function updateOneLayer(item, currZIndex) {
  if (defined(item.imageryLayer) && defined(item.imageryLayer.setZIndex)) {
    if (item.supportsReordering) {
      item.imageryLayer.setZIndex(currZIndex.reorderable++);
    } else {
      item.imageryLayer.setZIndex(currZIndex.fixed++);
    }
  }
}
801239
function(map) {
        OpenLayers.Layer.Vector.prototype.setMap.apply(this, arguments);
        this.collectRoots();
        map.events.register("changelayer", this, this.handleChangeLayer);
    }
327976
function (layers) {
		var layersArray = this._toArray(layers),
		    separated = this._checkInGetSeparated(layersArray),
		    groups = separated.groups,
		    i, group, id;

		// Batch add all single layers.
		this._originalAddLayers(separated.singles);

		// Add Layer Groups to the map so that they are registered there and
		// the map fires 'layeradd' events for them as well.
		for (i = 0; i < groups.length; i++) {
			group = groups[i];
			id = L.stamp(group);
			this._proxyLayerGroups[id] = group;
			delete this._proxyLayerGroupsNeedRemoving[id];
			if (this._map) {
				this._map._originalAddLayer(group);
			}
		}
	}
998409
void refresh(long now) {
    refreshCandidateSpeculativeMaps(now);
    refreshCandidateSpeculativeReduces(now);
    refreshTaskCountsAndWaitTime(TaskType.MAP, now);
    refreshTaskCountsAndWaitTime(TaskType.REDUCE, now);
  }
561129
def update_layers(self):
        

        signals.post_save.disconnect(layer_post_save, sender=Layer)

        try:
            LOGGER.debug('Updating layers for service id %s' % self.id)
            if self.type == 'OGC:WMS':
                update_layers_wms(self)
            elif self.type == 'OGC:WMTS':
                update_layers_wmts(self)
            elif self.type == 'ESRI:ArcGIS:MapServer':
                update_layers_esri_mapserver(self)
            elif self.type == 'ESRI:ArcGIS:ImageServer':
                update_layers_esri_imageserver(self)
            elif self.type == 'Hypermap:WorldMapLegacy':
                update_layers_wm_legacy(self)
            elif self.type == 'Hypermap:WorldMap':
                update_layers_geonode_wm(self)
            elif self.type == 'Hypermap:WARPER':
                update_layers_warper(self)

        except:
            LOGGER.error('Error updating layers for service %s' % self.uuid)

        signals.post_save.connect(layer_post_save, sender=Layer)
417195
def _read_layers(self, layers, image_id):
        

        for layer in self.docker.history(image_id):
            layers.append(layer['Id'])
1034595
def update_hash(self):
        
        _logger.debug('update hash')
        layer_in_cnt = [len(layer.input) for layer in self.layers]
        topo_queue = deque([i for i, layer in enumerate(self.layers) if not layer.is_delete and layer.graph_type == LayerType.input.value])
        while topo_queue:
            layer_i = topo_queue.pop()
            self.layers[layer_i].update_hash(self.layers)
            for layer_j in self.layers[layer_i].output:
                layer_in_cnt[layer_j] -= 1
                if layer_in_cnt[layer_j] == 0:
                    topo_queue.appendleft(layer_j)
1136819
function updateTrack( newList, oldList, steps,  rawNewValue, oldKeyMap ){
    
    for(var i =0, slen = steps.length; i < slen ;i++){
      var step = steps[i];
      switch( step.mode){
        case 0 : //remove
          removeRange(step.index, step.len, group.children, oldKeyMap);
          break;
        case 1 : //insert
          addRange(step.index, step.index + step.len, newList, rawNewValue, oldKeyMap )
          break;
      }
    }     
    var children = group.children;
    for(var j=1, len = children.length; j < len; j++){
      var child = children[j];
      if( child ){
        child.data[variable] = newList[j-1];
        child.data[indexName] = j-1
      }
    }

    
  }
733277
def __update_layer_density(self):
        """"""
        _stack = self.stack
        _density_lock = self.density_lock
        list_compound = _stack.keys()
        for _key in list_compound:
            if _density_lock[_key]:
                continue

            _list_ratio = _stack[_key]['stoichiometric_ratio']
            _list_density = []
            for _element in _stack[_key]['elements']:
                _list_density.append(_stack[_key][_element]['density']['value'])
                _compound_density = _utilities.get_compound_density(list_density=_list_density,
                                                                    list_ratio=_list_ratio)

            _stack[_key]['density']['value'] = _compound_density
        self.stack = _stack
497194
def _insert_new_layers(self, new_layers, start_node_id, end_node_id):
        """"""
        new_node_id = self._add_node(deepcopy(self.node_list[end_node_id]))
        temp_output_id = new_node_id
        for layer in new_layers[:-1]:
            temp_output_id = self.add_layer(layer, temp_output_id)

        self._add_edge(new_layers[-1], temp_output_id, end_node_id)
        new_layers[-1].input = self.node_list[temp_output_id]
        new_layers[-1].output = self.node_list[end_node_id]
        self._redirect_edge(start_node_id, end_node_id, new_node_id)
181463
def update_mappings(self):
        """"""
        self.pos2id = dict((v, k) for k, v in self.id2pos.iteritems())
        assert len(self.pos2id) == len(self.id2pos), "duplicate ids or positions detected"
572794
def update_layers_wmts(service):
    
    try:
        wmts = WebMapTileService(service.url)

        # set srs
        # WMTS is always in 4326
        srs, created = SpatialReferenceSystem.objects.get_or_create(code='EPSG:4326')
        service.srs.add(srs)

        service.update_validity()

        layer_names = list(wmts.contents)
        layer_n = 0
        total = len(layer_names)
        for layer_name in layer_names:
            ows_layer = wmts.contents[layer_name]
            LOGGER.debug('Updating layer %s' % ows_layer.name)
            layer, created = Layer.objects.get_or_create(name=ows_layer.name, service=service, catalog=service.catalog)
            if layer.active:
                links = [['OGC:WMTS', service.url],
                         ['OGC:WMTS', settings.SITE_URL.rstrip('/') + '/' + layer.get_url_endpoint()]]
                layer.type = 'OGC:WMTS'
                layer.title = ows_layer.title
                layer.abstract = ows_layer.abstract
                # keywords
                # @tomkralidis wmts does not seem to support this attribute
                keywords = None
                if hasattr(ows_layer, 'keywords'):
                    keywords = ows_layer.keywords
                    for keyword in keywords:
                        layer.keywords.add(keyword)
                layer.url = service.url
                layer.page_url = layer.get_absolute_url
                links.append([
                    'WWW:LINK',
                    settings.SITE_URL.rstrip('/') + layer.page_url
                ])
                bbox = list(ows_layer.boundingBoxWGS84 or (-179.0, -89.0, 179.0, 89.0))
                layer.bbox_x0 = bbox[0]
                layer.bbox_y0 = bbox[1]
                layer.bbox_x1 = bbox[2]
                layer.bbox_y1 = bbox[3]
                layer.wkt_geometry = bbox2wktpolygon(bbox)
                layer.xml = create_metadata_record(
                    identifier=str(layer.uuid),
                    source=service.url,
                    links=links,
                    format='OGC:WMS',
                    type=layer.csw_type,
                    relation=service.id_string,
                    title=ows_layer.title,
                    alternative=ows_layer.name,
                    abstract=layer.abstract,
                    keywords=keywords,
                    wkt_geometry=layer.wkt_geometry
                )
                layer.anytext = gen_anytext(layer.title, layer.abstract, keywords)
                layer.save()
                # dates
                add_mined_dates(layer)
            layer_n = layer_n + 1
            # exits if DEBUG_SERVICES
            LOGGER.debug("Updating layer n. %s/%s" % (layer_n, total))
            if DEBUG_SERVICES and layer_n == DEBUG_LAYER_NUMBER:
                return
    except Exception as err:
        message = "update_layers_wmts: {0}".format(
            err
        )
        check = Check(
            content_object=service,
            success=False,
            response_time=0,
            message=message
        )
        check.save()
753391
function() {
        var index = this.layer.getZIndex() - 1;
        if (index >= this.map.Z_INDEX_BASE['Feature']) {
            this.layer.setZIndex(index);
        } else {
            this.map.setLayerZIndex(this.layer,
                this.map.getLayerIndex(this.layer));
        }
    }
852464
def update(self, new_vals):
        
        for k, v in six.iteritems(new_vals):
            k = k.strip()
            if k in self.row:
                warnings.warn("Adding history key ({}) that is already set in this step".format(
                    k), wandb.WandbWarning)
            self.row[k] = v
714519
def get_map_template(layers, has_zoom):
    """"""
    num_layers = len(non_basemap_layers(layers))
    has_time = has_time_layer(layers)
    name = get_map_name(layers, has_zoom=has_zoom)

    # Add basemap layer
    layers_field = [{
        'type': 'http',
        'options': {
            # TODO: Remove this once baselayer urls can be passed in named map
            #       config
            'urlTemplate': layers[0].url,
            # 'urlTemplate': '<%= basemap_url %>',
            'subdomains': "abcd",
        },
    }]

    # [BUG] Remove this once baselayer urls can be passed in named map config
    placeholders = {}
    # placeholders = {
    #     'basemap_url': {
    #         'type': 'sql_ident',
    #         'default': ('https://cartodb-basemaps-{s}.global.ssl.fastly.net/'
    #                     'dark_all/{z}/{x}/{y}.png'),
    #     },
    # }

    for idx in range(num_layers):
        layers_field.extend([{
            'type': ('torque' if (has_time and idx == (num_layers - 1))
                     else 'mapnik'),
            'options': {
                'cartocss_version': '2.1.1',
                'cartocss': '<%= cartocss_{idx} %>'.format(idx=idx),
                'sql': '<%= sql_{idx} %>'.format(idx=idx),
                # [BUG] No [] for templating
                # 'interactivity': '<%= interactivity_{idx} %>'.format(
                #                                                 idx=idx),
            }
        }])
        placeholders.update({
            'cartocss_{idx}'.format(idx=idx): {
                'type': 'sql_ident',
                'default': ('#layer {'
                            ' marker-fill: red;'
                            ' marker-width: 5;'
                            ' marker-allow-overlap: true;'
                            ' marker-line-color: #000; }'),
            },
            'sql_{idx}'.format(idx=idx): {
                'type': 'sql_ident',
                'default': (
                        "SELECT "
                        "ST_PointFromText('POINT(0 0)', 4326) AS the_geom, "
                        "1 AS cartodb_id, "
                        "ST_PointFromText('Point(0 0)', 3857) AS "
                        "the_geom_webmercator"
                    ),
            },
            # [BUG] No [] for templating
            # 'interactivity_{idx}'.format(idx=idx): {
            #     'type': 'sql_ident',
            #     'default': '["cartodb_id"]',
            # },
        })

    # Add labels if they're in front
    if num_layers > 0 and layers[-1].is_basemap:
        layers_field.extend([{
            'type': 'http',
            'options': {
                # TODO: Remove this once baselayer urls can be passed in named
                #       map config
                'urlTemplate': layers[-1].url,
                # 'urlTemplate': '<%= basemap_url %>',
                'subdomains': "abcd",
            },
        }])

    if has_zoom:
        view = {
            'zoom': '<%= zoom %>',
            'center': {
                'lng': '<%= lng %>',
                'lat': '<%= lat %>',
            },
        }
        placeholders.update({
            'zoom': {
                'type': 'number',
                'default': 3,
            },
            'lng': {
                'type': 'number',
                'default': 0,
            },
            'lat': {
                'type': 'number',
                'default': 0,
            },
        })
    else:
        view = {
            'bounds': {
                'west': '<%= west %>',
                'south': '<%= south %>',
                'east': '<%= east %>',
                'north': '<%= north %>',
            },
        }
        placeholders.update({
            'west': {
                'type': 'number',
                'default': -45,
            },
            'south': {
                'type': 'number',
                'default': -45,
            },
            'east': {
                'type': 'number',
                'default':  45,
            },
            'north': {
                'type': 'number',
                'default':  45,
            },
        })

    return json.dumps({
        'version': '0.0.1',
        'name': name,
        'placeholders': placeholders,
        'layergroup': {
            'version': '1.0.1',
            'layers': layers_field,
        },
        'view': view,
    })