Unverified Commit cfb7d41c authored by brittainjackson7's avatar brittainjackson7 Committed by GitHub
Browse files

Merge pull request #10 from ausvat/main

Adjustments to current and correct version of Elastic Search
parents f25328fd e27b6c17
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ export default function FootprintResults(props) {
    let newPage = numFeatures/step + 1;
    let newPage = numFeatures/step + 1;
    let newFeatures = await FetchFootprints(featureCollections[collectionId], newPage, step);
    let newFeatures = await FetchFootprints(featureCollections[collectionId], newPage, step);
    
    
    // If any features are returned, add them to currecnt collection
    // If any features are returned, add them to current collection
    if (newFeatures.length > 0) {
    if (newFeatures.length > 0) {
      addFeatures(newFeatures, collectionId);
      addFeatures(newFeatures, collectionId);
    }
    }
@@ -126,7 +126,7 @@ export default function FootprintResults(props) {
          myFilter = "&limit=" + step;
          myFilter = "&limit=" + step;
        }
        }


        if(isInStacAPI) {
        if(isInStacAPI || isInPyAPI) {
          let itemsUrl = collection.links.find(link => link.rel === "items").href;
          let itemsUrl = collection.links.find(link => link.rel === "items").href;
          collectionUrls[collection.id] = itemsUrl + myFilter + pageInfo;
          collectionUrls[collection.id] = itemsUrl + myFilter + pageInfo;
        }
        }
+60 −2
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ export async function FetchObjects(objInfo) {
 * @param {string} queryString - The query to narrow the results returned from the collection.
 * @param {string} queryString - The query to narrow the results returned from the collection.
 */
 */
export async function FetchFootprints(collection, page, step){
export async function FetchFootprints(collection, page, step){
    let collectionUrl;
    let offsetMulitiplier;
    let offsetMulitiplier;
    let pageInfo = "";
    let pageInfo = "";
    if(collection.url.slice(-1) !== "?") {
    if(collection.url.slice(-1) !== "?") {
@@ -63,12 +64,69 @@ export async function FetchFootprints(collection, page, step){
    // check for pyGeo API
    // check for pyGeo API
    if (!collection.url.includes('stac')) 
    if (!collection.url.includes('stac')) 
    {
    {
        offsetMulitiplier = (page * 10 - 10);

        // set offset for 5 & 10 steps
        offsetMulitiplier = (page * 10 - step);
        pageInfo = "&offset=" + offsetMulitiplier;
        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;
            
            
        }
        }
        // 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;
                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;
        }
        
    }
    
    // reset offset
    offsetMulitiplier = 0;


    let jsonRes = await FetchObjects(collection.url + pageInfo);
    let jsonRes = await FetchObjects(collection.url + pageInfo);
    return jsonRes.features;
    return jsonRes.features;
+1 −1

File changed.

Contains only whitespace changes.