xbikuna / nettopologysuite

Automatically exported from code.google.com/p/nettopologysuite
0 stars 0 forks source link

Deserialize array of complex objects that include geometry #148

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create an array of objects that includes a polygon geometry
2. Serialize array of objects using GeoJsonSerializer
3. Deserailize array of objects using GeoJsonSerializer

What is the expected output? What do you see instead?
Deserializing throws exception. 

What version of the product are you using? On what operating system?
NetTopologySuite 1.13.0.0

Please provide any additional information below.
Can be fixed by adding reader.Read() inside  GeometryConverter.cs before 
returning Polygon from ReadJson(...).

Original issue reported on code.google.com by christia...@enbio.se on 22 May 2013 at 8:50

GoogleCodeExporter commented 8 years ago
I've made some tests and the problem looks not related to the presence of a 
polygon object. I'm investigating...

Original comment by diegogu...@gmail.com on 28 May 2013 at 7:33

GoogleCodeExporter commented 8 years ago
Simply speaking, serializing an IGeometry[] array generates an INVALID GeoJson 
feature: even better, it generates a VALID GeoJSON fragment.
This looks the correct behavior, and using GeoJsonReader/Writer objects, you 
can't pass arrays as parameters.
Actually, you should use GeometryCollection objects to work with, ehm, 
collections.
See the attached the code I've used to test your issue.

An idea is to make GeoJsonSerializer class internal, or throws a specific 
exception that can help the user to understand where's the problem

Original comment by diegogu...@gmail.com on 28 May 2013 at 8:16

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the feedback! 

Original comment by christia...@enbio.se on 28 May 2013 at 11:01