Skip to content

Commit

Permalink
Merge pull request #15 from MIERUNE/feature/add-function
Browse files Browse the repository at this point in the history
処理終了後にcsmap.tifをレイヤに追加
  • Loading branch information
Kanahiro authored Jun 7, 2024
2 parents 74d55d3 + dfc8a7e commit cbc549c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
18 changes: 12 additions & 6 deletions dem_to_csmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from PyQt5.QtWidgets import QDialog
from qgis.PyQt import uic
from qgis.utils import iface

from csmap_py.csmap import process

Expand All @@ -15,25 +16,30 @@ def __init__(self):

# ウィンドウタイトル
self.setWindowTitle("CSMap Plugin")
# ラスタデータのみ選択(現状tifのみにしています)
self.ui.mQgsFileWidget.setFilter('*.tif')
# QGISでサポートされているラスタデータのみ選択可能
self.ui.mQgsFileWidget.setFilter('*.tif;;*.tiff;;*.dt0;;*.dt1;;*.dt2;;*.dem;;*.asc;;*.adf;;*.hgt;;*.bil;;*.nc;;*.img;;*.flt;;*.bt;;*.xyz;;*.grd;;*.ter')
# 出力先をフォルダに指定
self.ui.mQgsFileWidget_.setStorageMode(1)

self.ui.pushButton_run.clicked.connect(self.get_and_show_input_text)
self.ui.pushButton_run.clicked.connect(self.convert_dem_to_csmap)
self.ui.pushButton_cancel.clicked.connect(self.close)

def get_and_show_input_text(self):
def convert_dem_to_csmap(self):
params = process.CsmapParams()

# 入力・出力をUIで操作
input_path = self.ui.mQgsFileWidget.filePath()
output_path = self.ui.mQgsFileWidget_.filePath()
output_dir = self.ui.mQgsFileWidget_.filePath()
output_path = os.path.join(output_dir, 'csmap.tif')

process.process(
input_path,
output_path=os.path.join(output_path, 'csmap.tif'),
output_path,
chunk_size=256,
params=params,
)

# csmap.tifをQGISに読み込む
iface.addRasterLayer(output_path)

self.close()
10 changes: 5 additions & 5 deletions dem_to_csmap.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>357</width>
<width>524</width>
<height>168</height>
</rect>
</property>
Expand Down Expand Up @@ -37,16 +37,16 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_run">
<widget class="QPushButton" name="pushButton_cancel">
<property name="text">
<string>Run</string>
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_cancel">
<widget class="QPushButton" name="pushButton_run">
<property name="text">
<string>Cancel</string>
<string>Run</string>
</property>
</widget>
</item>
Expand Down

0 comments on commit cbc549c

Please sign in to comment.