Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit ad22d8b

Browse files
authored
Merge pull request #66 from fabianazioti/improves09
adding support for multiple layers
2 parents a04d265 + b507cc0 commit ad22d8b

File tree

9 files changed

+44
-31
lines changed

9 files changed

+44
-31
lines changed

wlts/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,16 @@ def handle_exception(e):
4646
return {'code': InternalServerError.code,
4747
'description': InternalServerError.description}, InternalServerError.code
4848

49-
from .views import bp
49+
@app.after_request
50+
def after_request(response):
51+
"""Enable CORS."""
52+
response.headers.add('Access-Control-Allow-Origin', '*')
53+
response.headers.add('Access-Control-Allow-Methods', '*')
54+
response.headers.add('Access-Control-Allow-Headers',
55+
'Origin, X-Requested-With, Content-Type, Accept, Authorization')
56+
return response
5057

58+
from .views import bp
5159
app.register_blueprint(bp)
5260

5361

wlts/collections/collection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Collection(metaclass=ABCMeta):
1515
"""Abstract class to represent an collection."""
1616

1717
def __init__(self, name, authority_name, description, detail, datasource_id, dataset_type,
18-
classification_class, temporal, scala, spatial_extent, period, is_public):
18+
classification_class, temporal, scala, spatial_extent, period, is_public, deprecated):
1919
"""Create Collection."""
2020
self.name = name
2121
self.authority_name = authority_name
@@ -27,6 +27,7 @@ def __init__(self, name, authority_name, description, detail, datasource_id, dat
2727
self.spatial_extent = spatial_extent
2828
self.period = period
2929
self.is_public = is_public
30+
self.deprecated = deprecated
3031
self.classification_class = self.create_classification_system(classification_class)
3132

3233
self.datasource = datasource_manager.get_datasource(datasource_id)

wlts/collections/feature_collection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ def __init__(self, collections_info):
3030
collections_info["scala"],
3131
collections_info["spatial_extent"],
3232
collections_info["period"],
33-
collections_info["is_public"])
33+
collections_info["is_public"],
34+
collections_info["deprecated"],
35+
)
3436

35-
self.feature_name = collections_info["feature_name"]
3637
self.geom_property = collections_info["geom_property"]
3738
self.observations_properties = collections_info["observations_properties"]
3839

@@ -59,7 +60,6 @@ def trajectory(self, tj_attr, x, y, start_date, end_date, geometry):
5960
for obs in self.observations_properties:
6061

6162
args = {
62-
"feature_name": self.feature_name,
6363
"temporal": self.temporal,
6464
"x": x,
6565
"y": y,

wlts/collections/image_collection.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def __init__(self, collections_info):
2929
collections_info["scala"],
3030
collections_info["spatial_extent"],
3131
collections_info["period"],
32-
collections_info["is_public"])
32+
collections_info["is_public"],
33+
collections_info["deprecated"])
3334

34-
self.image = collections_info["image"]
3535
self.grid = collections_info["grid"]
3636
self.spatial_ref_system = collections_info["spatial_reference_system"]
3737
self.observations_properties = collections_info["attributes_properties"]
@@ -58,23 +58,24 @@ def trajectory(self, tj_attr, x, y, start_date, end_date, geometry):
5858
ds = self.get_datasource()
5959

6060
for time in self.timeline:
61-
args = {
62-
"image": self.image,
63-
"temporal": self.temporal,
64-
"x": x,
65-
"y": y,
66-
"grid": self.grid,
67-
"srid": self.spatial_ref_system["srid"],
68-
"start_date": start_date,
69-
"end_date": end_date,
70-
"time": time,
71-
"classification_class": self.classification_class,
72-
"geometry_flag": geometry
73-
}
61+
for att in self.observations_properties:
62+
args = {
63+
"image": att["image"],
64+
"temporal": self.temporal,
65+
"x": x,
66+
"y": y,
67+
"grid": self.grid,
68+
"srid": self.spatial_ref_system["srid"],
69+
"start_date": start_date,
70+
"end_date": end_date,
71+
"time": time,
72+
"classification_class": self.classification_class,
73+
"geometry_flag": geometry
74+
}
7475

75-
result = ds.get_trajectory(**args)
76-
77-
if result is not None:
78-
result["collection"] = self.get_name()
79-
tj_attr.append(result)
76+
result = ds.get_trajectory(**args)
77+
78+
if result is not None:
79+
result["collection"] = self.get_name()
80+
tj_attr.append(result)
8081

wlts/controller.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def describe_collection(cls, collection_name, roles=None):
8181
describe["name"] = collection.name
8282
describe["description"] = collection.description
8383
describe["detail"] = collection.detail
84+
describe["is_public"] = collection.is_public
85+
describe["deprecated"] = collection.deprecated
8486
describe["collection_type"] = collection.collection_type()
8587
describe["resolution_unit"] = {
8688
"unit": collection.get_resolution_unit(),

wlts/datasources/wfs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ def organize_trajectory(self, result, obs, geom_flag, geom_property, classificat
247247

248248
def get_trajectory(self, **kwargs):
249249
"""Return a trajectory observation of this datasource."""
250-
invalid_parameters = set(kwargs) - {"feature_name", "temporal",
250+
invalid_parameters = set(kwargs) - {"temporal",
251251
"x", "y", "obs", "geom_property",
252252
"classification_class", "start_date", "end_date",
253253
"geometry_flag"}
254254
if invalid_parameters:
255255
raise AttributeError('invalid parameter(s): {}'.format(invalid_parameters))
256256

257-
type_name = self.workspace + ":" + kwargs['feature_name']
257+
type_name = self.workspace + ":" + (kwargs['obs'])['feature_name']
258258

259259
geom = Point(kwargs['x'], kwargs['y'])
260260

wlts/json_configs/feature_collection/deter_amz.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"detail": "http://www.obt.inpe.br/OBT/assuntos/programas/amazonia/deter",
66
"datasource_id": "3c20cbb4-ca94-4c1f-99af-6377f30bc683",
77
"dataset_type": "Feature",
8+
"deprecated": false,
89
"is_public": true,
910
"classification_class": {
1011
"datasource_id": "3c20cbb4-ca94-4c1f-99af-6377f30bc683",
@@ -29,15 +30,14 @@
2930
"ymin": -18.0364406523564,
3031
"ymax": 4.55537642867927
3132
},
32-
"feature_name": "deter_amz",
33-
"feature_id_property": "gid",
3433
"geom_property": {
3534
"property_name": "geom",
3635
"srid": 4674,
3736
"type": "MultiPolygon"
3837
},
3938
"observations_properties": [
4039
{
40+
"feature_name": "deter_amz",
4141
"class_property": "classname",
4242
"temporal_property": "view_date"
4343
}

wlts/json_configs/image_collection/terraclass_cerrado.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"detail": "Para mais informacoes acesse: https://www.terraclass.gov.br/",
66
"datasource_id": "3c20cbb4-ca94-4c1f-99af-6377f30bc644",
77
"dataset_type": "Image",
8+
"deprecated": false,
89
"is_public": true,
910
"classification_class": {
1011
"datasource_id": "3c20cbb4-ca94-4c1f-99af-6377f30bc644",
@@ -29,7 +30,6 @@
2930
"max_x": "-41.522427616",
3031
"max_y": "-2.32678430299999"
3132
},
32-
"image": "tc_cerrado_2018_raster",
3333
"grid": {
3434
"row": "768",
3535
"column": "638"
@@ -39,6 +39,7 @@
3939
},
4040
"attributes_properties": [
4141
{
42+
"image": "tc_cerrado_2018_raster",
4243
"name": "GRAY_INDEX",
4344
"data_type": "int",
4445
"valid_range": {

wlts/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
"""
1414

1515

16-
__version__ = '0.8.0'
16+
__version__ = '0.9.0'

0 commit comments

Comments
 (0)