-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[GEOT-7422] Adapt to GeoTools upgrade of java units "indriya" to version 2.2 #7545
Conversation
|
||
package org.geoserver.netcdf; | ||
|
||
import org.geotools.imageio.netcdf.NetCDFUnitFormat; |
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.
This is not going to work. The units configuration is there to support reads too (see VariableAdapter usage in GeoTools), otherwise the class would be placed in netcdf-out.
However, I don't see why you can't use NetCDFUnitFormat directly, rather than creating NetCDFUnitFormatInstance (all it does is to create a second instance of the format, that is then being re-configured).
If mutability is the issue, thinking out loud, we could have a way to build a new NetCDFUnitFormat internal instance, and just throw away the old one: this way the unit format would be immutable, for as long as it lives. Just inform the callers not to cache the formatter instance, but always get it fresh from NetCDFUnitFormat.
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.
Thanks! You mean that we also use that instance from VariableAdapter
then?
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.
I mean the configuration file in GeoServer should affect also VariableAdapter parsing. In other words, the configuration is used also to parse NetCDF files with uncommon units, and not only to control the generation of new NetCDFs in the GeoServer output format.
Another thing I've noticed, gs-main won't build unless I control the unit-api dependency in the main GeoServer pom file, adding it to the dependency management. |
Thanks, will try addressing these things! |
…d NetCDFUnitFormat instance instead of global state
e1c89e3
to
a032b2f
Compare
Reverted the undesired changes, added the unit-api dependency. |
@@ -40,7 +40,7 @@ private void configure() { | |||
LinkedHashMap<String, String> aliases = | |||
getMapResource(NETCDF_UNIT_ALIASES, NetCDFUnitFormat.NETCDF_UNIT_ALIASES); | |||
if (aliases != null) { | |||
NetCDFUnitFormat.setAliases(aliases); | |||
NetCDFUnitFormat.getInstance().setAliases(aliases); |
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.
The changes look good but setAliases is private in the GeoTools PR.
Did you forget to push some changes over there?
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.
Not sure, but I updated the PR to keep them public
, can you try again? :-)
@@ -51,7 +51,7 @@ private void configure() { | |||
getMapResource( | |||
NETCDF_UNIT_REPLACEMENTS, NetCDFUnitFormat.NETCDF_UNIT_REPLACEMENTS); | |||
if (replacements != null) { | |||
NetCDFUnitFormat.setReplacements(replacements); | |||
NetCDFUnitFormat.getInstance().setReplacements(replacements); |
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.
Same as above, this is also private in the corresponding GeoTools PR.
Looks good, thanks, merging! |
Companion change to geotools/geotools#4690.
Checklist
main
branch (backports managed later; ignore for branch specific issues).For core and extension modules:
[GEOS-XYZWV] Title of the Jira ticket
.