S
S
se2711962021-05-09 22:10:28
JSON
se271196, 2021-05-09 22:10:28

How to process geojson coordinates with file deserialization?

deserialization of the geojson file, used special insertion as a json class to describe it.
public object[] coordinates { get; set; }
get objects

string jsonString = File.ReadAllText(path);            
Rootobject GJ = JsonSerializer.Deserialize<Rootobject>(jsonString);

There was a problem reading "coordinates". I need to pull out the values ​​and process let's find the average, max, etc.
but when I read it, I get the following.
Console.WriteLine(GJ.features[1].geometry.coordinates[0]);
[
                        [
                            [
                                30.46470800000,
                                59.89300470000
                            ],
                            [
                                30.46487460000,
                                59.89282660000
                            ],
                            [
                                30.46417270000,
                                59.89266140000
                            ],
                            [
                                30.46392510000,
                                59.89292610000
                            ],
                            [
                                30.46462700000,
                                59.89309130000
                            ],
                            [
                                30.46465360000,
                                59.89306280000
                            ],
                            [
                                30.46470800000,
                                59.89300470000
                            ]
                        ],
                        [
                            [
                                30.46419040000,
                                59.89274570000
                            ],
                            [
                                30.46459240000,
                                59.89283940000
                            ],
                            [
                                30.46449880000,
                                59.89294050000
                            ],
                            [
                                30.46409680000,
                                59.89284680000
                            ],
                            [
                                30.46419040000,
                                59.89274570000
                            ]
                        ]
                    ]

in another GJ.features[].geometry.coordinate may be
[
                    30.46396390000,
                    59.89615690000
                ]

Who faced similar problems? how did you decide?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
se271196, 2021-05-10
@se271196

options:
public double[][][] coordinates - error in conversion did not work
public List>> coordinates - error in conversion did not work
processing crutch
=> object.toString() Split(',') remove \n \r \ t (i.e. everything extra) worked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question