<commit_before># encoding: utf-8

require_relative '../../lib/carto/styles/style'
require_relative '../../lib/carto/styles/point'
require_relative '../../lib/carto/styles/line'
require_relative '../../lib/carto/styles/polygon'
require_relative '../../lib/carto/form'

module ModelFactories
  class LayerFactory
    def self.get_new(options)
      ::Layer.new(options)
    end

    def self.get_default_base_layer(user)
      basemap = user.default_basemap
      options = if basemap['className'] === 'googlemaps'
                  { kind: 'gmapsbase', options: basemap }
                else
                  { kind: 'tiled', options: basemap.merge('urlTemplate' => basemap['url']) }
                end

      ::Layer.new(options)
    end

    def self.get_default_data_layer(table_name, user, geometry_type)
      data_layer = ::Layer.new(Cartodb.config[:layer_opts]['data'])
      data_layer.options['table_name'] = table_name
      data_layer.options['user_name'] = user.username
      data_layer.options['tile_style'] = tile_style(user, geometry_type)
      data_layer.infowindow ||= {}
      data_layer.infowindow['fields'] = []
      data_layer.tooltip ||= {}
      data_layer.tooltip['fields'] = []

      if user.force_builder?
        data_layer.options['style_properties'] = style_properties(user, geometry_type)
      end

      data_layer
    end

    # Info: does not perform validity checks<commit_msg>hotfix arg number<commit_after># encoding: utf-8

require_relative '../../lib/carto/styles/style'
require_relative '../../lib/carto/styles/point'
require_relative '../../lib/carto/styles/line'
require_relative '../../lib/carto/styles/polygon'
require_relative '../../lib/carto/form'

module ModelFactories
  class LayerFactory
    def self.get_new(options)
      ::Layer.new(options)
    end

    def self.get_default_base_layer(user)
      basemap = user.default_basemap
      options = if basemap['className'] === 'googlemaps'
                  { kind: 'gmapsbase', options: basemap }
                else
                  { kind: 'tiled', options: basemap.merge('urlTemplate' => basemap['url']) }
                end

      ::Layer.new(options)
    end

    def self.get_default_data_layer(table_name, user, geometry_type)
      data_layer = ::Layer.new(Cartodb.config[:layer_opts]['data'])
      data_layer.options['table_name'] = table_name
      data_layer.options['user_name'] = user.username
      data_layer.options['tile_style'] = tile_style(user, geometry_type)
      data_layer.infowindow ||= {}
      data_layer.infowindow['fields'] = []
      data_layer.tooltip ||= {}
      data_layer.tooltip['fields'] = []

      if user.force_builder?
        data_layer.options['style_properties'] = style_properties(geometry_type)
      end

      data_layer
    end

    # Info: does not perform validity checks
{'fraction_non_alphanumeric': 0.1372618207480593, 'fraction_numerical': 0.0007057163020465773, 'mean_word_length': 2.9049586776859506, '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': '6522646', 'n_tokens_mistral': 878, 'n_tokens_neox': 861, 'n_words': 146}