def testLocateStreamflowGage(self): badGage = "3ti04ti04tgi0" (response, url) = locateStreamflowGage(self.context.config, badGage) self.assertTrue(response["message"] == "Illegal gageid '%s'" % (badGage,)) unknownGage = "123456789101112" (response, url) = locateStreamflowGage(self.context.config, unknownGage) self.assertTrue(response["message"] == "Reachcode for gage '%s' not found" % (unknownGage,)) goodGage = "01589312" (response, url) = locateStreamflowGage(self.context.config, goodGage) self.assertTrue(response["message"] == RESPONSE_OK) self.assertTrue(response["measure"] == 75.06239) self.assertTrue(response["gage_lon"] == -76.74433974864309) self.assertTrue(response["gage_lat"] == 39.295559099434264) self.assertTrue(response["reachcode"] == "02060003000745")
def testLocateStreamflowGage(self): badGage = "3ti04ti04tgi0" (response, url) = locateStreamflowGage(self.context.config, badGage) self.assertTrue( response['message'] == "Illegal gageid '%s'" % (badGage,) ) unknownGage = "123456789101112" (response, url) = locateStreamflowGage(self.context.config, unknownGage) self.assertTrue( response['message'] == "Reachcode for gage '%s' not found" % (unknownGage,) ) goodGage = "01589312" (response, url) = locateStreamflowGage(self.context.config, goodGage) self.assertTrue( response['message'] == RESPONSE_OK ) self.assertTrue( response['measure'] == 75.06239 ) self.assertTrue( response['gage_lon'] == -76.74433974864309 ) self.assertTrue( response['gage_lat'] == 39.295559099434264 ) self.assertTrue( response['reachcode'] == "02060003000745" )
sys.exit("Gage '%s' not found" % (args.gageid,) ) result = getLocationForStreamGageByGageSourceFea(context.config, args.gageid) if result: gage_lat = result[1] gage_lon = result[0] else: sys.exit("Gage '%s' not found" % (args.gageid,) ) source = 'http://www.horizon-systems.com/NHDPlus/NHDPlusV2_home.php' sys.stdout.write('done\n') else: # Query NHDPlusV2 dataset via web service sys.stdout.write('Geting identifiers and location via NHDPlus webservice...') sys.stdout.flush() (response, source) = locateStreamflowGage(context.config, args.gageid) if response['message'] != RESPONSE_OK: sys.exit("Failed to get gage identifiers/location for gage '%s', webservice response: %s" % \ (args.gageid, response['message']) ) else: reachcode = response['reachcode'] measure = response['measure'] gage_lat = response['gage_lat'] gage_lon = response['gage_lon'] sys.stdout.write('done\n') # Write gage coordinates to a shapefile in the project directory shpFilename = writeCoordinatePairsToPointShapefile(context.projectDir, "gage", "gage_id", [args.gageid], [(gage_lon, gage_lat)])
result = getLocationForStreamGageByGageSourceFea(context.config, args.gageid) if result: gage_lat = result[1] gage_lon = result[0] else: sys.exit("Gage '%s' not found" % (args.gageid, )) source = 'http://www.horizon-systems.com/NHDPlus/NHDPlusV2_home.php' sys.stdout.write('done\n') else: # Query NHDPlusV2 dataset via web service sys.stdout.write( 'Geting identifiers and location via NHDPlus webservice...') sys.stdout.flush() (response, source) = locateStreamflowGage(context.config, args.gageid) if response['message'] != RESPONSE_OK: sys.exit("Failed to get gage identifiers/location for gage '%s', webservice response: %s" % \ (args.gageid, response['message']) ) else: reachcode = response['reachcode'] measure = response['measure'] gage_lat = response['gage_lat'] gage_lon = response['gage_lon'] sys.stdout.write('done\n') # Write gage coordinates to a shapefile in the project directory shpFilename = writeCoordinatePairsToPointShapefile(context.projectDir, "gage", "gage_id", [args.gageid], [(gage_lon, gage_lat)])