Announcement

Collapse

WorldWind project shut down, this site probably will be too.

Hello all,

With the recent announcement that the NASA World Wind project has been shut down (https://worldwind.arc.nasa.gov/news/...ension-notice/) there is really very little reason to continue running this forum, and as NASA staff were providing most of the moderation and responses it will likely fill up with spam shortly.

Unless something changes in the near future, I will be shutting down worldwindcentral.com as well as this forum, as it is no longer useful. Most of the data on WWC is referencing the legacy C# version of World Wind anyway.

Thanks,
Matt.
See more
See less

Serializable Angle, LatLon, Position

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Serializable Angle, LatLon, Position

    Hi, all. I have a feature request, but wasn't sure if it's valid. Would it be possible to make Angle, LatLon, and Position implement Serializable? I find it quite handy to use them in various classes in my app as basic location types, but one requirement I have is that my classes must be serializable. I've been messing around with setting up serialization proxies for them, but can't find a solution that would be as elegant as just having an "implements Serializable" added to those three classes. If need be, I'd be happy to log an issue/pull request on GitHub, just thought I'd check here first if this made sense.

  • #2
    I second this. I've had to hack around these classes to make them serialize by making "wrapper" classes with a default constructor. Very hacky:

    Code:
    class SerializablePosition implements Serializable {
    
        /** The Constant serialVersionUID. */
        private static final long serialVersionUID = 1L;
    
        transient private Position position;
    
        public SerializablePosition() {
    
        }
    
        public SerializablePosition(Position positionVal) {
            this.position = positionVal;
        }
    
        public Position getPosition() {
            return position;
        }
    
    
        private void writeObject(final java.io.ObjectOutputStream out)
                throws IOException {
    
            out.writeDouble(position.latitude.getDegrees());
            out.writeDouble(position.longitude.getDegrees());
            out.writeDouble(position.getAltitude());
    
        }
    
        private void readObject(final java.io.ObjectInputStream in)
                throws IOException {
    
            try {
                in.defaultReadObject();
                final double lat = in.readDouble();
                final double lon = in.readDouble();
                final double alt = in.readDouble();
    
                position = Position.fromDegrees(lat, lon, alt);
    
            } catch (final ClassNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
        }
    
    }

    Comment

    Working...
    X