-
Notifications
You must be signed in to change notification settings - Fork 334
Closed
Labels
Description
Bug report
Describe the bug
QuPath can (attempt to) export GeoJSON containing NaNs, but can't then read the GeoJSON it has written itself.
See https://forum.image.sc/t/qupath-object-import-via-geojson-file-error/85384 for the initial bug report.
To Reproduce
Run the following script:
def json = """
{
"type": "Feature",
"id": "d0852662-6941-4506-bc90-cbda1c2fa7b0",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[44196, 21480],
[44420, 21480],
[44420, 21687],
[44196, 21687],
[44196, 21480]
]
]
},
"properties": {
"objectType": "annotation",
"measurements": {
"Anything": NaN,
"Anything else": 2.0
}
}
}
"""
def po = GsonTools.getInstance().fromJson(json, PathObject)The result is an exception
class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap') in QuPathScript at line number 27
ERROR: qupath.lib.measurements.MeasurementList.putAll(MeasurementList.java:234)
qupath.lib.io.QuPathTypeAdapters$MeasurementListTypeAdapter.read(QuPathTypeAdapters.java:679)
qupath.lib.io.QuPathTypeAdapters$MeasurementListTypeAdapter.read(QuPathTypeAdapters.java:634)
com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:296)
qupath.lib.io.QuPathTypeAdapters$PathObjectTypeAdapter.parseObject(QuPathTypeAdapters.java:535)
qupath.lib.io.QuPathTypeAdapters$PathObjectTypeAdapter.read(QuPathTypeAdapters.java:464)
qupath.lib.io.QuPathTypeAdapters$PathObjectTypeAdapter.read(QuPathTypeAdapters.java:280)
com.google.gson.Gson.fromJson(Gson.java:1214)
Expected behavior
NaNs import properly... and export is also handled properly (whatever way that is).
Desktop (please complete the following information):
- OS: All
- QuPath Version: 0.4.3 (but likely before)
Reactions are currently unavailable