Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"alpha-shape": "^1.0.0",
"arraytools": "^1.0.0",
"convex-hull": "^1.0.3",
"country-regex": "^1.0.0",
"d3": "^3.5.12",
"delaunay-triangulate": "^1.1.6",
"es6-promise": "^3.0.2",
Expand Down
268 changes: 0 additions & 268 deletions src/constants/country-name_to_iso3.js

This file was deleted.

17 changes: 7 additions & 10 deletions src/lib/geo_location_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@

'use strict';

var locationUtils = module.exports = {};
var countryRegex = require('country-regex');
var Lib = require('./');

var Plotly = require('../plotly');

// an hash object iso3 to regex string
var countryNameData = require('../constants/country-name_to_iso3');

// make list of all country iso3 ids from at runtime
var countryIds = Object.keys(countryNameData);
var countryIds = Object.keys(countryRegex);

var locationmodeToIdFinder = {
'ISO-3': Plotly.Lib.identity,
'USA-states': Plotly.Lib.identity,
'ISO-3': Lib.identity,
'USA-states': Lib.identity,
'country names': countryNameToISO3
};

locationUtils.locationToFeature = function(locationmode, location, features) {
exports.locationToFeature = function(locationmode, location, features) {
var locationId = getLocationId(locationmode, location);
var feature;

Expand All @@ -51,7 +48,7 @@ function countryNameToISO3(countryName) {

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

if(regex.test(countryName.toLowerCase())) return iso3;
}
Expand Down