Skip to content

Commit

Permalink
Add Intensity parameter.
Browse files Browse the repository at this point in the history
zip-dropbox.ps1 script.
  • Loading branch information
breki committed May 25, 2024
1 parent 3443c96 commit 0ffc88e
Show file tree
Hide file tree
Showing 14 changed files with 170 additions and 57 deletions.
3 changes: 2 additions & 1 deletion Demeton.Tests/Aw3d/AW3D experiments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let options: ShadeCommand.Options =
IgnoredParameters = [] } }


// todo 0: move this to the command module?
// todo 10: move this to the command module?
let fetchAw3dHeightsArray _ =
let tileDownloadingResult = ensureAw3dTiles CacheDir area

Expand Down Expand Up @@ -94,6 +94,7 @@ let ``Generate hillshading from AW3D`` () =
IgorHillshader.shadePixel
{ SunAzimuth = IgorHillshader.DefaultSunAzimuth
ShadingColor = 0u
Intensity = 1.
HeightsArrayIndex = 0 }

let createShaderFunction _ =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ let ``Geo area needed is calculated correctly`` () =
PixelSize = None
MapScale = Some 250000
Dpi = 245
WaterBodiesColor = "#49C8FF" |> Png.Rgba8Bit.parseColorHexValue }
IgorHillshadingIntensity = 1.
SlopeShadingIntensity = 1.
WaterBodiesColor = "#49C8FF" |> Png.Rgba8Bit.parseColorHexValue
LocalCacheDir = TileShadeCommand.DefaultLocalCacheDir
OutputDir = TileShadeCommand.DefaultOutputDir }

match
TileShadeCommand.createProjection options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ open Demeton.Commands
open Xunit

[<Fact>]
let ``Projection is created``() =
let options: TileShadeCommand.Options = {
TileWidth= 100
TileHeight = 200
TileCenter = (10, 20)
PixelSize= None
MapScale= Some 250000
Dpi=245
WaterBodiesColor = "#49C8FF" |> Png.Rgba8Bit.parseColorHexValue
}
let ``Projection is created`` () =
let options: TileShadeCommand.Options =
{ TileWidth = 100
TileHeight = 200
TileCenter = (10, 20)
PixelSize = None
MapScale = Some 250000
Dpi = 245
IgorHillshadingIntensity = 1.
SlopeShadingIntensity = 1.
WaterBodiesColor = "#49C8FF" |> Png.Rgba8Bit.parseColorHexValue
LocalCacheDir = TileShadeCommand.DefaultLocalCacheDir
OutputDir = TileShadeCommand.DefaultOutputDir }

let projection = TileShadeCommand.createProjection options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ let ``run command`` () =
PixelSize = None
MapScale = Some 500000
Dpi = 245
WaterBodiesColor = "#49C8FF" |> Png.Rgba8Bit.parseColorHexValue }
IgorHillshadingIntensity = 1.
SlopeShadingIntensity = 1.
WaterBodiesColor = "#49C8FF" |> Png.Rgba8Bit.parseColorHexValue
LocalCacheDir = TileShadeCommand.DefaultLocalCacheDir
OutputDir = TileShadeCommand.DefaultOutputDir }

TileShadeCommand.run options
2 changes: 2 additions & 0 deletions Demeton.Tests/Shaders/Building igor hillshading step.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let ``Can parse step without parameters`` () =
IgorHillshading(
{ SunAzimuth = degToRad -45.
ShadingColor = 0u
Intensity = 1.
HeightsArrayIndex = 0 }
)
)
Expand All @@ -47,6 +48,7 @@ let ``Can parse step with valid parameters`` () =
IgorHillshading(
{ SunAzimuth = degToRad -90.
ShadingColor = 0x333333ffu
Intensity = 1.
HeightsArrayIndex = 0 }
)
)
Expand Down
2 changes: 2 additions & 0 deletions Demeton.Tests/Shaders/Building slope shader step.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ let ``Can parse step without parameters`` () =
SlopeShading
{ HorizontalColor = Rgba8Bit.rgbaColor 0uy 0uy 0uy 0uy
VerticalColor = Rgba8Bit.rgbaColor 0uy 0uy 0uy 255uy
Intensity = 1.
HeightsArrayIndex = 0 }
)
@>
Expand All @@ -48,6 +49,7 @@ let ``Can parse step with valid parameters`` () =
{ HorizontalColor = 0u
VerticalColor =
Rgba8Bit.rgbaColor 0x33uy 0x33uy 0x33uy 0xffuy
Intensity = 1.
HeightsArrayIndex = 0 }
)
)
Expand Down
1 change: 1 addition & 0 deletions Demeton.Tests/Shaders/Hillshading/Igor's shading method.fs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ let ``Igor shading properties test`` () =
) : IgorHillshader.ShaderParameters =
{ SunAzimuth = az
ShadingColor = col
Intensity = 1.
HeightsArrayIndex = 0 }

let genCircleAngle = floatInRange 0 360 |> Gen.map degToRad
Expand Down
6 changes: 1 addition & 5 deletions Demeton.Tests/todo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

module Demeton.Tests.todo


// todo 0: add less intensity to slope shading
// todo 1: add more intensity to the main hillshading

// todo 2: limit the command to stick to the SRTM level 0
// todo 6: limit the command to stick to the SRTM level 0

// todo 100: update shading docs now that we have added an array of fetchers

Expand Down
1 change: 1 addition & 0 deletions Demeton.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
lint.bat = lint.bat
build.ps1 = build.ps1
.config\dotnet-tools.json = .config\dotnet-tools.json
zip-dropbox.ps1 = zip-dropbox.ps1
EndProjectSection
EndProject
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Demeton", "Demeton\Demeton.fsproj", "{74E691F7-30D6-4D0B-AF9A-D9738C901E3A}"
Expand Down
50 changes: 28 additions & 22 deletions Demeton/CommandLine/Option.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,66 @@ module CommandLine.Option

open CommandLine.Common

let build name: CommandOption = {
Name = name
Description = ""
ValuePlaceholder = "value"
Format = ""
Default = None
Example = None
Parser = fun _ -> OkValue None
}

let desc description (opt: CommandOption) =
let build name : CommandOption =
{ Name = name
Description = ""
ValuePlaceholder = "value"
Format = ""
Default = None
Example = None
Parser = fun _ -> OkValue None }

let desc description (opt: CommandOption) =
{ opt with Description = description }

let asFloat minValue (opt: CommandOption) =
{ opt with
{ opt with
Parser = (ValueParsers.parseFloat minValue)
ValuePlaceholder = "number"
Format = sprintf "real number >= %g" minValue }

let asInt (opt: CommandOption) =
{ opt with
{ opt with
Parser = ValueParsers.parseInt
ValuePlaceholder = "number"
Format = "integer value" }

let asDirectory (opt: CommandOption) =
{ opt with
{ opt with
Parser = ValueParsers.parseDir
ValuePlaceholder = "path"
Format = "directory path" }

let asFileName (opt: CommandOption) =
{ opt with
{ opt with
Parser = ValueParsers.parseFileName
ValuePlaceholder = "text"
Format = "text" }

let asPositiveFloat (opt: CommandOption) =
{ opt with
Parser = ValueParsers.parsePositiveFloat
let asPositiveFloat (opt: CommandOption) =
{ opt with
Parser = ValueParsers.parsePositiveFloat
ValuePlaceholder = "number"
Format = "positive real number" }

let asPositiveInt (opt: CommandOption) =
{ opt with
let asNonNegativeFloat (opt: CommandOption) =
{ opt with
Parser = (ValueParsers.parseFloat 0.)
ValuePlaceholder = "number"
Format = "non-negative real number" }

let asPositiveInt (opt: CommandOption) =
{ opt with
Parser = ValueParsers.parsePositiveInt
ValuePlaceholder = "number"
Format = "positive integer number" }

let format formatDescription (opt: CommandOption) =
let format formatDescription (opt: CommandOption) =
{ opt with Format = formatDescription }

let example usage description (opt: CommandOption) =
{ opt with Example = Some (usage, description) }
{ opt with
Example = Some(usage, description) }

let parser optParser (opt: CommandOption) = { opt with Parser = optParser }

Expand Down
Loading

0 comments on commit 0ffc88e

Please sign in to comment.