Comments (9)
merged serializable
branch into master (7c32e28)
from citygml4j.
No considerations so far because I am using CityGML or CityJSON for de-/serialization. I like your idea and it shouldn't be too hard to implement it. Btw, your are talking about the classes in org.citygml4j.model
, right?
from citygml4j.
Correct! I think it is just a matter of adding the interface and potentially adding serialVersionUID
. Agreed that CityGML or CityJSON also works for serialization but a bit bloated for inter-process communication. If you are open to it I can submit a PR.
from citygml4j.
Yes, a PR would be great. I think, the root interface of all model classes is org.citygml4j.model.common.base.ModelObject
. So it should be sufficient to let this interface extend Serializable
.
I am not sure about the serialVersionUID
field. Is it required for every non-abstract class? Or is it sufficient to be present for the (abstract) root class of an inheritance chain to be considered for all classes in that inheritance chain? If the latter is possible, this would substantially reduce the effort.
from citygml4j.
I am not an expert in this space, but my sense is that any class which contains fields that you intend to be restored after deserialization need to be marked as Serializable
otherwise the default empty constructor will be called. So I think this means that most of the classes in the org.citygml4j.model
will need to explicitly implement Serializable
(and therefore should probably maintain their own serialVersionUID
).
from citygml4j.
I did a quick test. It seems to be sufficient to let the interface org.citygml4j.model.common.base.ModelObject
and the abstract class org.citygml4j.model.module.AbstractModule
extend resp. implement the Serializable
interface. After that I was able to serialize and deserialize a citygml4j object. Well, I have not worked with Java serialization before so I was surprised to learn that it is quite slow.
Afterwards, I added a serialVersionUID
to org.citygml4j.model.gml.base.AbstractGML
which is a base class for many citygml4j classes. With that change, I was not able to deserialize the object from my previous test anymore. So it seems to be sufficient to use serialVersionUID
on root classes of an inheritance chain.
from citygml4j.
You should read https://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-why-should-i-use-it
Afterwards, I added a serialVersionUID to org.citygml4j.model.gml.base.AbstractGML which is a base class for many citygml4j classes. With that change, I was not able to deserialize the object from my previous test anymore. So it seems to be sufficient to use serialVersionUID on root classes of an inheritance chain.
this conforms to the spec; because you now have a different version of the object so it is assumed incompatible.
if you always want to create compatible java serializations each generated class should have a serialVersionUID, it can be 1L, otherwise data may not be deserialized in a different JVM
from citygml4j.
@kainoa21 Sorry for not being very active on this lately. I pushed the implementation of the Serializable interface to the serializable
branch for testing. It required just a small change to the model classes as written above. And when using buffered input and output streams, serialization performance is just fine. So feel free to test the branch and provide feedback or edits.
@mprins Thanks for your input.
from citygml4j.
This is great @clausnagel and I have verified that is working for my use case. Thank you for enabling this!
from citygml4j.
Related Issues (20)
- conversion CityGML to CityJSON: empty list of CityObjects (<grp:CityObjectGroup> supported?) HOT 6
- citygml2cityjson: appearances are not converted HOT 8
- CityGML2CityJSON: SolitaryVegetationObject(s) in a CityObjectGroup are not converted HOT 2
- Failed to build JAXB context. HOT 8
- I want to read all type of citygml. HOT 4
- Cityjson Lod4 Marshaller HOT 1
- converstion CityGML --> CityJSON: how to create "geometre-templates"? HOT 1
- does citygml 4j support lidar data? HOT 1
- ADE Module HOT 4
- Seeking input on citygml4j 3.0 HOT 4
- citygml2cityjson HOT 3
- Ampersand character in attribute value HOT 2
- Add support for surfaces with gml:PolygonPatch HOT 1
- Add opening geometry to multiple wall surfaceMembers HOT 5
- CityModelWriter does not write CityModel ADE HOT 7
- v3.0.0-rc.2: AbstractGenericAttribute as Template HOT 7
- building v3.0.0-rc.3 fails HOT 4
- Pb with the CityJSON transform HOT 2
- CityJSON with "transform" ignored when converting to CityGML HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from citygml4j.