<commit_before>app.features = (options) ->
  map = options.map
  db = map.db

  lakes = options.g.append('g')
  rivers = options.g.append('g')
  highways = options.g.append('g')
  segments = options.g.append('g')
  symbols = options.symbols

  lakesLayer = topojson.feature(db.topo, db.topo.objects.lakes).features
  segmentLayer = topojson.feature(db.topo, db.topo.objects.segments).features
  segmentMap = app.index(segmentLayer)
  for s in segmentLayer
    s.properties.length = app.length(s.geometry.coordinates, true)

  poiLayer = topojson.feature(db.topo, db.topo.objects.poi).features
  riversLayer = topojson.feature(db.topo, db.topo.objects.rivers).features
  highwaysLayer = topojson.feature(db.topo, db.topo.objects.highways).features

  for route in db.routes
    for id in route.segments
      if route.symbol?
        segment = segmentMap.get(id)
        segment.properties.symbols = [] unless segment.properties.symbols?
        segment.properties.symbols.push(route.symbol)

  labelWidthG = symbols.append('g').attr('transform', "translate(0,-100)")
  app.symbol.calculateLabelWidth(labelWidthG, poiLayer)
  labelWidthG.remove()

  segments.selectAll('.segment')
      .data(segmentLayer)
    .enter().append('path')
      .attr('class', 'segment')

  lakes.selectAll('.lake')
      .data(lakesLayer)
    .enter().append('path')
      .attr('class', 'lake')

  rivers.selectAll('.river')
      .data(riversLayer)
    .enter().append('path')
      .attr('class', 'river')

  highways.selectAll('.highway')
      .data(highwaysLayer)
    .enter().append('path')
      .attr('class', (d) -> "highway highway-#{d.properties.grade}")

  render = ->
    segments.selectAll('.segment')
        .attr('d', map.path)

    lakes.selectAll('.lake')
        .attr('d', map.path)

    rivers.selectAll('.river')
        .attr('d', map.path)

    highways.selectAll('.highway')
        .attr('d', map.path)

    symbols.selectAll('.symbol').remove()

    interval = 80 / map.sc
    segmentSymbols = []
    for segment in segmentLayer
      length = segment.properties.length
      for n in d3.range(0, d3.round(length / interval))
        point = app.along(segment.geometry.coordinates, interval * (n + 0.5))
        point.properties = {symbols: segment.properties.symbols}
        if app.inside(point.geometry.coordinates, db.bbox)
          xyproj = map.projection(point.geometry.coordinates)
          x = d3.round(xyproj[0])
          y = d3.round(xyproj[1])
          if app.inside([x, y], [0, 0, map.width, map.height])
            symbol = {properties: point.properties, x: x, y: y}
            segmentSymbols.push(symbol)

    symbols.selectAll('.segmentSymbol').data(segmentSymbols)
      .enter().append('g')
        .attr('class', 'symbol segmentSymbol')
        .attr('transform', (d) -> "translate(#{d.x},#{d.y})")
        .each (d) ->
          return unless d.properties.symbols
          for i in d3.range(0, d.properties.symbols.length)
            dx = - d3.round(13 / 2 * (d.properties.symbols.length - 1))
            g = d3.select(@).append('g')
                .attr('transform', "translate(#{i * 13 + dx},0)")
            app.symbol.osmc(d.properties.symbols[i])(g)

    poiSymbols = []
    for poi in poiLayer
      xyproj = map.projection(poi.geometry.coordinates)
      x = d3.round(xyproj[0])
      y = d3.round(xyproj[1])
      if x > 0 and x < map.width and y > 0 and y < map.height
        symbol = {properties: poi.properties, x: x, y: y}
        poiSymbols.push(symbol)

    symbols.selectAll('.poiSymbol').data(poiSymbols)
      .enter().append('g')
        .attr('class', 'symbol poiSymbol')
        .attr('transform', (d) -> "translate(#{d.x},#{d.y})")
        .each (poi) ->
          if (drawSymbol = app.symbol[poi.properties.type])?
            drawSymbol(d3.select(@))

  map.dispatch.on 'redraw.features', ->
    render()

  map.dispatch.on 'zoomend.features', ->
    render()<commit_msg>only add symbol to drawlist if we can draw it<commit_after>app.features = (options) ->
  map = options.map
  db = map.db

  lakes = options.g.append('g')
  rivers = options.g.append('g')
  highways = options.g.append('g')
  segments = options.g.append('g')
  symbols = options.symbols

  lakesLayer = topojson.feature(db.topo, db.topo.objects.lakes).features
  segmentLayer = topojson.feature(db.topo, db.topo.objects.segments).features
  segmentMap = app.index(segmentLayer)
  for s in segmentLayer
    s.properties.length = app.length(s.geometry.coordinates, true)

  poiLayer = topojson.feature(db.topo, db.topo.objects.poi).features
  riversLayer = topojson.feature(db.topo, db.topo.objects.rivers).features
  highwaysLayer = topojson.feature(db.topo, db.topo.objects.highways).features

  for route in db.routes
    for id in route.segments
      if route.symbol?
        segment = segmentMap.get(id)
        segment.properties.symbols = [] unless segment.properties.symbols?
        segment.properties.symbols.push(route.symbol)

  labelWidthG = symbols.append('g').attr('transform', "translate(0,-100)")
  app.symbol.calculateLabelWidth(labelWidthG, poiLayer)
  labelWidthG.remove()

  segments.selectAll('.segment')
      .data(segmentLayer)
    .enter().append('path')
      .attr('class', 'segment')

  lakes.selectAll('.lake')
      .data(lakesLayer)
    .enter().append('path')
      .attr('class', 'lake')

  rivers.selectAll('.river')
      .data(riversLayer)
    .enter().append('path')
      .attr('class', 'river')

  highways.selectAll('.highway')
      .data(highwaysLayer)
    .enter().append('path')
      .attr('class', (d) -> "highway highway-#{d.properties.grade}")

  render = ->
    segments.selectAll('.segment')
        .attr('d', map.path)

    lakes.selectAll('.lake')
        .attr('d', map.path)

    rivers.selectAll('.river')
        .attr('d', map.path)

    highways.selectAll('.highway')
        .attr('d', map.path)

    symbols.selectAll('.symbol').remove()

    interval = 80 / map.sc
    segmentSymbols = []
    for segment in segmentLayer
      length = segment.properties.length
      for n in d3.range(0, d3.round(length / interval))
        point = app.along(segment.geometry.coordinates, interval * (n + 0.5))
        if segment.properties.symbols
          point.properties = {symbols: segment.properties.symbols}
          if app.inside(point.geometry.coordinates, db.bbox)
            xyproj = map.projection(point.geometry.coordinates)
            x = d3.round(xyproj[0])
            y = d3.round(xyproj[1])
            if app.inside([x, y], [0, 0, map.width, map.height])
              symbol = {properties: point.properties, x: x, y: y}
              segmentSymbols.push(symbol)

    symbols.selectAll('.segmentSymbol').data(segmentSymbols)
      .enter().append('g')
        .attr('class', 'symbol segmentSymbol')
        .attr('transform', (d) -> "translate(#{d.x},#{d.y})")
        .each (d) ->
          for i in d3.range(0, d.properties.symbols.length)
            dx = - d3.round(13 / 2 * (d.properties.symbols.length - 1))
            g = d3.select(@).append('g')
                .attr('transform', "translate(#{i * 13 + dx},0)")
            app.symbol.osmc(d.properties.symbols[i])(g)

    poiSymbols = []
    for poi in poiLayer
      xyproj = map.projection(poi.geometry.coordinates)
      x = d3.round(xyproj[0])
      y = d3.round(xyproj[1])
      if x > 0 and x < map.width and y > 0 and y < map.height
        if app.symbol[poi.properties.type]
          symbol = {properties: poi.properties, x: x, y: y}
          poiSymbols.push(symbol)

    symbols.selectAll('.poiSymbol').data(poiSymbols)
      .enter().append('g')
        .attr('class', 'symbol poiSymbol')
        .attr('transform', (d) -> "translate(#{d.x},#{d.y})")
        .each (poi) ->
          app.symbol[poi.properties.type](d3.select(@))

  map.dispatch.on 'redraw.features', ->
    render()

  map.dispatch.on 'zoomend.features', ->
    render()
{'fraction_non_alphanumeric': 0.1652338811630847, 'fraction_numerical': 0.008849557522123894, 'mean_word_length': 2.7245762711864407, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 25, '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': '775171', 'n_tokens_mistral': 2685, 'n_tokens_neox': 2624, 'n_words': 460}