diff --git a/api/models/download.go b/api/models/download.go index 5ab63c19..6a92a219 100644 --- a/api/models/download.go +++ b/api/models/download.go @@ -73,6 +73,7 @@ type PackagerRequest struct { type Extent struct { Name string `json:"name"` Bbox []float64 `json:"bbox"` + Srid float64 `json:"srid"` } // PackagerContentItem is a single item for Packager to include in output file @@ -181,9 +182,12 @@ func GetDownloadPackagerRequest(db *pgxpool.Pool, downloadID *uuid.UUID) (*Packa json_build_object( 'name', w.name, 'bbox', ARRAY[ - ST_XMin(w.geometry),ST_Ymin(w.geometry), - ST_XMax(w.geometry),ST_YMax(w.geometry) - ] + ST_XMin(ST_Transform(w.geometry,w.output_srid)), + ST_YMin(ST_Transform(w.geometry,w.output_srid)), + ST_XMax(ST_Transform(w.geometry,w.output_srid)), + ST_YMax(ST_Transform(w.geometry,w.output_srid)) + ], + 'srid', w.output_srid ) AS extent, CONCAT( 'cumulus/download/', f.abbreviation, diff --git a/async_packager/src/cumulus_packager/heclib/__init__.py b/async_packager/src/cumulus_packager/heclib/__init__.py index c6f37010..30db715e 100644 --- a/async_packager/src/cumulus_packager/heclib/__init__.py +++ b/async_packager/src/cumulus_packager/heclib/__init__.py @@ -60,6 +60,7 @@ AXIS["Easting",EAST],AXIS["Northing",NORTH]]' """str: UTM WKT""" + # ProjectionDatum class ProjectionDatum(Enum): UNDEFINED_PROJECTION_DATUM = 0 @@ -79,6 +80,7 @@ class CompressionMethod(Enum): compression_method = {i.name: i.value for i in CompressionMethod} + # StorageDataType class StorageDataType(Enum): GRID_FLOAT = 0 @@ -89,6 +91,7 @@ class StorageDataType(Enum): storage_data_type = {i.name: i.value for i in StorageDataType} + # DataType class DataType(Enum): PER_AVER = 0 @@ -101,6 +104,7 @@ class DataType(Enum): data_type = {i.name.replace("_", "-"): i.value for i in DataType} + # GridStructVersion class GridStructVersion(Enum): VERSION_100 = -100 @@ -108,35 +112,41 @@ class GridStructVersion(Enum): grid_struct_version = {i.name: i.value for i in GridStructVersion} + # DssGridType class DssGridType(Enum): UNDEFINED_GRID_TYPE = 400 HRAP = 410 SHG = ALBERS = 420 SPECIFIED_GRID_TYPE = 430 + UTM6N = 430 dss_grid_type = {i.name: i.value for i in DssGridType} + # DssGridTypeName class DssGridTypeName(Enum): HRAP = "HRAP" SHG = "ALBERS" - UTM = "UMT%s%s" + UTM = "UTM%s%s" dss_grid_type_name = {i.name: i.value for i in DssGridTypeName} + # SpatialRefereceDefinition class SpatialReferenceDefinition(Enum): UNDEFINED_GRID_TYPE = None HRAP = HRAP_SRC_DEFINITION SHG = ALBERS = SHG_SRC_DEFINITION SPECIFIED_GRID_TYPE = None + UTM6N = UTM_SRC_DEFINITION % ("6", "N", "-147", "0") spatial_reference_definition = {i.name: i.value for i in SpatialReferenceDefinition} + # TimeZones class TimeZone(Enum): GMT = UTC = 0 @@ -194,6 +204,7 @@ def __init__(self, *args, **kw): self._nullValue = UNDEFINED super().__init__(*args, **kw) + def zwrite_record( dssfilename: str, gridStructStore: zStructSpatialGrid, diff --git a/async_packager/src/cumulus_packager/packager/handler.py b/async_packager/src/cumulus_packager/packager/handler.py index f28464ec..d8411a0d 100644 --- a/async_packager/src/cumulus_packager/packager/handler.py +++ b/async_packager/src/cumulus_packager/packager/handler.py @@ -85,14 +85,18 @@ def handle_message(payload_resp: namedtuple, dst: str): """ logger.info(f'Handle message with plugin "{payload_resp.format}"') + extent = payload_resp.extent + logger.info(f"extent {extent}") + dst_srs = f'EPSG:{extent["srid"]}' + logger.info(f"output projection of grids will be {dst_srs}") result = pkg_writer( plugin=payload_resp.format, id=payload_resp.download_id, src=json.dumps(payload_resp.contents), - extent=json.dumps(payload_resp.extent), + extent=json.dumps(extent), dst=dst, cellsize=2000, - dst_srs="EPSG:5070", + dst_srs=dst_srs, ) return result diff --git a/async_packager/src/cumulus_packager/writers/dss7.py b/async_packager/src/cumulus_packager/writers/dss7.py index 4ad4e9ec..13f66564 100644 --- a/async_packager/src/cumulus_packager/writers/dss7.py +++ b/async_packager/src/cumulus_packager/writers/dss7.py @@ -1,6 +1,7 @@ """DSS7 package writer """ + import json import os import sys @@ -69,8 +70,15 @@ def writer( destination_srs.ImportFromEPSG(int(epsg_code)) ###### this can go away when the payload has the resolution ###### - grid_type_name = "SHG" - grid_type = heclib.dss_grid_type[grid_type_name] + if epsg_code == "26906": + grid_type_name = "UTM6N" + grid_type = 430 + else: + grid_type_name = "SHG" + grid_type = heclib.dss_grid_type[grid_type_name] + logger.info( + f"grid type name {grid_type_name}", + ) zcompression = heclib.compression_method["ZLIB_COMPRESSION"] srs_definition = heclib.spatial_reference_definition[grid_type_name] tz_name = "GMT" diff --git a/sql/common/V2.38.0__Add_srid_Watershed_col.sql b/sql/common/V2.38.0__Add_srid_Watershed_col.sql new file mode 100644 index 00000000..2ad9a8c3 --- /dev/null +++ b/sql/common/V2.38.0__Add_srid_Watershed_col.sql @@ -0,0 +1,13 @@ +-- add output_srid column to watershed table. this column will define what output +-- projection the grids should be in. default as SHG EPSG 5070. +ALTER TABLE watershed ADD COLUMN output_srid INTEGER DEFAULT 5070; + +--update alaska watersheds to output as EPSG 26906. +UPDATE watershed + SET output_srid = 26906 +WHERE id = 'ba17efef-1edc-4c1e-8b70-8c2d27861ee1'; + +--update alaska watersheds to output as EPSG 26906. +UPDATE watershed + SET output_srid = 26906 +WHERE id = 'afec9c31-60ee-4a8c-bc2b-d4427d037b45'; \ No newline at end of file