Loading app/Miniconda3.sh 0 → 100644 +63.6 MiB File added.No diff preview for this file type. View file app/src/components/presentational/SearchAndFilterInput.jsx +2 −2 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ export default function SearchAndFilterInput() { label="From" value={dateFromVal} onChange={handleDateFromChange} renderInput={(params) => <TextField {...params} />} renderInput={(params) => <TextField id="dateFromID" {...params} />} /> </LocalizationProvider> </div> Loading @@ -288,7 +288,7 @@ export default function SearchAndFilterInput() { label="To" value={dateToVal} onChange={handleDateToChange} renderInput={(params) => <TextField {...params} />} renderInput={(params) => <TextField id="dateToID"{...params} />} /> </LocalizationProvider> </div> Loading app/src/js/ApiJsonCollection.js +33 −26 Original line number Diff line number Diff line function callAPI() { return fetch("https://stac.astrogeology.usgs.gov/api/collections") .then(response => response.json()); return fetch( "https://stac.astrogeology.usgs.gov/api/collections" ).then(response => response.json()); } function getItemCollection(name, page) { function getItemCollection(name, queryString) { var urlArray = []; return callAPI().then(result => { for (let i = 0; i < result.collections.length; i++) { if (result.collections[i].summaries["ssys:targets"] == name.toLowerCase()) { if ( result.collections[i].summaries["ssys:targets"] == name.toLowerCase() ) { let length = result.collections[i].links.length; for (let j = 0; j < length; j++) { let link = result.collections[i].links[j]; if (link.rel == 'items') { if (link.rel == "items") { var url = result.collections[i].links[j].href; // this is temporary until stac.astrogeology is working with pagination url = url.replace("https://stac.astrogeology.usgs.gov/api/collections", "https://jat52qc8c0.execute-api.us-west-2.amazonaws.com/dev/collections"); url = url + "?page=" + page; url = url.replace( "https://stac.astrogeology.usgs.gov/api/collections", "https://jat52qc8c0.execute-api.us-west-2.amazonaws.com/dev/collections" ); url = url + queryString; urlArray.push(url); } } Loading @@ -30,11 +35,13 @@ function getItemCollection(name, page) { promiseArray.push(fetch(urlArray[i])); } return Promise.all(promiseArray).then(function(responses) { return Promise.all(responses.map(function (response) { return Promise.all( responses.map(function(response) { return response.json(); })); }); }) ); }); }); } export { getItemCollection }; No newline at end of file app/src/js/AstroDrawControl.js +106 −5 Original line number Diff line number Diff line import L from "leaflet"; import "leaflet-draw"; import Wkt from "wicket"; /** * @class AstroDrawControl * @aka L.Control.AstroDrawControl Loading Loading @@ -72,6 +71,14 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.wktButton = L.DomUtil.get("wktButton"); L.DomEvent.on(this.wktButton, "click", this.mapWKTString, this); L.DomEvent.on( L.DomUtil.get("applyButton"), "click", this.applyFilter, this ); L.DomEvent.on(L.DomUtil.get("clearButton"), "click", this.clearMap, this); map.on("draw:created", this.shapesToWKT, this); // map.on("projChange", this.reprojectFeature, this); Loading Loading @@ -100,6 +107,104 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ } }, clearMap: function() { this._map._footprintControl.remove(); this._map._geoLayer.clearLayers(); }, /** * @function shapesToFootprint * @description Is called when a user draws a shape using the on map drawing features. * Renders all footprints that intersect the drawn area. * * @param {String} coords - The drawn shape’s coordinates. */ shapesToFootprint: function(coords) { let strArr = coords .slice(coords.indexOf("((") + 2, coords.indexOf("))")) .split(","); let bboxCoordArr = []; for (let i = 0; i < 3; i++) { if (i != 1) { let temp = strArr[i].split(" "); bboxCoordArr.push([parseFloat(temp[0]), parseFloat(temp[1])]); } } // will proballby end up refactoring this a little bit when the front end of // this is up let bboxArr = [ bboxCoordArr[0][0], bboxCoordArr[0][1], bboxCoordArr[1][0], bboxCoordArr[1][1] ]; this._map._footprintControl.remove(); this._map._geoLayer.clearLayers(); this._map.removeControl(this._map._htmllegend); let queryString = "bbox=" + "[" + bboxArr + "]"; return queryString; }, applyFilter: function() { let filterOptions = []; if (L.DomUtil.get("dateCheckBox").checked == true) { let fromDate = L.DomUtil.get("dateFromID").value; let toDate = L.DomUtil.get("dateToID").value; fromDate = fromDate.split("/"); toDate = toDate.split("/"); let newFromDate = ""; newFromDate = newFromDate.concat( fromDate[2], "-", fromDate[0], "-", fromDate[1], "T00:00:00Z" ); let newToDate = ""; newToDate = newToDate.concat( toDate[2], "-", toDate[0], "-", toDate[1], "T23:59:59Z" ); let timeQuery = "".concat("datetime=", newFromDate, "/", newToDate); filterOptions.push(timeQuery); } if (L.DomUtil.get("keywordCheckBox").checked == true) { filterOptions.push(L.DomUtil.get("keywordTextBox").value); } if (L.DomUtil.get("areaCheckBox").checked == true) { console.log("area"); let bboxValue = this.shapesToFootprint(this.wktTextBox.value); filterOptions.push(bboxValue); } let queryString = ""; for (let i = 0; i < filterOptions.length; i++) { if (queryString == "") { queryString = queryString.concat("?", filterOptions[i]); } else { queryString = queryString.concat("&", filterOptions[i]); } } // re render map this._map._footprintControl.remove(); this._map._geoLayer.clearLayers(); this._map.removeControl(this._map._htmllegend); this._map.loadFootprintLayer(this._map._name, queryString); }, /** * @function AstroDrawControl.prototype.mapWKTString * @description Is called when a user clicks the draw button below the AstroMap. Loading Loading @@ -129,8 +234,4 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.myLayer.addData(geojsonFeature); } // reprojectFeature: function(e) { // } }); app/src/js/AstroMap.js +44 −24 Original line number Diff line number Diff line import L from "leaflet"; import "proj4leaflet"; import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; import { getItemCollection, url } from "./ApiJsonCollection"; import { MY_JSON_MAPS } from "./layers"; import "leaflet-html-legend"; import React from "react"; /** * @class AstroMap Loading Loading @@ -48,6 +48,9 @@ export default L.Map.AstroMap = L.Map.extend({ this._footprintCollection = {}; this._footprintControl = null; this._geoLayer = null; this._name = null; this._htmllegend = null; this._currentPage = 1; // Set by layer collection or baselayerchange event this._currentLayer = null; Loading Loading @@ -95,7 +98,7 @@ export default L.Map.AstroMap = L.Map.extend({ L.Map.prototype.initialize.call(this, this._mapDiv, this.options); this.loadLayerCollection("cylindrical"); this.loadFootprintLayer(target, 1); this.loadFootprintLayer(target, "?page=" + this._currentPage); // Listen to baselayerchange event so that we can set the current layer being // viewed by the map. Loading Loading @@ -128,11 +131,15 @@ export default L.Map.AstroMap = L.Map.extend({ * * @param {String} name - Name of the target * * @param {Int} page - current selected page number of the pagination * @param {String} queryString - Filter for deisered footprints ie: ?page=1 * * @param {Boolean} loadFootprintLegend - Boolean value used to bypass adding * the FootprintLegend */ loadFootprintLayer: function(name, page) { getItemCollection(name, page).then(result => { loadFootprintLayer: function(name, queryString, loadFootprintLegend = true) { getItemCollection(name, queryString).then(result => { if (result != undefined) { this._name = name; this._geoLayer = L.geoJSON() .on('click', function(e){ console.log(e); Loading @@ -143,54 +150,67 @@ export default L.Map.AstroMap = L.Map.extend({ this._geoLayer.addData(result[i].features[j]); } } this._footprintControl = L.control.layers(null, this._footprintCollection).addTo(this); this.addFootprintLegend(name, page); this._footprintControl = L.control .layers(null, this._footprintCollection) .addTo(this); if (loadFootprintLegend) { this.addFootprintLegend(name); } } }); }, /** * @function AstroMap.prototype.addFootprintLegend * @description Adds legend for each footprint layer * * @param {String} name - Name of the projection * * @param {Int} page - current selected page number of the pagination */ addFootprintLegend: function(name, page) { addFootprintLegend: function(name) { var self = this; var legend = L.control.htmllegend({ legends: [{ name: 'Footprints', legends: [ { name: "Footprints", layer: this._geoLayer, elements: [{ elements: [ { html: `<div class="pagination"> <a id=footprint_left>«</a> <a id=footprint_pageNumber>${page}</a> <a id=footprint_pageNumber>${self._currentPage}</a> <a id=footprint_right>»</a> </div>` }] }] } ] } ] }); this._htmllegend = legend; this.addControl(legend); $('#footprint_right').click(function () { page = page + 1; $("#footprint_right").click(function() { self._currentPage += 1; self._footprintControl.remove(); self._geoLayer.clearLayers(); self.removeControl(legend); self.loadFootprintLayer(name, page); let queryString = "?page=" + self._currentPage; self.loadFootprintLayer(name, queryString); }); $('#footprint_left').click(function () { page = page - 1; if (page > 0) { $("#footprint_left").click(function() { self._currentPage -= 1; if (this._currentPage > 0) { self._footprintControl.remove(); self._geoLayer.clearLayers(); self.removeControl(legend); self.loadFootprintLayer(name, page); let queryString = "?page=" + self._currentPage; self.loadFootprintLayer(name, queryString); } // should add some error message here eventually }); }, Loading Loading
app/src/components/presentational/SearchAndFilterInput.jsx +2 −2 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ export default function SearchAndFilterInput() { label="From" value={dateFromVal} onChange={handleDateFromChange} renderInput={(params) => <TextField {...params} />} renderInput={(params) => <TextField id="dateFromID" {...params} />} /> </LocalizationProvider> </div> Loading @@ -288,7 +288,7 @@ export default function SearchAndFilterInput() { label="To" value={dateToVal} onChange={handleDateToChange} renderInput={(params) => <TextField {...params} />} renderInput={(params) => <TextField id="dateToID"{...params} />} /> </LocalizationProvider> </div> Loading
app/src/js/ApiJsonCollection.js +33 −26 Original line number Diff line number Diff line function callAPI() { return fetch("https://stac.astrogeology.usgs.gov/api/collections") .then(response => response.json()); return fetch( "https://stac.astrogeology.usgs.gov/api/collections" ).then(response => response.json()); } function getItemCollection(name, page) { function getItemCollection(name, queryString) { var urlArray = []; return callAPI().then(result => { for (let i = 0; i < result.collections.length; i++) { if (result.collections[i].summaries["ssys:targets"] == name.toLowerCase()) { if ( result.collections[i].summaries["ssys:targets"] == name.toLowerCase() ) { let length = result.collections[i].links.length; for (let j = 0; j < length; j++) { let link = result.collections[i].links[j]; if (link.rel == 'items') { if (link.rel == "items") { var url = result.collections[i].links[j].href; // this is temporary until stac.astrogeology is working with pagination url = url.replace("https://stac.astrogeology.usgs.gov/api/collections", "https://jat52qc8c0.execute-api.us-west-2.amazonaws.com/dev/collections"); url = url + "?page=" + page; url = url.replace( "https://stac.astrogeology.usgs.gov/api/collections", "https://jat52qc8c0.execute-api.us-west-2.amazonaws.com/dev/collections" ); url = url + queryString; urlArray.push(url); } } Loading @@ -30,11 +35,13 @@ function getItemCollection(name, page) { promiseArray.push(fetch(urlArray[i])); } return Promise.all(promiseArray).then(function(responses) { return Promise.all(responses.map(function (response) { return Promise.all( responses.map(function(response) { return response.json(); })); }); }) ); }); }); } export { getItemCollection }; No newline at end of file
app/src/js/AstroDrawControl.js +106 −5 Original line number Diff line number Diff line import L from "leaflet"; import "leaflet-draw"; import Wkt from "wicket"; /** * @class AstroDrawControl * @aka L.Control.AstroDrawControl Loading Loading @@ -72,6 +71,14 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.wktButton = L.DomUtil.get("wktButton"); L.DomEvent.on(this.wktButton, "click", this.mapWKTString, this); L.DomEvent.on( L.DomUtil.get("applyButton"), "click", this.applyFilter, this ); L.DomEvent.on(L.DomUtil.get("clearButton"), "click", this.clearMap, this); map.on("draw:created", this.shapesToWKT, this); // map.on("projChange", this.reprojectFeature, this); Loading Loading @@ -100,6 +107,104 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ } }, clearMap: function() { this._map._footprintControl.remove(); this._map._geoLayer.clearLayers(); }, /** * @function shapesToFootprint * @description Is called when a user draws a shape using the on map drawing features. * Renders all footprints that intersect the drawn area. * * @param {String} coords - The drawn shape’s coordinates. */ shapesToFootprint: function(coords) { let strArr = coords .slice(coords.indexOf("((") + 2, coords.indexOf("))")) .split(","); let bboxCoordArr = []; for (let i = 0; i < 3; i++) { if (i != 1) { let temp = strArr[i].split(" "); bboxCoordArr.push([parseFloat(temp[0]), parseFloat(temp[1])]); } } // will proballby end up refactoring this a little bit when the front end of // this is up let bboxArr = [ bboxCoordArr[0][0], bboxCoordArr[0][1], bboxCoordArr[1][0], bboxCoordArr[1][1] ]; this._map._footprintControl.remove(); this._map._geoLayer.clearLayers(); this._map.removeControl(this._map._htmllegend); let queryString = "bbox=" + "[" + bboxArr + "]"; return queryString; }, applyFilter: function() { let filterOptions = []; if (L.DomUtil.get("dateCheckBox").checked == true) { let fromDate = L.DomUtil.get("dateFromID").value; let toDate = L.DomUtil.get("dateToID").value; fromDate = fromDate.split("/"); toDate = toDate.split("/"); let newFromDate = ""; newFromDate = newFromDate.concat( fromDate[2], "-", fromDate[0], "-", fromDate[1], "T00:00:00Z" ); let newToDate = ""; newToDate = newToDate.concat( toDate[2], "-", toDate[0], "-", toDate[1], "T23:59:59Z" ); let timeQuery = "".concat("datetime=", newFromDate, "/", newToDate); filterOptions.push(timeQuery); } if (L.DomUtil.get("keywordCheckBox").checked == true) { filterOptions.push(L.DomUtil.get("keywordTextBox").value); } if (L.DomUtil.get("areaCheckBox").checked == true) { console.log("area"); let bboxValue = this.shapesToFootprint(this.wktTextBox.value); filterOptions.push(bboxValue); } let queryString = ""; for (let i = 0; i < filterOptions.length; i++) { if (queryString == "") { queryString = queryString.concat("?", filterOptions[i]); } else { queryString = queryString.concat("&", filterOptions[i]); } } // re render map this._map._footprintControl.remove(); this._map._geoLayer.clearLayers(); this._map.removeControl(this._map._htmllegend); this._map.loadFootprintLayer(this._map._name, queryString); }, /** * @function AstroDrawControl.prototype.mapWKTString * @description Is called when a user clicks the draw button below the AstroMap. Loading Loading @@ -129,8 +234,4 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.myLayer.addData(geojsonFeature); } // reprojectFeature: function(e) { // } });
app/src/js/AstroMap.js +44 −24 Original line number Diff line number Diff line import L from "leaflet"; import "proj4leaflet"; import AstroProj from "./AstroProj"; import LayerCollection from "./LayerCollection"; import { getItemCollection, url } from "./ApiJsonCollection"; import { MY_JSON_MAPS } from "./layers"; import "leaflet-html-legend"; import React from "react"; /** * @class AstroMap Loading Loading @@ -48,6 +48,9 @@ export default L.Map.AstroMap = L.Map.extend({ this._footprintCollection = {}; this._footprintControl = null; this._geoLayer = null; this._name = null; this._htmllegend = null; this._currentPage = 1; // Set by layer collection or baselayerchange event this._currentLayer = null; Loading Loading @@ -95,7 +98,7 @@ export default L.Map.AstroMap = L.Map.extend({ L.Map.prototype.initialize.call(this, this._mapDiv, this.options); this.loadLayerCollection("cylindrical"); this.loadFootprintLayer(target, 1); this.loadFootprintLayer(target, "?page=" + this._currentPage); // Listen to baselayerchange event so that we can set the current layer being // viewed by the map. Loading Loading @@ -128,11 +131,15 @@ export default L.Map.AstroMap = L.Map.extend({ * * @param {String} name - Name of the target * * @param {Int} page - current selected page number of the pagination * @param {String} queryString - Filter for deisered footprints ie: ?page=1 * * @param {Boolean} loadFootprintLegend - Boolean value used to bypass adding * the FootprintLegend */ loadFootprintLayer: function(name, page) { getItemCollection(name, page).then(result => { loadFootprintLayer: function(name, queryString, loadFootprintLegend = true) { getItemCollection(name, queryString).then(result => { if (result != undefined) { this._name = name; this._geoLayer = L.geoJSON() .on('click', function(e){ console.log(e); Loading @@ -143,54 +150,67 @@ export default L.Map.AstroMap = L.Map.extend({ this._geoLayer.addData(result[i].features[j]); } } this._footprintControl = L.control.layers(null, this._footprintCollection).addTo(this); this.addFootprintLegend(name, page); this._footprintControl = L.control .layers(null, this._footprintCollection) .addTo(this); if (loadFootprintLegend) { this.addFootprintLegend(name); } } }); }, /** * @function AstroMap.prototype.addFootprintLegend * @description Adds legend for each footprint layer * * @param {String} name - Name of the projection * * @param {Int} page - current selected page number of the pagination */ addFootprintLegend: function(name, page) { addFootprintLegend: function(name) { var self = this; var legend = L.control.htmllegend({ legends: [{ name: 'Footprints', legends: [ { name: "Footprints", layer: this._geoLayer, elements: [{ elements: [ { html: `<div class="pagination"> <a id=footprint_left>«</a> <a id=footprint_pageNumber>${page}</a> <a id=footprint_pageNumber>${self._currentPage}</a> <a id=footprint_right>»</a> </div>` }] }] } ] } ] }); this._htmllegend = legend; this.addControl(legend); $('#footprint_right').click(function () { page = page + 1; $("#footprint_right").click(function() { self._currentPage += 1; self._footprintControl.remove(); self._geoLayer.clearLayers(); self.removeControl(legend); self.loadFootprintLayer(name, page); let queryString = "?page=" + self._currentPage; self.loadFootprintLayer(name, queryString); }); $('#footprint_left').click(function () { page = page - 1; if (page > 0) { $("#footprint_left").click(function() { self._currentPage -= 1; if (this._currentPage > 0) { self._footprintControl.remove(); self._geoLayer.clearLayers(); self.removeControl(legend); self.loadFootprintLayer(name, page); let queryString = "?page=" + self._currentPage; self.loadFootprintLayer(name, queryString); } // should add some error message here eventually }); }, Loading