Skip to content

Commit

Permalink
Merge pull request #130 from minorsecond/release-v1.0.0
Browse files Browse the repository at this point in the history
Release v1.0.0
  • Loading branch information
minorsecond authored Sep 11, 2020
2 parents 3829af3 + 2c8d6a9 commit c9b1e84
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 85 deletions.
14 changes: 14 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pipeline {
steps {
bat """call activate GIS-Helper
call conda info --envs
call pyinstaller --onefile gh-debug.spec"""
call pyinstaller --onefile gh-release.spec"""
}
post {
success {
Expand Down
51 changes: 51 additions & 0 deletions gh-release.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# -*- mode: python -*-

block_cipher = None

block_cipher = None
import os
from pathlib import Path
from PyInstaller.utils.hooks import exec_statement

env_path = os.environ['CONDA_PREFIX']
current_path = os.getcwd()
home_path = str(Path.home())
mpl_data_dir = exec_statement("import matplotlib; print(matplotlib._get_data_path())")
linalg_dir = os.path.join(env_path, 'lib\\site-packages\\numpy\\linalg\\')

a = Analysis(['gh.py'],
pathex=[current_path, os.path.join(env_path, '\\Library\\bin')],
binaries=[(os.path.join(linalg_dir, "_umath_linalg.cp37-win_amd64.pyd"), "numpy\\linalg"),
(os.path.join(linalg_dir, "lapack_lite.cp37-win_amd64.pyd"), "numpy\\linalg"),
(os.path.join(env_path, "api-ms-win-crt-stdio-l1-1-0.dll"), "."),
(os.path.join(env_path, "api-ms-win-crt-heap-l1-1-0.dll"), "."),
(os.path.join(env_path, "api-ms-win-crt-math-l1-1-0.dll"), "."),
(os.path.join(env_path, "api-ms-win-crt-runtime-l1-1-0.dll"), "."),
(os.path.join(env_path, "api-ms-win-crt-string-l1-1-0.dll"), "."),
(os.path.join(env_path, "api-ms-win-crt-convert-l1-1-0.dll"), ".")
],
datas=[('matplotlibrc', '.config'), (mpl_data_dir, 'matplotlib\\mpl-data')],
hiddenimports=['numpy', 'packaging', 'matplotlib', 'tkinter', 'matplotlib.backends.backend_Qt5Agg', 'gishelper.ui', 'tkinter.filedialog', 'PyQt5'],
#hookspath=['hooks'],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='gh',
debug=True,
strip=False,
upx=False,
console=False , icon='assets\\map.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name='gh')
97 changes: 85 additions & 12 deletions gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from vector import meta
from raster import measurements
from spatial_functions.calculations import Convert, origin_calc
from raster import meta as raster_functions
from shapely.geometry import Polygon
import shutil
from PyQt5.QtWidgets import QHeaderView, QTableWidgetItem

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

self.catalogTiffOutputWindow.setColumnCount(5)
self.catalogTiffOutputWindow.setHorizontalHeaderLabels(['Filename',
'ULX', 'ULY',
'LRX', 'LRY'])

self.copyTiffOutputWindow.setColumnCount(2)
self.copyTiffOutputWindow.setColumnWidth(0, 380)
self.copyTiffOutputWindow.setColumnWidth(1, 379)
self.copyTiffOutputWindow.setHorizontalHeaderLabels(["Source",
"Destination"])

self.catalogTiffOutputWindow.horizontalHeader().\
setSectionResizeMode(0, QHeaderView.Stretch)

self.shape_functions = meta.PolygonFunctions()

# GIS Calculator page
Expand Down Expand Up @@ -64,7 +82,7 @@ def browse_for_intersecting_shp(self):
:return:
"""

openfile = QtWidgets.QFileDialog.getOpenFileName(self)
openfile = QtWidgets.QFileDialog.getOpenFileName(self, "Open Intersecting Shapefile", None, "shp(*.shp)")[0]
self.intersectingShapefileEdit.setText(openfile)

def browse_for_tiff_directory(self):
Expand Down Expand Up @@ -239,36 +257,91 @@ def get_raster_bounds(self):

path = self.geoTiffDir1.text()
output_path = self.TiffCatalogOutputEdit.text()
fanout = False

if self.FanOutByRes.isChecked():
fanout = True
print("Fanning out by resolution.")

raster_count, raster_dictionary = measurements.\
create_catalog(path, output_path)
create_catalog(path, output_path, fanout)

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

row = 0
self.catalogTiffOutputWindow.setRowCount(len(raster_dictionary))
for filepath, bounds in raster_dictionary.items():
output_text += '{0}: {1}\n\n'.format(filepath, bounds)

self.catalogTiffOutputWindow.setText(output_text)
print(f"adding {filepath} to window.")
print(bounds[1])

filename = os.path.basename(filepath)

self.catalogTiffOutputWindow.setItem(row, 0,
QTableWidgetItem(filename))
self.catalogTiffOutputWindow.\
setItem(row, 1, QTableWidgetItem(str(bounds[0])))
self.catalogTiffOutputWindow.\
setItem(row, 2, QTableWidgetItem(str(bounds[1])))
self.catalogTiffOutputWindow.\
setItem(row, 3, QTableWidgetItem(str(bounds[2])))
self.catalogTiffOutputWindow.\
setItem(row, 4, QTableWidgetItem(str(bounds[3])))
row += 1

return raster_count, raster_dictionary

def handle_tiff_copy(self):
"""
Handles code that copies tifs
:return: IO
:return: None
"""
rasters_by_resolution = {}
resolution = None

tiff_directory = self.TiffDirectory.text()
shapefile_directory = self.intersectingShapefileEdit.text()
shapefile_path = self.intersectingShapefileEdit.text()
output_directory = self.geoTiffOutputDirEdit.text()

payload = (tiff_directory, shapefile_directory, output_directory)

polygon_functions = meta.PolygonFunctions()
polygon_functions.get_polygon_vertices(payload)

intersecting_rasters = raster_functions.\
intersect_by_shape(tiff_directory, shapefile_path,
output_directory)
self.copyTiffOutputWindow.clear()

if self.CopyFanoutByResolution.isChecked():
for raster_path in intersecting_rasters:
row_position = self.copyTiffOutputWindow.rowCount()
self.copyTiffOutputWindow.insertRow(row_position)
resolution = measurements.get_resolution(raster_path)

# Create resolution directory name
resolution = f"{resolution[0]}x{resolution[1]}"
output_basedir = os.path.join(output_directory, resolution)
if not os.path.exists(output_basedir):
os.mkdir(output_basedir)
output_filename = os.path.basename(raster_path)
output_raster_path = os.path.join(output_basedir,
output_filename)
shutil.copy(raster_path, output_raster_path)

self.copyTiffOutputWindow.setItem(row_position, 0,
QTableWidgetItem(raster_path))
self.copyTiffOutputWindow.setItem(row_position, 1,
QTableWidgetItem(output_raster_path))
self.copyTiffOutputWindow.resizeRowsToContents()
else:
for raster_path in intersecting_rasters:
row_position = self.copyTiffOutputWindow.rowCount()
self.copyTiffOutputWindow.insertRow(row_position)
output_path = os.path.join(output_directory,
os.path.basename(raster_path))
shutil.copy(raster_path, output_path)
self.copyTiffOutputWindow.setItem(row_position, 0,
QTableWidgetItem(raster_path))
self.copyTiffOutputWindow.setItem(row_position, 1,
QTableWidgetItem(output_path))
self.copyTiffOutputWindow.resizeRowsToContents()
def get_origin(self):
"""
Button function to get origin calculation. Runs the origin_calc()
Expand Down
58 changes: 23 additions & 35 deletions gisHelperGui.ui
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<bool>false</bool>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="gisCalc">
<attribute name="title">
Expand Down Expand Up @@ -668,26 +668,7 @@
<string>Browse</string>
</property>
</widget>
<widget class="QTextEdit" name="catalogTiffOutputWindow">
<property name="geometry">
<rect>
<x>10</x>
<y>192</y>
<width>755</width>
<height>325</height>
</rect>
</property>
<property name="font">
<font>
<family>Helvetica</family>
<pointsize>11</pointsize>
</font>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QCheckBox" name="checkBox">
<widget class="QCheckBox" name="FanOutByRes">
<property name="geometry">
<rect>
<x>12</x>
Expand Down Expand Up @@ -771,6 +752,16 @@
<string>Process</string>
</property>
</widget>
<widget class="QTableWidget" name="catalogTiffOutputWindow">
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<width>761</width>
<height>341</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="copyTiffs">
<attribute name="title">
Expand Down Expand Up @@ -899,7 +890,7 @@
<string>Browse</string>
</property>
</widget>
<widget class="QCheckBox" name="checkBox_2">
<widget class="QCheckBox" name="CopyFanoutByResolution">
<property name="geometry">
<rect>
<x>12</x>
Expand All @@ -917,19 +908,6 @@
<string>Fan out by resolution</string>
</property>
</widget>
<widget class="QTextEdit" name="catalogTiffOutputWindow_2">
<property name="geometry">
<rect>
<x>10</x>
<y>192</y>
<width>755</width>
<height>325</height>
</rect>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
Expand All @@ -956,6 +934,16 @@
<string>Process</string>
</property>
</widget>
<widget class="QTableWidget" name="copyTiffOutputWindow">
<property name="geometry">
<rect>
<x>10</x>
<y>190</y>
<width>761</width>
<height>341</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="qkShp">
<attribute name="title">
Expand Down
Loading

0 comments on commit c9b1e84

Please sign in to comment.