@aguacerowx/react-native 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/aguacerowx-react-native.podspec +21 -5
- package/android/build.gradle +31 -7
- package/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayer.java +17 -1
- package/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayerView.java +5 -0
- package/android/src/main/java/com/aguacerowx/reactnative/GridRenderManager.java +8 -0
- package/android/src/main/res/raw/fragment_shader.glsl +120 -66
- package/ios/GridRenderLayer.swift +113 -92
- package/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/ios/compiled-shaders/Shaders.metallib +0 -0
- package/lib/commonjs/README.md +66 -0
- package/lib/commonjs/aguacerowx-react-native.podspec +21 -5
- package/lib/commonjs/android/build.gradle +31 -7
- package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayer.java +17 -1
- package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayerView.java +5 -0
- package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/GridRenderManager.java +8 -0
- package/lib/commonjs/android/src/main/res/raw/fragment_shader.glsl +120 -66
- package/lib/commonjs/ios/GridRenderLayer.swift +113 -92
- package/lib/commonjs/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/lib/commonjs/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/commonjs/ios/compiled-shaders/Shaders.metallib +0 -0
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js +128 -68
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js.map +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js +39 -12
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js.map +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js +38 -20
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js.map +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/index.js +0 -6
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/index.js.map +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/package.json +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js +28 -2
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js.map +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js +35 -8
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js.map +1 -1
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js +38 -20
- package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js.map +1 -1
- package/lib/commonjs/package.json +9 -4
- package/lib/commonjs/scripts/compile-shaders.sh +27 -0
- package/lib/commonjs/src/GridRenderLayer.js +8 -0
- package/lib/commonjs/src/GridRenderLayer.js.map +1 -1
- package/lib/commonjs/src/WeatherLayerManager.js +5 -0
- package/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
- package/lib/module/README.md +66 -0
- package/lib/module/aguacerowx-react-native.podspec +21 -5
- package/lib/module/android/build.gradle +31 -7
- package/lib/module/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayer.java +17 -1
- package/lib/module/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayerView.java +5 -0
- package/lib/module/android/src/main/java/com/aguacerowx/reactnative/GridRenderManager.java +8 -0
- package/lib/module/android/src/main/res/raw/fragment_shader.glsl +120 -66
- package/lib/module/ios/GridRenderLayer.swift +113 -92
- package/lib/module/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/lib/module/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/module/ios/compiled-shaders/Shaders.metallib +0 -0
- package/lib/module/lib/commonjs/README.md +66 -0
- package/lib/module/lib/commonjs/aguacerowx-react-native.podspec +21 -5
- package/lib/module/lib/commonjs/android/build.gradle +31 -7
- package/lib/module/lib/commonjs/ios/GridRenderLayer.swift +113 -92
- package/lib/module/lib/commonjs/ios/compiled-shaders/Shaders-device.metallib +0 -0
- package/lib/module/lib/commonjs/ios/compiled-shaders/Shaders-simulator.metallib +0 -0
- package/lib/module/lib/commonjs/ios/compiled-shaders/Shaders.metallib +0 -0
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js +128 -68
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js.map +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js +39 -12
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js.map +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js +38 -20
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js.map +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/index.js +0 -6
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/index.js.map +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/package.json +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js +28 -2
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js.map +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js +35 -8
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js.map +1 -1
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js +38 -20
- package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js.map +1 -1
- package/lib/module/lib/commonjs/package.json +9 -4
- package/lib/module/lib/commonjs/scripts/compile-shaders.sh +27 -0
- package/lib/module/lib/commonjs/src/GridRenderLayer.js +8 -0
- package/lib/module/lib/commonjs/src/GridRenderLayer.js.map +1 -1
- package/lib/module/lib/commonjs/src/WeatherLayerManager.js +5 -0
- package/lib/module/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js +128 -68
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js +39 -12
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js +38 -20
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/index.js +0 -6
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/index.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/package.json +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js +28 -2
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js +35 -8
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js.map +1 -1
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js +38 -20
- package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js.map +1 -1
- package/lib/module/package.json +9 -4
- package/lib/module/scripts/compile-shaders.sh +27 -0
- package/lib/module/src/GridRenderLayer.js +8 -0
- package/lib/module/src/GridRenderLayer.js.map +1 -1
- package/lib/module/src/WeatherLayerManager.js +5 -0
- package/lib/module/src/WeatherLayerManager.js.map +1 -1
- package/lib/typescript/src/GridRenderLayer.d.ts.map +1 -1
- package/lib/typescript/src/WeatherLayerManager.d.ts.map +1 -1
- package/package.json +9 -4
- package/src/GridRenderLayer.js +13 -0
- package/src/WeatherLayerManager.js +7 -0
package/README.md
CHANGED
|
@@ -25,6 +25,72 @@ $RNMapboxMapsVersion = '~> 11.0' # This enforces Mapbox SDK v11
|
|
|
25
25
|
use_mapbox_maps!
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
### Enable Modular Headers (Required for New Architecture)
|
|
29
|
+
|
|
30
|
+
If you're using React Native's new architecture (`newArchEnabled: true`), you **must** enable modular headers.
|
|
31
|
+
|
|
32
|
+
#### For Expo Projects (Recommended)
|
|
33
|
+
|
|
34
|
+
If you're using Expo, add the `expo-build-properties` plugin to your `app.config.js` or `app.config.ts`:
|
|
35
|
+
```bash
|
|
36
|
+
npm install expo-build-properties
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then add it to your Expo config:
|
|
40
|
+
```typescript
|
|
41
|
+
// app.config.ts
|
|
42
|
+
export default {
|
|
43
|
+
// ... other config
|
|
44
|
+
plugins: [
|
|
45
|
+
// ... other plugins
|
|
46
|
+
[
|
|
47
|
+
'expo-build-properties',
|
|
48
|
+
{
|
|
49
|
+
ios: {
|
|
50
|
+
useFrameworks: 'static',
|
|
51
|
+
useModularHeaders: true, // Add this line
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Then run:
|
|
60
|
+
```bash
|
|
61
|
+
npx expo prebuild --clean
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### For Non-Expo React Native Projects
|
|
65
|
+
|
|
66
|
+
**Option 1: Enable modular headers globally (Recommended)**
|
|
67
|
+
|
|
68
|
+
Add this line after the `platform :ios` line in your `ios/Podfile`:
|
|
69
|
+
```ruby
|
|
70
|
+
platform :ios, '13.4'
|
|
71
|
+
use_modular_headers! # Add this line
|
|
72
|
+
|
|
73
|
+
prepare_react_native_project!
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Option 2: Enable modular headers in post_install hook**
|
|
77
|
+
|
|
78
|
+
Add this code inside your `post_install do |installer|` block:
|
|
79
|
+
```ruby
|
|
80
|
+
post_install do |installer|
|
|
81
|
+
# Enable modular headers for libzstd
|
|
82
|
+
installer.pods_project.targets.each do |target|
|
|
83
|
+
if target.name == 'libzstd'
|
|
84
|
+
target.build_configurations.each do |config|
|
|
85
|
+
config.build_settings['DEFINES_MODULE'] = 'YES'
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# ... rest of your existing post_install code
|
|
91
|
+
end
|
|
92
|
+
```
|
|
93
|
+
|
|
28
94
|
### Install Pods
|
|
29
95
|
|
|
30
96
|
After saving the Podfile, navigate to your `ios` directory in the terminal and run a fresh pod installation.
|
|
@@ -11,8 +11,6 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.platforms = { :ios => "13.4" }
|
|
12
12
|
s.source = { :git => "https://github.com/AguaceroWx/aguacero-sdks.git", :tag => "v#{s.version}" }
|
|
13
13
|
s.swift_version = "5.0"
|
|
14
|
-
|
|
15
|
-
# Add this line to make it a dynamic framework
|
|
16
14
|
s.static_framework = false
|
|
17
15
|
|
|
18
16
|
s.pod_target_xcconfig = {
|
|
@@ -26,9 +24,27 @@ Pod::Spec.new do |s|
|
|
|
26
24
|
'DEFINES_MODULE' => 'YES'
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
s.
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
s.resources = ['ios/compiled-shaders/*.metallib', 'ios/*.metal']
|
|
28
|
+
|
|
29
|
+
s.script_phases = [
|
|
30
|
+
{
|
|
31
|
+
:name => 'Copy Metal Shaders',
|
|
32
|
+
:script => 'echo "🔨 Copying Metal shaders..."
|
|
33
|
+
SHADER_DIR="${PODS_TARGET_SRCROOT}/ios/compiled-shaders"
|
|
34
|
+
METAL_SOURCE="${PODS_TARGET_SRCROOT}/ios/Shaders.metal"
|
|
35
|
+
|
|
36
|
+
if [ -f "$SHADER_DIR/Shaders.metallib" ]; then
|
|
37
|
+
cp -v "$SHADER_DIR/Shaders.metallib" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/" || true
|
|
38
|
+
echo "✅ Pre-compiled Metal shader copied"
|
|
39
|
+
elif [ -f "$METAL_SOURCE" ]; then
|
|
40
|
+
echo "⚠️ No pre-compiled shader found, will compile from source"
|
|
41
|
+
cp -v "$METAL_SOURCE" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/" || true
|
|
42
|
+
else
|
|
43
|
+
echo "❌ No Metal shaders found!"
|
|
44
|
+
fi',
|
|
45
|
+
:execution_position => :before_compile
|
|
46
|
+
}
|
|
47
|
+
]
|
|
32
48
|
|
|
33
49
|
s.source_files = "ios/**/*.{h,m,mm,swift}", "ios/generated/**/*.{h,m,mm,cpp}"
|
|
34
50
|
|
package/android/build.gradle
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// @aguacerowx/react-native/android/build.gradle
|
|
2
2
|
|
|
3
|
+
buildscript {
|
|
4
|
+
repositories {
|
|
5
|
+
google()
|
|
6
|
+
mavenCentral()
|
|
7
|
+
}
|
|
8
|
+
dependencies {
|
|
9
|
+
classpath("com.facebook.react:react-native-gradle-plugin")
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
3
13
|
repositories {
|
|
4
14
|
google()
|
|
5
15
|
mavenCentral()
|
|
@@ -17,6 +27,12 @@ repositories {
|
|
|
17
27
|
|
|
18
28
|
apply plugin: 'com.android.library'
|
|
19
29
|
|
|
30
|
+
def isNewArchEnabled = project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
31
|
+
|
|
32
|
+
if (isNewArchEnabled) {
|
|
33
|
+
apply plugin: "com.facebook.react"
|
|
34
|
+
}
|
|
35
|
+
|
|
20
36
|
android {
|
|
21
37
|
namespace 'com.aguacerowx.reactnative'
|
|
22
38
|
compileSdk 34
|
|
@@ -44,6 +60,13 @@ android {
|
|
|
44
60
|
}
|
|
45
61
|
}
|
|
46
62
|
|
|
63
|
+
if (isNewArchEnabled) {
|
|
64
|
+
react {
|
|
65
|
+
libraryName = "AguaceroWxReactNativeSpec"
|
|
66
|
+
codegenJavaPackageName = "com.aguacerowx.reactnative"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
47
70
|
dependencies {
|
|
48
71
|
implementation 'com.facebook.react:react-native:+'
|
|
49
72
|
api 'org.locationtech.proj4j:proj4j:1.1.5'
|
|
@@ -51,7 +74,14 @@ dependencies {
|
|
|
51
74
|
}
|
|
52
75
|
|
|
53
76
|
project.afterEvaluate {
|
|
54
|
-
//
|
|
77
|
+
// Fix Gradle 9 task dependency issue
|
|
78
|
+
if (isNewArchEnabled) {
|
|
79
|
+
tasks.named("generateCodegenArtifactsFromSchema").configure {
|
|
80
|
+
dependsOn("generateCodegenSchemaFromJavaScript")
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Mapbox version resolution
|
|
55
85
|
def resolvedMapboxVersion
|
|
56
86
|
if (project.rootProject.hasProperty('mapboxMapsVersion')) {
|
|
57
87
|
resolvedMapboxVersion = project.rootProject.mapboxMapsVersion
|
|
@@ -61,23 +91,17 @@ project.afterEvaluate {
|
|
|
61
91
|
println "[aguacerowx] WARNING: Could not find 'mapboxMapsVersion' property. Falling back to ${resolvedMapboxVersion}."
|
|
62
92
|
}
|
|
63
93
|
|
|
64
|
-
// 2. Detect if @rnmapbox/maps is present in the user's project
|
|
65
|
-
// We check the root project to see all included modules.
|
|
66
94
|
def rnMapboxIsPresent = project.rootProject.findProject(':rnmapbox_maps') != null
|
|
67
95
|
def mapboxArtifact
|
|
68
96
|
|
|
69
|
-
// 3. Choose the correct Mapbox artifact based on the detection
|
|
70
97
|
if (rnMapboxIsPresent) {
|
|
71
|
-
// If @rnmapbox/maps is present, we MUST use the ndk27 variant to avoid conflicts.
|
|
72
98
|
mapboxArtifact = "android-ndk27"
|
|
73
99
|
println "[aguacerowx] @rnmapbox/maps detected. Using Mapbox artifact: '${mapboxArtifact}' to ensure compatibility."
|
|
74
100
|
} else {
|
|
75
|
-
// If it's not present, use the standard 'android' variant.
|
|
76
101
|
mapboxArtifact = "android"
|
|
77
102
|
println "[aguacerowx] @rnmapbox/maps not detected. Using standard Mapbox artifact: '${mapboxArtifact}'."
|
|
78
103
|
}
|
|
79
104
|
|
|
80
|
-
// 4. Add the chosen Mapbox dependency using the version and artifact we just determined.
|
|
81
105
|
dependencies {
|
|
82
106
|
implementation "com.mapbox.maps:${mapboxArtifact}:${resolvedMapboxVersion}"
|
|
83
107
|
}
|
|
@@ -33,7 +33,7 @@ public class GridRenderLayer implements CustomLayerHost {
|
|
|
33
33
|
// Uniform and Attribute locations
|
|
34
34
|
private int uMatrix, uDataTexture, uColormapTexture, uOpacity, uDataRange,
|
|
35
35
|
uScale, uOffset, uMissingQuantized, uTextureSize, uConversionType, uSmoothing,
|
|
36
|
-
uScaleType;
|
|
36
|
+
uScaleType, uIsPtype;
|
|
37
37
|
private int aPosition, aTexCoord;
|
|
38
38
|
|
|
39
39
|
// GPU-side resource IDs
|
|
@@ -54,6 +54,8 @@ public class GridRenderLayer implements CustomLayerHost {
|
|
|
54
54
|
private int conversionType = 0;
|
|
55
55
|
private boolean smoothingEnabled = true;
|
|
56
56
|
private int scaleType = 0;
|
|
57
|
+
private boolean isPtype = false; // ADDED
|
|
58
|
+
private String currentVariable = "";
|
|
57
59
|
private boolean textureParametersDirty = true;
|
|
58
60
|
private volatile boolean isVisible = true;
|
|
59
61
|
|
|
@@ -120,9 +122,22 @@ public class GridRenderLayer implements CustomLayerHost {
|
|
|
120
122
|
uConversionType = GLES20.glGetUniformLocation(program, "u_conversion_type");
|
|
121
123
|
uSmoothing = GLES20.glGetUniformLocation(program, "u_smoothing");
|
|
122
124
|
uScaleType = GLES20.glGetUniformLocation(program, "u_scale_type");
|
|
125
|
+
uIsPtype = GLES20.glGetUniformLocation(program, "u_is_ptype");
|
|
123
126
|
aPosition = GLES20.glGetAttribLocation(program, "a_position");
|
|
124
127
|
aTexCoord = GLES20.glGetAttribLocation(program, "a_texCoord");
|
|
125
128
|
}
|
|
129
|
+
|
|
130
|
+
public void setVariable(String variable) {
|
|
131
|
+
if (variable == null) {
|
|
132
|
+
this.currentVariable = "";
|
|
133
|
+
} else {
|
|
134
|
+
this.currentVariable = variable;
|
|
135
|
+
}
|
|
136
|
+
// MODIFICATION: Add detailed logging here
|
|
137
|
+
this.isPtype = "ptypeRefl".equals(this.currentVariable) || "ptypeRate".equals(this.currentVariable);
|
|
138
|
+
Log.d(TAG, "setVariable called. Variable: '" + this.currentVariable + "', isPtype set to: " + this.isPtype);
|
|
139
|
+
}
|
|
140
|
+
|
|
126
141
|
|
|
127
142
|
public void clearData() {
|
|
128
143
|
this.isVisible = false;
|
|
@@ -243,6 +258,7 @@ public class GridRenderLayer implements CustomLayerHost {
|
|
|
243
258
|
GLES20.glUniform1i(uConversionType, conversionType);
|
|
244
259
|
GLES20.glUniform1i(uSmoothing, smoothingEnabled ? 1 : 0);
|
|
245
260
|
GLES20.glUniform1i(uScaleType, this.scaleType);
|
|
261
|
+
GLES20.glUniform1i(uIsPtype, this.isPtype ? 1 : 0);
|
|
246
262
|
|
|
247
263
|
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
|
|
248
264
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, dataTextureId);
|
|
@@ -297,4 +297,9 @@ public class GridRenderLayerView extends FrameLayout {
|
|
|
297
297
|
gridLayerImplementation.clearData();
|
|
298
298
|
triggerRepaint();
|
|
299
299
|
}
|
|
300
|
+
|
|
301
|
+
public void setVariable(String variable) {
|
|
302
|
+
gridLayerImplementation.setVariable(variable);
|
|
303
|
+
triggerRepaint();
|
|
304
|
+
}
|
|
300
305
|
}
|
|
@@ -21,6 +21,7 @@ public class GridRenderManager extends SimpleViewManager<GridRenderLayerView> {
|
|
|
21
21
|
private static final int COMMAND_UPDATE_GEOMETRY = 3;
|
|
22
22
|
private static final int COMMAND_UPDATE_DATA_PARAMETERS = 4;
|
|
23
23
|
private static final int COMMAND_CLEAR = 5;
|
|
24
|
+
private static final int COMMAND_SET_VARIABLE = 6;
|
|
24
25
|
|
|
25
26
|
@NonNull
|
|
26
27
|
@Override
|
|
@@ -68,6 +69,7 @@ public class GridRenderManager extends SimpleViewManager<GridRenderLayerView> {
|
|
|
68
69
|
commands.put("updateGeometry", COMMAND_UPDATE_GEOMETRY);
|
|
69
70
|
commands.put("updateDataParameters", COMMAND_UPDATE_DATA_PARAMETERS);
|
|
70
71
|
commands.put("clear", COMMAND_CLEAR);
|
|
72
|
+
commands.put("setVariable", COMMAND_SET_VARIABLE);
|
|
71
73
|
return commands;
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -113,6 +115,12 @@ public class GridRenderManager extends SimpleViewManager<GridRenderLayerView> {
|
|
|
113
115
|
case COMMAND_CLEAR:
|
|
114
116
|
view.clearData();
|
|
115
117
|
break;
|
|
118
|
+
|
|
119
|
+
case COMMAND_SET_VARIABLE:
|
|
120
|
+
if (args != null && args.size() > 0) {
|
|
121
|
+
view.setVariable(args.getString(0));
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
}
|
|
@@ -5,94 +5,148 @@ varying vec2 v_texCoord;
|
|
|
5
5
|
|
|
6
6
|
uniform sampler2D u_data_texture;
|
|
7
7
|
uniform sampler2D u_colormap_texture;
|
|
8
|
+
|
|
9
|
+
// Data parameters
|
|
8
10
|
uniform float u_scale;
|
|
9
11
|
uniform float u_offset;
|
|
10
12
|
uniform float u_missing_quantized;
|
|
13
|
+
uniform int u_scale_type; // 0 for linear, 1 for sqrt
|
|
14
|
+
|
|
15
|
+
// Style parameters
|
|
11
16
|
uniform float u_opacity;
|
|
12
17
|
uniform vec2 u_data_range;
|
|
18
|
+
|
|
19
|
+
// Rendering parameters
|
|
13
20
|
uniform vec2 u_texture_size;
|
|
14
21
|
uniform int u_smoothing;
|
|
22
|
+
uniform int u_is_ptype; // ADDED: Flag for ptype variables
|
|
15
23
|
|
|
16
|
-
// ---
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
vec2 pixel_floor = floor(pixel_coord - 0.5) + 0.5;
|
|
27
|
-
vec2 f = pixel_coord - pixel_floor;
|
|
28
|
-
|
|
29
|
-
// Sample the 2x2 grid
|
|
30
|
-
float s00 = texture2D(u_data_texture, (pixel_floor + vec2(0.0, 0.0)) / u_texture_size).a * 255.0;
|
|
31
|
-
float s10 = texture2D(u_data_texture, (pixel_floor + vec2(1.0, 0.0)) / u_texture_size).a * 255.0;
|
|
32
|
-
float s01 = texture2D(u_data_texture, (pixel_floor + vec2(0.0, 1.0)) / u_texture_size).a * 255.0;
|
|
33
|
-
float s11 = texture2D(u_data_texture, (pixel_floor + vec2(1.0, 1.0)) / u_texture_size).a * 255.0;
|
|
34
|
-
|
|
35
|
-
// Check which samples are valid (not NaN)
|
|
36
|
-
bool valid00 = abs(s00 - missing_in_texture_range) >= 0.5;
|
|
37
|
-
bool valid10 = abs(s10 - missing_in_texture_range) >= 0.5;
|
|
38
|
-
bool valid01 = abs(s01 - missing_in_texture_range) >= 0.5;
|
|
39
|
-
bool valid11 = abs(s11 - missing_in_texture_range) >= 0.5;
|
|
40
|
-
|
|
41
|
-
// If ANY sample is NaN, return NaN (this pixel is on an edge)
|
|
42
|
-
if (!valid00 || !valid10 || !valid01 || !valid11) {
|
|
43
|
-
return missing_in_texture_range;
|
|
24
|
+
// --- HELPER FUNCTIONS ---
|
|
25
|
+
|
|
26
|
+
// Dequantizes a signed value (-127 to 127) into a physical value
|
|
27
|
+
float dequantize_val(float q_val) {
|
|
28
|
+
if (abs(q_val - u_missing_quantized) < 0.5) {
|
|
29
|
+
return -9999.0;
|
|
30
|
+
}
|
|
31
|
+
float intermediate = q_val * u_scale + u_offset;
|
|
32
|
+
if (u_scale_type == 1) { // 1 = sqrt
|
|
33
|
+
return intermediate * abs(intermediate);
|
|
44
34
|
}
|
|
35
|
+
return intermediate;
|
|
36
|
+
}
|
|
45
37
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
// Samples texture, converts 0-255 to signed -128-127 range.
|
|
39
|
+
// Returns a quantized value, or a large positive sentinel for missing data.
|
|
40
|
+
float get_value(vec2 coord) {
|
|
41
|
+
float value_0_to_255 = texture2D(u_data_texture, coord).a * 255.0;
|
|
42
|
+
float val = value_0_to_255 - 128.0;
|
|
43
|
+
float missing_in_texture_range_0_255 = u_missing_quantized + 128.0;
|
|
44
|
+
if (abs(value_0_to_255 - missing_in_texture_range_0_255) < 0.5) {
|
|
45
|
+
return 99999.0; // Sentinel for "missing"
|
|
46
|
+
}
|
|
47
|
+
return val;
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
//
|
|
53
|
-
float
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
// Maps a physical value to a precipitation type category
|
|
51
|
+
float get_ptype_from_physical(float val) {
|
|
52
|
+
if (val < 0.0) return -1.0; // Missing/Invalid
|
|
53
|
+
if (val < 100.0) return 0.0; // Rain
|
|
54
|
+
if (val < 200.0) return 1.0; // Mix
|
|
55
|
+
if (val < 300.0) return 2.0; // Snow
|
|
56
|
+
return 3.0; // Pellets
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
|
|
59
60
|
void main() {
|
|
60
|
-
|
|
61
|
-
float
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
float raw_value;
|
|
62
|
+
float total_weight = 1.0; // Used for alpha feathering at data edges
|
|
63
|
+
|
|
64
|
+
if (u_smoothing == 0) { // Nearest neighbor
|
|
65
|
+
float quantized_value = get_value(v_texCoord);
|
|
66
|
+
if (quantized_value >= 99999.0) {
|
|
67
|
+
discard;
|
|
68
|
+
}
|
|
69
|
+
raw_value = dequantize_val(quantized_value);
|
|
70
|
+
|
|
71
|
+
} else { // Bilinear interpolation
|
|
72
|
+
vec2 texel_size = 1.0 / u_texture_size;
|
|
73
|
+
vec2 tex_coord_in_texels = v_texCoord * u_texture_size;
|
|
74
|
+
vec2 bl_texel_index = floor(tex_coord_in_texels - 0.5);
|
|
75
|
+
vec2 f = fract(tex_coord_in_texels - 0.5); // Interpolation factors
|
|
76
|
+
|
|
77
|
+
// Coordinates of the 4 neighboring texels
|
|
78
|
+
vec2 v00_coord = (bl_texel_index + vec2(0.5, 0.5)) * texel_size;
|
|
79
|
+
vec2 v10_coord = (bl_texel_index + vec2(1.5, 0.5)) * texel_size;
|
|
80
|
+
vec2 v01_coord = (bl_texel_index + vec2(0.5, 1.5)) * texel_size;
|
|
81
|
+
vec2 v11_coord = (bl_texel_index + vec2(1.5, 1.5)) * texel_size;
|
|
82
|
+
|
|
83
|
+
if (u_is_ptype == 1) {
|
|
84
|
+
// --- PTYPE-SPECIFIC INTERPOLATION ---
|
|
85
|
+
float v00 = dequantize_val(get_value(v00_coord));
|
|
86
|
+
float v10 = dequantize_val(get_value(v10_coord));
|
|
87
|
+
float v01 = dequantize_val(get_value(v01_coord));
|
|
88
|
+
float v11 = dequantize_val(get_value(v11_coord));
|
|
89
|
+
|
|
90
|
+
float p00 = get_ptype_from_physical(v00);
|
|
91
|
+
float p10 = get_ptype_from_physical(v10);
|
|
92
|
+
float p01 = get_ptype_from_physical(v01);
|
|
93
|
+
float p11 = get_ptype_from_physical(v11);
|
|
94
|
+
|
|
95
|
+
// Determine the dominant precipitation type for this pixel
|
|
96
|
+
float dominant_ptype = -1.0;
|
|
97
|
+
if (p00 != -1.0) dominant_ptype = p00;
|
|
98
|
+
else if (p10 != -1.0) dominant_ptype = p10;
|
|
99
|
+
else if (p01 != -1.0) dominant_ptype = p01;
|
|
100
|
+
else if (p11 != -1.0) dominant_ptype = p11;
|
|
101
|
+
|
|
102
|
+
if (dominant_ptype == -1.0) discard;
|
|
103
|
+
|
|
104
|
+
// Interpolate ONLY the values that match the dominant ptype
|
|
105
|
+
float total_value = 0.0;
|
|
106
|
+
total_weight = 0.0;
|
|
107
|
+
if (p00 == dominant_ptype) { float w = (1.0-f.x)*(1.0-f.y); total_value+=v00*w; total_weight+=w; }
|
|
108
|
+
if (p10 == dominant_ptype) { float w = f.x*(1.0-f.y); total_value+=v10*w; total_weight+=w; }
|
|
109
|
+
if (p01 == dominant_ptype) { float w = (1.0-f.x)*f.y; total_value+=v01*w; total_weight+=w; }
|
|
110
|
+
if (p11 == dominant_ptype) { float w = f.x*f.y; total_value+=v11*w; total_weight+=w; }
|
|
111
|
+
|
|
112
|
+
if (total_weight <= 0.0) discard;
|
|
113
|
+
raw_value = total_value / total_weight;
|
|
114
|
+
|
|
115
|
+
// Force full alpha to prevent dark borders between ptype regions
|
|
116
|
+
total_weight = 1.0;
|
|
117
|
+
|
|
118
|
+
} else {
|
|
119
|
+
// --- STANDARD INTERPOLATION ---
|
|
120
|
+
float v00_q = get_value(v00_coord);
|
|
121
|
+
float v10_q = get_value(v10_coord);
|
|
122
|
+
float v01_q = get_value(v01_coord);
|
|
123
|
+
float v11_q = get_value(v11_coord);
|
|
124
|
+
|
|
125
|
+
float total_value_q = 0.0;
|
|
126
|
+
total_weight = 0.0;
|
|
127
|
+
if (v00_q < 99999.0) { float w = (1.0-f.x)*(1.0-f.y); total_value_q+=v00_q*w; total_weight+=w; }
|
|
128
|
+
if (v10_q < 99999.0) { float w = f.x*(1.0-f.y); total_value_q+=v10_q*w; total_weight+=w; }
|
|
129
|
+
if (v01_q < 99999.0) { float w = (1.0-f.x)*f.y; total_value_q+=v01_q*w; total_weight+=w; }
|
|
130
|
+
if (v11_q < 99999.0) { float w = f.x*f.y; total_value_q+=v11_q*w; total_weight+=w; }
|
|
131
|
+
|
|
132
|
+
if (total_weight <= 0.0) discard;
|
|
133
|
+
raw_value = dequantize_val(total_value_q / total_weight);
|
|
134
|
+
}
|
|
66
135
|
}
|
|
67
136
|
|
|
68
|
-
|
|
137
|
+
// --- COMMON FINAL STEPS ---
|
|
69
138
|
|
|
70
|
-
|
|
71
|
-
if (abs(value_in_texture - missing_in_texture_range) < 0.5) {
|
|
139
|
+
if (raw_value < u_data_range.x) {
|
|
72
140
|
discard;
|
|
73
141
|
}
|
|
74
142
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Step 2: Apply non-linear inverse scaling if specified
|
|
81
|
-
if (u_scale_type == 1) { // 1 represents 'sqrt'
|
|
82
|
-
// Square the intermediate value while preserving its sign
|
|
83
|
-
raw_value = intermediate_value * abs(intermediate_value);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// If the data is below the specified minimum range, make it invisible.
|
|
87
|
-
if (raw_value < u_data_range.x) {
|
|
143
|
+
float colormap_coord = clamp((raw_value - u_data_range.x) / (u_data_range.y - u_data_range.x), 0.0, 1.0);
|
|
144
|
+
vec4 color = texture2D(u_colormap_texture, vec2(colormap_coord, 0.5));
|
|
145
|
+
|
|
146
|
+
if (color.a < 0.1) {
|
|
88
147
|
discard;
|
|
89
148
|
}
|
|
90
149
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
colormap_coord = clamp(colormap_coord, 0.0, 1.0);
|
|
94
|
-
|
|
95
|
-
// Sample the colormap and apply opacity
|
|
96
|
-
vec4 color = texture2D(u_colormap_texture, vec2(colormap_coord, 0.5));
|
|
97
|
-
gl_FragColor = vec4(color.rgb, color.a * u_opacity);
|
|
150
|
+
float final_alpha = color.a * u_opacity * total_weight;
|
|
151
|
+
gl_FragColor = vec4(color.rgb * final_alpha, final_alpha);
|
|
98
152
|
}
|