opensensorhub / osh-core

OpenSensorHub Core Modules
http://docs.opensensorhub.org
Mozilla Public License 2.0
32 stars 16 forks source link

Walking parent components to find size component results in illegal state exception even if component found #132

Open nickgaray opened 4 years ago

nickgaray commented 4 years ago

AbstractArrayImpl.java getArraySizeComponent reports IllegalStateException even though sizeComponent is located as parentComponent is set to null if current parentComponent is the root component in the hierarchy. See image below for print statements depicting the search for Count ref id 'k'

image

In this case a DataRecord contains timestamp, count component, and data array component. When seeking data array's component (as it is variable) the parent component is retrieved, then its children are traversed to find the variable count component by id, even though match is found, the exception is still generated.

nickgaray commented 4 years ago

The issue may be at a higher level than reported. It may be the DataStructFilter is revisiting the data component hierarchy. DataComponent

First pass, TIME and COUNT are visited and COUNT component has correct Id Second pass, TIME and DATA ARRAY are visited and neither has correct id

alexrobin commented 4 years ago

It looks like the request is made to a component other than the root component. This results in a filtered output, where everything else that the requested component, the entity ID (if present) and the timestamp is stripped out. So, in this case, I believe the problem is caused by the array size component itself being stripped out.

So, to fix this, there should be a check to make sure that if a variable size component is requested, the array size component of that array must always be included in the output.

In the mean time, to avoid the problem, you can set observedProperty={definition URI of root component} in the SOS request instead.