Skip to content

Commit

Permalink
Merge pull request #519 from EOxServer/dseo-product-metadata
Browse files Browse the repository at this point in the history
add product metadata to dseo getproduct
  • Loading branch information
constantinius committed May 12, 2022
2 parents 6c886cf + 49a0160 commit 661024e
Showing 1 changed file with 33 additions and 18 deletions.
51 changes: 33 additions & 18 deletions eoxserver/services/ows/dseo/v10/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,15 @@ def handle(self, request):
coverage.arraydata_items.all(),
coverage.metadata_items.all()
)

for data_item in items:
# faster encoding when local files. Fallback on VSI API otherwise
if not data_item.storage:
zip_stream.write(
data_item.location,
join(
product.identifier, coverage.identifier,
basename(data_item.location)
)
)
else:
zip_stream.write_iter(
join(
product.identifier, coverage.identifier,
basename(data_item.location)
),
_iter_data_item(data_item)
)
add_item_to_zipstream(data_item, zip_stream, product, coverage)

# add product metadata
product_items = chain(
product.metadata_items.all()
)
for metadata_item in product_items:
add_item_to_zipstream(metadata_item, zip_stream, product, None)

response = StreamingHttpResponse(
zip_stream, content_type='application/octet-stream'
Expand All @@ -166,6 +156,31 @@ def _iter_data_item(data_item, chunk_size=65535):
break


def add_item_to_zipstream(data_item, zip_stream, product, coverage):
if coverage:
filepath = join(
product.identifier,
coverage.identifier,
basename(data_item.location)
)
else:
filepath = join(
product.identifier,
basename(data_item.location)
)
# faster encoding when local files. Fallback on VSI API otherwise
if not data_item.storage:
zip_stream.write(
data_item.location,
filepath
)
else:
zip_stream.write_iter(
filepath,
_iter_data_item(data_item)
)


class GetCapabilitiesKVPDecoder(kvp.Decoder):
sections = kvp.Parameter(type=typelist(lower, ","), num="?", default=["all"])
updatesequence = kvp.Parameter(num="?")
Expand Down

0 comments on commit 661024e

Please sign in to comment.