Code for survey grid in mission planner

Can Any one help where is the code for survey grid lines in Mission Planner ,
How Mission Planner decides number of lines inside the polygon