-
-
Notifications
You must be signed in to change notification settings - Fork 847
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: Add bounds to raster source #3672
feat: Add bounds to raster source #3672
Conversation
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.
@Elter71 Thanks much amazing work!
Some minor nitpicks
val readableArray: ReadableArray = value.asArray() | ||
|
||
if (readableArray.size() == 4) { |
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.
Is this check necessary here? We'll just silently error if the size is not 4
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.
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.
Sorry, mybad, you're right I've missed the Logger.e at the end.
Nitpick: Can please you rewrite the logic so we have early return on error statements, and not, the success case
Something like:
if (value.type.name != "Array" || readableArray.size() != 4) {
Logger.e(RNMBXRasterSourceManager.REACT_CLASS, "source bounds must be an array with left, bottom, top, and right values")
return
}
val bboxArray = Array(4) { i -> readableArray.getDouble(i)
source.setSourceBounds(bboxArray)
...
@@ -35,10 +36,14 @@ abstract class RNMBXTileSource<T : Source?>(context: Context?) : RNMBXSource<T>( | |||
if (attribution != null) { | |||
builder.attribution(attribution) | |||
} | |||
if(bounds != null) { | |||
val boundsArray = bounds!!.clone() |
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.
do we need !!
we've tested above for null already
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.
Without this, you will get an error:
Smart cast to 'Array<Double>' is impossible, because 'bounds' is a mutable property that could have been changed by this time FAILURE: Build failed with an exception.
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.
We should be able to do something like this:
bounds?.let {
builder.bounds(Arrays.asList(it))
}
@mfazekas All suggestions have been applied. Thanks for the quick response! |
@Elter71 thanks much, amazing! |
Description
Added
bounds support for RasterSource
. Now, you can limit the bounds within which raster tiles will render.Checklist
CONTRIBUTING.md
yarn generate
in the root folder/example
app./example
)Screenshot OR Video