Skip to content

Commit 42bd840

Browse files
committed
remove hard-coded clipping service url; instead, load from config like with tileserver
1 parent 81a06ab commit 42bd840

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

clipping-service/app/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
'origins': [
3030
# Only use localhost for local development.
3131
# 'http://localhost:*',
32+
# 'https://localhost:*',
3233
# 'http://127.0.0.1:*',
3334
'https://data-staging.naturalcapitalproject.org',
3435
'https://data.naturalcapitalproject.stanford.edu',

src/ckanext-mappreview/ckanext/mappreview/assets/js/mappreview.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ ckan.module("mappreview", function ($, _) {
149149

150150
const config = JSON.parse(this.options.config.replace(/'/g, '"'));
151151
const globalConfig = this._getGlobalConfig();
152+
const clipping_service_url = this._getGlobalConfig().clipping_service_url;
152153

153154
mapboxgl.accessToken = globalConfig.mapbox_api_key;
154155
const map = new mapboxgl.Map({
@@ -862,7 +863,6 @@ ckan.module("mappreview", function ($, _) {
862863
clipping_options['target_cellsize'] = [target_pixel_size, -target_pixel_size];
863864
}
864865

865-
const clipping_service_url = 'https://clipping-service-897938321824.us-west1.run.app';
866866
fetch(`${clipping_service_url}/clip`, {
867867
method: "POST",
868868
body: JSON.stringify(clipping_options),
@@ -940,12 +940,9 @@ ckan.module("mappreview", function ($, _) {
940940
document.getElementById('natcap-clip-submit-button').innerHTML = submit_text;
941941
});
942942

943-
const clipping_endpoint = 'https://clipping-service-897938321824.us-west1.run.app'
944-
945-
946943
function _setEPSGItems(epsg_code) {
947944
console.log(`Updating SRS info for ${epsg_code}`);
948-
fetch(`${clipping_endpoint}/epsg_info?epsg_code=${epsg_code}`, {
945+
fetch(`${clipping_service_url}/epsg_info?epsg_code=${epsg_code}`, {
949946
method: "GET",
950947
}).then(epsg_response => {
951948
if (epsg_response.ok) {
@@ -981,7 +978,7 @@ ckan.module("mappreview", function ($, _) {
981978
console.log('updating source raster from cog ' + cog);
982979

983980
var epsg_input = document.getElementById('natcapClipSettingEPSGCode');
984-
var cog_stats_url = `${clipping_endpoint}/info?cog_url=${encodeURIComponent(cog)}`;;
981+
var cog_stats_url = `${clipping_service_url}/info?cog_url=${encodeURIComponent(cog)}`;
985982
fetch(cog_stats_url).then(response => {
986983
if (response.ok) {
987984
return response.json();

0 commit comments

Comments
 (0)