Loading app/Miniconda3.sh 0 → 100644 +63.6 MiB File added.No diff preview for this file type. View file app/src/components/container/App.jsx +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ const useStyles = makeStyles(theme => ({ */ export default function App() { const classes = useStyles(); const [targetPlanet, setTargetPlanet] = React.useState("Mercury"); const [targetPlanet, setTargetPlanet] = React.useState("Mars"); /** * Handles target selection 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 @@ -67,6 +66,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 @@ -93,6 +100,104 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.wktTextBox.value = this.wkt.write(); }, 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 @@ -122,8 +227,4 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.myLayer.addData(geojsonFeature); } // reprojectFeature: function(e) { // } }); Loading
app/src/components/container/App.jsx +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ const useStyles = makeStyles(theme => ({ */ export default function App() { const classes = useStyles(); const [targetPlanet, setTargetPlanet] = React.useState("Mercury"); const [targetPlanet, setTargetPlanet] = React.useState("Mars"); /** * Handles target selection 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 @@ -67,6 +66,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 @@ -93,6 +100,104 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.wktTextBox.value = this.wkt.write(); }, 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 @@ -122,8 +227,4 @@ export default L.Control.AstroDrawControl = L.Control.Draw.extend({ this.myLayer.addData(geojsonFeature); } // reprojectFeature: function(e) { // } });