<commit_before>// ---------------------------------------
// Build a mapacache.xml file from
// a WMS capabilies xml file
// (Synchronous request)
// --------------------------------------------
// Parameters
//  - capabilitiesFile : xml capabilities
//  - urlRequestCapa : WMS getCapabilities request
//  - projectName : name of the project
// --------------------------------------------
buildMapcacheXmlFromContent = (function(capabilitiesXmlContent, urlRequestCapa, projectName) {
    var parser = new ol.parser.ogc.WMSCapabilities(), capabilitiesXmlContent;
    capabilitiesXmlContent = parser.read(capabilitiesXmlContent);
    
    var layers = capabilitiesXmlContent.capability.layers;

    var project = projectName;
    var mapcache = '';
    var tileset = '';
    var source = '';
    var concat = '&amp;';
    var idx = urlRequestCapa.indexOf('?');
    if (idx == -1) {
        concat = '?';
    }

    mapcache = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;\n';
    mapcache += '&lt;mapcache&gt;\n';
    mapcache += '  &lt;metadata&gt;\n';
    mapcache += '    &lt;title&gt;Mapcache service for url: ' + urlRequestCapa + '&lt;/title&gt;\n';
    mapcache += '    &lt;abstract&gt;Render map services for url: ' + urlRequestCapa + '&lt;/abstract&gt;\n';
    mapcache += '  &lt;/metadata&gt;\n\n';


    // Cache: Disk
    mapcache += '  &lt;cache name="disk" type="disk"&gt;\n';
    mapcache += '    &lt;base&gt;/tmp/' + project + '&lt;/base&gt;\n';
    mapcache += '    &lt;symlink_blank/&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Cache: template
    mapcache += '  &lt;cache name="tmpl" type="disk"&gt;\n';
    mapcache += '    &lt;base&gt;/tmp' + project + '&lt;/base&gt;\n';
    mapcache += '    &lt;template&gt;/tmp/' + project + '/template/{tileset}#{grid}#{dim}/{z}/{x}/{y}.{ext}&lt;/template&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Cache: sqlite
    mapcache += '  &lt;cache name="sqlite" type="sqlite3"&gt;\n';
    mapcache += '    &lt;dbfile&gt;/tmp/' + project + '/sqlitetiles.db&lt;/dbfile&gt;\n';
    mapcache += '    &lt;pragma name="key"&gt;value&lt;/pragma&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Cache: MbTiles
    mapcache += '  &lt;cache name="mbtiles" type="mbtiles"&gt;\n';
    mapcache += '    &lt;dbfile&gt;/tmp/' + project + '/' + project + '.mbtiles&lt;/dbfile&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Format: png
    mapcache += '  &lt;format name="PNGQ_FAST" type ="PNG"&gt;\n';
    mapcache += '    &lt;compression&gt;fast&lt;/compression&gt;\n';
    mapcache += '    &lt;colors&gt;256&lt;/colors&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    // Format: jpeg
    mapcache += '  &lt;format name="JPEG_75" type ="JPEG"&gt;\n';
    mapcache += '    &lt;quality&gt;75&lt;/quality&gt;\n';
    mapcache += '    &lt;photometric&gt;RGB&lt;/photometric&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    // Format: png
    mapcache += '  &lt;format name="PNG_BEST" type ="PNG"&gt;\n';
    mapcache += '    &lt;compression&gt;best&lt;/compression&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    // Format: mixed
    mapcache += '  &lt;format name="mixed" type="MIXED"&gt;\n';
    mapcache += '    &lt;transparent&gt;PNG_BEST&lt;/transparent&gt;\n';
    mapcache += '    &lt;opaque&gt;JPEG&lt;/opaque&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    for (var l = 0; l < layers.length; ++l) {
        layer = layers[l];

        console.log('Layer:' + layer.name);
        console.log('\tAvailable elevations: ' + layer.dimensions.elevation.values);
        console.log('\tAvailable times: ' + layer.dimensions.time.values);

        var arrayTab = layer.styles;
        for (var s = 0; s < arrayTab.length; ++s) {
            style = arrayTab[s];

            tileset = layer.name + '_' + style.name;
            source = 'SOURCE_' + layer.name + '_' + style.name;

            mapcache += '  &lt;!-- Source for layer: ' + layer.name + ', style: ' + style.name + ' --&gt;\n';
            mapcache += '  &lt;source name="' + source + '" type="wms"&gt;\n';
            mapcache += '    &lt;http&gt;\n';
            mapcache += '      &lt;url&gt;' + urlRequestCapa + '&lt;/url&gt;\n';
            mapcache += '    &lt;/http&gt;\n';
            mapcache += '    &lt;getmap&gt;\n';
            mapcache += '      &lt;params&gt;\n';
            mapcache += '        &lt;FORMAT&gt;image/png&lt;/FORMAT&gt;\n';
            mapcache += '        &lt;LAYERS&gt;' + layer.name + '&lt;/LAYERS&gt;\n';
            mapcache += '        &lt;STYLES&gt;' + style.name + '&lt;/STYLES&gt;\n';
            mapcache += '      &lt;/params&gt;\n';
            mapcache += '    &lt;/getmap&gt;\n';
            mapcache += '  &lt;/source&gt;\n\n';

            mapcache += '  &lt;!-- Tileset for layer: ' + layer.name + ', style: ' + style.name + ' --&gt;\n';
            mapcache += '  &lt;tileset name="' + tileset + '"&gt;\n';
            mapcache += '    &lt;source&gt;' + source + '&lt;/source&gt;\n';<commit_msg>correction for missing elevation<commit_after>// ---------------------------------------
// Build a mapacache.xml file from
// a WMS capabilies xml file
// (Synchronous request)
// --------------------------------------------
// Parameters
//  - capabilitiesFile : xml capabilities
//  - urlRequestCapa : WMS getCapabilities request
//  - projectName : name of the project
// --------------------------------------------
buildMapcacheXmlFromContent = (function(capabilitiesXmlContent, urlRequestCapa, projectName) {
    var parser = new ol.parser.ogc.WMSCapabilities(), capabilitiesXmlContent;
    capabilitiesXmlContent = parser.read(capabilitiesXmlContent);
    
    var layers = capabilitiesXmlContent.capability.layers;

    var project = projectName;
    var mapcache = '';
    var tileset = '';
    var source = '';
    var concat = '&amp;';
    var idx = urlRequestCapa.indexOf('?');
    if (idx == -1) {
        concat = '?';
    }

    mapcache = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;\n';
    mapcache += '&lt;mapcache&gt;\n';
    mapcache += '  &lt;metadata&gt;\n';
    mapcache += '    &lt;title&gt;Mapcache service for url: ' + urlRequestCapa + '&lt;/title&gt;\n';
    mapcache += '    &lt;abstract&gt;Render map services for url: ' + urlRequestCapa + '&lt;/abstract&gt;\n';
    mapcache += '  &lt;/metadata&gt;\n\n';


    // Cache: Disk
    mapcache += '  &lt;cache name="disk" type="disk"&gt;\n';
    mapcache += '    &lt;base&gt;/tmp/' + project + '&lt;/base&gt;\n';
    mapcache += '    &lt;symlink_blank/&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Cache: template
    mapcache += '  &lt;cache name="tmpl" type="disk"&gt;\n';
    mapcache += '    &lt;base&gt;/tmp' + project + '&lt;/base&gt;\n';
    mapcache += '    &lt;template&gt;/tmp/' + project + '/template/{tileset}#{grid}#{dim}/{z}/{x}/{y}.{ext}&lt;/template&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Cache: sqlite
    mapcache += '  &lt;cache name="sqlite" type="sqlite3"&gt;\n';
    mapcache += '    &lt;dbfile&gt;/tmp/' + project + '/sqlitetiles.db&lt;/dbfile&gt;\n';
    mapcache += '    &lt;pragma name="key"&gt;value&lt;/pragma&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Cache: MbTiles
    mapcache += '  &lt;cache name="mbtiles" type="mbtiles"&gt;\n';
    mapcache += '    &lt;dbfile&gt;/tmp/' + project + '/' + project + '.mbtiles&lt;/dbfile&gt;\n';
    mapcache += '  &lt;/cache&gt;\n\n';

    // Format: png
    mapcache += '  &lt;format name="PNGQ_FAST" type ="PNG"&gt;\n';
    mapcache += '    &lt;compression&gt;fast&lt;/compression&gt;\n';
    mapcache += '    &lt;colors&gt;256&lt;/colors&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    // Format: jpeg
    mapcache += '  &lt;format name="JPEG_75" type ="JPEG"&gt;\n';
    mapcache += '    &lt;quality&gt;75&lt;/quality&gt;\n';
    mapcache += '    &lt;photometric&gt;RGB&lt;/photometric&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    // Format: png
    mapcache += '  &lt;format name="PNG_BEST" type ="PNG"&gt;\n';
    mapcache += '    &lt;compression&gt;best&lt;/compression&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    // Format: mixed
    mapcache += '  &lt;format name="mixed" type="MIXED"&gt;\n';
    mapcache += '    &lt;transparent&gt;PNG_BEST&lt;/transparent&gt;\n';
    mapcache += '    &lt;opaque&gt;JPEG&lt;/opaque&gt;\n';
    mapcache += '  &lt;/format&gt;\n\n';

    for (var l = 0; l < layers.length; ++l) {
        layer = layers[l];

        console.log('Layer:' + layer.name);
        //console.log('\tAvailable elevations: ' + layer.dimensions.elevation.values);
        console.log('\tAvailable times: ' + layer.dimensions.time.values);

        var arrayTab = layer.styles;
        for (var s = 0; s < arrayTab.length; ++s) {
            style = arrayTab[s];

            tileset = layer.name + '_' + style.name;
            source = 'SOURCE_' + layer.name + '_' + style.name;

            mapcache += '  &lt;!-- Source for layer: ' + layer.name + ', style: ' + style.name + ' --&gt;\n';
            mapcache += '  &lt;source name="' + source + '" type="wms"&gt;\n';
            mapcache += '    &lt;http&gt;\n';
            mapcache += '      &lt;url&gt;' + urlRequestCapa + '&lt;/url&gt;\n';
            mapcache += '    &lt;/http&gt;\n';
            mapcache += '    &lt;getmap&gt;\n';
            mapcache += '      &lt;params&gt;\n';
            mapcache += '        &lt;FORMAT&gt;image/png&lt;/FORMAT&gt;\n';
            mapcache += '        &lt;LAYERS&gt;' + layer.name + '&lt;/LAYERS&gt;\n';
            mapcache += '        &lt;STYLES&gt;' + style.name + '&lt;/STYLES&gt;\n';
            mapcache += '      &lt;/params&gt;\n';
            mapcache += '    &lt;/getmap&gt;\n';
            mapcache += '  &lt;/source&gt;\n\n';

            mapcache += '  &lt;!-- Tileset for layer: ' + layer.name + ', style: ' + style.name + ' --&gt;\n';
            mapcache += '  &lt;tileset name="' + tileset + '"&gt;\n';
            mapcache += '    &lt;source&gt;' + source + '&lt;/source&gt;\n';
{'fraction_non_alphanumeric': 0.23461346633416458, 'fraction_numerical': 0.002793017456359102, 'mean_word_length': 2.368951612903226, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 2, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5407786', 'n_tokens_mistral': 3619, 'n_tokens_neox': 3557, 'n_words': 576}