Copy link to clipboard
Copied
Attempting to crack the newest hardshell nut that's landed in front of me and thought I'd yet again turn to the experts. I started to research it but this one is waaaayyyyy beyond my limited ability.
For those not familiar with the Nautical Realm, here's a quick primer for Sea State (Beaufort Scale):
The Beaufort Scale is a not entirely objective method to rate the Sea State of any body of water on this planet assigning a numeric value from 0 to 12 -- there is an extended set of values from 13-17 but it is primarily only used in the S. China Sea. The Beaufort Scale is typically used for larger bodies, i.e. Great Lakes, Oceans, Seas, etc. and determined based on wind speed and wave height.
I'd like to have a custom keystroke limit the possible input for all three (3) fields while automating the assignment of the Sea State Field with an ability for the mariner to overwrite the "sea state" field as needed. Unfortunately, Mother Nature is not always consistent and it is possible to have low speed winds with a higher wave height leading to a more subjective assessment of sea state -- ambient air/bathythermographic temperature differentials, thermal layer depth, currents, and underwater seismic activity are the typical culprits for this potential discrepancy.
EDIT: I started drafting this yesterday but got pulled away for other stuff. In the interim and as of 15 minutes ago, my boss just dropped a Ship's Speed of Advance (SoA) pdf request on my lap -- it'll be based on extrapolating the minutes from a start & stop time input then using distance traveled to determine the actual ship's SoA. I haven't had time to research it yet but if anyone has come across this next particular headache already, I would be much obliged for the assist.
Again, my thanks and I hope everyone has a great day. 🙂
Very Respectfully,
Charlie
A regexp is not really needed for this. You can just set the field as having a Number format, or even as a drop-down, to limit what values the user can enter. However, you named both fields the same ("Wind Speed") which means they will always have the same value. You need to give each one a unique name.
Once you do that the calculation script for the Scale field is not too complicated. It can be something like this:
if (event.source && (event.source.name=="Wind Speed" || event.source.name=="Wave
...
Copy link to clipboard
Copied
So you want to calculate the Sea State field based on the table below it, but also allow the user to overwrite it manually, basically?
Copy link to clipboard
Copied
Yes, that is what I'd like to do, assuming it's even possible. It doesn't seem like it should be possible to modify an assigned 0-12 scale forcing a contradiction to what I'm assuming would end up being a regex limiting the inputs of the wind speed and wave height and their associated calculation creating the sea state -- which, I would think, would also require a regex limiting the user input.
Copy link to clipboard
Copied
A regexp is not really needed for this. You can just set the field as having a Number format, or even as a drop-down, to limit what values the user can enter. However, you named both fields the same ("Wind Speed") which means they will always have the same value. You need to give each one a unique name.
Once you do that the calculation script for the Scale field is not too complicated. It can be something like this:
if (event.source && (event.source.name=="Wind Speed" || event.source.name=="Wave Height")) {
var windSpeed = Number(this.getField("Wind Speed").valueAsString);
var waveHeight = Number(this.getField("Wave Height").valueAsString);
if (windSpeed<1 && waveHeight==0) event.value = 0;
else if ((windSpeed<=1 && windSpeed<=3) && (waveHeight>=0 && waveHeight<=1)) event.value = 0;
// etc.
}
The first line means the user will be able to manually overwrite the value. However, if they change one of other two fields after doing so, it will revert back to the automatically calculated one.
Copy link to clipboard
Copied