private void applyPatternsToOutput(String output, Metadata metadata,
                                       Map<Pattern, String> metadataPatterns) {
        try (Scanner scanner = new Scanner(output)) {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                for (Pattern p : metadataPatterns.keySet()) {
                    Matcher m = p.matcher(line);
                    if (m.find()) {
                        if (metadataPatterns.get(p) != null && !metadataPatterns.get(p).equals("")) {
                            metadata.add(metadataPatterns.get(p), m.group(1));
                        } else {
                            metadata.add(m.group(1), m.group(2));
                        }
                    }
                }
            }
        }
    }
Wraps execution of the <a href="http//gdal.org/">Geospatial Data Abstraction
Library (GDAL)</a> <code>gdalinfo</code> tool used to extract geospatial
information out of hundreds of geo file formats.
<p/>
The parser requires the installation of GDAL and for <code>gdalinfo</code> to
be located on the path.
<p/>
Basic information (Size, Coordinate System, Bounding Box, Driver, and
resource info) are extracted as metadata, and the remaining metadata patterns
are extracted and added.
<p/>
The output of the command is available from the provided
{@link ContentHandler} in the
{@link #parse(InputStream, ContentHandler, Metadata, ParseContext)} method.
tika-parsers/tika-parsers-extended/tika-parser-scientific-module/src/main/java/org/apache/tika/parser/gdal/GDALParser.java