bilaldursun1 / nettopologysuite

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

Add support for FeatureCollection and extend NetTopologySuite.IO.GeoJSON to support it #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to add support for FeatureCollection to NetTopologySuite and 
extend NetTopologySuite.IO.GeoJSON to support it. I needed that for a project 
so I have written the code already. It might need some rework to fit into the 
NetTopologySuite architecture but it works fine as is also. See attached.

Original issue reported on code.google.com by jan...@gmail.com on 8 Aug 2012 at 9:03

Attachments:

GoogleCodeExporter commented 9 years ago
Interesting addition!.
Two things: 
1) have you some unit tests or some sample code to add?
2) we need to evaluate if this code can be added to current NTS trunk, or to 
current SharpMap trunk (NTS based). to me, the better place for IO 
functionalities is SharpMap, since NTS is simply a topology library.
anyway, thanks :)

Original comment by diegogu...@gmail.com on 13 Aug 2012 at 7:53

GoogleCodeExporter commented 9 years ago
Added code, with some changes, with commit 863: 
http://code.google.com/p/nettopologysuite/source/detail?r=863
Please check modifies: I've removed "EnumMemner" attribute from CRS code becsue 
unsupported with target framework. 
Hope that default Newtonsoft attributes are right.

Original comment by diegogu...@gmail.com on 13 Aug 2012 at 8:06

GoogleCodeExporter commented 9 years ago
Hi,

since I posted the code, I have written unit tests so here they are. I also 
cleaned the code a bit and resolved some code analysis errors. The removal of 
EnumMember attribute actually broke the unit tests as the casing was not 
correct. I fixed the issue by adding a simple JSON.NET converter that corrects 
the casing and no EnumMember attribute is required. So the modified code is 
also attached.

Pavel

Original comment by jan...@gmail.com on 13 Aug 2012 at 9:34

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
another issue with code youìve sent to me.
JsonSerializer.DateFormatHandling doesn't exists. We're using nuget 
<package id="Newtonsoft.Json" version="4.0.3" />
maybe we need a higher version?

Original comment by diegogu...@gmail.com on 13 Aug 2012 at 10:49

GoogleCodeExporter commented 9 years ago
I am using Newtonsoft.Json 4.5.8 - the latest. But you can remove that line of 
code completely because it is related to how Newtonsoft.Json formats dates. 
Prior to version 4.5 (you are using), the default date format for JSON 
serializing was as per Microsoft. However, since 4.5 the default date format 
was changed as specified by ISO 8601. Since you are using the older version, 
you don't need that line of code.

Pavel

Original comment by jan...@gmail.com on 13 Aug 2012 at 10:57

GoogleCodeExporter commented 9 years ago
committed updated code with changeset 865
AttributesTableConverterTest.WriteJsonTest fails in my machine due to 
attributes order. 
Interesting issue.

Original comment by diegogu...@gmail.com on 13 Aug 2012 at 11:06

GoogleCodeExporter commented 9 years ago
hmm, must be caused by different version of Newtonsoft.Json, it probably 
processes attributes differently. 

One thing I noticed with the changeset. Some of the classes should actually go 
to the core NetTopologySuite.Features namespace rather than to 
NetTopologySuite.IO.GeoJSON. I don't know whether you want to do it but e.g. 
FeatureCollection was supposed to sit side by side Feature class in 
NetTopologySuite.Feature namespace and similar with the others. If you check 
the namespaces in each file, that would be suggested location.

Original comment by jan...@gmail.com on 13 Aug 2012 at 11:20

GoogleCodeExporter commented 9 years ago
I d'n't like to move featurecollection side by side to feature, mailly because 
of JsonProperty attributes. FeatureCollection should be aware of Json 
serialization (My2Cents).
As first step I plan to let the code "as is", step 2 can be to create a 
"FeatureCollectionConverter" and remove JsonProperty attributes, then move 
FeatureCollection inside NTS assembly.

Original comment by diegogu...@gmail.com on 13 Aug 2012 at 5:13

GoogleCodeExporter commented 9 years ago
yep, that makes sense. Good luck

Original comment by jan...@gmail.com on 13 Aug 2012 at 5:47

GoogleCodeExporter commented 9 years ago
updated code with changeset 869. please check.

Original comment by diegogu...@gmail.com on 22 Aug 2012 at 7:19

GoogleCodeExporter commented 9 years ago
Any plans to implement the FeatureCollection deserializer part?
I would like to help but my attempts have failed. I've tried to implement the 
method ReadJson of the FeatureCollectionConverter class. 
Thanks.

Original comment by pazun...@gmail.com on 19 Nov 2012 at 9:53

GoogleCodeExporter commented 9 years ago
Hi,

I have since made a small modification to AttributeTable converter to support 
arrays. See the updated file attached. It might be worth adding it into the 
code base.

Btw. the code works fine, I just removed my original code and started using the 
code from NetTopologySuite.

I will work on the deserializer part soon as it came up in one of the projects 
I work on and will post it also.

Pavel

Original comment by jan...@gmail.com on 6 Aug 2013 at 3:50

Attachments:

GoogleCodeExporter commented 9 years ago
using the current trunk, the exception to handle is "ArgumentException" and not 
JsonWriterException.
Anyway, a code like this looks more correct to me:
writer.WritePropertyName(name);
object val = attributes[name];
serializer.Serialize(writer, val);  

Original comment by diegogu...@gmail.com on 19 Aug 2013 at 7:51

GoogleCodeExporter commented 9 years ago
please take alook at rev.1068:
https://code.google.com/p/nettopologysuite/source/detail?r=1068
I've added a small test to verify handling.

Original comment by diegogu...@gmail.com on 19 Aug 2013 at 7:54

GoogleCodeExporter commented 9 years ago
Looks good, thanks for adding that.

As promised, attached are files for reading GeoJSON including some unit tests. 
I started with the code from Trunk and then modified it to support reading of 
GeoJSON so in most converters, only ReadJson method has changed. I also had to 
make some modifications ot CoordinateConverter and GeometryConverter and marked 
the changed lines with '//PJANDA' so it would be easier for you to find them.

The files attached have different namespaces as I am referencing 
NetTopologySuite in my project and was overwriting only certain bits of it 
(rather than working with the full source code) so it will need some tweaking.

Let me know if you had any issues or questions. I will start using this code in 
a real project so in case I ran into some issues, I will post the fixes.

Good luck,
Pavel

Original comment by jan...@gmail.com on 19 Aug 2013 at 5:42

Attachments:

GoogleCodeExporter commented 9 years ago
applied patch with changeset: 1069 
https://code.google.com/p/nettopologysuite/source/detail?r=1069
Please can you take a look? Tests are all red but I fear to lose some detail...
BTW, Thanks for sharing this code :)

Original comment by diegogu...@gmail.com on 23 Aug 2013 at 12:40

GoogleCodeExporter commented 9 years ago
Hi,

I verified your updates and it is all fine, no detail lost. I also checked the 
tests and there is one test missing in AttributesTableConverterTest.cs and one 
was incorrect. Please find the fixed file attached.

Pavel

Original comment by jan...@gmail.com on 27 Aug 2013 at 8:39

Attachments:

GoogleCodeExporter commented 9 years ago
added with r1070: 
https://code.google.com/p/nettopologysuite/source/detail?r=1070
thanks for the check :)

Original comment by diegogu...@gmail.com on 27 Aug 2013 at 11:00