Skip to content

Commit

Permalink
adding spatial reference to structure provider
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryGeorgist committed Sep 26, 2024
1 parent cfefba9 commit 2fc9480
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
12 changes: 6 additions & 6 deletions compute/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ func Test_Config(t *testing.T) {
}
func Test_StreamAbstract(t *testing.T) {
//initialize the NSI API structure provider
//nsp := structureprovider.InitNSISP()
nsp := structureprovider.InitNSISP()
now := time.Now()
fmt.Println(now)
nsp, _ := structureprovider.InitStructureProvider("/workspaces/Go_Consequences/data/ffrd/Lower Kanawha-Elk Lower.gpkg", "Lower Kanawha-Elk Lower", "GPKG")
nsp.SetDeterministic(true)
//nsp, _ := structureprovider.InitStructureProvider("/workspaces/Go_Consequences/data/ffrd/Lower Kanawha-Elk Lower.gpkg", "Lower Kanawha-Elk Lower", "GPKG")
//nsp.SetDeterministic(true)
//identify the depth grid to apply to the structures.
root := "/workspaces/Go_Consequences/data/ffrd/LowKanLowElk/depth_grid"
filepath := root + ".vrt"
w, _ := resultswriters.InitSpatialResultsWriter(root+"_consequences.json", "results", "GeoJSON")
root := "/workspaces/Go_Consequences/data/kc_silverjackets/Douglas_Co_depth/DG_Depth_01pct"
filepath := root + ".tif"
w, _ := resultswriters.InitSpatialResultsWriter(root+"_consequences3.gpkg", "results", "GPKG")
//w := consequences.InitSummaryResultsWriterFromFile(root + "_consequences_SUMMARY.json")
//create a result writer based on the name of the depth grid.
//w, _ := resultswriters.InitGpkResultsWriter(root+"_consequences_nsi.gpkg", "nsi_result")
Expand Down
13 changes: 13 additions & 0 deletions structureprovider/structure-provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,19 @@ func (gpk *gdalDataSet) SetDeterministic(useDeterministic bool) {
func (gpk *gdalDataSet) SetSeed(seed int64) {
gpk.seed = seed
}
func (gpk *gdalDataSet) SpatialReference() string {
l := gpk.ds.LayerByName(gpk.LayerName)
sr := l.SpatialReference()
wkt, err := sr.ToWKT()
if err != nil {
return ""
}
return wkt
}
func (gpk *gdalDataSet) UpdateSpatialReference(sr_wkt string) {
// unimplemented
fmt.Println("could not set spatial reference")
}

// StreamByFips a streaming service for structure stochastic based on a bounding box
func (gpk gdalDataSet) ByFips(fipscode string, sp consequences.StreamProcessor) {
Expand Down
33 changes: 21 additions & 12 deletions structures/jsonocctypeprovider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,20 +913,29 @@ func toContinuousDistribution(data []float64) []statistics.ContinuousDistributio
}
}
func Test_FEMACurves(t *testing.T) {
jotp := JsonOccupancyTypeProvider{}
jotp.InitLocalPath("/workspaces/Go_Consequences/data/Inland_FFRD_damageFunctions_final.json")
for OccupancyTypeName, v := range jotp.occupancyTypesContainer.OccupancyTypes {
fmt.Println(OccupancyTypeName)
for loss_component, component_damageFunctions := range v.ComponentDamageFunctions {
s := loss_component + ":\n"
for damageFunctionParameter, damageFunction := range component_damageFunctions.DamageFunctions {
s += "\t" + damageFunctionParameter.String() + ", " + damageFunction.Source + "\n"
}
fmt.Println(s)
}
func Test_FEMACurves(t *testing.T) {
jotp := JsonOccupancyTypeProvider{}
jotp.InitLocalPath("/workspaces/Go_Consequences/data/Inland_FFRD_damageFunctions_final_final.json")
//addedVals := []float64{15, 16}
for OccupancyTypeName, v := range jotp.occupancyTypesContainer.OccupancyTypes {
fmt.Println(OccupancyTypeName)
for loss_component, component_damageFunctions := range v.ComponentDamageFunctions {
s := loss_component + ":\n"
for damageFunctionParameter, damageFunction := range component_damageFunctions.DamageFunctions {
s += "\t" + damageFunctionParameter.String() + ", " + damageFunction.Source + "\n"
/*if damageFunction.Source == "FEMA Inland Damage Functions Report 20211001" {
//extend depth to include 15 and 16 ft.
damageFunction.DamageFunction.Xvals = append(damageFunction.DamageFunction.Xvals, addedVals...)
component_damageFunctions.DamageFunctions[damageFunctionParameter] = damageFunction
}*/
/*}
//v.ComponentDamageFunctions[loss_component] = component_damageFunctions
fmt.Println(s)
}
}
//jotp.Write("/workspaces/Go_Consequences/data/Inland_FFRD_damageFunctions_final_final.json")
}
func CombineOcctypes(a OccupancyTypeStochastic, b OccupancyTypeStochastic) OccupancyTypeStochastic {
for componentkey, adff := range a.ComponentDamageFunctions {
Expand Down

0 comments on commit 2fc9480

Please sign in to comment.