@boundlessgeo/cloud-core
Advanced tools
Comparing version 0.6.0 to 0.6.1
10
bcis.js
@@ -17,5 +17,4 @@ 'use strict'; | ||
'TRANSPARENT': 'true', | ||
'LAYERS': 'rgb', | ||
'SRS': 'EPSG:3857', | ||
'STYLES': 'transfer(contrast:3;brightness:1.2)' | ||
'LAYERS': 'B1', | ||
'SRS': 'EPSG:3857' | ||
}; | ||
@@ -36,3 +35,3 @@ var query_string = (0, _util.encodeQueryObject)(params); | ||
var d = new Date(feature.properties.datetime); | ||
var title = feature.properties.provider + ' ' + d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2); | ||
var title = 'Landsat 8 ' + d.getFullYear() + '-' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2); | ||
return { | ||
@@ -56,3 +55,4 @@ id: feature.id, | ||
bbox_y1: feature.bbox[3], | ||
category__gn_description: '' + feature.properties.provider, | ||
extent: (0, _util.bboxCoverage)(feature), | ||
category__gn_description: '' + feature.properties.collection, | ||
thumbnail: feature.assets && feature.assets.thumbnail ? feature.assets.thumbnail.href : null, | ||
@@ -59,0 +59,0 @@ layerDef: {}, |
{ | ||
"name": "@boundlessgeo/cloud-core", | ||
"author": "Boundless Spatial Inc.", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "A library for facilitating communication with the Boundless mBSE.", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -16,3 +16,3 @@ 'use strict'; | ||
var d = new Date(item.properties.acquired); | ||
var title = ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2) + '-' + d.getFullYear() + ' ' + d.toLocaleTimeString(); | ||
var title = item.properties.item_type + ' ' + ('0' + (d.getMonth() + 1)).slice(-2) + '-' + ('0' + d.getDate()).slice(-2) + '-' + d.getFullYear() + ' ' + d.toLocaleTimeString(); | ||
return { | ||
@@ -31,3 +31,4 @@ id: item.id, | ||
tile_url: 'https://tiles2.planet.com/data/v1/' + item.properties.item_type + '/' + item.id + '/{z}/{x}/{y}.png', | ||
thumbnail: item._links.thumbnail | ||
thumbnail: item._links.thumbnail, | ||
extent: (0, _util.bboxCoverage)(item) | ||
}; | ||
@@ -34,0 +35,0 @@ } |
27
util.js
@@ -9,2 +9,3 @@ 'use strict'; | ||
exports.getFetchOptions = getFetchOptions; | ||
exports.bboxCoverage = bboxCoverage; | ||
/** Converts an object into a query string. | ||
@@ -58,2 +59,28 @@ * | ||
return fetch_opts; | ||
} | ||
/** | ||
* Create a [minX, minY, maxX, maxY] extent bbox from a geojson polygon | ||
* | ||
* @param {Object} geojson - A geojson polygon | ||
* | ||
* @return {Array} [minX, minY, maxX, maxY] | ||
*/ | ||
function bboxCoverage(geojson) { | ||
var result = [0, 0, 0, 0]; | ||
geojson.geometry.coordinates[0].forEach(function (coord) { | ||
if (result[0] > coord[0]) { | ||
result[0] = coord[0]; | ||
} | ||
if (result[1] > coord[1]) { | ||
result[1] = coord[1]; | ||
} | ||
if (result[2] < coord[0]) { | ||
result[2] = coord[0]; | ||
} | ||
if (result[3] < coord[1]) { | ||
result[3] = coord[1]; | ||
} | ||
}); | ||
return result; | ||
} |
67
wps.js
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.handleFetch = handleFetch; | ||
exports.parseProcesses = parseProcesses; | ||
@@ -58,2 +59,14 @@ exports.getProcesses = getProcesses; | ||
function handleFetch(url, fetch_opts, method) { | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return method ? response[method]() : response; | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}); | ||
} | ||
function parseProcesses(xmlText) { | ||
@@ -98,11 +111,3 @@ var parser = new DOMParser(); | ||
var url = geoServerUrl + '/ows?' + query_string; | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.text(); | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}).then(function (xmlText) { | ||
return handleFetch(url, fetch_opts, 'text').then(function (xmlText) { | ||
return parseProcesses(xmlText); | ||
@@ -287,11 +292,3 @@ }); | ||
var url = geoServerUrl + '/ows?' + query_string; | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.text(); | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}).then(function (xmlText) { | ||
return handleFetch(url, fetch_opts, 'text').then(function (xmlText) { | ||
return parseProcessDescription(xmlText); | ||
@@ -312,13 +309,5 @@ }); | ||
var url = geoServerUrl + '/ows?' + query_string; | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
// return the response promise as various | ||
// data type (binary, text, json) can be used. | ||
return response; | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}); | ||
// return the response promise as various | ||
// data type (binary, text, json) can be used. | ||
return handleFetch(url, fetch_opts); | ||
} | ||
@@ -341,11 +330,3 @@ | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.json(); | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}); | ||
return handleFetch(url, fetch_opts, 'json'); | ||
} | ||
@@ -367,11 +348,3 @@ | ||
return fetch(url, fetch_opts).then(function (response) { | ||
if (response.ok) { | ||
return response.text(); | ||
} else { | ||
return response.text().then(function (text) { | ||
throw new Error(response.statusText + ': ' + text); | ||
}); | ||
} | ||
}); | ||
return handleFetch(url, fetch_opts, 'text'); | ||
} |
29
61904
1555