Commit 23da3532 authored by ausvat's avatar ausvat
Browse files

Merge branch 'main' of github.com:ausvat/asc-geostac-forked

parents a8ba7590 f84bbb93
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -13,13 +13,12 @@ import Sidebar from "../presentational/Sidebar.jsx";
 * @component
 */
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
  let [queryAddress, setQueryAddress] = React.useState(
    props.mapList.systems[4].bodies[0].collections[0].links.find(link => link.rel === "items").href + "?");


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

        // check for both API's
        if(isInStacAPI || isInPyAPI)
        {
        if(isInStacAPI) {
          let itemsUrl = collection.links.find(link => link.rel === "items").href;

          collectionUrls[collection.id] = itemsUrl + myFilter + pageInfo;

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

      }

      (async () => {
+5 −2
Original line number 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?
  handleClick: function(e) {
    //const url_to_stac_item = e.layer.feature.links[0].href;
    //console.log (url_to_stac_item);
    console.log(e)
    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 => {
    //   const thumbnail = await L.stacLayer(feature, {displayPreview: true});
    //   thumbnail.on("click", e => {
+13 −15
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ export default async function Initialize(){
    const stacApiCollections = 
        "https://stac.astrogeology.usgs.gov/api/collections";

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

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

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

    // Fetch JSON and read into object
    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
    function organizeData(astroWebMaps, stacApiCollections, pygeoApiCollections) {
    function organizeData(astroWebMaps, stacApiCollections, vectorApiCollections) {
        
        // Initialize Objects
        let mapList = { "systems" : [] };
@@ -115,11 +115,9 @@ export default async function Initialize(){
                            myCollections.push(collection);
                        }
                    }
                    for (const pycollection of pygeoApiCollections.collections){

                    for (const pycollection of vectorApiCollections.collections){
                        // view the collection as GEOJSON
                        let target_name = pycollection.id.split('/')[0];

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

        // Wait for both to complete before moving on
        await ensureFetched(astroWebMaps);
        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();