-
Notifications
You must be signed in to change notification settings - Fork 304
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bounding box: calculation of MinMax values and add clamping options #1993
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
39a15af
feat(elevationLayers): Add config.clampValues for clamping values of …
ftoromanoff 43a06b5
feat(XbilParser): gestion nodata in elevation layer (elevation set to 0)
ftoromanoff 406ad32
fix(example): change config file linked with the clampValues config
ftoromanoff deeee31
fix(example): invert order of the ElevationLayer addition when using 2
ftoromanoff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
feat(elevationLayers): Add config.clampValues for clamping values of …
…the elevation dataset
- Loading branch information
commit 39a15afba80a715e5cb765b4095b1dcc7f345be0
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,38 @@ | ||
import { readTextureValueWithBilinearFiltering } from 'Utils/DEMUtils'; | ||
|
||
function minMax4Corners(texture, pitch, noDataValue) { | ||
function minMax4Corners(texture, pitch, options) { | ||
const u = pitch.x; | ||
const v = pitch.y; | ||
const w = pitch.z; | ||
const z = [ | ||
readTextureValueWithBilinearFiltering({ noDataValue }, texture, u, v), | ||
readTextureValueWithBilinearFiltering({ noDataValue }, texture, u + w, v), | ||
readTextureValueWithBilinearFiltering({ noDataValue }, texture, u + w, v + w), | ||
readTextureValueWithBilinearFiltering({ noDataValue }, texture, u, v + w), | ||
].filter(v => v != undefined && v > -10); | ||
readTextureValueWithBilinearFiltering(options, texture, u, v), | ||
readTextureValueWithBilinearFiltering(options, texture, u + w, v), | ||
readTextureValueWithBilinearFiltering(options, texture, u + w, v + w), | ||
readTextureValueWithBilinearFiltering(options, texture, u, v + w), | ||
].filter(val => val != undefined); | ||
|
||
if (z.length) { | ||
return { min: Math.min(...z), max: Math.max(...z) }; | ||
} else { | ||
return { | ||
min: Infinity, | ||
max: -Infinity, | ||
}; | ||
} | ||
} | ||
|
||
/** | ||
* Calculates the minimum maximum texture elevation with xbil data | ||
* | ||
* @param {THREE.Texture} texture The texture to parse | ||
* @param {THREE.Vector4} pitch The pitch, restrict zone to parse | ||
* @param {number} noDataValue No data value | ||
* @return {Object} The minimum maximum elevation. | ||
*/ | ||
export function computeMinMaxElevation(texture, pitch, noDataValue) { | ||
* Calculates the minimum maximum texture elevation with xbil data | ||
* | ||
* @param {THREE.Texture} texture The texture to parse | ||
* @param {THREE.Vector4} pitch The pitch, restrict zone to parse | ||
* @param {Object} options No data value and clamp values | ||
* @param {number} options.noDataValue No data value | ||
* @param {number} [options.zmin] The minimum elevation value after which it will be clamped | ||
* @param {number} [options.zmax] The maximum elevation value after which it will be clamped | ||
Comment on lines
+31
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you homogenize with |
||
* @return {Object} The minimum and maximum elevation. | ||
*/ | ||
export function computeMinMaxElevation(texture, pitch, options) { | ||
const { width, height, data } = texture.image; | ||
if (!data) { | ||
// Return null values means there's no elevation values. | ||
|
@@ -33,8 +41,8 @@ export function computeMinMaxElevation(texture, pitch, noDataValue) { | |
return { min: null, max: null }; | ||
} | ||
|
||
// compute extact minimum and maximum elvation on 4 corners texture. | ||
let { min, max } = minMax4Corners(texture, pitch, noDataValue) || { max: -Infinity, min: Infinity }; | ||
// compute the minimum and maximum elevation on the 4 corners texture. | ||
let { min, max } = minMax4Corners(texture, pitch, options); | ||
|
||
const sizeX = Math.floor(pitch.z * width); | ||
|
||
|
@@ -50,12 +58,14 @@ export function computeMinMaxElevation(texture, pitch, noDataValue) { | |
const limX = x + sizeX; | ||
for (x; x < limX; x += inc) { | ||
const val = data[x]; | ||
if (val > -10 && val != noDataValue) { | ||
if (val !== options.noDataValue) { | ||
max = Math.max(max, val); | ||
min = Math.min(min, val); | ||
} | ||
} | ||
} | ||
if (options.zmin > min) { min = options.zmin; } | ||
if (options.zmax < max) { max = options.zmax; } | ||
} | ||
|
||
if (max === -Infinity || min === Infinity) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you rename to make the parameters more understandable?
you keep
zmin
andzmax
name for the layer properties?