Commit 776ac91e authored by zksx's avatar zksx
Browse files

added some stuff for styling

parent 16df93f7
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -119,6 +119,8 @@ export default function FootprintResults(props) {
      }

      let collectionUrls = {};
      let styleSheetUrls = [];

      for (const collection of props.target.collections) {
        
        
@@ -133,15 +135,37 @@ export default function FootprintResults(props) {
          // change filter for the pygeo api
          myFilter = "&limit=" + step;
        }
        let styleSheet;
        const foundStyleSheet = collection.links.find(link=> link.rel == "stylesheet");

        if(foundStyleSheet) {
          styleSheet = foundStyleSheet.href;
          styleSheetUrls[collection.id] = styleSheet;
          console.log("Found Style Sheet");
        }

        if(isInStacAPI || isInPyAPI) {
          let itemsUrl = collection.links.find(link => link.rel === "items").href;
          collectionUrls[collection.id] = itemsUrl + myFilter + pageInfo;

          let style_url = null;
          for (let index = 0; index < collection.links.length; index++) {
            if (collection.links[index].rel === "stylesheet") {
              style_url = collection.links[index].href
            }
          }
          collectionUrls[collection.id + ": stylesheet"] = style_url;

          // if (collection.links.find(link => link.rel === "stylesheet").href != undefined) {
          //   let styleUrl = collection.links.find(link => link.rel === "stylesheet").href;
          //   collectionUrls[collection.id].style = styleUrl;
          // }

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

@@ -153,6 +177,7 @@ export default function FootprintResults(props) {
          collections[key].id = key;
          collections[key].title = props.target.collections.find(collection => collection.id === key).title;
          collections[key].url = collectionUrls[key];
          collections[key].styleSheets = styleSheetUrls[key];
        }

        // Updates collectionId if switching to a new set of collections (new target)
+16 −15
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@ import L from "leaflet";
import "proj4leaflet";
import AstroProj from "./AstroProj";
import LayerCollection from "./LayerCollection";
import SLDText from "../slds/Global_Geology.sld";
import FecthData from "./FetchData";
import { data } from "autoprefixer";


/**
@@ -58,8 +59,7 @@ export default L.Map.AstroMap = L.Map.extend({
    // Set by layer collection or baselayerchange event
    this._currentLayer = null;

    this.SLDStyler = new L.SLDStyler(SLDText);

    this.SLDStyler = new L.SLDStyler();

    // Store layers at map creation so we only need to create layers once.
    let cylLayerInfo = this.parseJSON("cylindrical");
@@ -302,26 +302,27 @@ export default L.Map.AstroMap = L.Map.extend({

        let title = featureCollections[i].title;

        let sld_file =  featureCollections[i].styleSheets;
        // set style if available

        let myStyle = null;

        // Add each _geoLayer that has footprints to the FootprintCollection object.
        // The collection title is used as the property name
        // [old] and it shows up as the layer title when added to the separate Leaflet control
        if(featureCollections[i].features.length > 0) {

          let found_stylesheet = false;
          let sld_file = null;
          // set style if available
          for (let j = 0; j < featureCollections[i].links.length; j++) {
            if (featureCollections[i].links[j].rel == "stylesheet") {
              found_stylesheet = true;
              sld_file = fetch(featureCollections[i].links[j].href);
              this.SLDStyler = new L.SLDStyler(sld_file);
            }
          }

          let myStyle = null;

          if (found_stylesheet) {
          if (sld_file) {
            let sldtext = fetch(sld_file);
            let res = sldtext.res

            console.log("good style wow");
            this.SLDStyler = new L.SLDStyler(sldtext);

            myStyle = this.SLDStyler.getStyleFunction();

          }
          else{
            // Set colors if available
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ export default async function Initialize(){
                        // 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;
                            pycollection.links.find(link => link.rel === "items").href = "https://astrogeology.usgs.gov/pygeoapi" + pycollection.links.find(link => link.rel === "items").href;
                            // Add a specification to the title in order to show what kind of data the user is requesting
                            pycollection.title = pycollection.title.concat(" (Vector)");
                            myCollections.push(pycollection);