Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https fetches for layers and requests #3358

Merged
merged 4 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ RACK_ENV=development
GFW_API_HOST_NEW_API=https://staging-api.globalforestwatch.org/v1
GFW_API_HOST_PROD=https://production-api.globalforestwatch.org/v1
GFW_API_AUTH=https://production-api.globalforestwatch.org
GFW_API_HOST=http://api.globalforestwatch.org/
GFW_API_HOST=https://api.globalforestwatch.org/
AWS_HOST=/uploads
LAYER_SPEC=layerspec
TERMS_COOKIE=true
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/abstract/layer/CartoDBLayerClass.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
}]
};

cartodb.createLayer(this.map, cartodbOptions)
cartodb.createLayer(this.map, cartodbOptions, { https: true })
.on('done',
_.bind(function(layer) {
this.cdbLayer = layer;
Expand Down
30 changes: 15 additions & 15 deletions app/assets/javascripts/cartodbGFW.js
Original file line number Diff line number Diff line change
Expand Up @@ -20978,8 +20978,8 @@ if(!window.JSON) {

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

})();
Expand Down Expand Up @@ -21916,10 +21916,10 @@ cdb.geo.CartoDBLayer = cdb.geo.MapLayer.extend({
interactivity: null,
interaction: true,
debug: false,
tiler_domain: "cartodb.com",
tiler_domain: "carto.com",
tiler_port: "80",
tiler_protocol: "http",
sql_api_domain: "cartodb.com",
sql_api_domain: "carto.com",
sql_api_port: "80",
sql_api_protocol: "http",
extra_params: {},
Expand Down Expand Up @@ -28119,9 +28119,9 @@ LayerDefinition.prototype = _.extend({}, Map.prototype, {
var domain = attrs.sql_api_domain + (port ? ':' + port: '')
var protocol = attrs.sql_api_protocol;
var version = 'v1';
if (domain.indexOf('cartodb.com') !== -1) {
if (domain.indexOf('carto.com') !== -1) {
//protocol = 'http';
domain = "cartodb.com";
domain = "carto.com";
version = 'v2';
}

Expand Down Expand Up @@ -28820,10 +28820,10 @@ L.CartoDBGroupLayerBase = L.TileLayer.extend({
debug: false,
visible: true,
added: false,
tiler_domain: "cartodb.com",
tiler_domain: "carto.com",
tiler_port: "80",
tiler_protocol: "http",
sql_api_domain: "cartodb.com",
sql_api_domain: "carto.com",
sql_api_port: "80",
sql_api_protocol: "http",
maxZoom: 30, // default leaflet zoom level for a layers is 18, raise it
Expand Down Expand Up @@ -29998,10 +29998,10 @@ var default_options = {
debug: false,
visible: true,
added: false,
tiler_domain: "cartodb.com",
tiler_domain: "carto.com",
tiler_port: "80",
tiler_protocol: "http",
sql_api_domain: "cartodb.com",
sql_api_domain: "carto.com",
sql_api_port: "80",
sql_api_protocol: "http",
extra_params: {
Expand Down Expand Up @@ -32776,9 +32776,9 @@ var Vis = cdb.core.View.extend({
var domain = attrs.sql_api_domain + (port ? ':' + port: '')
var protocol = attrs.sql_api_protocol;
var version = 'v1';
if (domain.indexOf('cartodb.com') !== -1) {
if (domain.indexOf('carto.com') !== -1) {
protocol = 'http';
domain = "cartodb.com";
domain = "carto.com";
version = 'v2';
}

Expand Down Expand Up @@ -33773,7 +33773,7 @@ Layers.register('namedmap', function(vis, data) {
Layers.register('torque', function(vis, data) {
// default is https
if(vis.https) {
if(data.sql_api_domain && data.sql_api_domain.indexOf('cartodb.com') !== -1) {
if(data.sql_api_domain && data.sql_api_domain.indexOf('carto.com') !== -1) {
data.sql_api_protocol = 'https';
data.sql_api_port = 443;
data.tiler_protocol = 'https';
Expand Down Expand Up @@ -33812,7 +33812,7 @@ Layers.register('torque', function(vis, data) {
* compose cartodb url
*/
function cartodbUrl(opts) {
var host = opts.host || 'cartodb.com';
var host = opts.host || 'carto.com';
var protocol = opts.protocol || 'https';
return protocol + '://' + opts.user + '.' + host + '/api/v1/viz/' + opts.table + '/viz.json';
}
Expand Down Expand Up @@ -34045,7 +34045,7 @@ Layers.register('torque', function(vis, data) {
if(opts && opts.completeDomain) {
return opts.completeDomain + '/api/' + opts.version + '/sql'
} else {
var host = opts.host || 'cartodb.com';
var host = opts.host || 'carto.com';
var protocol = opts.protocol || 'https';

return protocol + '://' + opts.user + '.' + host + '/api/' + opts.version + '/sql';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ define([
var threshold = (this.helper.config.canopy_choice) ? this.helper.config.canopy_choice : 30;
var layers = {
'forest2000': {
url: 'http://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_' + threshold + '_2014/%z/%x/%y.png',
url: 'https://earthengine.google.org/static/hansen_2014/gfw_loss_tree_year_' + threshold + '_2014/%z/%x/%y.png',
dataMaxZoom: 12,
tileSize: [256, 256],
_filterCanvasImage: function(imageData, w, h) {
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/countries/views/CountryListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ define([
'WHERE c.iso = m.adm0_a3',
"AND c.iso = 'TWN'&format=topojson"].join(' ');

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

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

d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql_, _.bind(function(error, topology) {
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql_, _.bind(function(error, topology) {
this.helper.draw(topology, 0, 'CHN', { alerts: false, bounds: that.bounds});
}, this ));
}
Expand Down
26 changes: 13 additions & 13 deletions app/assets/javascripts/countries/views/CountryOverviewView.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ define([
$('.countries_list ul').html('');
$('.show-more-countries').show();
}
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
var self = that,
markup_list = '';

Expand Down Expand Up @@ -324,7 +324,7 @@ define([
sql += ' LIMIT 10 ';
}

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

Expand Down Expand Up @@ -400,7 +400,7 @@ define([
sql += ' LIMIT 10 ';
}

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

Expand Down Expand Up @@ -469,7 +469,7 @@ define([
sql += ' LIMIT 10 ';
}

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

Expand Down Expand Up @@ -509,7 +509,7 @@ define([
} else if (this.model.get('graph') === 'domains') {
$('.countries_list__header__minioverview').show();
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";
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
var self = that,
markup_list = '';
var data = json.rows;
Expand Down Expand Up @@ -566,7 +566,7 @@ define([

if (this.model.get('graph') === ('total_loss')) {
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';
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
var data = json.rows;

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

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

var data_ = data;
Expand Down Expand Up @@ -627,7 +627,7 @@ define([
AND iso = \''+ iso +'\' \
AND year > 2000 AND year < 2015';

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

var graph2 = d3.select('.countries_list__minioverview_'+iso)
.append('div')
Expand Down Expand Up @@ -822,7 +822,7 @@ define([
if (!!mode && mode.mode == 'percent') {
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 ';
}
d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+encodeURIComponent(sql), _.bind(function(error, json) {
d3.json('https://wri-01.carto.com/api/v2/sql?q='+encodeURIComponent(sql), _.bind(function(error, json) {
var data = json.rows;

var data_ = data;
Expand Down Expand Up @@ -897,7 +897,7 @@ define([
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 ';
}
$.ajax({
url: 'https://wri-01.cartodb.com/api/v2/sql?q=' + query,
url: 'https://wri-01.carto.com/api/v2/sql?q=' + query,
dataType: 'json',
success: _.bind(function(data) {
var gain = data.rows[0].sum;
Expand All @@ -920,7 +920,7 @@ define([
query = 'SELECT sum(extent_perc)/count(extent_perc) as sum from umd_nat_staging WHERE thresh = ' + (this.helper.config.canopy_choice || 30) +'';
}
$.ajax({
url: 'https://wri-01.cartodb.com/api/v2/sql?q=' + query,
url: 'https://wri-01.carto.com/api/v2/sql?q=' + query,
dataType: 'json',
success: _.bind(function(data) {
var extent = data.rows[0].sum;
Expand Down Expand Up @@ -1016,7 +1016,7 @@ define([
AND e.iso = u.iso \
ORDER BY u.sum_loss DESC limit 50 ';

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

var log_m = 50;
Expand Down Expand Up @@ -1181,7 +1181,7 @@ define([
} else if (this.model.get('graph') === 'domains') {
this._showYears();
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";
d3.json('http://wri-01.cartodb.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
d3.json('https://wri-01.carto.com/api/v2/sql/?q='+encodeURIComponent(sql), _.bind(function(json) {
var data = _.groupBy(_.sortBy(json.rows, function(row){ return row.year}), function(row){
return row.name;
});
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/countries/views/CountryShowView.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ define([
'WHERE iso = \'' + this.country.get('iso') + '\''
].join(' ');

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

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

d3.json('https://wri-01.cartodb.com/api/v2/sql?q='+sql, function(json) {
d3.json('https://wri-01.carto.com/api/v2/sql?q='+sql, function(json) {
if (json && json.rows.length > 0) {
var data = json.rows.slice(1, json.rows.length);
if (data.length == 0) data = json.rows;
Expand Down
16 changes: 8 additions & 8 deletions app/assets/javascripts/embed_countries.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ gfw.ui.view.CountriesEmbedOverview = cdb.core.View.extend({
FROM countries_gain) as gain\
FROM loss_gt_0';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/helpers/geojsonUtilsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ define([
// changed function to calculate areas in cartodb instead of using the google library

// var area;
// var theurl="http://wri-01.cartodb.com/api/v2/sql";
// var theurl="https://wri-01.carto.com/api/v2/sql";
// var thequery="select st_area(st_geomfromgeojson('"+JSON.stringify(geojson)+"')::geography)/10000 as area_ha";
// $.ajax({
// url: theurl,
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/map/collections/CountryCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ define([
'use strict';

var CountryCollection = Backbone.Collection.extend({
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',

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',

parse: function(response) {
return response.rows
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define([
'use strict';

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

var CartoDbLayerDateService = Class.extend({

Expand Down
Loading