Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BiG-CZ: Increase Area of Interest Size #2418

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/mmw/apps/bigcz/clients/cuahsi/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,9 @@ def group_series_by_location(series):
return records


def make_request(request, expiry, **kwargs):
key = 'bigcz_{}_{}'.format(request.method.name,
hash(frozenset(kwargs.items())))
cached = cache.get(key)
if cached:
return cached

def make_request(request, **kwargs):
try:
response = recursive_asdict(request(**kwargs))
cache.set(key, response, timeout=expiry)
return response
return request(**kwargs)
except URLError, e:
if isinstance(e.reason, timeout):
raise RequestTimedOutError()
Expand All @@ -222,15 +214,21 @@ def make_request(request, expiry, **kwargs):


def get_services_in_box(box):
key = 'bigcz_cuahsi_GetServicesInBox2_{}'.format(hash(box))
cached = cache.get(key)
if cached:
return cached

result = make_request(client.service.GetServicesInBox2,
604800, # Cache for one week
xmin=box.xmin,
xmax=box.xmax,
ymin=box.ymin,
ymax=box.ymax)

try:
return result['ServiceInfo']
data = recursive_asdict(result)
cache.set(key, data['ServiceInfo'], timeout=604800) # Cache for 1 week
return data['ServiceInfo']
except KeyError:
# Missing key may indicate a server-side error
raise ValueError(result)
Expand All @@ -244,7 +242,6 @@ def get_series_catalog_in_box(box, from_date, to_date, networkIDs):
to_date = to_date or DATE_MAX

result = make_request(client.service.GetSeriesCatalogForBox2,
300, # Cache for 5 minutes
xmin=box.xmin,
xmax=box.xmax,
ymin=box.ymin,
Expand Down
66 changes: 37 additions & 29 deletions src/mmw/js/src/data_catalog/controllers.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"use strict";

var App = require('../app'),
var turfArea = require('turf-area'),
moment = require('moment'),
App = require('../app'),
router = require('../router').router,
coreUtils = require('../core/utils'),
models = require('./models'),
views = require('./views');

var MAX_UNCAPPED_AOI = 1500000000; // 1,500 km²

var DataCatalogController = {
dataCatalogPrepare: function() {
if (!App.map.get('areaOfInterest')) {
Expand All @@ -21,36 +25,40 @@ var DataCatalogController = {
'active_page': coreUtils.dataCatalogPageTitle,
});

var form = new models.SearchForm();
var dateFilter = new models.DateFilter();
var aoiArea = turfArea(App.map.get('areaOfInterest')),
fromDate = aoiArea < MAX_UNCAPPED_AOI ? null :
moment().subtract(5, 'years').format('L'),

var catalogs = new models.Catalogs([
new models.Catalog({
id: 'cinergi',
name: 'CINERGI',
active: true,
results: new models.Results(null, { catalog: 'cinergi' }),
filters: new models.FilterCollection([dateFilter])
}),
new models.Catalog({
id: 'hydroshare',
name: 'HydroShare',
results: new models.Results(null, { catalog: 'hydroshare' }),
filters: new models.FilterCollection([dateFilter])
}),
new models.Catalog({
id: 'cuahsi',
name: 'WDC',
is_pageable: false,
results: new models.Results(null, { catalog: 'cuahsi' }),
filters: new models.FilterCollection([
dateFilter,
new models.GriddedServicesFilter()
])
})
]);
form = new models.SearchForm(),
dateFilter = new models.DateFilter({ fromDate: fromDate }),

catalogs = new models.Catalogs([
new models.Catalog({
id: 'cinergi',
name: 'CINERGI',
active: true,
results: new models.Results(null, { catalog: 'cinergi' }),
filters: new models.FilterCollection([dateFilter])
}),
new models.Catalog({
id: 'hydroshare',
name: 'HydroShare',
results: new models.Results(null, { catalog: 'hydroshare' }),
filters: new models.FilterCollection([dateFilter])
}),
new models.Catalog({
id: 'cuahsi',
name: 'WDC',
is_pageable: false,
results: new models.Results(null, { catalog: 'cuahsi' }),
filters: new models.FilterCollection([
dateFilter,
new models.GriddedServicesFilter()
])
})
]),

var resultsWindow = new views.ResultsWindow({
resultsWindow = new views.ResultsWindow({
model: form,
collection: catalogs
}),
Expand Down
2 changes: 1 addition & 1 deletion src/mmw/mmw/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def get_env_setting(setting):
MMW_MAX_AREA = 75000 # Max area in km2, about the size of West Virginia

BIGCZ_HOST = 'portal.bigcz.org' # BiG-CZ Host, for enabling custom behavior
BIGCZ_MAX_AREA = 1500 # Max area in km2, limited by CUAHSI
BIGCZ_MAX_AREA = 8000 # Max area in km2, limited by CUAHSI
BIGCZ_CLIENT_TIMEOUT = 5 # timeout in seconds
BIGCZ_CLIENT_PAGE_SIZE = 100

Expand Down