This seems to be an occurrence with methods that return iterable types. My specific example is utilizing FieldOfView.getFootprint()
The return type is java.util.List[java.util.List[org.orekit.bodies.GeodeticPoint]]
so it returns a list of lists of points. When accessing the sublist inside the main list, the return is a java Object class and only methods native to that base class are available.
object = footprint_raw.get(0)
print(type(object))
print(object.getClass())
<class 'java.lang.Object'>
class java.util.ArrayList
This is easy enough to recover from by creating a new instance from the object because an ArrayList can be initialized from another Array List
shape = java.util.ArrayList(object)
Now we have shape which is a list of GeodeticPoint
but when trying to access a point the return type is once again just the Object
base class
point = shape.get(0)
print(point)
print(type(point))
print(point.getClass())
{lat: 9.9077704309 deg, lon: 61.472804441 deg, alt: 0}
<class 'java.lang.Object'>
class org.orekit.bodies.GeodeticPoint
None of the methods from GeodeticPoint
are available when using Python, only base Object
methods are. For example:
point.getLatitude()
results in
point.getLatitude()
^^^^^^^^^^^^^^^^^
AttributeError: 'Object' object has no attribute 'getLatitude'
Is there a way to get an actual GeodeticPoint
instance without calling .toString()
and parsing out the values to initialize new instances? That would work in a bind for a simple class like this but would not be feasible for other classes who need more complex variable types in their __init__()
.
One thing I did try was point.clone()
to see what type gets returned but even though it’s a method of the Object
class it is not implemented and fails.
In short how do I get access to the methods of an implemented class in Python when it thinks my object is Object
even though it is implementing an actual Orekit class
Thanks in advance!