Skip to content

Commit

Permalink
Merge pull request #473 from USACE/feature/APRFC_projection
Browse files Browse the repository at this point in the history
Feature/aprfc projection
  • Loading branch information
Enovotny authored May 21, 2024
2 parents e632479 + befeb6d commit 95bbcb5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
10 changes: 7 additions & 3 deletions api/models/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 12 additions & 1 deletion async_packager/src/cumulus_packager/heclib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
AXIS["Easting",EAST],AXIS["Northing",NORTH]]'
"""str: UTM WKT"""


# ProjectionDatum
class ProjectionDatum(Enum):
UNDEFINED_PROJECTION_DATUM = 0
Expand All @@ -79,6 +80,7 @@ class CompressionMethod(Enum):

compression_method = {i.name: i.value for i in CompressionMethod}


# StorageDataType
class StorageDataType(Enum):
GRID_FLOAT = 0
Expand All @@ -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
Expand All @@ -101,42 +104,49 @@ class DataType(Enum):

data_type = {i.name.replace("_", "-"): i.value for i in DataType}


# GridStructVersion
class GridStructVersion(Enum):
VERSION_100 = -100


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
Expand Down Expand Up @@ -194,6 +204,7 @@ def __init__(self, *args, **kw):
self._nullValue = UNDEFINED
super().__init__(*args, **kw)


def zwrite_record(
dssfilename: str,
gridStructStore: zStructSpatialGrid,
Expand Down
8 changes: 6 additions & 2 deletions async_packager/src/cumulus_packager/packager/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 10 additions & 2 deletions async_packager/src/cumulus_packager/writers/dss7.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""DSS7 package writer
"""

import json
import os
import sys
Expand Down Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions sql/common/V2.38.0__Add_srid_Watershed_col.sql
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit 95bbcb5

Please sign in to comment.