@@ -24,18 +24,21 @@ var locationmodeToIdFinder = {
2424
2525exports . locationToFeature = function ( locationmode , location , features ) {
2626 var locationId = getLocationId ( locationmode , location ) ;
27- var feature ;
2827
29- for ( var i = 0 ; i < features . length ; i ++ ) {
30- feature = features [ i ] ;
28+ if ( locationId ) {
29+ for ( var i = 0 ; i < features . length ; i ++ ) {
30+ var feature = features [ i ] ;
3131
32- if ( feature . id === locationId ) return feature ;
32+ if ( feature . id === locationId ) return feature ;
33+ }
34+
35+ Lib . warn ( [
36+ 'Location with id' , locationId ,
37+ 'does not have a matching topojson feature at this resolution.'
38+ ] . join ( ' ' ) ) ;
3339 }
3440
35- Lib . warn ( [
36- 'Location with id' , locationId ,
37- 'does not have a matching topojson feature at this resolution.'
38- ] . join ( ' ' ) ) ;
41+ return false ;
3942} ;
4043
4144function getLocationId ( locationmode , location ) {
@@ -44,14 +47,14 @@ function getLocationId(locationmode, location) {
4447}
4548
4649function countryNameToISO3 ( countryName ) {
47- var iso3 , regex ;
48-
4950 for ( var i = 0 ; i < countryIds . length ; i ++ ) {
50- iso3 = countryIds [ i ] ;
51- regex = new RegExp ( countryRegex [ iso3 ] ) ;
51+ var iso3 = countryIds [ i ] ,
52+ regex = new RegExp ( countryRegex [ iso3 ] ) ;
5253
5354 if ( regex . test ( countryName . toLowerCase ( ) ) ) return iso3 ;
5455 }
5556
5657 Lib . warn ( 'Unrecognized country name: ' + countryName + '.' ) ;
58+
59+ return false ;
5760}
0 commit comments