John Lloyd MEA582 Fall 2011 Final Project [email protected] John
Lloyd MEA582 Final Project1
Slide 3
Introduction Environment Setup Linux Windows Running Python
v.transects.py Testing Methodology Test Cases Results Conclusions
John Lloyd MEA582 Final Project 2
Slide 4
Setup Linux and Windows Environments Built GRASS from source
code Python script v.transects.py Script partitions the shoreline
Written by Eric Hardin Tested script Linux Windows John Lloyd
MEA582 Final Project3
Slide 5
Introduction Environment Setup Linux Windows v.transects.py
Testing Methodology Test Sets Results Conclusions John Lloyd MEA582
Final Project4
Slide 6
Linux and Windows Built GRASS from source code Latest versions
not dependent on pre-built binaries Debug problems by following
execution in code Add enhancements Understand algorithms GRASS Wiki
- http://grass.osgeo.org/wiki/Compile_and_Install
http://grass.osgeo.org/wiki/Compile_and_Install John Lloyd MEA582
Final Project5
Slide 7
CentOS Linux 5.7 Free distribution of Enterprise Linux
Installed groups for software development Downloaded prerequisite
packages for GRASS Downloaded GRASS source code
(http://grass.osgeo.org/download/software.phphttp://grass.osgeo.org/download/software.php
Compiled and Installed John Lloyd MEA582 Final Project6
Slide 8
Microsoft Windows7 Professional OSGeo4W Installs binaries of
open source geospatial software for Windows MinGW Minimalist GNU
for Windows A Unix like environment for Windows Downloaded
prerequisite packages for GRASS Downloaded GRASS source code
Compiled and Installed John Lloyd MEA582 Final Project7
Slide 9
Introduction Environment Setup Linux Windows Running Python
v.transects.py Testing Methodology Test Sets Results Conclusions
John Lloyd MEA582 Final Project8
Slide 10
script Open Source Interpreted Contains GRASS APIs Written by
Eric Hardin Graduate Research Assistant at NCSU Used to partition
the shore along Outer Banks Creates Lines/transects perpendicular
to shore Or polygons along the shore Parameters Distance between
transects Length of transects John Lloyd MEA582 Final Project9
Slide 11
Introduction Environment Setup Linux Windows Running Python
v.transects.py Testing Methodology Test Sets Results Conclusions
John Lloyd MEA582 Final Project10
Slide 12
Run Test Cases in Linux Defects found? Fix Defects Run Test
Cases in Windows Defects found? Finish Yes No Start Compare
Linux/Windows Output Layers Layers the Same? No Yes John Lloyd
MEA582 Final Project11
Slide 13
Parameter Verification Set Verifies detects and handles
incorrect parameters 10 test cases Shoreline Dataset Verification
Set Nags Head shoreline in NC State Plane 9 test cases Polylines of
Various Shapes Set Polylines not representative of shorelines 12
test cases WGS84 Set Data in the WGS84 projection 3 test cases John
Lloyd MEA582 Final Project12
Slide 14
Parameter defects Before: ValueError: invalid literal for
float(): xxx After: ERROR: Invalid transect_spacing value. Windows
Compatibility Defects ValueError: close_fds is not supported on
Windows platforms ERROR: Unable to open ASCII file Transects along
network of lines failed in Windows but passed in Linux Logic
defects Output layer always correct layer if produced John Lloyd
MEA582 Final Project13
Slide 15
John Lloyd MEA582 Final Project14 50m Transects along Shore50m
Polygons along Shore Transects around circleTransects along in
street network (created in Linux only)
Slide 16
John Lloyd MEA582 Final Project15
#################################### # write transects def
writeTransects( transects, output ): transects_str = '' for
transect in transects: transects_str += '\n'.join( [ 'L 2\n'+' '.
join(map(str,end_points[0])) +'\n'+'
'.join(map(str,end_points[1]))+ '\n' for end_points in transect ] )
a = tempfile.NamedTemporaryFile() a.write( transects_str )
a.seek(0) grass.run_command('v.in.ascii', flags='n', input=a.name,
output=output, format='standard') a.close()
#################################### # write transects def
writeTransects( transects, output ): transects_str = '' for
transect in transects: transects_str += '\n'.join( [ 'L 2\n'+' '.
join(map(str,end_points[0])) +'\n'+'
'.join(map(str,end_points[1]))+ '\n' for end_points in transect ] )
# JL Rewrote Temporary File Logic for Windows _, temp_path =
tempfile.mkstemp() a = open(temp_path, 'w') a.write( transects_str
) a.seek(0) a.close() grass.run_command('v.in.ascii', flags='n',
input=temp_path, output=output, format='standard') Example 1.
Changed Temporary File Creation System Call # JL Handling Invalid
transect_spacing parameter try: transect_spacing =
float(options['transect_spacing']) except: grass.fatal(_("Invalid
transect_spacing value.")) if transect_spacing == 0.0:
grass.fatal(_("Zero invalid transect_spacing value."))
transect_spacing = float(options['transect_spacing']) Example 2.
Added Additional Parameter Validation
Slide 17
Introduction Environment Setup Linux Windows Running Python
v.transects.py Testing Methodology Test Sets Results Conclusions
John Lloyd MEA582 Final Project16
Slide 18
Setting up environment from GRASS source Problems encountered
Linux - missing packages Windows - environment variables for python
Advantages of build from source not realized v.transect.py Previous
testing eliminated logic defects Special testing for Windows needed
Now fit for multiple environment and applications John Lloyd MEA582
Final Project17