Sha256: 1593fa3cad054945f147fab84dc568da46358b2ec3626924e52f1fd4f372dee7

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'simple_mapnik'

module GeoConcerns
  module Processors
    module Mapnik
      extend ActiveSupport::Concern

      included do
        def self.mapnik_vector_thumbnail(in_path, out_path, options)
          vector_info = GeoConcerns::Processors::Vector::Info.new(in_path)
          options[:name] = vector_info.name
          SimpleMapnik.register_datasources mapnik_datasources
          map = SimpleMapnik::Map.new(*mapnik_size(options))
          map.load_string(mapnik_config(in_path, options).xml)
          map.zoom_all
          map.to_file out_path
        end

        def self.mapnik_size(options)
          options[:output_size].split(' ').map(&:to_i)
        end

        def self.mapnik_config(in_path, options)
          path_name = "#{in_path}/#{options[:name]}"
          SimpleMapnik::Config.new(path_name)
        end

        def self.mapnik_datasources
          standard = '/usr/local/lib/mapnik/input'
          Dir.exist?(standard) ? standard : '/usr/lib/mapnik/input'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
geo_concerns-0.0.10 app/processors/geo_concerns/processors/mapnik.rb
geo_concerns-0.0.9 app/processors/geo_concerns/processors/mapnik.rb
geo_concerns-0.0.8 app/processors/geo_concerns/processors/mapnik.rb
geo_concerns-0.0.7 app/processors/geo_concerns/processors/mapnik.rb
geo_concerns-0.0.6 app/processors/geo_concerns/processors/mapnik.rb