Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added min and max value to algorithms #783

Conversation

JinIgarashi
Copy link
Contributor

@vincentsarago

Based on the discussion here (#760), I added min/max settings for algorithms parameters. I think these min/max values can be useful to create UI parts dynamically from titiler endpoint.

some parameters are straightforward to set min/max values, but some are not easy to set. Could you also check these min/max values are appropriate?

settings are shown as follow.

  • Hillshade
azimuth: int = Field(90, ge=0, lt=360)
angle_altitude: float = Field(90.0, ge=-90.0, lt=90.0)
buffer: int = Field(3, ge=0, lt=99)
  • Contours
increment: int = Field(35, ge=0, lt=999)
thickness: int = Field(1, ge=0, lt=10)
minz: int = Field(-12000, ge=-99999, lt=99999)
maxz: int = Field(8000, ge=-99999, lt=99999)
  • TerrainRGB
interval: float = Field(0.1, ge=0.0, lt=1.0)
baseval: float = Field(-10000.0, ge=-99999.0, lt=99999.0)
/algorithms endpoint response
{
   "hillshade":{
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":1,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         "azimuth":{
            "default":90,
            "exclusiveMaximum":360,
            "minimum":0,
            "title":"Azimuth",
            "type":"integer"
         },
         "angle_altitude":{
            "default":90,
            "exclusiveMaximum":90,
            "minimum":-90,
            "title":"Angle Altitude",
            "type":"number"
         },
         "buffer":{
            "default":3,
            "exclusiveMaximum":99,
            "minimum":0,
            "title":"Buffer",
            "type":"integer"
         }
      }
   },
   "contours":{
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":3,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         "increment":{
            "default":35,
            "minimum":0,
            "title":"Increment",
            "type":"integer"
         },
         "thickness":{
            "default":1,
            "minimum":0,
            "title":"Thickness",
            "type":"integer"
         },
         "minz":{
            "default":-12000,
            "exclusiveMaximum":99999,
            "minimum":-99999,
            "title":"Minz",
            "type":"integer"
         },
         "maxz":{
            "default":8000,
            "exclusiveMaximum":99999,
            "minimum":-99999,
            "title":"Maxz",
            "type":"integer"
         }
      }
   },
   "normalizedIndex":{
      "inputs":{
         "nbands":2
      },
      "outputs":{
         "nbands":1,
         "dtype":"float32",
         "min":[
            -1
         ],
         "max":[
            1
         ]
      },
      "parameters":{
         
      }
   },
   "terrarium":{
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":3,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         
      }
   },
   "terrainrgb":{
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":3,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         "interval":{
            "default":0.1,
            "exclusiveMaximum":1,
            "minimum":0,
            "title":"Interval",
            "type":"number"
         },
         "baseval":{
            "default":-10000,
            "exclusiveMaximum":99999,
            "minimum":-99999,
            "title":"Baseval",
            "type":"number"
         }
      }
   }
}

@JinIgarashi
Copy link
Contributor Author

@vincentsarago I added title and description based on #786
for title and description, I copied text from comments in source code, but there might be better title and description for algorithms (especially for terrarium and terrainrgb)

new response of /algorithm endpoint is shown at the below.

/algorithms endpoint response
{
   "hillshade":{
      "title":"Hillshade",
      "description":"Create hillshade from DEM dataset.",
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":1,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         "azimuth":{
            "default":90,
            "exclusiveMaximum":360,
            "minimum":0,
            "title":"Azimuth",
            "type":"integer"
         },
         "angle_altitude":{
            "default":90,
            "exclusiveMaximum":90,
            "minimum":-90,
            "title":"Angle Altitude",
            "type":"number"
         },
         "buffer":{
            "default":3,
            "exclusiveMaximum":99,
            "minimum":0,
            "title":"Buffer",
            "type":"integer"
         }
      }
   },
   "contours":{
      "title":"Contours",
      "description":"Create contours from DEM dataset.",
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":3,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         "increment":{
            "default":35,
            "exclusiveMaximum":999,
            "minimum":0,
            "title":"Increment",
            "type":"integer"
         },
         "thickness":{
            "default":1,
            "exclusiveMaximum":10,
            "minimum":0,
            "title":"Thickness",
            "type":"integer"
         },
         "minz":{
            "default":-12000,
            "exclusiveMaximum":99999,
            "minimum":-99999,
            "title":"Minz",
            "type":"integer"
         },
         "maxz":{
            "default":8000,
            "exclusiveMaximum":99999,
            "minimum":-99999,
            "title":"Maxz",
            "type":"integer"
         }
      }
   },
   "normalizedIndex":{
      "title":"Normalized Difference Index",
      "description":"Compute normalized difference index from two bands.",
      "inputs":{
         "nbands":2
      },
      "outputs":{
         "nbands":1,
         "dtype":"float32",
         "min":[
            -1
         ],
         "max":[
            1
         ]
      },
      "parameters":{
         
      }
   },
   "terrarium":{
      "title":"Terrarium",
      "description":"Encode DEM into RGB (Mapzen Terrarium).",
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":3,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         
      }
   },
   "terrainrgb":{
      "title":"Terrarium",
      "description":"Encode DEM into RGB (Mapbox Terrain RGB).",
      "inputs":{
         "nbands":1
      },
      "outputs":{
         "nbands":3,
         "dtype":"uint8",
         "min":null,
         "max":null
      },
      "parameters":{
         "interval":{
            "default":0.1,
            "exclusiveMaximum":1,
            "minimum":0,
            "title":"Interval",
            "type":"number"
         },
         "baseval":{
            "default":-10000,
            "exclusiveMaximum":99999,
            "minimum":-99999,
            "title":"Baseval",
            "type":"number"
         }
      }
   }
}

@JinIgarashi
Copy link
Contributor Author

@vincentsarago I just got notification email for CI. I have no idea why only 3.10 failed. Could you rerun this job for 3.10?

@vincentsarago
Copy link
Member

@JinIgarashi it failed because of linting issue. do you have pre-commit installed?

@vincentsarago vincentsarago merged commit 247da5d into developmentseed:main Mar 6, 2024
9 checks passed
@JinIgarashi
Copy link
Contributor Author

@vincentsarago ah, I see. sorry I missed the info at CONTRIBUTING.md. I will install pre-commit. also, thank you for merging the PR

@JinIgarashi JinIgarashi deleted the feat/add-min-max-for-algorithms branch March 6, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants