首页 / 浏览问题 / 组件GIS / 问题详情
Toolkit.GeoJsonToGeometry返回是null
37EXP 2021年03月08日
iobject java ,GeoJson字符串转换为Gemetry返回为null,是什么原因?我传递的是String类型的geojson数据

如下:

{
    "type": "FeatureCollection",
    "features": [{
        "geometry": {
            "coordinates": [
                [
                    [
                        [
                            112.4774,
                            24.8459
                        ],
                        [
                            112.4778,
                            24.8459
                        ],
                        [
                            112.4777,
                            24.8458
                        ],
                        [
                            112.4776,
                            24.8458
                        ],
                        [
                            112.4776,
                            24.8458
                        ],
                        [
                            112.4774,
                            24.8459
                        ]
                    ]
                ]
            ],
            "type": "MultiPolygon"
        },
        "id": "水系面.1",
        "type": "Feature",
        "properties": {
            "Id": 0
        }
    }]
}

1个回答

你好,您的json参数设置,请参考范例:

String json2 = "{\"type\":\"Polygon\",\"coordinates\":[[[192.058133847925,450.239607082329],[362.877814602317,450.239607082329],[362.877814602317,13.1625292006452],[198.973910396686,28.377237607919],[187.908667918668,29.0688152627951],[192.058133847925,450.239607082329]]]}";
Geometry geo = Toolkit.GeoJsonToGeometry(json2);
System.out.println(geo);

2,842EXP 2021年03月08日
...