2017-03-17 160 views
0

我正在使用OGR2OGR将geojson文件转换为dxf格式。 它在本地服务器上工作,但在heroku服务器上不工作。这是使用genrating文件 查找代码:如何在heroku服务器上运行系统命令?

  str2 = { 
      "type":"FeatureCollection", 
      "features":[ 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@substation]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@feeder]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@form3]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@pdt_array]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@edt_array]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@composite_array]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@al_array]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@tp_array]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"Point","coordinates":[@ot_array]}}, 
       {"type":"Feature","properties":{"color":"red"},"geometry":{"type":"LineString","coordinates":[@lt_array,@ht_array,@consumer_array]}} 
       ]} 

    path = "#{Rails.root}/public/data.geojson" 
    File.open(path, "w+") do |f| 
    f.write(JSON.pretty_generate(str2)) 
    end 
    system("ogr2ogr -f DXF #{Rails.root}/public/delhiii.dxf #{Rails.root}/public/data.geojson") 

回答

0

的Heroku不会让你直接将文件保存到自己的文件系统。有一种叫做Ephemeral filesystem的东西,但它不可靠。我会建议使用S3来保存文件。

此外,Heroku不会让你安装外部库(ogr2ogr)。有时你可以用二进制文件获得宝石(如wkhtmltopdf-binary gem),但我找不到ogr2ogr的解决方案。

相关问题