diff --git a/curve_number_generator/metadata.txt b/curve_number_generator/metadata.txt
index 3a40ca1..ffafbb5 100644
--- a/curve_number_generator/metadata.txt
+++ b/curve_number_generator/metadata.txt
@@ -6,7 +6,7 @@
name=Curve Number Generator
qgisMinimumVersion=3.18
description=Curve Number Generator plugin has multiple algorithms to generate the curve number layer for any area of interest using different datasets.
-version=2.1.2
+version=2.1.3
author=Abdul Raheem Siddiqui
email=ars.work.ce@gmail.com
@@ -21,7 +21,9 @@ repository=https://github.com/ar-siddiqui/curve_number_generator
hasProcessingProvider=yes
# Uncomment the following line and add your changelog:
-changelog= Version 2.1.2 - 2023-05-24
+changelog= Version 2.1.3 - 2023-10-17
+ - Change NLCD Land Cover and Impervious layer to 2021 dataset
+ Version 2.1.2 - 2023-05-24
- conus_nlcd_ssurgo: Fix missing data on corners of a rectangle AOI
Version 2.1.1 - 2023-03-19
- Fix custom algorithm formula
diff --git a/curve_number_generator/processing/algorithms/conus_nlcd_ssurgo/conus_nlcd_ssurgo.py b/curve_number_generator/processing/algorithms/conus_nlcd_ssurgo/conus_nlcd_ssurgo.py
index 742b26e..9eb69ce 100644
--- a/curve_number_generator/processing/algorithms/conus_nlcd_ssurgo/conus_nlcd_ssurgo.py
+++ b/curve_number_generator/processing/algorithms/conus_nlcd_ssurgo/conus_nlcd_ssurgo.py
@@ -41,6 +41,7 @@
getExtent,
getExtentArea,
reprojectLayer,
+ getAndUpdateMessage,
)
from qgis.core import (
QgsCoordinateReferenceSystem,
@@ -181,13 +182,13 @@ def processAlgorithm(self, parameters, context, model_feedback):
# NLCD Impervious Raster
if parameters.get("NLCDImpervious", None):
outputs["DownloadNlcdImp"] = downloadFile(
- CONUS_NLCD_SSURGO["NLCD_IMP_2019"].format(
+ CONUS_NLCD_SSURGO["NLCD_IMP_2021"].format(
epsg_code,
bbox_dim[0],
bbox_dim[1],
",".join([str(item) for item in extent]),
),
- "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Impervious_L48/ows",
+ "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2021_Impervious_L48/ows",
"Error requesting land use data from 'www.mrlc.gov'. Most probably because either their server is down or there is a certification issue.\nThis should be temporary. Try again later.\n",
context=context,
feedback=feedback,
@@ -225,13 +226,13 @@ def processAlgorithm(self, parameters, context, model_feedback):
# NLCD Land Cover Data
if any([parameters.get("NLCDLandCover", None), parameters.get("CurveNumber", None)]):
outputs["DownloadNlcdLC"] = downloadFile(
- CONUS_NLCD_SSURGO["NLCD_LC_2019"].format(
+ CONUS_NLCD_SSURGO["NLCD_LC_2021"].format(
epsg_code,
bbox_dim[0],
bbox_dim[1],
",".join([str(item) for item in extent]),
),
- "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/ows",
+ "https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2021_Land_Cover_L48/ows",
"Error requesting land use data from 'www.mrlc.gov'. Most probably because either their server is down or there is a certification issue.\nThis should be temporary. Try again later.\n",
context=context,
feedback=feedback,
@@ -452,7 +453,13 @@ def icon(self):
return icon
def shortHelpString(self):
- return f"""
Video Tutorial
+ msg = ""
+ try:
+ msg = getAndUpdateMessage()
+ except Exception as e:
+ print(e)
+
+ return msg + f"""Video Tutorial
Algorithm description
This algorithm generates Curve Number layer for the given Area of Interest within the contiguous United States. It can also download Soil, Land Cover, and Impervious Surface datasets for the same area.
Input parameters
@@ -468,9 +475,9 @@ def shortHelpString(self):
If checked the algorithm will assume HSG A/B/C for each dual category soil.
Outputs
NLCD Land Cover
-NLCD 2019 Land Cover Raster
+NLCD 2021 Land Cover Raster
NLCD Impervious Surface
-NLCD 2019 Impervious Surface Raster
+NLCD 2021 Impervious Surface Raster
Soils
SSURGO Extended Soil Dataset
Curve Number
diff --git a/curve_number_generator/processing/algorithms/custom/custom.py b/curve_number_generator/processing/algorithms/custom/custom.py
index 2e7c2b0..83cf7ff 100644
--- a/curve_number_generator/processing/algorithms/custom/custom.py
+++ b/curve_number_generator/processing/algorithms/custom/custom.py
@@ -31,7 +31,7 @@
from curve_number_generator.processing.config import PLUGIN_VERSION
from curve_number_generator.processing.curve_number_generator_algorithm import CurveNumberGeneratorAlgorithm
from curve_number_generator.processing.tools.curve_numper import CurveNumber
-from curve_number_generator.processing.tools.utils import clip, fixGeometries, gdalPolygonize
+from curve_number_generator.processing.tools.utils import clip, fixGeometries, gdalPolygonize, getAndUpdateMessage
from qgis.core import (
QgsProcessing,
QgsProcessingMultiStepFeedback,
@@ -195,7 +195,12 @@ def icon(self):
return icon
def shortHelpString(self):
- return f"""Video Tutorial
+ try:
+ msg = getAndUpdateMessage()
+ except Exception as e:
+ print(e)
+
+ return msg + f"""Video Tutorial
Algorithm description
This algorithm generates Curve Number layer for the given Area of Interest given a Land Cover Raster, Soil Layer, and a Lookup Table.
Input parameters
diff --git a/curve_number_generator/processing/config.py b/curve_number_generator/processing/config.py
index eb43820..537068e 100644
--- a/curve_number_generator/processing/config.py
+++ b/curve_number_generator/processing/config.py
@@ -1,5 +1,5 @@
# Constants
-PLUGIN_VERSION = "2.1.2"
+PLUGIN_VERSION = "2.1.3"
REGISTRATION_FORM_LINK = (
"https://docs.google.com/forms/d/e/1FAIpQLSe-X-OR6tFvULP6oiiPK3M49-v07sjtxTu8md9XAuBOwxk7Xg/formResponse"
@@ -16,11 +16,13 @@
CONUS_NLCD_SSURGO = {
# urls
- "NLCD_IMP_2019": "https://www.mrlc.gov/geoserver/ows?version=1.1.0&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&FORMAT=GeoTIFF&COVERAGE=mrlc_download:NLCD_2019_Impervious_L48&CRS={}&WIDTH={}&HEIGHT={}&BBOX={}&",
- "NLCD_LC_2019": "https://www.mrlc.gov/geoserver/ows?version=1.1.0&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&FORMAT=GeoTIFF&COVERAGE=mrlc_download:NLCD_2019_Land_Cover_L48&CRS={}&WIDTH={}&HEIGHT={}&BBOX={}&",
+ "NLCD_IMP_2021": "https://www.mrlc.gov/geoserver/ows?version=1.1.0&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&FORMAT=GeoTIFF&COVERAGE=mrlc_download:NLCD_2021_Impervious_L48&CRS={}&WIDTH={}&HEIGHT={}&BBOX={}&",
+ "NLCD_LC_2021": "https://www.mrlc.gov/geoserver/ows?version=1.1.0&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&FORMAT=GeoTIFF&COVERAGE=mrlc_download:NLCD_2021_Land_Cover_L48&CRS={}&WIDTH={}&HEIGHT={}&BBOX={}&",
"SSURGO_Soil": "https://sdmdataaccess.sc.egov.usda.gov/Spatial/SDMWGS84GEOGRAPHIC.wfs?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=mapunitpolyextended&SRSNAME=EPSG:4326&BBOX={}",
}
+MESSAGE_URL = "https://gist.githubusercontent.com/ar-siddiqui/2260461cfd0107150840ab6fb4f83516/raw"
+
LIST_OF_COUNTRIES = [
"",
"Afghanistan",
diff --git a/curve_number_generator/processing/curve_number_generator_algorithm.py b/curve_number_generator/processing/curve_number_generator_algorithm.py
index 81f8ab0..34a5336 100644
--- a/curve_number_generator/processing/curve_number_generator_algorithm.py
+++ b/curve_number_generator/processing/curve_number_generator_algorithm.py
@@ -43,7 +43,6 @@
cmd_folder = os.path.split(inspect.getfile(inspect.currentframe()))[0]
sys.path.append(cmd_folder)
qgis_settings_path = QgsApplication.qgisSettingsDirPath().replace("\\", "/")
-cn_log_path = os.path.join(qgis_settings_path, "curve_number_generator.log")
__author__ = "Abdul Raheem Siddiqui"
__date__ = "2022-06-29"
diff --git a/curve_number_generator/processing/tools/utils.py b/curve_number_generator/processing/tools/utils.py
index 6f3dafd..3dca09a 100644
--- a/curve_number_generator/processing/tools/utils.py
+++ b/curve_number_generator/processing/tools/utils.py
@@ -1,10 +1,12 @@
import os
import pickle
+import requests
+import time
import xml.etree.ElementTree as ET
import processing
import requests
-from curve_number_generator.processing.config import PLUGIN_VERSION, PROFILE_DICT
+from curve_number_generator.processing.config import PLUGIN_VERSION, PROFILE_DICT, MESSAGE_URL
from qgis.core import (
Qgis,
QgsApplication,
@@ -21,7 +23,41 @@
qgis_settings_path = QgsApplication.qgisSettingsDirPath().replace("\\", "/")
cn_log_path = os.path.join(qgis_settings_path, "curve_number_generator.log")
cn_pickle_path = os.path.join(qgis_settings_path, "curve_number_generator.p")
-
+cn_msg_path = os.path.join(qgis_settings_path, 'curve_number_generator_msg.html')
+cn_msg_cache_duration = 24 * 60 * 60 # 24 hours in seconds
+
+def fetchMessage(url, timeout=2) -> str:
+ response = requests.get(url, timeout=timeout)
+ response.raise_for_status()
+ return response.text
+
+
+def saveToCache(message):
+ with open(cn_msg_path, 'w') as file:
+ file.write(message)
+
+def isCacheValid():
+ if os.path.exists(cn_msg_path):
+ file_timestamp = os.path.getmtime(cn_msg_path)
+ if time.time() - file_timestamp < cn_msg_cache_duration:
+ return True
+ return False
+
+def loadMessageFromCache():
+ if isCacheValid():
+ with open(cn_msg_path, 'r') as file:
+ text = file.read()
+ return text
+ return ""
+
+def getAndUpdateMessage():
+ cached_message = loadMessageFromCache()
+ if cached_message:
+ return cached_message
+
+ fetched_message = fetchMessage(MESSAGE_URL)
+ saveToCache(fetched_message)
+ return fetched_message
def incrementUsageCounter() -> int:
# log usage