Compare commits
No commits in common. "060e387b9f1dcbab93fe29c88eedb8815d5c1d92" and "4c7d5e33d0f7761b2b45a98417b3bb77a801a21d" have entirely different histories.
060e387b9f
...
4c7d5e33d0
@ -132,9 +132,8 @@ function hasAddressOrNumberHeader(headers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasGeoHeaders(headers) {
|
function hasGeoHeaders(headers) {
|
||||||
const norm = headers.map(normalizeHeader);
|
return hasHeaderAlias(headers, ['latitude', 'lat'])
|
||||||
return norm.some(h => /\blat(itude)?\b/.test(h))
|
&& hasHeaderAlias(headers, ['longitude', 'long', 'lng', 'lon']);
|
||||||
&& norm.some(h => /\blo?n[g]?(itude)?\b/.test(h));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function findHeaderRowIndex(rows) {
|
function findHeaderRowIndex(rows) {
|
||||||
@ -153,10 +152,8 @@ function resolveColumnIndexes(headers) {
|
|||||||
idxCep: findFirstHeaderIndex(headers, header => /\bcep\b/.test(header) || header === 'codigo postal'),
|
idxCep: findFirstHeaderIndex(headers, header => /\bcep\b/.test(header) || header === 'codigo postal'),
|
||||||
idxNumero: exactIndex(['numero', 'número', 'num', 'nº', 'n°']),
|
idxNumero: exactIndex(['numero', 'número', 'num', 'nº', 'n°']),
|
||||||
idxEndereco: findFirstHeaderIndex(headers, header => header.includes('endereco') || header.includes('logradouro')),
|
idxEndereco: findFirstHeaderIndex(headers, header => header.includes('endereco') || header.includes('logradouro')),
|
||||||
// Antes: exactIndex(['latitude', 'lat'])
|
idxLatitude: exactIndex(['latitude', 'lat']),
|
||||||
idxLatitude: findFirstHeaderIndex(headers, header => /\blat(itude)?\b/.test(header)),
|
idxLongitude: exactIndex(['longitude', 'long', 'lng', 'lon'])
|
||||||
// Antes: exactIndex(['longitude', 'long', 'lng', 'lon'])
|
|
||||||
idxLongitude: findFirstHeaderIndex(headers, header => /\blo?n[g]?(itude)?\b/.test(header)),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,20 +187,7 @@ function buildCepPayload(cols, indexes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseCoordinate(value) {
|
function parseCoordinate(value) {
|
||||||
const str = String(value ?? '')
|
const parsed = parseFloat(String(value ?? '').trim().replace(',', '.'));
|
||||||
.replace(/[\u00A0\u202F\u2000-\u200B\u3000]/g, '') // Bug 2: remove non-breaking spaces
|
|
||||||
.trim()
|
|
||||||
.replace(',', '.');
|
|
||||||
|
|
||||||
// Bug 3: converte DMS "17 38 18.80 S" → -17.638556
|
|
||||||
const dms = str.match(/^(\d+)[°\s]+(\d+)['\s]+(\d+(?:\.\d+)?)["\s]*([NSEW])?$/i);
|
|
||||||
if (dms) {
|
|
||||||
const decimal = parseFloat(dms[1]) + parseFloat(dms[2]) / 60 + parseFloat(dms[3]) / 3600;
|
|
||||||
const negative = /[SW]/i.test(dms[4] ?? '');
|
|
||||||
return negative ? -decimal : decimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
const parsed = parseFloat(str);
|
|
||||||
return Number.isFinite(parsed) ? parsed : NaN;
|
return Number.isFinite(parsed) ? parsed : NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,8 +105,8 @@ function hasAddressOrNumberHeader(headers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasGeoHeaders(headers) {
|
function hasGeoHeaders(headers) {
|
||||||
return headers.some(h => /\blat(itude)?\b/.test(h))
|
return hasHeader(headers, ['latitude', 'lat'])
|
||||||
&& headers.some(h => /\blo?n[g]?(itude)?\b/.test(h));
|
&& hasHeader(headers, ['longitude', 'long', 'lng', 'lon']);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function consultarViabilidade(data) {
|
async function consultarViabilidade(data) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user