我有GeoJSON,存储的建筑数据作为坐标。
如果我将其拖放到谷歌地图上,将会渲染形状。我想学习如何在babylon.js
中使用GeoJSON编码的数据创建多边形。 JSON我在谈论:
{
"type":"FeatureCollection",
"features":[
{
"id":"w26358613",
"properties":{
"levels":8
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[ 13.426791, 52.518344 ],
[ 13.426866, 52.518303 ],
[ 13.426951, 52.51826 ],
[ 13.427045, 52.518216 ],
[ 13.427139, 52.518175 ],
[ 13.427233, 52.518136 ],
[ 13.427341, 52.518095 ],
[ 13.427484, 52.518046 ],
[ 13.427489, 52.51805 ],
[ 13.42749, 52.51805 ],
[ 13.427493, 52.518052 ],
[ 13.427677, 52.518013 ],
[ 13.427653, 52.517971 ],
[ 13.427668, 52.517968 ],
[ 13.42762, 52.517885 ],
[ 13.427605, 52.517887 ],
[ 13.42758, 52.517846 ],
[ 13.427396, 52.517885 ],
[ 13.427435, 52.517952 ],
[ 13.427253, 52.518014 ],
[ 13.427237, 52.517997 ],
[ 13.427073, 52.51806 ],
[ 13.427092, 52.518077 ],
[ 13.426946, 52.51814 ],
[ 13.426927, 52.518124 ],
[ 13.426775, 52.518198 ],
[ 13.426796, 52.518213 ],
[ 13.426662, 52.518285 ],
[ 13.426639, 52.518271 ],
[ 13.426558, 52.518318 ],
[ 13.426502, 52.518353 ],
[ 13.426503, 52.518354 ],
[ 13.426483, 52.518366 ],
[ 13.426559, 52.518474 ],
[ 13.426651, 52.51845 ],
[ 13.426643, 52.518438 ],
[ 13.426647, 52.518436 ],
[ 13.426641, 52.518433 ],
[ 13.426727, 52.51838 ],
[ 13.426791, 52.518344 ]
]
]
},
"type":"Feature"
}
]
}
感谢。
答案 0 :(得分:1)
您在GeoJSON中获得的是多边形点的地理坐标。 Google Maps API的作用是选择从这些坐标到2D坐标系的投影,可以在地图上绘制。 IIRC,Google Maps API使用spherical Mercator projection。因此,如果您使用您选择的投影中的公式(强烈建议使用墨卡托),您将获得一组2D协调,您可以使用它来创建Babylon.js使用的多边形,例如: PolygonMeshBuilder