def proj4_to_epsg(projection):
def make_definition(value):<EOL><INDENT>return {x.strip().lower() for x in value.split('<STR_LIT:+>') if x}<EOL><DEDENT>match = EPSG_RE.search(projection.srs)<EOL>if match:<EOL><INDENT>return int(match.group(<NUM_LIT:1>))<EOL><DEDENT>pyproj_data_dir = os.path.join(os.path.dirname(pyproj.__file__), '<STR_LIT:data>')<EOL>pyproj_epsg_file = os.path.join(pyproj_data_dir, '<STR_LIT>')<EOL>if os.path.exists(pyproj_epsg_file):<EOL><INDENT>definition = make_definition(projection.srs)<EOL>f = open(pyproj_epsg_file, '<STR_LIT:r>')<EOL>for line in f.readlines():<EOL><INDENT>match = PYPROJ_EPSG_FILE_RE.search(line)<EOL>if match:<EOL><INDENT>file_definition = make_definition(match.group(<NUM_LIT:2>))<EOL>if definition == file_definition:<EOL><INDENT>return int(match.group(<NUM_LIT:1>))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return None<EOL>
Attempts to convert a PROJ4 projection object to an EPSG code and returns None if conversion fails