def get_projection(projectionId, projectionConfig, lcdir, tilematrixset_configuration):
    try:
        # Open file.
        projection_config=open(projectionConfig, 'r')
        print ('Using projection config: ' + projectionConfig + '\n')
    except IOError:
        mssg=str().join(['Cannot read projection configuration file:  ', projectionConfig])
        log_sig_exit('ERROR', mssg, sigevent_url)
        
    dom = xml.dom.minidom.parse(projection_config)
    projection = None
    projectionTags = dom.getElementsByTagName('Projection')
    for projectionElement in projectionTags:
        if projectionElement.attributes['id'].value == projectionId:
            wkt = projectionElement.getElementsByTagName('WKT')[0].firstChild.data.strip()
            try:
                wgsbbox = projectionElement.getElementsByTagName('WGS84BoundingBox')[0].toxml().replace("WGS84BoundingBox", "ows:WGS84BoundingBox")
            except:
                wgsbbox = ""
            try:
                boundbox = "\n         " + projectionElement.getElementsByTagName('BoundingBox')[0].toxml().replace("BoundingBox", "ows:BoundingBox")
            except:
                boundbox = ""
            bbox = str(wgsbbox + boundbox).replace("LowerCorner","ows:LowerCorner").replace("UpperCorner","ows:UpperCorner")
            # get corners...a bit messy
            lowercorner = xml.dom.minidom.parseString("<bbox>"+str(boundbox+wgsbbox).replace("ows:", "")+"</bbox>").getElementsByTagName('LowerCorner')[0].firstChild.nodeValue.split(" ")
            uppercorner = xml.dom.minidom.parseString("<bbox>"+str(boundbox+wgsbbox).replace("ows:", "")+"</bbox>").getElementsByTagName('UpperCorner')[0].firstChild.nodeValue.split(" ")
            tilematrixsets = {}
            try:
                # Open file.
                tilematrixsetconfig=open(tilematrixset_configuration, 'r')
                print ('Using TileMatrixSet config: ' + tilematrixset_configuration + '\n')
            except IOError:
                mssg=str().join(['Cannot read TileMatrixSet configuration file:  ', tilematrixset_configuration])
                log_sig_exit('ERROR', mssg, sigevent_url)
            tms_dom = xml.dom.minidom.parse(tilematrixsetconfig)
            tms_projections = tms_dom.getElementsByTagName('Projection')
            tms_xml = ""
            for tms_projection in tms_projections:
                try:
                    if tms_projection.attributes['id'].value == projectionId:
                        tms_xml = '\n'.join(tms_projection.toxml().split('\n')[1:-1]) # remove <Projection> lines
                        tms_xml = re.sub(r'<TileMatrixSet level="\d+">', '<TileMatrixSet>', tms_xml) # remove added level metadata
                        tileMatrixSetElements = tms_projection.getElementsByTagName('TileMatrixSet')
                        for tilematrixset in tileMatrixSetElements:
                            scale_denominators = tilematrixset.getElementsByTagName("ScaleDenominator")
                            if scale_denominators.length > 1:
                                scale = int(round(float(scale_denominators[0].firstChild.nodeValue.strip())/float(scale_denominators[1].firstChild.nodeValue.strip())))
                            else:
                                scale = 2 # default to powers of 2 scale
                            print "TileMatrixSet: " + tilematrixset.getElementsByTagName('ows:Identifier')[0].firstChild.nodeValue.strip() + " - levels: " + str(tilematrixset.getElementsByTagName("TileMatrix").length) + ", overview scale: " + str(scale)
                            tilematrixsets[tilematrixset.getElementsByTagName('ows:Identifier')[0].firstChild.nodeValue.strip()] = TileMatrixSetMeta(tilematrixset.getElementsByTagName("TileMatrix").length, scale)
                                
                except KeyError, e:
                    log_sig_exit('ERROR', 'Projection ' + projectionId + " " + str(e) + ' missing in TileMatrixSet configuration ' + tilematrixset_configuration, sigevent_url)
                
            projection = Projection(projectionId, wkt, bbox, tilematrixsets, tms_xml, lowercorner, uppercorner)
    
    if projection == None:
        mssg = "Projection " + projectionId + " could not be found in projection configuration file."
        raise Exception(mssg)
    
    return projection
Gets projection metadata from a projection configuration file based on the projection ID.
dataset/ETHPy150Open nasa-gibs/onearth/src/layer_config/bin/oe_configure_layer.py/get_projection