简体   繁体   English

GeoDjango-LineStringField-如何使用? 我在哪里可以找到文件?

[英]GeoDjango - LineStringField - how to use it? Where do I find documentation?

Good day everyone. 今天是个好日子。

I'm using Django 1.6 with GeoDjango and Postgresql+PostGIS backend. 我正在将Django 1.6与GeoDjango和Postgresql + PostGIS后端一起使用。 I want to use LineStringField to save some routes. 我想使用LineStringField保存一些路由。 But I can't find any documentation about how to do it. 但我找不到有关如何执行操作的任何文档。 I have model, have LineStringField attribute - but what to do next? 我有模型,有LineStringField属性-但是下一步该怎么做?

Here https://docs.djangoproject.com/en/1.6/ref/contrib/gis/model-api/#linestringfield are only class names, nothing else. 这里https://docs.djangoproject.com/zh-CN/1.6/ref/contrib/gis/model-api/#linestringfield只是类名,仅此而已。 I also tried to google some examples, but it wasn't successful. 我也尝试过搜索一些示例,但没有成功。 Can you please point me where to search for it? 您能指出我在哪里搜索吗? And also I'll highly appreciate some examples of code - like creating object of model with LineStringField, saving it to DB and then getting points from it (to display on the map). 而且,我还将高度赞赏一些代码示例-例如,使用LineStringField创建模型对象,将其保存到DB,然后从中获取点(以显示在地图上)。

Ps Please sorry for my english. 附言:请为我的英语感到抱歉。

Finally I found it myself. 终于我自己找到了。 We need just to use coords property of LineStringField, like this: 我们只需要使用LineStringField的coords属性,如下所示:

>>> event.route.coords
((15.732421875, 8.5775756835938), (10.986328125, 3.3041381835938), (3.779296875, 10.862731933594), (-1.58203125, 7.8744506835938), (-4.74609375, 14.114685058594))
>>> event.route.x
[15.732421875, 10.986328125, 3.779296875, -1.58203125, -4.74609375]
>>> event.route.y
[8.5775756835938, 3.3041381835938, 10.862731933594, 7.8744506835938, 14.114685058594]
>>> event.route.json
'{ "type": "LineString", "coordinates": [ [ 15.732421875, 8.5775756835938 ], [ 10.986328125, 3.3041381835938 ], [ 3.779296875, 10.862731933594 ], [ -1.58203125, 7.8744506835938 ], [ -4.74609375, 14.114685058594 ] ] }'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM