Skip to content

Commit fc50594

Browse files
authored
Merge pull request #3358 from Vizzuality/feature/https
https fetches for layers and requests
2 parents 4035253 + 5d520b7 commit fc50594

File tree

87 files changed

+209
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+209
-196
lines changed

.env.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ RACK_ENV=development
22
GFW_API_HOST_NEW_API=https://staging-api.globalforestwatch.org/v1
33
GFW_API_HOST_PROD=https://production-api.globalforestwatch.org/v1
44
GFW_API_AUTH=https://production-api.globalforestwatch.org
5-
GFW_API_HOST=http://api.globalforestwatch.org/
5+
GFW_API_HOST=https://api.globalforestwatch.org/
66
AWS_HOST=/uploads
77
LAYER_SPEC=layerspec
88
TERMS_COOKIE=true

app/assets/javascripts/abstract/layer/CartoDBLayerClass.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ define([
4949
}]
5050
};
5151

52-
cartodb.createLayer(this.map, cartodbOptions)
52+
cartodb.createLayer(this.map, cartodbOptions, { https: true })
5353
.on('done',
5454
_.bind(function(layer) {
5555
this.cdbLayer = layer;

app/assets/javascripts/cartodbGFW.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -20978,8 +20978,8 @@ if(!window.JSON) {
2097820978

2097920979
cdb.config = new Config();
2098020980
cdb.config.set({
20981-
cartodb_attributions: "CartoDB <a href='http://cartodb.com/attributions' target='_blank'>attribution</a>",
20982-
cartodb_logo_link: "http://www.cartodb.com"
20981+
cartodb_attributions: "CartoDB <a href='http://carto.com/attributions' target='_blank'>attribution</a>",
20982+
cartodb_logo_link: "http://www.carto.com"
2098320983
});
2098420984

2098520985
})();
@@ -21916,10 +21916,10 @@ cdb.geo.CartoDBLayer = cdb.geo.MapLayer.extend({
2191621916
interactivity: null,
2191721917
interaction: true,
2191821918
debug: false,
21919-
tiler_domain: "cartodb.com",
21919+
tiler_domain: "carto.com",
2192021920
tiler_port: "80",
2192121921
tiler_protocol: "http",
21922-
sql_api_domain: "cartodb.com",
21922+
sql_api_domain: "carto.com",
2192321923
sql_api_port: "80",
2192421924
sql_api_protocol: "http",
2192521925
extra_params: {},
@@ -28119,9 +28119,9 @@ LayerDefinition.prototype = _.extend({}, Map.prototype, {
2811928119
var domain = attrs.sql_api_domain + (port ? ':' + port: '')
2812028120
var protocol = attrs.sql_api_protocol;
2812128121
var version = 'v1';
28122-
if (domain.indexOf('cartodb.com') !== -1) {
28122+
if (domain.indexOf('carto.com') !== -1) {
2812328123
//protocol = 'http';
28124-
domain = "cartodb.com";
28124+
domain = "carto.com";
2812528125
version = 'v2';
2812628126
}
2812728127

@@ -28820,10 +28820,10 @@ L.CartoDBGroupLayerBase = L.TileLayer.extend({
2882028820
debug: false,
2882128821
visible: true,
2882228822
added: false,
28823-
tiler_domain: "cartodb.com",
28823+
tiler_domain: "carto.com",
2882428824
tiler_port: "80",
2882528825
tiler_protocol: "http",
28826-
sql_api_domain: "cartodb.com",
28826+
sql_api_domain: "carto.com",
2882728827
sql_api_port: "80",
2882828828
sql_api_protocol: "http",
2882928829
maxZoom: 30, // default leaflet zoom level for a layers is 18, raise it
@@ -29998,10 +29998,10 @@ var default_options = {
2999829998
debug: false,
2999929999
visible: true,
3000030000
added: false,
30001-
tiler_domain: "cartodb.com",
30001+
tiler_domain: "carto.com",
3000230002
tiler_port: "80",
3000330003
tiler_protocol: "http",
30004-
sql_api_domain: "cartodb.com",
30004+
sql_api_domain: "carto.com",
3000530005
sql_api_port: "80",
3000630006
sql_api_protocol: "http",
3000730007
extra_params: {
@@ -32776,9 +32776,9 @@ var Vis = cdb.core.View.extend({
3277632776
var domain = attrs.sql_api_domain + (port ? ':' + port: '')
3277732777
var protocol = attrs.sql_api_protocol;
3277832778
var version = 'v1';
32779-
if (domain.indexOf('cartodb.com') !== -1) {
32779+
if (domain.indexOf('carto.com') !== -1) {
3278032780
protocol = 'http';
32781-
domain = "cartodb.com";
32781+
domain = "carto.com";
3278232782
version = 'v2';
3278332783
}
3278432784

@@ -33773,7 +33773,7 @@ Layers.register('namedmap', function(vis, data) {
3377333773
Layers.register('torque', function(vis, data) {
3377433774
// default is https
3377533775
if(vis.https) {
33776-
if(data.sql_api_domain && data.sql_api_domain.indexOf('cartodb.com') !== -1) {
33776+
if(data.sql_api_domain && data.sql_api_domain.indexOf('carto.com') !== -1) {
3377733777
data.sql_api_protocol = 'https';
3377833778
data.sql_api_port = 443;
3377933779
data.tiler_protocol = 'https';
@@ -33812,7 +33812,7 @@ Layers.register('torque', function(vis, data) {
3381233812
* compose cartodb url
3381333813
*/
3381433814
function cartodbUrl(opts) {
33815-
var host = opts.host || 'cartodb.com';
33815+
var host = opts.host || 'carto.com';
3381633816
var protocol = opts.protocol || 'https';
3381733817
return protocol + '://' + opts.user + '.' + host + '/api/v1/viz/' + opts.table + '/viz.json';
3381833818
}
@@ -34045,7 +34045,7 @@ Layers.register('torque', function(vis, data) {
3404534045
if(opts && opts.completeDomain) {
3404634046
return opts.completeDomain + '/api/' + opts.version + '/sql'
3404734047
} else {
34048-
var host = opts.host || 'cartodb.com';
34048+
var host = opts.host || 'carto.com';
3404934049
var protocol = opts.protocol || 'https';
3405034050

3405134051
return protocol + '://' + opts.user + '.' + host + '/api/' + opts.version + '/sql';

app/assets/javascripts/countries/views/CountryHeaderView.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ define([
2424
var threshold = (this.helper.config.canopy_choice) ? this.helper.config.canopy_choice : 30;
2525
var layers = {
2626
'forest2000': {
27-
url: 'http://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_' + threshold + '_2014/%z/%x/%y.png',
27+
url: 'https://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_' + threshold + '_2014/%z/%x/%y.png',
2828
dataMaxZoom: 12,
2929
tileSize: [256, 256],
3030
_filterCanvasImage: function(imageData, w, h) {

app/assets/javascripts/countries/views/CountryListView.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ define([
8282
'WHERE c.iso = m.adm0_a3',
8383
"AND c.iso = 'TWN'&format=topojson"].join(' ');
8484

85-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, _.bind(function(error, topology) {
85+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, _.bind(function(error, topology) {
8686
for (var i = 0; i < Object.keys(topology.objects).length; i++) {
8787
var iso = topology.objects[i].properties.iso;
8888

@@ -91,7 +91,7 @@ define([
9191
if (iso === 'CHN') {
9292
that.bounds = bounds;
9393

94-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql_, _.bind(function(error, topology) {
94+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql_, _.bind(function(error, topology) {
9595
this.helper.draw(topology, 0, 'CHN', { alerts: false, bounds: that.bounds});
9696
}, this ));
9797
}

app/assets/javascripts/countries/views/CountryOverviewView.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ define([
235235
$('.countries_list ul').html('');
236236
$('.show-more-countries').show();
237237
}
238-
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
238+
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
239239
var self = that,
240240
markup_list = '';
241241

@@ -324,7 +324,7 @@ define([
324324
sql += ' LIMIT 10 ';
325325
}
326326

327-
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), function(json) {
327+
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), function(json) {
328328
var self = that,
329329
markup_list = '';
330330

@@ -400,7 +400,7 @@ define([
400400
sql += ' LIMIT 10 ';
401401
}
402402

403-
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), function(json) {
403+
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), function(json) {
404404
var self = that,
405405
markup_list = '';
406406

@@ -469,7 +469,7 @@ define([
469469
sql += ' LIMIT 10 ';
470470
}
471471

472-
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
472+
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
473473
var self = that,
474474
markup_list = '';
475475

@@ -509,7 +509,7 @@ define([
509509
} else if (this.model.get('graph') === 'domains') {
510510
$('.countries_list__header__minioverview').show();
511511
var sql = "SELECT ecozone as name, sum(loss) as total_loss, SUM(gain)/COUNT(gain) as total_gain FROM umd_eco_2014 where thresh = "+ (this.helper.config.canopy_choice || 30) +" and ecozone !='Water' and ecozone != 'Polar' group by ecozone";
512-
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
512+
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
513513
var self = that,
514514
markup_list = '';
515515
var data = json.rows;
@@ -566,7 +566,7 @@ define([
566566

567567
if (this.model.get('graph') === ('total_loss')) {
568568
var sql = 'SELECT iso, year, Sum(loss) loss, Sum(gain)/COUNT(gain) gain FROM umd_nat_staging WHERE iso = \''+ iso +'\' AND thresh = '+ (this.helper.config.canopy_choice || 30) +' AND year > 2000 AND year < 2017 GROUP BY iso, year ORDER BY year';
569-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
569+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
570570
var data = json.rows;
571571

572572
var data_ = data,
@@ -595,7 +595,7 @@ define([
595595
WHERE thresh = '+ (this.helper.config.canopy_choice || 30) +' \
596596
AND iso = \''+ iso +'\'';
597597

598-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
598+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
599599
var data = json.rows;
600600

601601
var data_ = data;
@@ -627,7 +627,7 @@ define([
627627
AND iso = \''+ iso +'\' \
628628
AND year > 2000 AND year < 2015';
629629

630-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
630+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
631631

632632
var graph2 = d3.select('.countries_list__minioverview_'+iso)
633633
.append('div')
@@ -822,7 +822,7 @@ define([
822822
if (!!mode && mode.mode == 'percent') {
823823
sql = 'SELECT year, Sum(loss) / Sum(extent_2000) loss FROM umd_nat_staging WHERE thresh = '+ (this.helper.config.canopy_choice || 30) +' AND year > 2000 AND year < 2017 GROUP BY year ORDER BY year ';
824824
}
825-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), _.bind(function(error, json) {
825+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), _.bind(function(error, json) {
826826
var data = json.rows;
827827

828828
var data_ = data;
@@ -897,7 +897,7 @@ define([
897897
query = 'WITH g AS (SELECT gain, extent_2000, land, country, iso FROM umd_nat_staging WHERE year = 2001 AND thresh = ' + (this.helper.config.canopy_choice || 30) + ' AND gain IS NOT NULL) SELECT ROUND(sum(gain)/sum(extent_2000) * 100, 2) as sum FROM g WHERE NOT extent_2000 = 0 ';
898898
}
899899
$.ajax({
900-
url: 'https://wri-01.cartodb.com/api/v2/sql?q=' + query,
900+
url: 'https://wri-01.carto.com/api/v2/sql?q=' + query,
901901
dataType: 'json',
902902
success: _.bind(function(data) {
903903
var gain = data.rows[0].sum;
@@ -920,7 +920,7 @@ define([
920920
query = 'SELECT sum(extent_perc)/count(extent_perc) as sum from umd_nat_staging WHERE thresh = ' + (this.helper.config.canopy_choice || 30) +'';
921921
}
922922
$.ajax({
923-
url: 'https://wri-01.cartodb.com/api/v2/sql?q=' + query,
923+
url: 'https://wri-01.carto.com/api/v2/sql?q=' + query,
924924
dataType: 'json',
925925
success: _.bind(function(data) {
926926
var extent = data.rows[0].sum;
@@ -1016,7 +1016,7 @@ define([
10161016
AND e.iso = u.iso \
10171017
ORDER BY u.sum_loss DESC limit 50 ';
10181018

1019-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
1019+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
10201020
var data = json.rows;
10211021

10221022
var log_m = 50;
@@ -1181,7 +1181,7 @@ define([
11811181
} else if (this.model.get('graph') === 'domains') {
11821182
this._showYears();
11831183
var sql = "SELECT ecozone as name, sum(loss), year FROM umd_eco_2014 where thresh = " + (this.helper.config.canopy_choice || 30) + " and ecozone !='Water' and ecozone != 'Polar' group by name, year";
1184-
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
1184+
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
11851185
var data = _.groupBy(_.sortBy(json.rows, function(row){ return row.year}), function(row){
11861186
return row.name;
11871187
});

app/assets/javascripts/countries/views/CountryShowView.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ define([
155155
'WHERE iso = \'' + this.country.get('iso') + '\''
156156
].join(' ');
157157

158-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+ sql, function(json) {
158+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+ sql, function(json) {
159159
var data = json.rows[0];
160160
var tenures = [{
161161
name: 'Public lands administered by the government',
@@ -199,7 +199,7 @@ define([
199199
'FROM gfw2_countries',
200200
"WHERE iso = '" + this.country.get('iso') + "'"].join(' ');
201201

202-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q=' + sql, function(json) {
202+
d3.json('https://wri-01.carto.com/api/v2/sql?q=' + sql, function(json) {
203203
var data = _.pluck(json.rows, 'percent'),
204204
sumData = _.reduce(data, function(memo, num){ return memo + num; }, 0),
205205
$countryForestType = $('.country-forests-type');
@@ -363,7 +363,7 @@ define([
363363
"GROUP BY date_trunc('month', date)",
364364
"ORDER BY date_trunc('month', date) ASC"].join(' ');
365365

366-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
366+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
367367
if (json && json.rows.length > 0) {
368368
var data = json.rows.slice(1, json.rows.length);
369369
if (data.length == 0) data = json.rows;

app/assets/javascripts/embed_countries.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ gfw.ui.view.CountriesEmbedOverview = cdb.core.View.extend({
216216
FROM countries_gain) as gain\
217217
FROM loss_gt_0';
218218

219-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(error, json) {
219+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(error, json) {
220220
var data = json.rows[0];
221221

222222
var data_ = [],
@@ -396,7 +396,7 @@ gfw.ui.view.CountriesEmbedOverview = cdb.core.View.extend({
396396
FROM countries_gain) as gain\
397397
FROM loss, extent';
398398

399-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
399+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
400400
var data = json.rows[0];
401401

402402
var data_ = [],
@@ -579,7 +579,7 @@ gfw.ui.view.CountriesEmbedOverview = cdb.core.View.extend({
579579
FROM loss_gt_25 loss, extent_gt_25 extent\
580580
WHERE loss.iso = extent.iso';
581581

582-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
582+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
583583
var data = json.rows[0];
584584

585585
var data_ = [],
@@ -789,7 +789,7 @@ gfw.ui.view.CountriesEmbedOverview = cdb.core.View.extend({
789789
WHERE ratio IS NOT null\
790790
ORDER BY ratio DESC';
791791

792-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
792+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
793793
var data = json.rows;
794794

795795
var log_m = 50;
@@ -964,7 +964,7 @@ gfw.ui.view.CountriesEmbedOverview = cdb.core.View.extend({
964964
sql += 'y2012) as max\
965965
FROM countries_domains';
966966

967-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(error, json) {
967+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(error, json) {
968968
var data = json.rows;
969969

970970
var r_scale = d3.scale.linear()
@@ -1267,7 +1267,7 @@ gfw.ui.view.CountriesEmbedShow = cdb.core.View.extend({
12671267
"ORDER BY date_trunc('month', date) ASC"].join(' ');
12681268

12691269
if (type === 'lines') {
1270-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
1270+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
12711271
if(json && json.rows.length > 0) {
12721272
$graph.removeClass('ghost');
12731273
$action.removeClass('disabled');
@@ -1347,7 +1347,7 @@ gfw.ui.view.CountriesEmbedShow = cdb.core.View.extend({
13471347
sql += "year, extent_gt_25 extent FROM umd WHERE iso='"+options.iso+"'";
13481348
}
13491349

1350-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
1350+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
13511351
if(json) {
13521352
$graph.removeClass('ghost');
13531353

@@ -1409,7 +1409,7 @@ gfw.ui.view.CountriesEmbedShow = cdb.core.View.extend({
14091409
} else if (type === 'comp') {
14101410
var sql = "SELECT iso, sum(umd.loss_gt_0) loss, max(umd.gain) gain FROM umd WHERE iso='"+options.iso+"' GROUP BY iso";
14111411

1412-
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
1412+
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), function(json) {
14131413
if(json) {
14141414
$graph.removeClass('ghost');
14151415

app/assets/javascripts/helpers/geojsonUtilsHelper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ define([
9393
// changed function to calculate areas in cartodb instead of using the google library
9494

9595
// var area;
96-
// var theurl="http://wri-01.cartodb.com/api/v2/sql";
96+
// var theurl="https://wri-01.carto.com/api/v2/sql";
9797
// var thequery="select st_area(st_geomfromgeojson('"+JSON.stringify(geojson)+"')::geography)/10000 as area_ha";
9898
// $.ajax({
9999
// url: theurl,

app/assets/javascripts/map/collections/CountryCollection.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ define([
55
'use strict';
66

77
var CountryCollection = Backbone.Collection.extend({
8-
9-
url: 'https://wri-01.cartodb.com/api/v2/sql?q=SELECT c.iso, c.name FROM gfw2_countries c WHERE c.enabled = true ORDER BY c.name',
10-
8+
9+
url: 'https://wri-01.carto.com/api/v2/sql?q=SELECT c.iso, c.name FROM gfw2_countries c WHERE c.enabled = true ORDER BY c.name',
10+
1111
parse: function(response) {
1212
return response.rows
1313
}

app/assets/javascripts/map/services/CartoDbLayerDateService.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ define([
66
'use strict';
77

88
var REQUEST_ID = 'CartoDbLayerDateService:fetchLayerDates';
9-
var URL = 'https://wri-01.cartodb.com/api/v2/sql{?q}';
9+
var URL = 'https://wri-01.carto.com/api/v2/sql{?q}';
1010

1111
var CartoDbLayerDateService = Class.extend({
1212

0 commit comments

Comments
 (0)