2017-03-17 9 views
0

私はgeojsonファイルをdxf形式に変換するためにOGR2OGRを使用しています。 ローカルサーバ上で動作していますが、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を使ってファイルを保存することをお勧めします。

また、外部ライブラリ(ogr2ogr)をインストールすることもできません。場合によってはバイナリ(wkhtmltopdf-binary gemなど)で宝石を手に入れることができますが、私はogr2ogrのような解決策を見つけることができません。

関連する問題