【问题标题】:Get Topojson from postgresql django从 postgresql django 获取 Topojson
【发布时间】:2019-02-26 19:27:27
【问题描述】:

我已经完成输入并运行了所有 geodjango 代码,它工作正常。但是我的数据一次又一次地变大,导致geojson的大小变大。 我使用此代码从 postgresql (postgis) 中读取数据库作为 geojson 并在传单中查看:

def testcrud_datasets(request):
    testcrud = serialize('geojson', Testcrud.objects.all())
    return HttpResponse(testcrud, content_type='json')

我读到的一些解决方案建议我应该使用 topojson,如何从我的 postgresql 数据库中获取 topojson 格式,因为序列化不支持 topojson 类型?

【问题讨论】:

    标签: python django geodjango topojson


    【解决方案1】:

    看起来您可以使用此库在客户端转换为 Topojson。

    https://github.com/topojson/topojson

    <script src="https://unpkg.com/topojson@3"></script>
    <script>
    
    var topology = topojson.topology({foo: geojson});
    
    </script>
    

    【讨论】:

      猜你喜欢
      • 2017-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-08
      • 1970-01-01
      • 2021-02-19
      • 2012-08-15
      相关资源
      最近更新 更多