Merge pull request #12753 from CartoDB/12566-georeferencer-connectors

Enable georeferencer for database connectors
pull/12761/head^2
Alberto Romeu 7 years ago committed by GitHub
commit 588cd56d76

3
.gitignore vendored

@ -72,4 +72,5 @@ doc/manual/build
/.tags_swap /.tags_swap
.vscode/ .vscode/
/private_gears /private_gears
/dist /dist
yarn.lock

2
.gitmodules vendored

@ -1,6 +1,6 @@
[submodule "lib/assets/javascripts/cdb"] [submodule "lib/assets/javascripts/cdb"]
path = lib/assets/javascripts/cdb path = lib/assets/javascripts/cdb
url = git://github.com/CartoDB/cartodb.js.git url = git://github.com/CartoDB/cartodb.js.git
[submodule "app/assets/stylesheets/old_common"] [submodule "app/assets/stylesheets/old_common"]
path = app/assets/stylesheets/old_common path = app/assets/stylesheets/old_common
url = git://github.com/CartoDB/cartodb.css.git url = git://github.com/CartoDB/cartodb.css.git

@ -2,6 +2,7 @@ Development
----------- -----------
### Features ### Features
* Enable georeferencer for database connectors (#12566)
* Enable other hosts apart from account host to include CORS headers via the cors_enabled_hosts param in app_config.yml (#12685) * Enable other hosts apart from account host to include CORS headers via the cors_enabled_hosts param in app_config.yml (#12685)
* Add tooltips to show bucket data in time-series (#11650) * Add tooltips to show bucket data in time-series (#11650)
* Improve legend items management (#12650) * Improve legend items management (#12650)

@ -2,6 +2,7 @@
require 'carto/connector' require 'carto/connector'
require_relative 'exceptions' require_relative 'exceptions'
require_relative 'georeferencer'
require_relative 'runner_helper' require_relative 'runner_helper'
module CartoDB module CartoDB
@ -28,6 +29,7 @@ module CartoDB
@job = options[:job] || new_job(@log, @pg_options) @job = options[:job] || new_job(@log, @pg_options)
@user = options[:user] @user = options[:user]
@collision_strategy = options[:collision_strategy] @collision_strategy = options[:collision_strategy]
@georeferencer = options[:georeferencer] || new_georeferencer(@job)
@id = @job.id @id = @job.id
@unique_suffix = @id.delete('-') @unique_suffix = @id.delete('-')
@ -49,6 +51,8 @@ module CartoDB
if should_import?(@connector.remote_table_name) if should_import?(@connector.remote_table_name)
@job.log "Copy connected table" @job.log "Copy connected table"
warnings = @connector.copy_table(schema_name: @job.schema, table_name: @job.table_name) warnings = @connector.copy_table(schema_name: @job.schema, table_name: @job.table_name)
@job.log 'Georeference geometry column'
georeference
@warnings.merge! warnings if warnings.present? @warnings.merge! warnings if warnings.present?
else else
@job.log "Table #{table_name} won't be imported" @job.log "Table #{table_name} won't be imported"
@ -64,6 +68,12 @@ module CartoDB
end end
end end
def georeference
@georeferencer.run
rescue => error
@job.log "ConnectorRunner Error while georeference #{error}"
end
def remote_data_updated? def remote_data_updated?
@connector.remote_data_updated? @connector.remote_data_updated?
end end
@ -134,6 +144,10 @@ module CartoDB
Job.new(logger: log, pg_options: pg_options) Job.new(logger: log, pg_options: pg_options)
end end
def new_georeferencer(job)
Georeferencer.new(job.db, job.table_name, {}, Georeferencer::DEFAULT_SCHEMA, job)
end
UNKNOWN_ERROR_CODE = 99999 UNKNOWN_ERROR_CODE = 99999
def error_for(exception) def error_for(exception)

Loading…
Cancel
Save