Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Replace country-regex with i18n-iso-countries#7366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dimitrov570 wants to merge9 commits intoplotly:master
base:master
Choose a base branch
Loading
fromdimitrov570:replace-country-regex
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
replace country-regex with i18n-iso-countries
  • Loading branch information
@dimitrov570
dimitrov570 committedFeb 13, 2025
commite803c5e487e185b6444e6afac9defe2a43a16b81
23 changes: 17 additions & 6 deletionspackage-lock.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,6 @@
"color-normalize": "1.5.0",
"color-parse": "2.0.0",
"color-rgba": "2.1.1",
"country-regex": "^1.1.0",
"css-loader": "^7.1.2",
"d3-force": "^1.2.1",
"d3-format": "^1.4.5",
Expand All@@ -97,6 +96,7 @@
"gl-text": "^1.4.0",
"has-hover": "^1.0.1",
"has-passive-events": "^1.0.0",
"i18n-iso-countries": "^7.13.0",
"is-mobile": "^4.0.0",
"maplibre-gl": "^4.7.1",
"mouse-change": "^1.4.0",
Expand Down
16 changes: 8 additions & 8 deletionssrc/lib/geo_location_utils.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
'use strict';

var d3 = require('@plotly/d3');
var countryRegex = require('country-regex');
var { area: turfArea } = require('@turf/area');
var { centroid: turfCentroid } = require('@turf/centroid');
var { bbox: turfBbox } = require('@turf/bbox');
Expand All@@ -12,8 +11,8 @@ var isPlainObject = require('./is_plain_object');
var nestedProperty = require('./nested_property');
var polygon = require('./polygon');

// make list of all country iso3 ids from at runtime
var countryIds = Object.keys(countryRegex);
const countries = require("i18n-iso-countries");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Could you please move thisrequire statement above with the others?

countries.registerLocale(require("i18n-iso-countries/langs/en.json"));

var locationmodeToIdFinder = {
'ISO-3': identity,
Expand All@@ -22,11 +21,12 @@ var locationmodeToIdFinder = {
};

function countryNameToISO3(countryName) {
for(var i = 0; i < countryIds.length; i++) {
var iso3 = countryIds[i];
var regex = new RegExp(countryRegex[iso3]);

if(regex.test(countryName.trim().toLowerCase())) return iso3;
// remove sequences of whitespaces
var cleanName = countryName.replace(/\s+/g, ' ').trim();
var alpha3Code = countries.getAlpha3Code(cleanName, "en")

if (alpha3Code !== undefined) {
return alpha3Code;
}

loggers.log('Unrecognized country name: ' + countryName + '.');
Expand Down
4 changes: 2 additions & 2 deletionstest/jasmine/tests/geo_test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -819,8 +819,8 @@ describe('geojson / topojson utils', function() {
var topojson = GeoAssets.topojson[topojsonName];

var shouldPass = [
'Virgin Islands (U.S.)',
' Virgin Islands (U.S.) '
'Virgin Islands,U.S.',
' Virgin Islands,U.S. '
];

shouldPass.forEach(function(str) {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp