2017-03-17 132 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的解決方案。

相關問題