def setupAdaguc(displayLogging=True): # Check if environment is specified if not os.getenv('ADAGUC_PATH'): print("ADAGUC_PATH not set") exit(1) if not os.getenv('ADAGUC_DATASET_DIR'): print("ADAGUC_DATASET_DIR not set") exit(1) if not os.getenv('ADAGUC_DATA_DIR'): print("ADAGUC_DATA_DIR not set") exit(1) if not os.getenv('ADAGUC_AUTOWMS_DIR'): print("ADAGUC_AUTOWMS_DIR not set") exit(1) # Get the location of the binaries adagucServerHome = os.getenv('ADAGUC_PATH') + '/' if adagucServerHome is None or len(adagucServerHome) < 1: print( 'Your ADAGUC_PATH environment variable is not set! It should point to the adaguc-server folder.' ) exit(1) # Get the location of the adaguc-server configuration file adagucServerConfig = os.getenv( 'ADAGUC_CONFIG', adagucServerHome + "/python/lib/adaguc/adaguc-server-config-python-postgres.xml") if adagucServerConfig is None or len(adagucServerConfig) < 1: print( 'Your ADAGUC_CONFIG environment variable is not set! It should point to a adaguc-server config file.' ) exit(1) if displayLogging == True: logger.info("Using config file %s" % adagucServerConfig) adagucInstance = runAdaguc() adagucInstance.setAdagucPath(adagucServerHome) adagucInstance.setConfiguration(adagucServerConfig) return adagucInstance
from adaguc.runAdaguc import runAdaguc adagucInstance = runAdaguc() import os adagucServerHome = os.getenv('ADAGUC_PATH', os.getcwd() + "/../../../../") adagucInstance.setAdagucPath(adagucServerHome) adagucInstance.setConfiguration( adagucServerHome + "/python/lib/adaguc/adaguc-server-config-python.xml") adagucInstance.setDatasetDir(adagucServerHome + "/python/examples/rundataset/config") adagucInstance.setDataDir(adagucServerHome + "/python/examples/rundataset/data") adagucInstance.setTmpDir(adagucServerHome + "/python/examples/rundataset/") # Scan the dataset: logfile = adagucInstance.scanDataset("exampledataset") print(logfile) # Do the GetMap request url = "dataset=exampledataset&&service=WMS&request=getmap&format=image/png32&layers=interpolatedObs,filledcountries,countryborders,provinces&width=461&CRS=EPSG%3A28992&BBOX=8687.5,286500,291312.5,663500&STYLES=monthlytemperaturenormals%2Fnearestcontour,filledcountries,countryborders&EXCEPTIONS=INIMAGE&showlegend=true&time=2019-07-01T00:00:00Z&title=Langjarig%20gemiddelde%201991-2020&subtitle=Gemiddelde%20maandtemperatuur%20juli&SHOWNORTHARROW=true&showscalebar=true" #url = "dataset=exampledataset&&service=WMS&request=getmap&format=image/png32&layers=interpolatedObs&width=461&CRS=EPSG%3A28992&BBOX=8687.5,286500,291312.5,663500&STYLES=monthlytemperaturenormals%2Fnearestcontour,filledcountries,countryborders&EXCEPTIONS=INIMAGE&showlegend=true&time=2019-01-01T00:00:00Z&title=Langjarig%20gemiddelde%201991-2020&subtitle=Gemiddelde%20maandtemperatuur%20juli&SHOWNORTHARROW=true&showscalebar=true" img, logfile = adagucInstance.runGetMapUrl(url) print(logfile) if img is not None: img.show()