From ea95c17cc372fc5e89c5e27fd9615b4af41c2c71 Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 11 Jan 2017 19:02:11 +0100 Subject: [PATCH 1/6] Test to ensure gpkg export does not add FID --- test/acceptance/export/geopackage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/acceptance/export/geopackage.js b/test/acceptance/export/geopackage.js index b7a9f5bf..981b0fdc 100644 --- a/test/acceptance/export/geopackage.js +++ b/test/acceptance/export/geopackage.js @@ -68,6 +68,7 @@ describe('geopackage query', function(){ assert.equal(err, null); assert.equal(row.cartodb_id, 1); assert.equal(row.name, 'Hawai'); + assert.equal(row.fid, undefined); done(); }); assert.notEqual(dqr, undefined); From d680da0548872bc0c03a81685c8a1c13a2f534ef Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 11 Jan 2017 19:02:45 +0100 Subject: [PATCH 2/6] Use cartodb_id as FID column in gpkg --- app/models/formats/ogr/geopackage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/formats/ogr/geopackage.js b/app/models/formats/ogr/geopackage.js index a3cf287c..bc287b89 100644 --- a/app/models/formats/ogr/geopackage.js +++ b/app/models/formats/ogr/geopackage.js @@ -16,6 +16,7 @@ GeoPackageFormat.prototype._fileExtension = "gpkg"; GeoPackageFormat.prototype._needSRS = true; GeoPackageFormat.prototype.generate = function(options, callback) { + options.cmd_params = ['-lco', 'FID=cartodb_id']; this.toOGR_SingleFile(options, 'GPKG', callback); }; From 4f8fa92272fad9ebd93f1390f837b7e48c2718c9 Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 11 Jan 2017 19:03:11 +0100 Subject: [PATCH 3/6] Correctly accept custom options for formats in ogr.js --- app/models/formats/ogr.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/formats/ogr.js b/app/models/formats/ogr.js index 29d0a7c1..ad505a6d 100644 --- a/app/models/formats/ogr.js +++ b/app/models/formats/ogr.js @@ -60,10 +60,10 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback var ogr2ogr = global.settings.ogr2ogrCommand || 'ogr2ogr'; var dbhost = dbopts.host; - var dbport = dbopts.port; - var dbuser = dbopts.user; + var dbport = dbopts.port; + var dbuser = dbopts.user; var dbpass = dbopts.pass; - var dbname = dbopts.dbname; + var dbname = dbopts.dbname; var that = this; @@ -72,7 +72,7 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback var pg; // Drop ending semicolon (ogr doens't like it) - sql = sql.replace(/;\s*$/, ''); + sql = sql.replace(/;\s*$/, ''); step ( @@ -162,7 +162,7 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback } if (options.cmd_params){ - ogrargs.concat(options.cmd_params); + ogrargs = ogrargs.concat(options.cmd_params); } ogrargs.push('-nln', out_layername); @@ -318,7 +318,7 @@ ExportRequest.prototype.sendFile = function (err, filename, callback) { }) .on('error', function(e) { console.log("Can't send response: " + e); - that.ostream.end(); + that.ostream.end(); callback(); }); } else { From 1f318a5f3110e0a50a17ba59ae1ff9f6215cb631 Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 11 Jan 2017 19:02:11 +0100 Subject: [PATCH 4/6] Test to ensure gpkg export does not add FID --- test/acceptance/export/geopackage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/acceptance/export/geopackage.js b/test/acceptance/export/geopackage.js index b7a9f5bf..981b0fdc 100644 --- a/test/acceptance/export/geopackage.js +++ b/test/acceptance/export/geopackage.js @@ -68,6 +68,7 @@ describe('geopackage query', function(){ assert.equal(err, null); assert.equal(row.cartodb_id, 1); assert.equal(row.name, 'Hawai'); + assert.equal(row.fid, undefined); done(); }); assert.notEqual(dqr, undefined); From c67a2e7d09d3b681e687e1e09a07a35dac89d3eb Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 11 Jan 2017 19:02:45 +0100 Subject: [PATCH 5/6] Use cartodb_id as FID column in gpkg --- app/models/formats/ogr/geopackage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/formats/ogr/geopackage.js b/app/models/formats/ogr/geopackage.js index a3cf287c..bc287b89 100644 --- a/app/models/formats/ogr/geopackage.js +++ b/app/models/formats/ogr/geopackage.js @@ -16,6 +16,7 @@ GeoPackageFormat.prototype._fileExtension = "gpkg"; GeoPackageFormat.prototype._needSRS = true; GeoPackageFormat.prototype.generate = function(options, callback) { + options.cmd_params = ['-lco', 'FID=cartodb_id']; this.toOGR_SingleFile(options, 'GPKG', callback); }; From 62a67f148caffbeeee174c033796658fb799d02b Mon Sep 17 00:00:00 2001 From: Javier Torres Date: Wed, 11 Jan 2017 19:03:11 +0100 Subject: [PATCH 6/6] Correctly accept custom options for formats in ogr.js --- app/models/formats/ogr.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/formats/ogr.js b/app/models/formats/ogr.js index 29d0a7c1..ad505a6d 100644 --- a/app/models/formats/ogr.js +++ b/app/models/formats/ogr.js @@ -60,10 +60,10 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback var ogr2ogr = global.settings.ogr2ogrCommand || 'ogr2ogr'; var dbhost = dbopts.host; - var dbport = dbopts.port; - var dbuser = dbopts.user; + var dbport = dbopts.port; + var dbuser = dbopts.user; var dbpass = dbopts.pass; - var dbname = dbopts.dbname; + var dbname = dbopts.dbname; var that = this; @@ -72,7 +72,7 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback var pg; // Drop ending semicolon (ogr doens't like it) - sql = sql.replace(/;\s*$/, ''); + sql = sql.replace(/;\s*$/, ''); step ( @@ -162,7 +162,7 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback } if (options.cmd_params){ - ogrargs.concat(options.cmd_params); + ogrargs = ogrargs.concat(options.cmd_params); } ogrargs.push('-nln', out_layername); @@ -318,7 +318,7 @@ ExportRequest.prototype.sendFile = function (err, filename, callback) { }) .on('error', function(e) { console.log("Can't send response: " + e); - that.ostream.end(); + that.ostream.end(); callback(); }); } else {