geoJson未经过验证

时间:2017-04-17 04:08:42

标签: javascript json geojson

我有以下geoJson多边形:

{"type": "Feature","geometry":{"type":"MultiPolygon", "coordinates":[[[[103.76772700000001,1.47063],[103.76772700000001,1.4795775862068967],[103.758794,1.4795775862068967],[103.758794,1.47063],[103.76772700000001,1.47063]]]]},"properties": {"number":"01"}},

{"type": "Feature","geometry":{"type":"MultiPolygon", "coordinates":[[[[104.00891800000001,1.47063],[104.00891800000001,1.4795775862068967],[103.99998500000001,1.4795775862068967],[103.99998500000001,1.47063],[104.00891800000001,1.47063]]]]},"properties": {"number":"03"}}

但是当我在geojson validator中验证它时会抛出EOF错误。但是,当我单独尝试每个时,它会验证为符合条件的geoJSON。所以我也试过这个。

"type":"FeatureCollection","features":[

 {"type": "Feature","geometry":{"type":"MultiPolygon", "coordinates":[[[[103.76772700000001,1.47063],[103.76772700000001,1.4795775862068967],[103.758794,1.4795775862068967],[103.758794,1.47063],[103.76772700000001,1.47063]]]]},"properties": {"number":"01"}},

 {"type": "Feature","geometry":{"type":"MultiPolygon", "coordinates":[[[[104.00891800000001,1.47063],[104.00891800000001,1.4795775862068967],[103.99998500000001,1.4795775862068967],[103.99998500000001,1.47063],[104.00891800000001,1.47063]]]]},"properties": {"number":"03"}}

]

但仍然引发了EOF错误。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:1)

它应该是一个JSON对象。您错过了{}

{
    "type": "FeatureCollection",
    "features": [

        {
            "type": "Feature",
            "geometry": {
                "type": "MultiPolygon",
                "coordinates": [
                    [
                        [
                            [103.76772700000001, 1.47063],
                            [103.76772700000001, 1.4795775862068967],
                            [103.758794, 1.4795775862068967],
                            [103.758794, 1.47063],
                            [103.76772700000001, 1.47063]
                        ]
                    ]
                ]
            },
            "properties": {
                "number": "01"
            }
        },

        {
            "type": "Feature",
            "geometry": {
                "type": "MultiPolygon",
                "coordinates": [
                    [
                        [
                            [104.00891800000001, 1.47063],
                            [104.00891800000001, 1.4795775862068967],
                            [103.99998500000001, 1.4795775862068967],
                            [103.99998500000001, 1.47063],
                            [104.00891800000001, 1.47063]
                        ]
                    ]
                ]
            },
            "properties": {
                "number": "03"
            }
        }

    ]
}