Commit e042fd04 authored by BrittainJackson7's avatar BrittainJackson7
Browse files

Update offset to be scaleable

parent 5e26bf4c
Loading
Loading
Loading
Loading
+4 −58
Original line number Diff line number Diff line
@@ -64,65 +64,11 @@ export async function FetchFootprints(collection, page, step){
    // check for pyGeo API
    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;
            
            
        }
        // 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;
        }
        offsetMulitiplier = (page - 1) * step;

        collection.url = `${collectionUrl}&offset=${offsetMulitiplier}&limit=${step}`;
    }
    
    // reset offset