英文:
Use JPA to store data in Array-list of coordinates as a polygon in spring-boot
问题
"boundary": {
"type": "Polygon",
"coordinates": [
[
[-73.9493302, 40.7851967],
[-73.9538181, 40.7870864],
[-73.9541536, 40.7872279],
[-73.9557237, 40.7878894],
[-73.9604089, 40.7815447],
[-73.9539823, 40.7788333],
[-73.9493302, 40.7851967]
]
]
}
我从API获取到了上述数据,我有用于保存所有其他数据的POJO。然而,我无法从这些坐标创建一个多边形,以便将其保存在MySQL中并在以后检索。
@JsonProperty("coordinates")
private Polygon geometry;
上述方法不起作用。我在这方面相对较新,所以任何帮助都受欢迎。
<details>
<summary>英文:</summary>
"boundary": {
"type": "Polygon",
"coordinates": [
[
[
-73.9493302,
40.7851967
],
[
-73.9538181,
40.7870864
],
[
-73.9541536,
40.7872279
],
[
-73.9557237,
40.7878894
],
[
-73.9604089,
40.7815447
],
[
-73.9539823,
40.7788333
],
[
-73.9493302,
40.7851967
]
]
]
}
I am getting the above data from an API and I have POJOs to save all the other data. I am however failing to create a polygon from the coordinates in order to save it in MySQL and retrieve later.
@JsonProperty("coordinates")
private Polygon geomertry;
The above won't work. I am fairly new to this so any help is welcome.
</details>
# 答案1
**得分**: 1
你必须使用数组或`List`。
@JsonProperty("coordinates")
private double[][][] geomertry;
<details>
<summary>英文:</summary>
You have to use arrays or `List`.
@JsonProperty("coordinates")
private double[][][] geomertry;
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论