Skip to content

Commit c9b1e84

Browse files
authored
Merge pull request #130 from minorsecond/release-v1.0.0
Release v1.0.0
2 parents 3829af3 + 2c8d6a9 commit c9b1e84

File tree

9 files changed

+319
-85
lines changed

9 files changed

+319
-85
lines changed

.idea/inspectionProfiles/Project_Default.xml

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Jenkinsfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pipeline {
5151
steps {
5252
bat """call activate GIS-Helper
5353
call conda info --envs
54-
call pyinstaller --onefile gh-debug.spec"""
54+
call pyinstaller --onefile gh-release.spec"""
5555
}
5656
post {
5757
success {

gh-release.spec

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# -*- mode: python -*-
2+
3+
block_cipher = None
4+
5+
block_cipher = None
6+
import os
7+
from pathlib import Path
8+
from PyInstaller.utils.hooks import exec_statement
9+
10+
env_path = os.environ['CONDA_PREFIX']
11+
current_path = os.getcwd()
12+
home_path = str(Path.home())
13+
mpl_data_dir = exec_statement("import matplotlib; print(matplotlib._get_data_path())")
14+
linalg_dir = os.path.join(env_path, 'lib\\site-packages\\numpy\\linalg\\')
15+
16+
a = Analysis(['gh.py'],
17+
pathex=[current_path, os.path.join(env_path, '\\Library\\bin')],
18+
binaries=[(os.path.join(linalg_dir, "_umath_linalg.cp37-win_amd64.pyd"), "numpy\\linalg"),
19+
(os.path.join(linalg_dir, "lapack_lite.cp37-win_amd64.pyd"), "numpy\\linalg"),
20+
(os.path.join(env_path, "api-ms-win-crt-stdio-l1-1-0.dll"), "."),
21+
(os.path.join(env_path, "api-ms-win-crt-heap-l1-1-0.dll"), "."),
22+
(os.path.join(env_path, "api-ms-win-crt-math-l1-1-0.dll"), "."),
23+
(os.path.join(env_path, "api-ms-win-crt-runtime-l1-1-0.dll"), "."),
24+
(os.path.join(env_path, "api-ms-win-crt-string-l1-1-0.dll"), "."),
25+
(os.path.join(env_path, "api-ms-win-crt-convert-l1-1-0.dll"), ".")
26+
],
27+
datas=[('matplotlibrc', '.config'), (mpl_data_dir, 'matplotlib\\mpl-data')],
28+
hiddenimports=['numpy', 'packaging', 'matplotlib', 'tkinter', 'matplotlib.backends.backend_Qt5Agg', 'gishelper.ui', 'tkinter.filedialog', 'PyQt5'],
29+
#hookspath=['hooks'],
30+
runtime_hooks=[],
31+
excludes=[],
32+
win_no_prefer_redirects=False,
33+
win_private_assemblies=False,
34+
cipher=block_cipher)
35+
pyz = PYZ(a.pure, a.zipped_data,
36+
cipher=block_cipher)
37+
exe = EXE(pyz,
38+
a.scripts,
39+
exclude_binaries=True,
40+
name='gh',
41+
debug=True,
42+
strip=False,
43+
upx=False,
44+
console=False , icon='assets\\map.ico')
45+
coll = COLLECT(exe,
46+
a.binaries,
47+
a.zipfiles,
48+
a.datas,
49+
strip=False,
50+
upx=False,
51+
name='gh')

gh.py

+85-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from vector import meta
1111
from raster import measurements
1212
from spatial_functions.calculations import Convert, origin_calc
13+
from raster import meta as raster_functions
14+
from shapely.geometry import Polygon
15+
import shutil
16+
from PyQt5.QtWidgets import QHeaderView, QTableWidgetItem
1317

1418
anaconda_dir = os.path.join(str(Path.home()), "anaconda3\\envs\\GIS-Helper")
1519
print("Anaconda3 Dir: {}".format(anaconda_dir))
@@ -27,6 +31,20 @@ def __init__(self):
2731
self.setupUi(self)
2832
self.setFixedSize(self.size())
2933

34+
self.catalogTiffOutputWindow.setColumnCount(5)
35+
self.catalogTiffOutputWindow.setHorizontalHeaderLabels(['Filename',
36+
'ULX', 'ULY',
37+
'LRX', 'LRY'])
38+
39+
self.copyTiffOutputWindow.setColumnCount(2)
40+
self.copyTiffOutputWindow.setColumnWidth(0, 380)
41+
self.copyTiffOutputWindow.setColumnWidth(1, 379)
42+
self.copyTiffOutputWindow.setHorizontalHeaderLabels(["Source",
43+
"Destination"])
44+
45+
self.catalogTiffOutputWindow.horizontalHeader().\
46+
setSectionResizeMode(0, QHeaderView.Stretch)
47+
3048
self.shape_functions = meta.PolygonFunctions()
3149

3250
# GIS Calculator page
@@ -64,7 +82,7 @@ def browse_for_intersecting_shp(self):
6482
:return:
6583
"""
6684

67-
openfile = QtWidgets.QFileDialog.getOpenFileName(self)
85+
openfile = QtWidgets.QFileDialog.getOpenFileName(self, "Open Intersecting Shapefile", None, "shp(*.shp)")[0]
6886
self.intersectingShapefileEdit.setText(openfile)
6987

7088
def browse_for_tiff_directory(self):
@@ -239,36 +257,91 @@ def get_raster_bounds(self):
239257

240258
path = self.geoTiffDir1.text()
241259
output_path = self.TiffCatalogOutputEdit.text()
260+
fanout = False
261+
262+
if self.FanOutByRes.isChecked():
263+
fanout = True
264+
print("Fanning out by resolution.")
242265

243266
raster_count, raster_dictionary = measurements.\
244-
create_catalog(path, output_path)
267+
create_catalog(path, output_path, fanout)
245268

246269
output_text = "Finished processing {0} rasters.\n\n".\
247270
format(raster_count)
248271
output_text += 'Raster paths and bounds (ulX, ulY, lrX, lrY): \n'
249272

273+
row = 0
274+
self.catalogTiffOutputWindow.setRowCount(len(raster_dictionary))
250275
for filepath, bounds in raster_dictionary.items():
251-
output_text += '{0}: {1}\n\n'.format(filepath, bounds)
252-
253-
self.catalogTiffOutputWindow.setText(output_text)
276+
print(f"adding {filepath} to window.")
277+
print(bounds[1])
278+
279+
filename = os.path.basename(filepath)
280+
281+
self.catalogTiffOutputWindow.setItem(row, 0,
282+
QTableWidgetItem(filename))
283+
self.catalogTiffOutputWindow.\
284+
setItem(row, 1, QTableWidgetItem(str(bounds[0])))
285+
self.catalogTiffOutputWindow.\
286+
setItem(row, 2, QTableWidgetItem(str(bounds[1])))
287+
self.catalogTiffOutputWindow.\
288+
setItem(row, 3, QTableWidgetItem(str(bounds[2])))
289+
self.catalogTiffOutputWindow.\
290+
setItem(row, 4, QTableWidgetItem(str(bounds[3])))
291+
row += 1
254292

255293
return raster_count, raster_dictionary
256294

257295
def handle_tiff_copy(self):
258296
"""
259297
Handles code that copies tifs
260-
:return: IO
298+
:return: None
261299
"""
300+
rasters_by_resolution = {}
301+
resolution = None
262302

263303
tiff_directory = self.TiffDirectory.text()
264-
shapefile_directory = self.intersectingShapefileEdit.text()
304+
shapefile_path = self.intersectingShapefileEdit.text()
265305
output_directory = self.geoTiffOutputDirEdit.text()
266306

267-
payload = (tiff_directory, shapefile_directory, output_directory)
268-
269-
polygon_functions = meta.PolygonFunctions()
270-
polygon_functions.get_polygon_vertices(payload)
271-
307+
intersecting_rasters = raster_functions.\
308+
intersect_by_shape(tiff_directory, shapefile_path,
309+
output_directory)
310+
self.copyTiffOutputWindow.clear()
311+
312+
if self.CopyFanoutByResolution.isChecked():
313+
for raster_path in intersecting_rasters:
314+
row_position = self.copyTiffOutputWindow.rowCount()
315+
self.copyTiffOutputWindow.insertRow(row_position)
316+
resolution = measurements.get_resolution(raster_path)
317+
318+
# Create resolution directory name
319+
resolution = f"{resolution[0]}x{resolution[1]}"
320+
output_basedir = os.path.join(output_directory, resolution)
321+
if not os.path.exists(output_basedir):
322+
os.mkdir(output_basedir)
323+
output_filename = os.path.basename(raster_path)
324+
output_raster_path = os.path.join(output_basedir,
325+
output_filename)
326+
shutil.copy(raster_path, output_raster_path)
327+
328+
self.copyTiffOutputWindow.setItem(row_position, 0,
329+
QTableWidgetItem(raster_path))
330+
self.copyTiffOutputWindow.setItem(row_position, 1,
331+
QTableWidgetItem(output_raster_path))
332+
self.copyTiffOutputWindow.resizeRowsToContents()
333+
else:
334+
for raster_path in intersecting_rasters:
335+
row_position = self.copyTiffOutputWindow.rowCount()
336+
self.copyTiffOutputWindow.insertRow(row_position)
337+
output_path = os.path.join(output_directory,
338+
os.path.basename(raster_path))
339+
shutil.copy(raster_path, output_path)
340+
self.copyTiffOutputWindow.setItem(row_position, 0,
341+
QTableWidgetItem(raster_path))
342+
self.copyTiffOutputWindow.setItem(row_position, 1,
343+
QTableWidgetItem(output_path))
344+
self.copyTiffOutputWindow.resizeRowsToContents()
272345
def get_origin(self):
273346
"""
274347
Button function to get origin calculation. Runs the origin_calc()

gisHelperGui.ui

+23-35
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<bool>false</bool>
4848
</property>
4949
<property name="currentIndex">
50-
<number>1</number>
50+
<number>2</number>
5151
</property>
5252
<widget class="QWidget" name="gisCalc">
5353
<attribute name="title">
@@ -668,26 +668,7 @@
668668
<string>Browse</string>
669669
</property>
670670
</widget>
671-
<widget class="QTextEdit" name="catalogTiffOutputWindow">
672-
<property name="geometry">
673-
<rect>
674-
<x>10</x>
675-
<y>192</y>
676-
<width>755</width>
677-
<height>325</height>
678-
</rect>
679-
</property>
680-
<property name="font">
681-
<font>
682-
<family>Helvetica</family>
683-
<pointsize>11</pointsize>
684-
</font>
685-
</property>
686-
<property name="readOnly">
687-
<bool>true</bool>
688-
</property>
689-
</widget>
690-
<widget class="QCheckBox" name="checkBox">
671+
<widget class="QCheckBox" name="FanOutByRes">
691672
<property name="geometry">
692673
<rect>
693674
<x>12</x>
@@ -771,6 +752,16 @@
771752
<string>Process</string>
772753
</property>
773754
</widget>
755+
<widget class="QTableWidget" name="catalogTiffOutputWindow">
756+
<property name="geometry">
757+
<rect>
758+
<x>10</x>
759+
<y>190</y>
760+
<width>761</width>
761+
<height>341</height>
762+
</rect>
763+
</property>
764+
</widget>
774765
</widget>
775766
<widget class="QWidget" name="copyTiffs">
776767
<attribute name="title">
@@ -899,7 +890,7 @@
899890
<string>Browse</string>
900891
</property>
901892
</widget>
902-
<widget class="QCheckBox" name="checkBox_2">
893+
<widget class="QCheckBox" name="CopyFanoutByResolution">
903894
<property name="geometry">
904895
<rect>
905896
<x>12</x>
@@ -917,19 +908,6 @@
917908
<string>Fan out by resolution</string>
918909
</property>
919910
</widget>
920-
<widget class="QTextEdit" name="catalogTiffOutputWindow_2">
921-
<property name="geometry">
922-
<rect>
923-
<x>10</x>
924-
<y>192</y>
925-
<width>755</width>
926-
<height>325</height>
927-
</rect>
928-
</property>
929-
<property name="readOnly">
930-
<bool>true</bool>
931-
</property>
932-
</widget>
933911
<widget class="QProgressBar" name="progressBar">
934912
<property name="geometry">
935913
<rect>
@@ -956,6 +934,16 @@
956934
<string>Process</string>
957935
</property>
958936
</widget>
937+
<widget class="QTableWidget" name="copyTiffOutputWindow">
938+
<property name="geometry">
939+
<rect>
940+
<x>10</x>
941+
<y>190</y>
942+
<width>761</width>
943+
<height>341</height>
944+
</rect>
945+
</property>
946+
</widget>
959947
</widget>
960948
<widget class="QWidget" name="qkShp">
961949
<attribute name="title">

0 commit comments

Comments
 (0)