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

Merge branch 'main' into main

parents 29dfef7f cf875435
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -13,13 +13,12 @@ import Sidebar from "../presentational/Sidebar.jsx";
 * @component
 * @component
 */
 */
export default function GeoStacApp(props) {
export default function GeoStacApp(props) {
  let [targetPlanet, setTargetPlanet] = React.useState(props.mapList.systems[4].bodies[0]);


  let [targetPlanet, setTargetPlanet] = React.useState(props.mapList.systems[4].bodies[0]);
  // make sure its a stac item for appending stuff
  // make sure its a stac item for appending stuff
  let [queryAddress, setQueryAddress] = React.useState(
  let [queryAddress, setQueryAddress] = React.useState(
    props.mapList.systems[4].bodies[0].collections[0].links.find(link => link.rel === "items").href + "?");
    props.mapList.systems[4].bodies[0].collections[0].links.find(link => link.rel === "items").href + "?");



  /**
  /**
   * Handles target body selection
   * Handles target body selection
   * @param {*} value selection event
   * @param {*} value selection event
+2 −9
Original line number Original line Diff line number Diff line
@@ -126,22 +126,15 @@ export default function FootprintResults(props) {
          myFilter = "&limit=" + step;
          myFilter = "&limit=" + step;
        }
        }


        // check for both API's
        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;

          
        }
        }
        else
        else {
        {
          let itemsUrl = collection.links.find(link => link.rel === "items").href;
          let itemsUrl = collection.links.find(link => link.rel === "items").href;
          collectionUrls[collection.id] = itemsUrl + pageInfo;
          collectionUrls[collection.id] = itemsUrl + pageInfo;
          
          
        }
        }

      }
      }


      (async () => {
      (async () => {
+5 −2
Original line number Original line Diff line number Diff line
@@ -200,8 +200,11 @@ export default L.Map.AstroMap = L.Map.extend({


  // show thumbnail on map when clicked - use stac-layer for this?
  // show thumbnail on map when clicked - use stac-layer for this?
  handleClick: function(e) {
  handleClick: function(e) {
    //const url_to_stac_item = e.layer.feature.links[0].href;
    console.log(e)
    //console.log (url_to_stac_item);
    if(!e) {
      let url_to_stac_item = e.layer.feature.links[0].href;
      console.log (url_to_stac_item);  
    }
    // fetch(url_to_stac_item).then(res => res.json()).then(async feature => {
    // fetch(url_to_stac_item).then(res => res.json()).then(async feature => {
    //   const thumbnail = await L.stacLayer(feature, {displayPreview: true});
    //   const thumbnail = await L.stacLayer(feature, {displayPreview: true});
    //   thumbnail.on("click", e => {
    //   thumbnail.on("click", e => {
+13 −15
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@ export default async function Initialize(){
    const stacApiCollections = 
    const stacApiCollections = 
        "https://stac.astrogeology.usgs.gov/api/collections";
        "https://stac.astrogeology.usgs.gov/api/collections";


    const pygeoApiCollections = 
    const vectorApiCollections = 
        "https://astrogeology.usgs.gov/pygeoapi/collections";
        "https://astrogeology.usgs.gov/pygeoapi/collections";


    // Async tracking
    // Async tracking
@@ -38,10 +38,10 @@ export default async function Initialize(){
    jsonPromise[stacApiCollections] = "Not Started";
    jsonPromise[stacApiCollections] = "Not Started";
    mapsJson[stacApiCollections] = [];
    mapsJson[stacApiCollections] = [];


    fetchStatus[pygeoApiCollections] = "Not Started";
    fetchStatus[vectorApiCollections] = "Not Started";
    fetchPromise[pygeoApiCollections] = "Not Started";
    fetchPromise[vectorApiCollections] = "Not Started";
    jsonPromise[pygeoApiCollections] = "Not Started";
    jsonPromise[vectorApiCollections] = "Not Started";
    mapsJson[pygeoApiCollections] = [];
    mapsJson[vectorApiCollections] = [];


    // Fetch JSON and read into object
    // Fetch JSON and read into object
    async function ensureFetched(targetUrl) {
    async function ensureFetched(targetUrl) {
@@ -65,7 +65,7 @@ export default async function Initialize(){
    }
    }


    // Combine data from Astro Web Maps and STAC API into one new object
    // Combine data from Astro Web Maps and STAC API into one new object
    function organizeData(astroWebMaps, stacApiCollections, pygeoApiCollections) {
    function organizeData(astroWebMaps, stacApiCollections, vectorApiCollections) {
        
        
        // Initialize Objects
        // Initialize Objects
        let mapList = { "systems" : [] };
        let mapList = { "systems" : [] };
@@ -115,11 +115,9 @@ export default async function Initialize(){
                            myCollections.push(collection);
                            myCollections.push(collection);
                        }
                        }
                    }
                    }
                    for (const pycollection of pygeoApiCollections.collections){
                    for (const pycollection of vectorApiCollections.collections){

                        // view the collection as GEOJSON
                        // view the collection as GEOJSON
                        let target_name = pycollection.id.split('/')[0];
                        let target_name = pycollection.id.split('/')[0];

                        if (target.name == target_name.toUpperCase()) {
                        if (target.name == target_name.toUpperCase()) {
                            pycollection.links[9].href = "https://astrogeology.usgs.gov/pygeoapi" + pycollection.links[9].href;
                            pycollection.links[9].href = "https://astrogeology.usgs.gov/pygeoapi" + pycollection.links[9].href;
                            myCollections.push(pycollection); 
                            myCollections.push(pycollection); 
@@ -218,14 +216,14 @@ export default async function Initialize(){
        // Start fetching from AWM and STAC API concurrently
        // Start fetching from AWM and STAC API concurrently
        ensureFetched(astroWebMaps);
        ensureFetched(astroWebMaps);
        ensureFetched(stacApiCollections);
        ensureFetched(stacApiCollections);
        ensureFetched(pygeoApiCollections);
        ensureFetched(vectorApiCollections);


        // Wait for both to complete before moving on
        // Wait for both to complete before moving on
        await ensureFetched(astroWebMaps);
        await ensureFetched(astroWebMaps);
        await ensureFetched(stacApiCollections);
        await ensureFetched(stacApiCollections);
        await ensureFetched(pygeoApiCollections);
        await ensureFetched(vectorApiCollections);


        return organizeData(mapsJson[astroWebMaps], mapsJson[stacApiCollections], mapsJson[pygeoApiCollections]);
        return organizeData(mapsJson[astroWebMaps], mapsJson[stacApiCollections], mapsJson[vectorApiCollections]);
    }
    }


    aggregateMapList = await getStacAndAstroWebMapsData();
    aggregateMapList = await getStacAndAstroWebMapsData();