diff --git a/src/components/presentational/Sidebar.jsx b/src/components/presentational/Sidebar.jsx index ea9a031dca3850ed1f64a4f139d0443f3c3d445c..ce383edb67ec061f450b95e5435fedd7c4d398d3 100644 --- a/src/components/presentational/Sidebar.jsx +++ b/src/components/presentational/Sidebar.jsx @@ -48,7 +48,6 @@ export default function Sidebar(props) { // Callback function to update selected title const updateAvailableQueriables = (queriables) => { - console.log(queriables); setAvailableQueriables(queriables); }; diff --git a/src/js/AstroMap.js b/src/js/AstroMap.js index a05cf8b9eb8506f0340b3d82bd8e64a421c5a3c5..ca320aa80a8ec5d037ecef969063d8782d3035e8 100644 --- a/src/js/AstroMap.js +++ b/src/js/AstroMap.js @@ -173,8 +173,12 @@ export default L.Map.AstroMap = L.Map.extend({ for(const feature of myFeatures) { // Check if feature or feature.geometry is null or undefined - if(!feature || !feature.geometry){ - console.warn("Invalid feature or missing geometry: ", feature); + if(!feature){ + console.log("Invalid/Null Feature", feature); + continue; + } + else if(!feature.geometry){ + console.log("Feature with missing geometry", feature) continue; } diff --git a/src/js/FootprintFetcher.js b/src/js/FootprintFetcher.js index 47acf86452f5d22023c698ef74af91b30a9bb442..728205a2886761f6499da8b0b04dea5e6e425154 100644 --- a/src/js/FootprintFetcher.js +++ b/src/js/FootprintFetcher.js @@ -17,19 +17,21 @@ export async function FetchObjects(objInfo) { // For each url given for(const key in objInfo) { - // Fetch JSON from url and read into object - fetchPromise[key] = fetch( - objInfo[key] - ).then((res)=>{ - jsonPromise[key] = res.json().then((jsonData)=>{ - jsonRes[key] = jsonData; - }).catch((err)=>{ + // The stylesheet ones \/ get 404s so I'm discarding them for now + if (!key.includes(": stylesheet")){ + fetchPromise[key] = fetch( + objInfo[key] + ).then((res) => { + jsonPromise[key] = res.json().then((jsonData) => { + jsonRes[key] = jsonData; + }).catch((err) => { + console.log(err); + }); + }).catch((err) => { console.log(err); }); - }).catch((err) => { - console.log(err); - }); + } } // Wait for each query to complete @@ -50,86 +52,35 @@ export async function FetchObjects(objInfo) { * @param {string} queryString - The query to narrow the results returned from the collection. */ export async function FetchFootprints(collection, page, step){ - let collectionUrl; - let offsetMulitiplier; + const stacDefaultLimit = 10; + const pyDefaultLimit = 25; + let baseURL = collection.url; let pageInfo = ""; + + // get rid of default limit present in some pygeoapi urls + if(baseURL.slice(-9) == "&limit=10") { + baseURL = baseURL.slice(0, -9); + } + if(collection.url.slice(-1) !== "?") { pageInfo += "&" } - pageInfo += "page=" + page; - if (step != 10){ - pageInfo += "&limit=" + step; - } - // check for pyGeo API - if (!collection.url.includes('stac')) + if (collection.url.includes('stac')) { - - // set offset for 5 & 10 steps - offsetMulitiplier = (page * 10 - step); - pageInfo = "&offset=" + offsetMulitiplier; - - - // checks for 5 change in step - if (step <= 10) - { - - // splice limit and change to new limit - collectionUrl = collection.url.split('&limit=')[0]; - collection.url = collectionUrl; - - - // update page pageInfo - pageInfo = "&offset=" + offsetMulitiplier + "&limit=" + step; - - + pageInfo += "page=" + page; + if (step !== stacDefaultLimit) { + pageInfo += "&limit=" + step; } - // checks for 50 & 100 step - else if (step == 50 || step == 100) - { - - // splice limit and change to new limit - collectionUrl = collection.url.split('&limit=')[0]; - collection.url = collectionUrl; - - // check for first page - if (page == 1) - { - // set multiplier to 0 - offsetMulitiplier = 0; - } - // check for second page - else if (page == 2) - { - // set multiplier to step - offsetMulitiplier = step; - - } - else - { - // check for 50 and set pages according - if (step == 50) - { - offsetMulitiplier = page * step - 50; - } - // check for 100 and set pages according - else - { - offsetMulitiplier = page * step - 100; - } - } - - // update page pageInfo - pageInfo = "&offset=" + offsetMulitiplier + "&limit=" + step; + } + else { + pageInfo += "offset=" + step * (page - 1); + if (step !== pyDefaultLimit) { + pageInfo += "&limit=" + step; } - - } - - // reset offset - offsetMulitiplier = 0; - let jsonRes = await FetchObjects(collection.url + pageInfo); + let jsonRes = await FetchObjects(baseURL + pageInfo); return jsonRes.features; }