| 1 | '''
|
|---|
| 2 | Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved.
|
|---|
| 3 |
|
|---|
| 4 | This program is free software: you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation, either version 3 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 16 | '''
|
|---|
| 17 | import celery
|
|---|
| 18 | import flask
|
|---|
| 19 | from flask import render_template, url_for
|
|---|
| 20 | import datetime
|
|---|
| 21 | from flask_mail import Message
|
|---|
| 22 | import os
|
|---|
| 23 | from dateutil.relativedelta import relativedelta
|
|---|
| 24 | import math
|
|---|
| 25 | import xml.etree.ElementTree as ET
|
|---|
| 26 | from subprocess import CalledProcessError
|
|---|
| 27 | import tempfile
|
|---|
| 28 | import shutil
|
|---|
| 29 |
|
|---|
| 30 | from osgeo import ogr
|
|---|
| 31 | from osgeo import osr
|
|---|
| 32 | from osgeo import gdal
|
|---|
| 33 | from osgeo import gdalconst
|
|---|
| 34 | import mercantile
|
|---|
| 35 |
|
|---|
| 36 | from gnuboat.common.datahandler import log_handler as loghandler
|
|---|
| 37 | from gnuboat.common.spatial import tile_generator as tilegenerator
|
|---|
| 38 | from gnuboat.common.spatial.tile_generator import (
|
|---|
| 39 | RasterSlice, LngLatBbox, ZoomRange
|
|---|
| 40 | )
|
|---|
| 41 |
|
|---|
| 42 | from gnuboat.mapservice_impl import mail, celery as celery_app
|
|---|
| 43 | from gnuboat.mapservice_impl.database.model import (
|
|---|
| 44 | User, Log, LogEntry, Water, ProcessingStatus, Queue, db,
|
|---|
| 45 | make_line, make_point
|
|---|
| 46 | )
|
|---|
| 47 | from gnuboat.mapservice_impl.tasks.tile_config import TileConfig
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 | class LogEntryCallback:
|
|---|
| 51 | def __init__(self):
|
|---|
| 52 | self._entries = []
|
|---|
| 53 | self._start = None
|
|---|
| 54 | self._end = None
|
|---|
| 55 |
|
|---|
| 56 | def valid(self):
|
|---|
| 57 | if self._start is None:
|
|---|
| 58 | return False
|
|---|
| 59 | if self._end is None:
|
|---|
| 60 | return False
|
|---|
| 61 | if len(self._entries) < 1:
|
|---|
| 62 | return False
|
|---|
| 63 | return True
|
|---|
| 64 |
|
|---|
| 65 | def start(self):
|
|---|
| 66 | return self._start
|
|---|
| 67 |
|
|---|
| 68 | def end(self):
|
|---|
| 69 | return self._end
|
|---|
| 70 |
|
|---|
| 71 | def entries(self):
|
|---|
| 72 | return self._entries
|
|---|
| 73 |
|
|---|
| 74 | def callback(self, dataset):
|
|---|
| 75 | self._entries.append(dataset)
|
|---|
| 76 |
|
|---|
| 77 | # check / set start and end date
|
|---|
| 78 | entry_datetime = dataset.datetime_object()
|
|---|
| 79 | if self.start() is None or entry_datetime < self.start():
|
|---|
| 80 | self._start = entry_datetime
|
|---|
| 81 | if self.end() is None or self.end() < entry_datetime:
|
|---|
| 82 | self._end = entry_datetime
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | class LogsLocked(Exception):
|
|---|
| 86 | pass
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | class SliceJob(dict):
|
|---|
| 90 | """
|
|---|
| 91 | Summarize all data needed to generate the tiles for a slice
|
|---|
| 92 | and also to cleanup the whole generation chain afterwards
|
|---|
| 93 |
|
|---|
| 94 | tile_slice: The slice, which should be rastered
|
|---|
| 95 | query: query used in the vrt source file
|
|---|
| 96 | log_id: Id of the log, initiating the job (before slicing)
|
|---|
| 97 | envelope: Enlarged envelope of the complete job
|
|---|
| 98 | (TileGenerator.LngLatBbox)
|
|---|
| 99 |
|
|---|
| 100 | It's derived from dict to be json serialisable
|
|---|
| 101 | """
|
|---|
| 102 | def __init__(self, tile_slice, query, log_id, envelope, epsg_code):
|
|---|
| 103 | super(SliceJob, self).__init__({
|
|---|
| 104 | 'tile_slice': tile_slice,
|
|---|
| 105 | 'query': query,
|
|---|
| 106 | 'log_id': log_id,
|
|---|
| 107 | 'envelope': envelope,
|
|---|
| 108 | 'epsg_code': epsg_code
|
|---|
| 109 | })
|
|---|
| 110 |
|
|---|
| 111 | def tile_slice(self):
|
|---|
| 112 | return self['tile_slice']
|
|---|
| 113 |
|
|---|
| 114 | def query(self):
|
|---|
| 115 | return self['query']
|
|---|
| 116 |
|
|---|
| 117 | def log_id(self):
|
|---|
| 118 | return self['log_id']
|
|---|
| 119 |
|
|---|
| 120 | def envelope(self):
|
|---|
| 121 | return self['envelope']
|
|---|
| 122 |
|
|---|
| 123 | def epsg_code(self):
|
|---|
| 124 | return self['epsg_code']
|
|---|
| 125 |
|
|---|
| 126 | def from_dict(dictionary):
|
|---|
| 127 | if dictionary is None:
|
|---|
| 128 | return None
|
|---|
| 129 | return SliceJob(
|
|---|
| 130 | RasterSlice.from_dict(dictionary['tile_slice']),
|
|---|
| 131 | dictionary['query'], dictionary['log_id'],
|
|---|
| 132 | LngLatBbox.from_dict(dictionary['envelope']),
|
|---|
| 133 | dictionary['epsg_code']
|
|---|
| 134 | )
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | # query to get all logentries in the enlarged envelope, younger than age_date
|
|---|
| 138 | def query():
|
|---|
| 139 | return """SELECT {make_point}Z(ST_x(entries.location), ST_y(entries.location),
|
|---|
| 140 | (entries.water_depth +
|
|---|
| 141 | (logs.gauge_height - gauges.reference_water_level_gauge_height)),
|
|---|
| 142 | ST_srid(entries.location))
|
|---|
| 143 | FROM logentries as entries, logs, gauges
|
|---|
| 144 | WHERE entries.log_id=logs.id AND gauges.id=logs.gauge_id
|
|---|
| 145 | AND ST_Within(entries.location, ST_Envelope({make_line}(ST_PointFromText(
|
|---|
| 146 | "POINT({longitude_west} {latitude_south})", {epsg_code}),
|
|---|
| 147 | ST_PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code}))))
|
|---|
| 148 | AND entries.datetime > \"{age_date}\"""".format(make_point=make_point(db.engine),
|
|---|
| 149 | make_line=make_line(db.engine))
|
|---|
| 150 |
|
|---|
| 151 | # query for retrieving processing state of affected logentries
|
|---|
| 152 | def query_select_processing_state():
|
|---|
| 153 | return """SELECT COUNT(id) FROM logs
|
|---|
| 154 | WHERE processing_state={processing_state} AND id IN (
|
|---|
| 155 | SELECT log_id FROM logentries WHERE
|
|---|
| 156 | ST_Within(logentries.location, ST_Envelope({make_line}(ST_PointFromText(
|
|---|
| 157 | "POINT({longitude_west} {latitude_south})", {epsg_code}),
|
|---|
| 158 | ST_PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code}))))
|
|---|
| 159 | AND datetime {age_condition} \"{age_date}\"
|
|---|
| 160 | GROUP BY log_id)""".format(make_line=make_line(db.engine))
|
|---|
| 161 |
|
|---|
| 162 | # query for updateting processing state of all affected logentries
|
|---|
| 163 | def query_update_processing_state():
|
|---|
| 164 | return """UPDATE logs SET
|
|---|
| 165 | processing_state={processing_state}
|
|---|
| 166 | WHERE id IN (
|
|---|
| 167 | SELECT log_id FROM logentries WHERE
|
|---|
| 168 | ST_Within(logentries.location, ST_Envelope({make_line}(ST_PointFromText(
|
|---|
| 169 | "POINT({longitude_west} {latitude_south})", {epsg_code}),
|
|---|
| 170 | ST_PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code}))))
|
|---|
| 171 | AND datetime {age_condition} \"{age_date}\"
|
|---|
| 172 | GROUP BY log_id)""".format(make_line=make_line(db.engine))
|
|---|
| 173 |
|
|---|
| 174 | def query_logs():
|
|---|
| 175 | return """SELECT logentries.log_id, COUNT(logentries.id) as entries
|
|---|
| 176 | FROM logentries
|
|---|
| 177 | WHERE ST_Within(logentries.location, ST_Envelope({make_line}(ST_PointFromText(
|
|---|
| 178 | "POINT({longitude_west} {latitude_south})", {epsg_code}),
|
|---|
| 179 | ST_PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code}))))
|
|---|
| 180 | AND logentries.datetime > \"{age_date}\" GROUP BY log_id""".format(make_line=make_line(db.engine))
|
|---|
| 181 |
|
|---|
| 182 |
|
|---|
| 183 | @celery_app.task
|
|---|
| 184 | def log_process(log_id, log_content):
|
|---|
| 185 | """
|
|---|
| 186 | Chain for processing a new log
|
|---|
| 187 | 1. Parse the log and add it to the datapase (s. log_parse)
|
|---|
| 188 | 2. Generate tiles out of the new and old data (s. log_slice)
|
|---|
| 189 | """
|
|---|
| 190 | chain = log_parse.s(log_id, log_content) | log_slice.s()
|
|---|
| 191 | chain()
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 | @celery_app.task
|
|---|
| 195 | def log_parse(log_id, log_content):
|
|---|
| 196 | """Background task to parse new logs"""
|
|---|
| 197 |
|
|---|
| 198 | log = _log_by_id(log_id)
|
|---|
| 199 | _update_log_state(log_id, 'Parsing')
|
|---|
| 200 |
|
|---|
| 201 | queue = Queue.query.filter_by(log_id=log.id).all()
|
|---|
| 202 | if len(queue) != 1:
|
|---|
| 203 | _mail_error(log_id, 'No queue for log file')
|
|---|
| 204 | _cleanup_error(log_id)
|
|---|
| 205 | raise LookupError('Could not find queue for log {}'.format(log.id))
|
|---|
| 206 | queue = queue[0]
|
|---|
| 207 | queue_date = queue.datetime
|
|---|
| 208 |
|
|---|
| 209 | log_callback = LogEntryCallback()
|
|---|
| 210 | log_handler = loghandler.LogHandler()
|
|---|
| 211 | result = log_handler.gnuboat_read(
|
|---|
| 212 | log_content.splitlines(), log_callback.callback, False, False
|
|---|
| 213 | )
|
|---|
| 214 | if not result.success():
|
|---|
| 215 | _mail_error(log_id, result.errors())
|
|---|
| 216 | _cleanup_error(log_id)
|
|---|
| 217 | raise SyntaxError(
|
|---|
| 218 | 'Could not parse logfile {}: {}'.format(
|
|---|
| 219 | log.id, '\n'.join(result.errors())
|
|---|
| 220 | )
|
|---|
| 221 | )
|
|---|
| 222 | if not log_callback.valid():
|
|---|
| 223 | _mail_error(log_id, 'Log has no entries')
|
|---|
| 224 | _cleanup_error(log_id)
|
|---|
| 225 | raise SyntaxError(
|
|---|
| 226 | 'Could not parse logfile {}: {}'.format(
|
|---|
| 227 | log.id, 'Log has no entries'
|
|---|
| 228 | )
|
|---|
| 229 | )
|
|---|
| 230 |
|
|---|
| 231 | for entry in log_callback.entries():
|
|---|
| 232 | if entry.water_depth() is not None:
|
|---|
| 233 | location = entry.location()
|
|---|
| 234 | log_entry = LogEntry(
|
|---|
| 235 | log=log,
|
|---|
| 236 | datetime=entry.datetime_object(),
|
|---|
| 237 | location='SRID=4326;POINT({} {})'.format(
|
|---|
| 238 | location.longitude, location.latitude
|
|---|
| 239 | ),
|
|---|
| 240 | water_depth=entry.water_depth()
|
|---|
| 241 | )
|
|---|
| 242 | db.session.add(log_entry)
|
|---|
| 243 |
|
|---|
| 244 | # set queue for processing
|
|---|
| 245 | queue.datetime = datetime.datetime.now(datetime.timezone.utc)
|
|---|
| 246 | db.session.add(queue)
|
|---|
| 247 | db.session.commit()
|
|---|
| 248 |
|
|---|
| 249 | # update state and start / end time of the log, gained from log parsing
|
|---|
| 250 | log.start = log_callback.start()
|
|---|
| 251 | log.end = log_callback.end()
|
|---|
| 252 | _update_log_state(log_id, 'Queued for Processing')
|
|---|
| 253 |
|
|---|
| 254 | message = Message(
|
|---|
| 255 | "Parsed log file successfully", recipients=[log.submitter.email]
|
|---|
| 256 | )
|
|---|
| 257 | message.html = render_template(
|
|---|
| 258 | 'log_parsed.html',
|
|---|
| 259 | first_name=log.submitter.first_name,
|
|---|
| 260 | queue_date=queue_date.isoformat('T'),
|
|---|
| 261 | water_link=_water_link(log.water.id),
|
|---|
| 262 | water_name=log.water.name
|
|---|
| 263 | )
|
|---|
| 264 | _mail_send(message)
|
|---|
| 265 |
|
|---|
| 266 | return log_id
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 | @celery_app.task(autoretry_for=(LogsLocked, ), default_retry_delay=1800)
|
|---|
| 270 | def log_slice(log_id):
|
|---|
| 271 | """
|
|---|
| 272 | Background task to process new logs
|
|---|
| 273 | If another job is already processing the same logs, a LogsLocked
|
|---|
| 274 | Exception is raised and an auto retry after 30 minutes is triggered.
|
|---|
| 275 | """
|
|---|
| 276 | try:
|
|---|
| 277 | tiles_config = _get_tile_config()
|
|---|
| 278 | except Exception as error:
|
|---|
| 279 | _update_log_state(log_id, 'Error')
|
|---|
| 280 | raise error
|
|---|
| 281 | try:
|
|---|
| 282 | sqlalchemy_database_uri = _get_database_uri()
|
|---|
| 283 | except Exception as error:
|
|---|
| 284 | _update_log_state(log_id, 'Error')
|
|---|
| 285 | raise error
|
|---|
| 286 |
|
|---|
| 287 | processing_state_processing = _processing_state_get('Processing')
|
|---|
| 288 | processing_state_deployed = _processing_state_get('Deployed')
|
|---|
| 289 | processing_state_to_old = _processing_state_get('To Old')
|
|---|
| 290 | processing_state_error = _processing_state_get('Error')
|
|---|
| 291 |
|
|---|
| 292 | try:
|
|---|
| 293 | _tile_cache_create(tiles_config)
|
|---|
| 294 | except Exception as error:
|
|---|
| 295 | _update_log_state(log_id, 'Error')
|
|---|
| 296 | raise error
|
|---|
| 297 |
|
|---|
| 298 | tilegen = tilegenerator.TileGenerator(
|
|---|
| 299 | tile_sizes=tiles_config.sizes,
|
|---|
| 300 | densities=tiles_config.densities,
|
|---|
| 301 | density_base=tiles_config.densitiy_base
|
|---|
| 302 | )
|
|---|
| 303 |
|
|---|
| 304 | newer_than = datetime.datetime.utcnow() - relativedelta(
|
|---|
| 305 | years=tiles_config.points_age_max
|
|---|
| 306 | )
|
|---|
| 307 |
|
|---|
| 308 | # Extend envelope of source log to the next tile borders
|
|---|
| 309 | connection = ogr.Open(sqlalchemy_database_uri, gdal.GA_ReadOnly)
|
|---|
| 310 | if connection is None:
|
|---|
| 311 | raise ConnectionError('Could not open database connection')
|
|---|
| 312 | envelope = connection.ExecuteSQL(
|
|---|
| 313 | "SELECT envelope FROM logview WHERE id={}".format(log_id)
|
|---|
| 314 | )
|
|---|
| 315 | if envelope is None:
|
|---|
| 316 | raise LookupError('Could query envelope for log {}'.format(log_id))
|
|---|
| 317 | west, east, south, north = envelope.GetExtent()
|
|---|
| 318 | envelope_spatial_ref = envelope.GetSpatialRef()
|
|---|
| 319 | epsg_code = envelope_spatial_ref.GetAuthorityCode(None)
|
|---|
| 320 | input_epsg = "{}:{}".format(
|
|---|
| 321 | envelope_spatial_ref.GetAuthorityName(None), epsg_code
|
|---|
| 322 | )
|
|---|
| 323 | envelope_enlarged = tilegen.fit_extent_to_tiles(
|
|---|
| 324 | tilegenerator.LngLatBbox(west, south, east, north),
|
|---|
| 325 | tiles_config.zoom_range
|
|---|
| 326 | )
|
|---|
| 327 |
|
|---|
| 328 | # Check that none of the affected logs are currently processed by
|
|---|
| 329 | # another job
|
|---|
| 330 | result = db.engine.execute(
|
|---|
| 331 | query_select_processing_state().format(
|
|---|
| 332 | processing_state=processing_state_processing.id,
|
|---|
| 333 | epsg_code=epsg_code,
|
|---|
| 334 | longitude_west=envelope_enlarged.west(),
|
|---|
| 335 | latitude_south=envelope_enlarged.south(),
|
|---|
| 336 | longitude_east=envelope_enlarged.east(),
|
|---|
| 337 | latitude_north=envelope_enlarged.north(),
|
|---|
| 338 | age_condition=">",
|
|---|
| 339 | age_date=newer_than.isoformat('T')
|
|---|
| 340 | )
|
|---|
| 341 | ).first()
|
|---|
| 342 | if result[0] > 0:
|
|---|
| 343 | # there are logs, which are currently processed by another job
|
|---|
| 344 | raise LogsLocked(
|
|---|
| 345 | '{} logs are currently processed by another job'.format(result[0])
|
|---|
| 346 | )
|
|---|
| 347 |
|
|---|
| 348 | # just for informational purpose
|
|---|
| 349 | if flask.current_app.debug:
|
|---|
| 350 | result = db.engine.execute(
|
|---|
| 351 | query_logs().format(
|
|---|
| 352 | processing_state=processing_state_processing.id,
|
|---|
| 353 | epsg_code=epsg_code,
|
|---|
| 354 | longitude_west=envelope_enlarged.west(),
|
|---|
| 355 | latitude_south=envelope_enlarged.south(),
|
|---|
| 356 | longitude_east=envelope_enlarged.east(),
|
|---|
| 357 | latitude_north=envelope_enlarged.north(),
|
|---|
| 358 | age_date=newer_than.isoformat('T')
|
|---|
| 359 | )
|
|---|
| 360 | )
|
|---|
| 361 | count_logentries = 0
|
|---|
| 362 | logs = 0
|
|---|
| 363 | for rows in result:
|
|---|
| 364 | logs += 1
|
|---|
| 365 | count_logentries += rows[1]
|
|---|
| 366 | flask.current_app.logger.info(
|
|---|
| 367 | ('Processing log {}, found {} datasets from {} logs in enlarged '
|
|---|
| 368 | 'envelope younger than {}')
|
|---|
| 369 | .format(log_id, count_logentries, logs, newer_than.isoformat('T'))
|
|---|
| 370 | )
|
|---|
| 371 |
|
|---|
| 372 | # update processing state of logentries, which will be processed
|
|---|
| 373 | db.engine.execute(
|
|---|
| 374 | query_update_processing_state().format(
|
|---|
| 375 | processing_state=processing_state_processing.id,
|
|---|
| 376 | epsg_code=epsg_code,
|
|---|
| 377 | longitude_west=envelope_enlarged.west(),
|
|---|
| 378 | latitude_south=envelope_enlarged.south(),
|
|---|
| 379 | longitude_east=envelope_enlarged.east(),
|
|---|
| 380 | latitude_north=envelope_enlarged.north(),
|
|---|
| 381 | age_condition=">",
|
|---|
| 382 | age_date=newer_than.isoformat('T')
|
|---|
| 383 | )
|
|---|
| 384 | )
|
|---|
| 385 | db.session.commit()
|
|---|
| 386 | # update processing state of logentries, which are to old
|
|---|
| 387 | db.engine.execute(
|
|---|
| 388 | query_update_processing_state().format(
|
|---|
| 389 | processing_state=processing_state_to_old.id,
|
|---|
| 390 | epsg_code=epsg_code,
|
|---|
| 391 | longitude_west=envelope_enlarged.west(),
|
|---|
| 392 | latitude_south=envelope_enlarged.south(),
|
|---|
| 393 | longitude_east=envelope_enlarged.east(),
|
|---|
| 394 | latitude_north=envelope_enlarged.north(),
|
|---|
| 395 | age_condition="<=",
|
|---|
| 396 | age_date=newer_than.isoformat('T')
|
|---|
| 397 | )
|
|---|
| 398 | )
|
|---|
| 399 | db.session.commit()
|
|---|
| 400 |
|
|---|
| 401 | data_query = query().format(
|
|---|
| 402 | epsg_code=epsg_code,
|
|---|
| 403 | longitude_west=envelope_enlarged.west(),
|
|---|
| 404 | latitude_south=envelope_enlarged.south(),
|
|---|
| 405 | longitude_east=envelope_enlarged.east(),
|
|---|
| 406 | latitude_north=envelope_enlarged.north(),
|
|---|
| 407 | age_date=newer_than.isoformat('T')
|
|---|
| 408 | )
|
|---|
| 409 |
|
|---|
| 410 | # create temporary directory
|
|---|
| 411 | try:
|
|---|
| 412 | datasource_file = _datasource_vrt_create(data_query)
|
|---|
| 413 | except Exception as error:
|
|---|
| 414 | flask.current_app.logger.error(
|
|---|
| 415 | ('Could not open the output file for the ogr data '
|
|---|
| 416 | 'source description: {}').format(error)
|
|---|
| 417 | )
|
|---|
| 418 | db.engine.execute(
|
|---|
| 419 | query_update_processing_state().format(
|
|---|
| 420 | processing_state=processing_state_error.id,
|
|---|
| 421 | epsg_code=epsg_code,
|
|---|
| 422 | longitude_west=envelope_enlarged.west(),
|
|---|
| 423 | latitude_south=envelope_enlarged.south(),
|
|---|
| 424 | longitude_east=envelope_enlarged.east(),
|
|---|
| 425 | latitude_north=envelope_enlarged.north(),
|
|---|
| 426 | age_condition=">",
|
|---|
| 427 | age_date=newer_than.isoformat('T')
|
|---|
| 428 | )
|
|---|
| 429 | )
|
|---|
| 430 | db.session.commit()
|
|---|
| 431 | os.remove(datasource_file)
|
|---|
| 432 | raise error
|
|---|
| 433 |
|
|---|
| 434 | slices = tilegen.slices(
|
|---|
| 435 | datasource_file,
|
|---|
| 436 | zoom_range=tiles_config.zoom_range,
|
|---|
| 437 | raster_file_size_max=tiles_config.raster_file_size_max
|
|---|
| 438 | )
|
|---|
| 439 | slice_jobs = []
|
|---|
| 440 | for tile_slice in slices:
|
|---|
| 441 | slice_jobs.append(
|
|---|
| 442 | SliceJob(
|
|---|
| 443 | tile_slice, data_query, log_id, envelope_enlarged, epsg_code
|
|---|
| 444 | )
|
|---|
| 445 | )
|
|---|
| 446 | os.remove(datasource_file)
|
|---|
| 447 |
|
|---|
| 448 | if flask.current_app.debug:
|
|---|
| 449 | flask.current_app.logger.info(
|
|---|
| 450 | 'Created {} tasks to process log {}'.format(
|
|---|
| 451 | len(slice_jobs), log_id
|
|---|
| 452 | )
|
|---|
| 453 | )
|
|---|
| 454 |
|
|---|
| 455 | celery.chord((log_generate_tiles.s(slice_job) for slice_job in slice_jobs),
|
|---|
| 456 | log_cleanup.s()).delay()
|
|---|
| 457 | return True
|
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 | @celery_app.task
|
|---|
| 461 | def log_generate_tiles(slice_job):
|
|---|
| 462 | try:
|
|---|
| 463 | tiles_config = _get_tile_config()
|
|---|
| 464 | except Exception as error:
|
|---|
| 465 | if slice_job.log_id() is not None:
|
|---|
| 466 | _update_log_state(slice_job.log_id(), 'Error')
|
|---|
| 467 | raise error
|
|---|
| 468 | try:
|
|---|
| 469 | sqlalchemy_database_uri = _get_database_uri()
|
|---|
| 470 | except Exception as error:
|
|---|
| 471 | if slice_job.log_id() is not None:
|
|---|
| 472 | _update_log_state(slice_job.log_id(), 'Error')
|
|---|
| 473 | raise error
|
|---|
| 474 |
|
|---|
| 475 | slice_job = SliceJob.from_dict(slice_job)
|
|---|
| 476 |
|
|---|
| 477 | if slice_job.log_id() is not None:
|
|---|
| 478 | processing_state_processing = _processing_state_get('Processing')
|
|---|
| 479 | processing_state_deployed = _processing_state_get('Deployed')
|
|---|
| 480 | processing_state_to_old = _processing_state_get('To Old')
|
|---|
| 481 | processing_state_error = _processing_state_get('Error')
|
|---|
| 482 |
|
|---|
| 483 | # create temporary directory
|
|---|
| 484 | try:
|
|---|
| 485 | datasource_file = _datasource_vrt_create(slice_job.query())
|
|---|
| 486 | except Exception as error:
|
|---|
| 487 | flask.current_app.logger.error(
|
|---|
| 488 | ('Could not open the output file for the ogr data '
|
|---|
| 489 | 'source description: {}').format(error)
|
|---|
| 490 | )
|
|---|
| 491 | os.remove(datasource_file)
|
|---|
| 492 | raise error
|
|---|
| 493 |
|
|---|
| 494 | temp_directory = tempfile.mkdtemp(prefix='gnuboat-tasks')
|
|---|
| 495 |
|
|---|
| 496 | tilegen = tilegenerator.TileGenerator(
|
|---|
| 497 | tile_sizes=tiles_config.sizes,
|
|---|
| 498 | densities=tiles_config.densities,
|
|---|
| 499 | density_base=tiles_config.densitiy_base
|
|---|
| 500 | )
|
|---|
| 501 | try:
|
|---|
| 502 | result_paths = tilegen.run(
|
|---|
| 503 | datasource_file, temp_directory, slice_job.tile_slice()
|
|---|
| 504 | )
|
|---|
| 505 | except CalledProcessError as e:
|
|---|
| 506 | flask.current_app.logger.error(
|
|---|
| 507 | 'Could not generate tiles. {} exited with the error: {}'.format(
|
|---|
| 508 | e.cmd, e.returncode
|
|---|
| 509 | )
|
|---|
| 510 | )
|
|---|
| 511 | flask.current_app.logger.error(
|
|---|
| 512 | 'Output of gdal2tiles: {}'.format(e.output)
|
|---|
| 513 | )
|
|---|
| 514 | if slice_job.log_id() is not None:
|
|---|
| 515 | db.engine.execute(
|
|---|
| 516 | query_update_processing_state().format(
|
|---|
| 517 | processing_state=processing_state_error.id,
|
|---|
| 518 | epsg_code=epsg_code,
|
|---|
| 519 | longitude_west=slice_job.envelope().west(),
|
|---|
| 520 | latitude_south=slice_job.envelope().south(),
|
|---|
| 521 | longitude_east=slice_job.envelope().east(),
|
|---|
| 522 | latitude_north=slice_job.envelope().north(),
|
|---|
| 523 | age_condition=">",
|
|---|
| 524 | age_date=newer_than.isoformat('T')
|
|---|
| 525 | )
|
|---|
| 526 | )
|
|---|
| 527 | db.session.commit()
|
|---|
| 528 | os.remove(datasource_file)
|
|---|
| 529 | shutil.rmtree(temp_directory)
|
|---|
| 530 | raise e
|
|---|
| 531 | except Exception as e:
|
|---|
| 532 | flask.current_app.logger.error(
|
|---|
| 533 | 'Could not raster the data and generate tiles. Error: {}'.format(
|
|---|
| 534 | repr(e)
|
|---|
| 535 | )
|
|---|
| 536 | )
|
|---|
| 537 | if slice_job.log_id() is not None:
|
|---|
| 538 | db.engine.execute(
|
|---|
| 539 | query_update_processing_state().format(
|
|---|
| 540 | processing_state=processing_state_error.id,
|
|---|
| 541 | epsg_code=epsg_code,
|
|---|
| 542 | longitude_west=slice_job.envelope().west(),
|
|---|
| 543 | latitude_south=slice_job.envelope().south(),
|
|---|
| 544 | longitude_east=slice_job.envelope().east(),
|
|---|
| 545 | latitude_north=slice_job.envelope().north(),
|
|---|
| 546 | age_condition=">",
|
|---|
| 547 | age_date=newer_than.isoformat('T')
|
|---|
| 548 | )
|
|---|
| 549 | )
|
|---|
| 550 | db.session.commit()
|
|---|
| 551 | os.remove(datasource_file)
|
|---|
| 552 | shutil.rmtree(temp_directory)
|
|---|
| 553 | raise e
|
|---|
| 554 |
|
|---|
| 555 | for path in result_paths:
|
|---|
| 556 | tilegen.move_tiles_in_place(
|
|---|
| 557 | path.path,
|
|---|
| 558 | os.path.join(
|
|---|
| 559 | tiles_config.cache_path, path.prefixes['density'],
|
|---|
| 560 | path.prefixes['tile_size']
|
|---|
| 561 | ),
|
|---|
| 562 | skip_empty=tiles_config.skip_empty
|
|---|
| 563 | )
|
|---|
| 564 |
|
|---|
| 565 | # delete temporary directory
|
|---|
| 566 | shutil.rmtree(temp_directory)
|
|---|
| 567 | os.remove(datasource_file)
|
|---|
| 568 |
|
|---|
| 569 | return slice_job
|
|---|
| 570 |
|
|---|
| 571 |
|
|---|
| 572 | @celery_app.task
|
|---|
| 573 | def log_cleanup(slice_jobs):
|
|---|
| 574 | log_id = None
|
|---|
| 575 | envelope = None
|
|---|
| 576 | epsg_code = None
|
|---|
| 577 | for slice_job in slice_jobs:
|
|---|
| 578 | slice_job = SliceJob.from_dict(slice_job)
|
|---|
| 579 | if envelope is None:
|
|---|
| 580 | envelope = slice_job.envelope()
|
|---|
| 581 | epsg_code = slice_job.epsg_code()
|
|---|
| 582 | if log_id is None:
|
|---|
| 583 | log_id = slice_job.log_id()
|
|---|
| 584 |
|
|---|
| 585 | processing_state_deployed = _processing_state_get('Deployed')
|
|---|
| 586 |
|
|---|
| 587 | try:
|
|---|
| 588 | tiles_config = _get_tile_config()
|
|---|
| 589 | except Exception as error:
|
|---|
| 590 | _update_log_state(log_id, 'Error')
|
|---|
| 591 | raise error
|
|---|
| 592 | newer_than = datetime.datetime.utcnow() - relativedelta(
|
|---|
| 593 | years=tiles_config.points_age_max
|
|---|
| 594 | )
|
|---|
| 595 |
|
|---|
| 596 | # update processing state of logentries, to deployed
|
|---|
| 597 | db.engine.execute(
|
|---|
| 598 | query_update_processing_state().format(
|
|---|
| 599 | processing_state=processing_state_deployed.id,
|
|---|
| 600 | epsg_code=epsg_code,
|
|---|
| 601 | longitude_west=envelope.west(),
|
|---|
| 602 | latitude_south=envelope.south(),
|
|---|
| 603 | longitude_east=envelope.east(),
|
|---|
| 604 | latitude_north=envelope.north(),
|
|---|
| 605 | age_condition=">",
|
|---|
| 606 | age_date=newer_than.isoformat('T')
|
|---|
| 607 | )
|
|---|
| 608 | )
|
|---|
| 609 | _queue_delete(log_id)
|
|---|
| 610 | db.session.commit()
|
|---|
| 611 |
|
|---|
| 612 | log = log = _log_by_id(log_id)
|
|---|
| 613 | message = Message(
|
|---|
| 614 | "Parsed log file successfully", recipients=[log.submitter.email]
|
|---|
| 615 | )
|
|---|
| 616 | message.html = render_template(
|
|---|
| 617 | 'log_processed.html',
|
|---|
| 618 | first_name=log.submitter.first_name,
|
|---|
| 619 | water_link=_water_link(log.water.id),
|
|---|
| 620 | water_name=log.water.name
|
|---|
| 621 | )
|
|---|
| 622 | _mail_send(message)
|
|---|
| 623 |
|
|---|
| 624 | return True
|
|---|
| 625 |
|
|---|
| 626 |
|
|---|
| 627 | @celery_app.task
|
|---|
| 628 | def log_little_zoom_slice():
|
|---|
| 629 | """
|
|---|
| 630 | Generate all little zoomlevels, which are not process per
|
|---|
| 631 | log with log_process
|
|---|
| 632 | """
|
|---|
| 633 | flask.current_app.logger.info('Recreating tiles for little zoomlevels')
|
|---|
| 634 | try:
|
|---|
| 635 | tiles_config = _get_tile_config()
|
|---|
| 636 | except Exception as error:
|
|---|
| 637 | _update_log_state(log_id, 'Error')
|
|---|
| 638 | raise error
|
|---|
| 639 | try:
|
|---|
| 640 | sqlalchemy_database_uri = _get_database_uri()
|
|---|
| 641 | except Exception as error:
|
|---|
| 642 | raise error
|
|---|
| 643 |
|
|---|
| 644 | try:
|
|---|
| 645 | _tile_cache_create(tiles_config)
|
|---|
| 646 | except Exception as error:
|
|---|
| 647 | raise error
|
|---|
| 648 |
|
|---|
| 649 | zoom_range_little_zoom = tilegenerator.ZoomRange(
|
|---|
| 650 | 0, tiles_config.zoom_range.minimum()
|
|---|
| 651 | )
|
|---|
| 652 |
|
|---|
| 653 | newer_than = datetime.datetime.utcnow() - relativedelta(
|
|---|
| 654 | years=tiles_config.points_age_max
|
|---|
| 655 | )
|
|---|
| 656 |
|
|---|
| 657 | # query to get all logentries in the world, younger than age_date
|
|---|
| 658 | query = """SELECT {make_point}Z(ST_x(entries.location), ST_y(entries.location),
|
|---|
| 659 | (entries.water_depth + (logs.gauge_height -
|
|---|
| 660 | gauges.reference_water_level_gauge_height)), ST_srid(entries.location))
|
|---|
| 661 | FROM logentries as entries, logs, gauges
|
|---|
| 662 | WHERE entries.log_id=logs.id AND gauges.id=logs.gauge_id
|
|---|
| 663 | AND entries.datetime > \"{age_date}\"""".format(
|
|---|
| 664 | make_point=make_point(db.engine),
|
|---|
| 665 | age_date=newer_than.isoformat('T')
|
|---|
| 666 | )
|
|---|
| 667 |
|
|---|
| 668 | try:
|
|---|
| 669 | datasource_file = _datasource_vrt_create(query)
|
|---|
| 670 | except Exception as error:
|
|---|
| 671 | flask.current_app.logger.error(
|
|---|
| 672 | ('Could not open the output file for the ogr data '
|
|---|
| 673 | 'source description: {}').format(error)
|
|---|
| 674 | )
|
|---|
| 675 | os.remove(datasource_file)
|
|---|
| 676 | raise error
|
|---|
| 677 |
|
|---|
| 678 | tilegen = tilegenerator.TileGenerator(
|
|---|
| 679 | tile_sizes=tiles_config.sizes,
|
|---|
| 680 | densities=tiles_config.densities,
|
|---|
| 681 | density_base=tiles_config.densitiy_base
|
|---|
| 682 | )
|
|---|
| 683 | try:
|
|---|
| 684 | slices = tilegen.slices(
|
|---|
| 685 | datasource_file,
|
|---|
| 686 | zoom_range=zoom_range_little_zoom,
|
|---|
| 687 | raster_file_size_max=tiles_config.raster_file_size_max
|
|---|
| 688 | )
|
|---|
| 689 | except Exception as e:
|
|---|
| 690 | flask.current_app.logger.error(
|
|---|
| 691 | 'Slicing of little zoom job failed. Error: {}'.format(repr(e))
|
|---|
| 692 | )
|
|---|
| 693 | raise e
|
|---|
| 694 |
|
|---|
| 695 | slice_jobs = []
|
|---|
| 696 | for tile_slice in slices:
|
|---|
| 697 | slice_jobs.append(SliceJob(tile_slice, query, None, None, None))
|
|---|
| 698 | os.remove(datasource_file)
|
|---|
| 699 |
|
|---|
| 700 | if flask.current_app.debug:
|
|---|
| 701 | flask.current_app.logger.info(
|
|---|
| 702 | 'Created {} tasks to create tiles for zoomlevels {} - {}'.format(
|
|---|
| 703 | len(slice_jobs), zoom_range_little_zoom.minimum(),
|
|---|
| 704 | zoom_range_little_zoom.maximum()
|
|---|
| 705 | )
|
|---|
| 706 | )
|
|---|
| 707 | # cleanup is not needed, because the processing state
|
|---|
| 708 | # is not changed and also no mails are send
|
|---|
| 709 | celery.group((log_generate_tiles.s(slice_job)
|
|---|
| 710 | for slice_job in slice_jobs)).delay()
|
|---|
| 711 | return True
|
|---|
| 712 |
|
|---|
| 713 |
|
|---|
| 714 | def _log_by_id(log_id):
|
|---|
| 715 | log = Log.query.filter_by(id=log_id).all()
|
|---|
| 716 | if len(log) != 1:
|
|---|
| 717 | flask.current_app.logger.warn('Could not find log {}'.format(log_id))
|
|---|
| 718 | raise LookupError('Could not find log {}'.format(log_id))
|
|---|
| 719 | return log[0]
|
|---|
| 720 |
|
|---|
| 721 |
|
|---|
| 722 | def _queue_delete(log_id):
|
|---|
| 723 | if not Queue.query.filter_by(log_id=log_id).delete():
|
|---|
| 724 | flask.current_app.logger.error(
|
|---|
| 725 | 'Could not delete queue for log {}'.format(log.id)
|
|---|
| 726 | )
|
|---|
| 727 | db.session.commit()
|
|---|
| 728 |
|
|---|
| 729 |
|
|---|
| 730 | def _processing_state_get(status):
|
|---|
| 731 | processing_state = ProcessingStatus.query.filter_by(label=status).all()
|
|---|
| 732 | if len(processing_state) != 1:
|
|---|
| 733 | flask.current_app.logger.error(
|
|---|
| 734 | 'Processing status {} not found database'.format(status)
|
|---|
| 735 | )
|
|---|
| 736 | raise LookupError(
|
|---|
| 737 | 'Processing status {} not found database'.format(status)
|
|---|
| 738 | )
|
|---|
| 739 | return processing_state[0]
|
|---|
| 740 |
|
|---|
| 741 |
|
|---|
| 742 | def _update_log_state(log_id, status):
|
|---|
| 743 | processing_state = _processing_state_get(status)
|
|---|
| 744 | log = _log_by_id(log_id)
|
|---|
| 745 | log.processingstatus = processing_state
|
|---|
| 746 | db.session.add(log)
|
|---|
| 747 | db.session.commit()
|
|---|
| 748 |
|
|---|
| 749 |
|
|---|
| 750 | def _cleanup_error(log_id):
|
|---|
| 751 | _update_log_state(log_id, 'Error')
|
|---|
| 752 | _queue_delete(log_id)
|
|---|
| 753 |
|
|---|
| 754 |
|
|---|
| 755 | def _mail_error(log_id, error_message):
|
|---|
| 756 | log = _log_by_id(log_id)
|
|---|
| 757 | queue = Queue.query.filter_by(log_id=log.id).all()
|
|---|
| 758 | if len(queue) != 1:
|
|---|
| 759 | queue_date = ''
|
|---|
| 760 | else:
|
|---|
| 761 | queue_date = queue[0].isoformat('T')
|
|---|
| 762 |
|
|---|
| 763 | message = Message(
|
|---|
| 764 | "Error parsing log file", recipients=[log.submitter.email]
|
|---|
| 765 | )
|
|---|
| 766 | message.html = render_template(
|
|---|
| 767 | 'log_parsing_error.html',
|
|---|
| 768 | first_name=log.submitter.first_name,
|
|---|
| 769 | queue_date=queue_date,
|
|---|
| 770 | water_link=_water_link(log.water.id),
|
|---|
| 771 | water_name=log.water.name,
|
|---|
| 772 | errors=error_message
|
|---|
| 773 | )
|
|---|
| 774 | _mail_send(message)
|
|---|
| 775 |
|
|---|
| 776 | def _mail_send(message):
|
|---|
| 777 | if message is None:
|
|---|
| 778 | raise RuntimeWarning('Requested to send empty message --> Skipped')
|
|---|
| 779 | try:
|
|---|
| 780 | mail.send(message)
|
|---|
| 781 | except:
|
|---|
| 782 | print('WARNING: Could not send mail')
|
|---|
| 783 |
|
|---|
| 784 | def _get_database_uri():
|
|---|
| 785 | if 'SQLALCHEMY_DATABASE_URI' not in flask.current_app.config:
|
|---|
| 786 | raise ImportError('SQLALCHEMY_DATABASE_URI not configured')
|
|---|
| 787 | return flask.current_app.config['SQLALCHEMY_DATABASE_URI']
|
|---|
| 788 |
|
|---|
| 789 |
|
|---|
| 790 | def _get_tile_config():
|
|---|
| 791 | if 'TILES_CACHE_PATH' not in flask.current_app.config:
|
|---|
| 792 | flask.current_app.logger.error('TILES_CACHE_PATH not configured')
|
|---|
| 793 | raise ImportError('TILES_CACHE_PATH not configured')
|
|---|
| 794 |
|
|---|
| 795 | if 'TILES_SIZES' not in flask.current_app.config:
|
|---|
| 796 | flask.current_app.logger.error('TILES_SIZES not configured')
|
|---|
| 797 | raise ImportError('TILES_SIZES not configured')
|
|---|
| 798 |
|
|---|
| 799 | if 'TILES_DENSITIES' not in flask.current_app.config:
|
|---|
| 800 | flask.current_app.logger.error('TILES_DENSITIES not configured')
|
|---|
| 801 | raise ImportError('TILES_DENSITIES not configured')
|
|---|
| 802 |
|
|---|
| 803 | if 'TILES_DENSITY_BASEE' not in flask.current_app.config:
|
|---|
| 804 | flask.current_app.logger.error('TILES_DENSITY_BASEE not configured')
|
|---|
| 805 | raise ImportError('TILES_DENSITY_BASEE not configured')
|
|---|
| 806 |
|
|---|
| 807 | if 'TILES_POINT_AGE_MAX' not in flask.current_app.config:
|
|---|
| 808 | flask.current_app.logger.error('TILES_POINT_AGE_MAX not configured')
|
|---|
| 809 | raise ImportError('TILES_POINT_AGE_MAX not configured')
|
|---|
| 810 |
|
|---|
| 811 | if 'TILES_ZOOM_RANGE' not in flask.current_app.config:
|
|---|
| 812 | flask.current_app.logger.error('TILES_ZOOM_RANGE not configured')
|
|---|
| 813 | raise ImportError('TILES_ZOOM_RANGE not configured')
|
|---|
| 814 |
|
|---|
| 815 | if 'TILES_SKIP_EMPTY' not in flask.current_app.config:
|
|---|
| 816 | flask.current_app.logger.error('TILES_SKIP_EMPTY not configured')
|
|---|
| 817 | raise ImportError('TILES_SKIP_EMPTY not configured')
|
|---|
| 818 |
|
|---|
| 819 | if 'TILES_RASTER_FILE_SIZE_MAX' not in flask.current_app.config:
|
|---|
| 820 | flask.current_app.logger.error(
|
|---|
| 821 | 'TILES_RASTER_FILE_SIZE_MAX not configured'
|
|---|
| 822 | )
|
|---|
| 823 | raise ImportError('TILES_RASTER_FILE_SIZE_MAX not configured')
|
|---|
| 824 |
|
|---|
| 825 | return TileConfig(
|
|---|
| 826 | flask.current_app.config['TILES_CACHE_PATH'],
|
|---|
| 827 | flask.current_app.config['TILES_SIZES'],
|
|---|
| 828 | flask.current_app.config['TILES_DENSITIES'],
|
|---|
| 829 | flask.current_app.config['TILES_DENSITY_BASEE'],
|
|---|
| 830 | flask.current_app.config['TILES_POINT_AGE_MAX'],
|
|---|
| 831 | ZoomRange.from_dict(flask.current_app.config['TILES_ZOOM_RANGE']),
|
|---|
| 832 | flask.current_app.config['TILES_RASTER_FILE_SIZE_MAX'],
|
|---|
| 833 | flask.current_app.config['TILES_SKIP_EMPTY']
|
|---|
| 834 | )
|
|---|
| 835 |
|
|---|
| 836 |
|
|---|
| 837 | def _tile_cache_create(tiles_config):
|
|---|
| 838 | # create tile cache directory, if it does not exists
|
|---|
| 839 | if not os.path.exists(tiles_config.cache_path):
|
|---|
| 840 | # Path does not exist, try to create it
|
|---|
| 841 | os.makedirs(tiles_config.cache_path)
|
|---|
| 842 | elif not os.access(tiles_config.cache_path, os.W_OK):
|
|---|
| 843 | raise PermissionError(
|
|---|
| 844 | 'TILES_CACHE_PATH {} is not writeable'.format(
|
|---|
| 845 | tiles_config.cache_path
|
|---|
| 846 | )
|
|---|
| 847 | )
|
|---|
| 848 |
|
|---|
| 849 |
|
|---|
| 850 | def _datasource_vrt_create(query):
|
|---|
| 851 | # Create Datasource for SQL database
|
|---|
| 852 | output = tempfile.NamedTemporaryFile(
|
|---|
| 853 | mode='wb', prefix='gnuboat-tasks', suffix='.vrt', delete=False
|
|---|
| 854 | )
|
|---|
| 855 | xml_data_source = ET.Element("OGRVRTDataSource")
|
|---|
| 856 | xml_layer = ET.SubElement(
|
|---|
| 857 | xml_data_source, "OGRVRTLayer",
|
|---|
| 858 | {"name": "tmp_corrected_joined_points"}
|
|---|
| 859 | )
|
|---|
| 860 | xml_source = ET.SubElement(xml_layer, 'SrcDataSource')
|
|---|
| 861 | xml_source.text = _get_database_uri()
|
|---|
| 862 | xml_source_sql = ET.SubElement(xml_layer, "SrcSQL")
|
|---|
| 863 | xml_source_sql.text = query()
|
|---|
| 864 | xml_geometry_type = ET.SubElement(xml_layer, "GeometryType")
|
|---|
| 865 | xml_geometry_type.text = "wkbPoint"
|
|---|
| 866 | xml_tree = ET.ElementTree(xml_data_source)
|
|---|
| 867 | xml_tree.write(output, encoding="UTF-8", xml_declaration=False)
|
|---|
| 868 | output.close()
|
|---|
| 869 | return os.path.join(tempfile.gettempdir(), output.name)
|
|---|
| 870 |
|
|---|
| 871 |
|
|---|
| 872 | def _water_link(log_id):
|
|---|
| 873 | webclient_url = ''
|
|---|
| 874 | if 'MAPSERVICE_WEBCLIENT' not in flask.current_app.config:
|
|---|
| 875 | flask.current_app.logger.error('MAPSERVICE_WEBCLIENT not configured')
|
|---|
| 876 | else:
|
|---|
| 877 | webclient_url = flask.current_app.config['MAPSERVICE_WEBCLIENT']
|
|---|
| 878 | return '{}/water/{}'.format(webclient_url, log_id)
|
|---|