@@ -511,7 +511,7 @@ function toggleCoverLayers()
511
511
if ( getCover )
512
512
{
513
513
let input = defaultMap . isocode + '-' + document . getElementById ( 'sel_jurL2' ) . value + '-' + document . getElementById ( 'sel_jurL3' ) . value
514
- loadGeojson ( uri_base + "/" + input + ".json/cover/" + defaultMap . scientificBase , [ layerCoverAll ] , function ( e ) { } , function ( e ) { } ) ;
514
+ loadGeojson ( uri_base + "/" + input + ".json/cover" , [ layerCoverAll ] , function ( e ) { } , function ( e ) { } ) ;
515
515
getCover = false ;
516
516
}
517
517
else
@@ -524,17 +524,44 @@ function toggleOfficialBordersLayers()
524
524
{
525
525
map . hasLayer ( layerJurisdAll ) ? map . removeLayer ( layerJurisdAll ) : map . addLayer ( layerJurisdAll ) ;
526
526
}
527
- function generateSelectLevel ( base , baseValue , size_shortestprefix , size = 0 )
527
+ function generateSelectLevel ( base , size_shortestprefix , size = 0 )
528
528
{
529
+ // let html = '';
530
+ //
531
+ // for (let i = base.iniLevel, k=base.iniDigit; i <= base.endLevel; i+=base.modLevel, k++)
532
+ // {
533
+ // if (k > size_shortestprefix)
534
+ // {
535
+ // html += '<option value="' + levelValues[i] + ( size > 0 ? (Math.floor(size) <= levelSize[i] ? '" selected>' : '">') : (i == base.levelDefault ? '" selected>' : '">') ) + 'L' + (0.5*i - 0.5*base.diffl0br).toString() + ' (' + ((levelSize[i]<1000)? Math.round(levelSize[i]*100.0)/100 : Math.round(levelSize[i]*100.0/1000)/100) + ((levelSize[i]<1000)? 'm': 'km') + ') ' + (i % 2 == 0 ? '▫' : '▭') + '</option>'
536
+ // }
537
+ // }
538
+ // return html
539
+
529
540
let html = '' ;
530
541
531
- for ( let i = base . iniLevel , k = base . iniDigit ; i <= base . endLevel ; i += base . modLevel , k ++ )
542
+ let m = 0 , p = 5 , q = base . iniLevel ;
543
+
544
+ const endLevel = base . endLevel ;
545
+
546
+ for ( let j = 0 ; j <= endLevel ; j ++ )
532
547
{
533
- if ( k > size_shortestprefix )
534
- {
535
- html += '<option value="' + levelValues [ i ] + ( size > 0 ? ( Math . floor ( size ) <= levelSize [ i ] ? '" selected>' : '">' ) : ( i == base . levelDefault ? '" selected>' : '">' ) ) + 'L' + ( 0.5 * i - 0.5 * base . diffl0br ) . toString ( ) + ' (' + ( ( levelSize [ i ] < 1000 ) ? Math . round ( levelSize [ i ] * 100.0 ) / 100 : Math . round ( levelSize [ i ] * 100.0 / 1000 ) / 100 ) + ( ( levelSize [ i ] < 1000 ) ? 'm' : 'km' ) + ') ' + ( i % 2 == 0 ? '▫' : '▭' ) + '</option>'
536
- }
548
+ if ( j % p !== q ) continue ;
549
+
550
+ m = ( j % 4 == 0 ? ( j / 4 ) + 1 : Math . floor ( j / 4 ) + 2 )
551
+
552
+ const levelSize = ( j % 2 === 0 )
553
+ ? Math . pow ( 2 , ( endLevel - j ) / 2 )
554
+ : Math . pow ( 2 , ( endLevel - j - 1 ) / 2 ) * 1.41 ;
555
+
556
+ const formattedSize = levelSize < 1000 ? ( Math . round ( levelSize * 100.0 ) / 100 ) + 'm' : ( Math . round ( levelSize * 100.0 / 1000 ) / 100 ) + 'km' ;
557
+
558
+ const symbol = j % 2 === 0 ? '▫' : '▭' ;
559
+
560
+ const selected = ( Math . floor ( size ) <= levelSize ? ' selected' : '' )
561
+
562
+ html += `<option value="${ levelValues [ j ] } "${ selected } >L${ j } (${ m } d) (${ formattedSize } ) ${ symbol } </option>` ;
537
563
}
564
+
538
565
return html
539
566
}
540
567
@@ -559,6 +586,8 @@ function isMarkerInsidePolygonOrMultiPolygon(x, y, poly) {
559
586
// Check if the input is a multi-polygon or a single polygon
560
587
const isMultiPolygon = Array . isArray ( polys [ 0 ] ) && Array . isArray ( polys [ 0 ] [ 0 ] ) ;
561
588
589
+ console . log ( isMultiPolygon )
590
+
562
591
// Function to check if a point is inside a polygon
563
592
const checkInside = ( polyPoints ) => {
564
593
for ( let k = 0 , l = polyPoints . length - 1 ; k < polyPoints . length ; l = k ++ ) {
@@ -896,9 +925,9 @@ function popUpFeature(feature,layer)
896
925
897
926
var popupContent = "" ;
898
927
899
- if ( feature . properties . short_code )
928
+ if ( feature . properties . logistic_id )
900
929
{
901
- popupContent += "Logistic code: <big><code>" + ( feature . properties . short_code . split ( / [ ~ ] / ) [ 1 ] ) + "</code></big><br>" ;
930
+ popupContent += "Logistic code: <big><code>" + ( feature . properties . logistic_id . split ( / [ ~ ] / ) [ 1 ] ) + "</code></big><br>" ;
902
931
popupContent += "Area: " + value_area + " " + sufix_area + "<br>" ;
903
932
popupContent += "Side: " + value_side + " " + sufix_side + "<br>" ;
904
933
@@ -916,15 +945,15 @@ function popUpFeature(feature,layer)
916
945
{
917
946
if ( feature . properties . type )
918
947
{
919
- popupContent += ( feature . properties . type ) . toUpperCase ( ) + " code: <big><code>" + ( feature . properties . code ) + "</code></big><br>" ;
948
+ popupContent += ( feature . properties . type ) . toUpperCase ( ) + " code: <big><code>" + ( feature . id ) + "</code></big><br>" ;
920
949
}
921
950
else if ( feature . properties . index )
922
951
{
923
952
popupContent += "Code: <big><code>" + ( feature . properties . index ) + "</code></big><br>" ;
924
953
}
925
954
else
926
955
{
927
- popupContent += "Code: <big><code>" + ( feature . properties . code ) + "</code></big><br>" ;
956
+ popupContent += "Code: <big><code>" + ( feature . id ) + "</code></big><br>" ;
928
957
}
929
958
popupContent += "Area: " + value_area + " " + sufix_area + "<br>" ;
930
959
popupContent += "Side: " + value_side + " " + sufix_side + "<br>" ;
@@ -949,17 +978,17 @@ function layerTooltipFeature(feature,layer)
949
978
{
950
979
var layerTooltip = feature . properties . code_subcell ;
951
980
}
952
- else if ( feature . properties . short_code )
981
+ else if ( feature . properties . logistic_id )
953
982
{
954
- var layerTooltip = '.' + ( feature . properties . short_code . split ( / [ ~ ] / ) [ 1 ] ) ;
983
+ var layerTooltip = '.' + ( feature . properties . logistic_id . split ( / [ ~ ] / ) [ 1 ] ) ;
955
984
}
956
985
else if ( feature . properties . index )
957
986
{
958
987
var layerTooltip = '.' + feature . properties . index
959
988
}
960
989
else
961
990
{
962
- var layerTooltip = ( feature . properties . code ) ;
991
+ var layerTooltip = ( feature . id ) ;
963
992
}
964
993
965
994
layer . bindTooltip ( layerTooltip , { permanent :toggleTooltipStatus , direction :'auto' , className :'tooltip' + feature . properties . base } ) ;
@@ -1009,16 +1038,16 @@ function onEachFeature(feature,layer)
1009
1038
1010
1039
L . circleMarker ( center , { color : 'black' , radius : 3 , weight : 1 , opacity : 0.8 , fillOpacity : 0.6 } ) . addTo ( layerPolygonCurrent ) ;
1011
1040
1012
- if ( feature . properties . scientic_code )
1041
+ if ( feature . id )
1013
1042
{
1014
- const codsci = ( feature . properties . scientic_code ) . replace ( / ( [ G Q H M R V J K N P S T Z Y ] ) / g, '\.$1' ) ;
1015
- document . getElementById ( 'sciCode' ) . innerHTML = '<a href="' + uri_base + '/' + defaultMap . isocode + defaultMap . bases [ defaultMap . scientificBase ] . symbol + feature . properties . scientic_code + '">' + defaultMap . isocode + defaultMap . bases [ defaultMap . scientificBase ] . symbol + '<span class="feSchrift">' + codsci + '</span></a>' ;
1043
+ const codsci = ( feature . id ) . replace ( / ( [ G Q H M R V J K N P S T Z Y ] ) / g, '\.$1' ) ;
1044
+ document . getElementById ( 'sciCode' ) . innerHTML = '<a href="' + uri_base + '/' + defaultMap . isocode + defaultMap . bases [ defaultMap . scientificBase ] . symbol + feature . id + '">' + defaultMap . isocode + defaultMap . bases [ defaultMap . scientificBase ] . symbol + '<span class="feSchrift">' + codsci + '</span></a>' ;
1016
1045
}
1017
1046
1018
- if ( feature . properties . short_code )
1047
+ if ( feature . properties . logistic_id )
1019
1048
{
1020
- document . getElementById ( 'sel_jurL3' ) . innerHTML == feature . properties . short_code . split ( / [ - ~ ] / ) [ 2 ] ? '' : updateJurisd ( feature . properties . isolabel_ext )
1021
- document . getElementById ( 'logCode' ) . innerHTML = ( feature . properties . short_code . split ( / [ ~ ] / ) [ 1 ] ) . replace ( reg , '$1.' ) ;
1049
+ document . getElementById ( 'sel_jurL3' ) . innerHTML == feature . properties . logistic_id . split ( / [ - ~ ] / ) [ 2 ] ? '' : updateJurisd ( feature . properties . isolabel_ext )
1050
+ document . getElementById ( 'logCode' ) . innerHTML = ( feature . properties . logistic_id . split ( / [ ~ ] / ) [ 1 ] ) . replace ( reg , '$1.' ) ;
1022
1051
}
1023
1052
1024
1053
layer . on ( {
@@ -1220,7 +1249,7 @@ function afterLoadJurisdAll(featureGroup,fittobounds=true,genSelect=true)
1220
1249
1221
1250
if ( genSelect )
1222
1251
{
1223
- document . getElementById ( 'level_size' ) . innerHTML = generateSelectLevel ( defaultMap . bases [ defaultMap . postalcodeBase ] , defaultMap . postalcodeBase , size_shortestprefix ) ;
1252
+ document . getElementById ( 'level_size' ) . innerHTML = generateSelectLevel ( defaultMap . bases [ defaultMap . postalcodeBase ] , size_shortestprefix ) ;
1224
1253
}
1225
1254
}
1226
1255
@@ -1249,7 +1278,7 @@ function afterData(data,layer)
1249
1278
}
1250
1279
}
1251
1280
1252
- if ( data . features [ 0 ] . properties . isolabel_ext && ! data . features [ 0 ] . properties . short_code )
1281
+ if ( data . features [ 0 ] . properties . isolabel_ext && ! data . features [ 0 ] . properties . logistic_id )
1253
1282
{
1254
1283
var nextURL = uri_base + "/" + data . features [ 0 ] . properties . canonical_pathname
1255
1284
const nextTitle = 'AFA.codes: ' + data . features [ 0 ] . properties . canonical_pathname ;
@@ -1259,7 +1288,7 @@ function afterData(data,layer)
1259
1288
}
1260
1289
else if ( ! data . features [ 0 ] . properties . index )
1261
1290
{
1262
- if ( data . features [ 0 ] . properties . short_code )
1291
+ if ( data . features [ 0 ] . properties . logistic_id )
1263
1292
{
1264
1293
if ( getJurisdAfterLoad )
1265
1294
{
@@ -1270,23 +1299,23 @@ function afterData(data,layer)
1270
1299
loadGeojson ( uri , [ layerJurisdAll ] , function ( e ) { afterLoadJurisdAll ( e , false ) } , function ( e ) { } ) ;
1271
1300
}
1272
1301
1273
- var nextURL = uri_base + "/" + data . features [ 0 ] . properties . short_code
1274
- const nextTitle = 'AFA.codes: ' + data . features [ 0 ] . properties . short_code ;
1302
+ var nextURL = uri_base + "/" + data . features [ 0 ] . properties . logistic_id
1303
+ const nextTitle = 'AFA.codes: ' + data . features [ 0 ] . properties . logistic_id ;
1275
1304
const nextState = { additionalInformation : 'to canonical.' } ;
1276
1305
1277
1306
window . history . pushState ( nextState , nextTitle , nextURL ) ;
1278
1307
1279
1308
1280
- document . getElementById ( 'fielddecode' ) . value = data . features [ 0 ] . properties . short_code . split ( / [ ~ ] / ) [ 1 ] ;
1309
+ document . getElementById ( 'fielddecode' ) . value = data . features [ 0 ] . properties . logistic_id . split ( / [ ~ ] / ) [ 1 ] ;
1281
1310
let df_short_code = ''
1282
1311
1283
1312
if ( data . features [ 0 ] . properties . isolabel_ext_abbrev )
1284
1313
{
1285
- df_short_code = '<small>' + ( data . features [ 0 ] . properties . isolabel_ext_abbrev ) + '~</small>' + data . features [ 0 ] . properties . short_code . split ( / [ ~ ] / ) [ 1 ] ;
1314
+ df_short_code = '<small>' + ( data . features [ 0 ] . properties . isolabel_ext_abbrev ) + '~</small>' + data . features [ 0 ] . properties . logistic_id . split ( / [ ~ ] / ) [ 1 ] ;
1286
1315
}
1287
1316
else
1288
1317
{
1289
- df_short_code = '<small>' + ( data . features [ 0 ] . properties . short_code ) . replace ( / ~ / , '~</small>' ) ;
1318
+ df_short_code = '<small>' + ( data . features [ 0 ] . properties . logistic_id ) . replace ( / ~ / , '~</small>' ) ;
1290
1319
}
1291
1320
1292
1321
document . getElementById ( 'canonicalCode' ) . innerHTML = df_short_code . replace ( / ( [ a - z ] ) ( [ A - Z ] ) / g, '$1.$2' ) ;
@@ -1300,7 +1329,7 @@ function afterData(data,layer)
1300
1329
{
1301
1330
sizeCurrentCell = data . features [ 0 ] . properties . side ;
1302
1331
1303
- document . getElementById ( 'level_size' ) . innerHTML = generateSelectLevel ( defaultMap . bases [ defaultMap . postalcodeBase ] , defaultMap . postalcodeBase , size_shortestprefix , sizeCurrentCell ) ;
1332
+ document . getElementById ( 'level_size' ) . innerHTML = generateSelectLevel ( defaultMap . bases [ defaultMap . postalcodeBase ] , size_shortestprefix , sizeCurrentCell ) ;
1304
1333
1305
1334
let level = document . getElementById ( 'level_size' ) . value
1306
1335
let decimals = ( level <= 64 ? 5 : 4 )
@@ -1312,9 +1341,9 @@ function afterData(data,layer)
1312
1341
document . getElementById ( 'fieldencode' ) . value = 'geo:' + latRound ( lat ) + "," + latRound ( lng ) + ";u=" + document . getElementById ( 'level_size' ) . value ;
1313
1342
}
1314
1343
}
1315
- else if ( data . features [ 0 ] . properties . code )
1344
+ else if ( data . features [ 0 ] . id )
1316
1345
{
1317
- document . getElementById ( 'fielddecode' ) . value = data . features [ 0 ] . properties . code ;
1346
+ document . getElementById ( 'fielddecode' ) . value = data . features [ 0 ] . id ;
1318
1347
}
1319
1348
}
1320
1349
}
@@ -1328,7 +1357,7 @@ function afterDataOlcGhs(data,layer)
1328
1357
{
1329
1358
sizeCurrentCell = data . features [ 0 ] . properties . side ;
1330
1359
1331
- document . getElementById ( 'level_size' ) . innerHTML = generateSelectLevel ( defaultMap . bases [ defaultMap . postalcodeBase ] , defaultMap . postalcodeBase , size_shortestprefix , sizeCurrentCell ) ;
1360
+ document . getElementById ( 'level_size' ) . innerHTML = generateSelectLevel ( defaultMap . bases [ defaultMap . postalcodeBase ] , size_shortestprefix , sizeCurrentCell ) ;
1332
1361
1333
1362
document . getElementById ( 'tcode' ) . innerHTML = generateSelectTypeCode ( data . features [ 0 ] . properties . type ) ;
1334
1363
@@ -1341,8 +1370,8 @@ function afterDataOlcGhs(data,layer)
1341
1370
document . getElementById ( 'geoUri' ) . innerHTML = 'geo:' + data . features [ 0 ] . properties . type + ':' + latRound ( lat , decimals ) + "," + latRound ( lng , decimals ) ;
1342
1371
document . getElementById ( 'fieldencode' ) . value = 'geo:' + data . features [ 0 ] . properties . type + ':' + latRound ( lat ) + "," + latRound ( lng ) + ";u=" + document . getElementById ( 'level_size' ) . value ;
1343
1372
1344
- var nextURL = uri_base + "/geo:" + data . features [ 0 ] . properties . type + ':' + data . features [ 0 ] . properties . code
1345
- const nextTitle = 'AFA.codes: ' + data . features [ 0 ] . properties . code ;
1373
+ var nextURL = uri_base + "/geo:" + data . features [ 0 ] . properties . type + ':' + data . features [ 0 ] . id
1374
+ const nextTitle = 'AFA.codes: ' + data . features [ 0 ] . id ;
1346
1375
const nextState = { additionalInformation : 'to canonical.' } ;
1347
1376
1348
1377
window . history . pushState ( nextState , nextTitle , nextURL ) ;
0 commit comments