Skip to content

Commit

Permalink
fix(csv): fixes issues with characters in csv headers breaking filter
Browse files Browse the repository at this point in the history
Closes #2653
  • Loading branch information
DamonU2 committed Jan 16, 2025
1 parent c382048 commit 235896e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ <h4 id="HMap1">OSDP Integration</h4>
const id = document.createAttribute('id');
id.value = 'Map1';
newDiv.setAttributeNode(id);
const lang = document.createAttribute('data-lang');
lang.value = 'fr';
newDiv.setAttributeNode(lang);
const dataLang = document.createAttribute('data-lang');
dataLang.value = lang;
newDiv.setAttributeNode(dataLang);
document.getElementById('mapSection').appendChild(newDiv);
}
</pre>
Expand Down Expand Up @@ -128,7 +128,8 @@ <h4 id="HMap1">OSDP Integration</h4>
</li>
<li>
<button id="changeLanguage" style="margin: 10px">Change Language</button>
Changes the language from french to english or english to french and reloads the map if it exists
Changes the language from french to english or english to french and reloads the map if it exists.
Note: this will not change the language of the layers, as they are loaded in the current state.
<details>
<summary>Code</summary>
<pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export type TypeVectorLayerGroup = LayerGroup;
export type TypeVectorLayer = VectorSource<Feature>;
export type TypeBaseVectorLayer = BaseLayer | TypeVectorLayerGroup | TypeVectorLayer;

const EXCLUDED_HEADERS_LAT = ['latitude', 'lat', 'y', 'ycoord', 'latitude/latitude', 'latitude / latitude'];
const EXCLUDED_HEADERS_LNG = ['longitude', 'lon', 'x', 'xcoord', 'longitude/longitude', 'longitude / longitude'];
const EXCLUDED_HEADERS_LAT = ['latitude', 'lat', 'y', 'ycoord', 'latitude|latitude', 'latitude | latitude'];
const EXCLUDED_HEADERS_LNG = ['longitude', 'lon', 'x', 'xcoord', 'longitude|longitude', 'longitude | longitude'];
const EXCLUDED_HEADERS_GEN = ['geometry', 'geom'];
const EXCLUDED_HEADERS = EXCLUDED_HEADERS_LAT.concat(EXCLUDED_HEADERS_LNG).concat(EXCLUDED_HEADERS_GEN);

Expand Down Expand Up @@ -428,6 +428,25 @@ export abstract class AbstractGeoViewVector extends AbstractGeoViewLayer {
if (matches[1].length && matches[1] !== separator) parsedData.push([]);
parsedData[parsedData.length - 1].push(matches[2] !== undefined ? matches[2].replace(/""/g, '"') : matches[3]);
}

// These characters are removed from the headers as they break the data table filtering (Issue #2693).
parsedData[0].forEach((header, i) => {
if (header.includes("'")) logger.logWarning("Header included illegal character (') replaced with (_)");
parsedData[0][i] = header.replaceAll("'", '_');
if (header.includes('/')) logger.logWarning('Header included illegal character (/) replaced with (|)');
parsedData[0][i] = parsedData[0][i].replaceAll('/', '|');
if (header.includes('+')) logger.logWarning('Header included illegal character (+) replaced with (plus)');
parsedData[0][i] = parsedData[0][i].replaceAll('+', 'plus');
if (header.includes('-')) logger.logWarning('Header included illegal character (-) replaced with (_)');
parsedData[0][i] = parsedData[0][i].replaceAll('-', '_');
if (header.includes('*')) logger.logWarning('Header included illegal character (*) replaced with (x)');
parsedData[0][i] = parsedData[0][i].replaceAll('*', 'x');
if (header.includes('(')) logger.logWarning('Header included illegal character (() replaced with ([)');
parsedData[0][i] = parsedData[0][i].replaceAll('(', '[');
if (header.includes(')')) logger.logWarning('Header included illegal character ()) replaced with (])');
parsedData[0][i] = parsedData[0][i].replaceAll(')', ']');
});

return parsedData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@ export function getAndCreateFeatureStyle(
}
}

// Get the style accordingly to its type and geometry.
// Get the style according to its type and geometry.
if (styleWorkOn![geometryType]) {
const styleSettings = style![geometryType]!;
const { type } = styleSettings;
Expand Down

0 comments on commit 235896e

Please sign in to comment.