Commit 63a1bc25 authored by Kaitlyn's avatar Kaitlyn
Browse files

Reverted changes.

parent cde3c51b
Loading
Loading
Loading
Loading
+12 −42
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ export default L.LayerCollection = L.Class.extend({
    this._overlays = {};
    this._defaultLayerIndex = 0;
    this._wfsLayer = null;
    this._wfsJSON = null;
    L.LayerCollection.layerControl = null;

    let layers = this.parseJSON();
@@ -51,7 +50,6 @@ export default L.LayerCollection = L.Class.extend({
      let currentTarget = targets[i];

      if (currentTarget["name"].toLowerCase() == this._target.toLowerCase()) {
        this._targetJSON = currentTarget["webmap"];
        let jsonLayers = currentTarget["webmap"];
        for (let j = 0; j < jsonLayers.length; j++) {
          let currentLayer = jsonLayers[j];
@@ -75,7 +73,6 @@ export default L.LayerCollection = L.Class.extend({
            }
          } else {
            layers["wfs"].push(currentLayer);
            this._wfsJSON = currentLayer;
          }
        }
      }
@@ -126,8 +123,8 @@ export default L.LayerCollection = L.Class.extend({

    this._wfsLayer = new L.GeoJSON(null, {
      onEachFeature: function(feature, layer) {
        if (feature.properties && feature.properties.clean_feature) {
          layer.bindPopup(feature.properties.clean_feature);
        if (feature.properties && feature.properties.name) {
          layer.bindPopup(feature.properties.name);
        }
      },
      pointToLayer: function(feature, latlng) {
@@ -185,25 +182,24 @@ export default L.LayerCollection = L.Class.extend({
   * @param  {AstroMap} map - The AstroMap to add the GeoJSON layer to.
   */
  loadWFS: function(map) {
    let geoJsonUrl = "https://wms.wr.usgs.gov/cgi-bin/mapserv";
    let geoJsonUrl =
      "https://astrocloud.wr.usgs.gov/dataset/data/nomenclature/" +
      map.target().toUpperCase() +
      "/WFS";

    let defaultParameters = {
      map: this._wfsJSON["map"],
      service: "WFS",
      version: "1.1.0",
      request: "GetFeature",
      typename: map.target().toUpperCase() + "_POLY",
      outputFormat: "application/json; subtype=geojson",
      PropertyName: "clean_feature",
      Filter:
        "<Filter><PropertyIsLike wildcard='*' singleChar='.' escape='!'><PropertyName>clean_feature</PropertyName><Literal>*</Literal></PropertyIsLike></Filter>"
      outputFormat: "application/json",
      srsName: "EPSG:4326"
    };

    // let customParams = {
    //   bbox: map.getBounds().toBBoxString()
    // };
    let customParams = {
      bbox: map.getBounds().toBBoxString()
    };

    let parameters = L.Util.extend(defaultParameters);
    let parameters = L.Util.extend(defaultParameters, customParams);
    console.log(geoJsonUrl + L.Util.getParamString(parameters));

    let thisContext = this;
@@ -211,33 +207,7 @@ export default L.LayerCollection = L.Class.extend({
      url: geoJsonUrl + L.Util.getParamString(parameters),
      dataType: "json",
      timeout: 30000,

      // MapServer is having problems returning a JSON when requesting polygon features.
      // Adds XML at the end for some reason.
      // error: function(response) {
      //   let lines = response.responseText.split("\n");

      //   // Remove lines in XML format
      //   let numLines = lines.length;
      //   let lineCount = 0;
      //   while (lineCount < numLines) {
      //     if (lines[lineCount].includes("Content-type")) {
      //       break;
      //     }
      //     lineCount++;
      //   }
      //   lines.splice(lineCount, numLines - 1);
      //   let jsonString = lines.join("\n");

      //   let data = $.parseJSON(jsonString);
      //   let sortedFeatures = thisContext.sortFeatures(data["features"]);
      //   data["features"] = sortedFeatures;
      //   thisContext._wfsLayer.clearLayers();
      //   thisContext._wfsLayer.addData(data);
      // },

      success: function(data) {
        console.log("GOT HERE");
        let sortedFeatures = thisContext.sortFeatures(data["features"]);
        data["features"] = sortedFeatures;
        thisContext._wfsLayer.clearLayers();