@@ -75,18 +75,33 @@ window.onload = function _onload() {
75
75
let layerControl ;
76
76
let config = { places : [ ] , tracks : [ ] } ;
77
77
mapInit ( ) ;
78
+ placeAddOption ( 'Overview' ) ;
78
79
trackTableUpdate ( ) ;
79
80
mapUpdateTrackLegend ( ) ;
80
- urls . forEach ( url => {
81
- if ( isDef ( url ) && ( '' != url ) ) {
82
- const name = url . toLowerCase ( ) ;
83
- if ( name . endsWith ( '.json' ) ) {
84
- configFetchJson ( url ) ;
85
- } else if ( name . endsWith ( '.ubx' ) ) {
86
- trackFetchUrl ( url ) ;
81
+ if ( 0 < urls . length ) {
82
+ urls . forEach ( url => {
83
+ if ( isDef ( url ) && ( '' != url ) ) {
84
+ const name = url . toLowerCase ( ) ;
85
+ if ( name . endsWith ( '.json' ) ) {
86
+ configFetchJson ( url ) ;
87
+ } else if ( name . endsWith ( '.ubx' ) ) {
88
+ trackFetchUrl ( url ) ;
89
+ }
87
90
}
91
+ } ) ;
92
+ } else {
93
+ if ( navigator . geolocation && map ) {
94
+ navigator . geolocation . getCurrentPosition (
95
+
96
+ ( position ) => {
97
+ map . setView ( [ position . coords . latitude , position . coords . longitude ] , 14 , { animate : false } )
98
+ mapsContainer . style . display = 'block' ;
99
+ } ,
100
+ ( err ) => { } ,
101
+ { timeout : 1000 } // Timeout in ms
102
+ ) ;
88
103
}
89
- } ) ;
104
+ }
90
105
91
106
// -------------------------------------------------------------
92
107
// MAP
@@ -101,7 +116,8 @@ window.onload = function _onload() {
101
116
}
102
117
} ) ;
103
118
resizeObserver . observe ( mapsContainer ) ;
104
- map = L . map ( mapsContainer , { zoomControl : true , zoomSnap : 0.1 , wheelPxPerZoomLevel : 20 , boxZoom : true , selectArea : true } ) ;
119
+ map = L . map ( mapsContainer , { zoomControl : true , zoomSnap : 0.1 , wheelPxPerZoomLevel : 20 , boxZoom : true } ) ;
120
+ map . selectArea . enable ( ) ;
105
121
map . selectArea . setControlKey ( true ) ;
106
122
L . control . scale ( ) . addTo ( map ) ;
107
123
mapSetOpacity ( opacitySlider . value ) ;
@@ -257,7 +273,6 @@ window.onload = function _onload() {
257
273
const w = parseInt ( Math . abs ( ne . x - sw . x ) ) ;
258
274
const h = parseInt ( Math . abs ( ne . y - sw . y ) ) ;
259
275
const place = { name :name , size : [ w , h ] , bounds :[ sw , ne ] } ;
260
- config . places . push ( place ) ;
261
276
placeAddOption ( place . name , place ) ;
262
277
}
263
278
}
@@ -269,23 +284,25 @@ window.onload = function _onload() {
269
284
option . place = place ;
270
285
placeSelect . appendChild ( option ) ;
271
286
if ( isDef ( place ) ) {
272
- let bounds = place . bounds ;
273
- if ( ! isDef ( bounds ) && isDef ( place . size ) && isDef ( place . center ) && isDef ( place . zoom ) ) {
287
+ if ( ! isDef ( place . bounds ) && isDef ( place . size ) && isDef ( place . center ) && isDef ( place . zoom ) ) {
274
288
const temp = L . map ( document . createElement ( 'div' ) , { center : place . center , zoom : place . zoom } ) ;
275
289
temp . _size = L . point ( place . size [ 0 ] , place . size [ 1 ] ) ;
276
290
temp . _resetView ( L . latLng ( place . center ) , place . zoom ) ;
277
- bounds = temp . getBounds ( ) ;
291
+ const sw = temp . getBounds ( ) . getSouthWest ( ) ;
292
+ const ne = temp . getBounds ( ) . getNorthEast ( ) ;
293
+ place . bounds = [ [ sw . lat , sw . lng ] , [ ne . lat , ne . lng ] ] ;
278
294
}
279
- if ( isDef ( bounds ) ) {
280
- const marker = L . rectangle ( bounds , { dashArray : '5, 5' , weight : 2 , className : 'place' } ) ;
295
+ if ( isDef ( place . bounds ) ) {
296
+ const marker = L . rectangle ( place . bounds , { dashArray : '5, 5' , weight : 2 , className : 'place' } ) ;
281
297
marker . place = place ;
282
298
marker . on ( 'click' , ( e ) => {
283
299
const isOverview = ( place . name == placeSelect . value ) ;
284
- placeChange ( isOverview ? null : place , e . originalEvent . ctrlKey ) ;
300
+ placeChange ( isOverview ? undefined : place , e . originalEvent . ctrlKey ) ;
285
301
placeSelect . value = isOverview ? 'Overview' : place . name ;
286
302
} ) ;
287
303
placesLayer . addLayer ( marker ) ;
288
304
}
305
+ config . places . push ( place ) ;
289
306
}
290
307
}
291
308
@@ -307,7 +324,6 @@ window.onload = function _onload() {
307
324
[ Math . min ( ...tracks . map ( item => item . bounds [ 0 ] [ 0 ] ) ) , Math . min ( ...tracks . map ( item => item . bounds [ 0 ] [ 1 ] ) ) ] ,
308
325
[ Math . max ( ...tracks . map ( item => item . bounds [ 1 ] [ 0 ] ) ) , Math . max ( ...tracks . map ( item => item . bounds [ 1 ] [ 1 ] ) ) ] ) ;
309
326
map . fitBounds ( bounds , { animate : false } ) ;
310
- map . panTo ( bounds . getCenter ( ) , { animate : false } ) ;
311
327
mapsContainer . style . display = 'block' ;
312
328
}
313
329
}
@@ -320,8 +336,8 @@ window.onload = function _onload() {
320
336
placesLayer = L . layerGroup ( ) . addTo ( map ) ;
321
337
layerControl . addOverlay ( placesLayer , "Places" ) ;
322
338
placeSelect . options . length = 0 ;
323
- config . places = [ ] ;
324
339
placeAddOption ( 'Overview' ) ;
340
+ config . places = [ ] ;
325
341
if ( isDef ( places ) ) {
326
342
places . forEach ( ( place , idx ) => {
327
343
placeAddOption ( place . name , place ) ;
@@ -387,7 +403,7 @@ window.onload = function _onload() {
387
403
function trackFetchUrl ( track ) {
388
404
const groupLayer = trackAdd ( track ) ;
389
405
if ( track . epochs ) {
390
- if ( ! track . bounds ) {
406
+ if ( track . bounds ) {
391
407
track . bounds = epochsGetBounds ( track . epochs ) ;
392
408
}
393
409
if ( track . selected ) {
@@ -466,10 +482,11 @@ window.onload = function _onload() {
466
482
467
483
function trackTableUpdate ( ) {
468
484
const table = document . getElementById ( 'table_tracks' ) ;
469
- let html = '<tr><th>Track Name</th><th>Color</th><th>Module</th><th>Firmware</th><th>Protocol</th><th>Hardware</th><th>ROM</th></tr>' ;
485
+ let html = '<tr><th>Track Name</th><th>Color</th><th>Epochs</th><th> Module</th><th>Firmware</th><th>Protocol</th><th>Hardware</th><th>ROM</th></tr>' ;
470
486
config . tracks . forEach ( ( track ) => {
471
487
html += '<tr><td>' + track . name + '</td>' ;
472
488
html += '<td><input type="color" disabled value="' + track . color + '"></input></td>' ;
489
+ html += '<td>' + ( isDef ( track . epochs ) ? track . epochs . length : '' ) + '</td>' ;
473
490
html += '<td>' + trackGetInfo ( track , 'module' ) + '</td>' ;
474
491
let fwVer = trackGetInfo ( track , 'fwVer' ) ;
475
492
if ( fwVer == '' ) {
@@ -509,21 +526,23 @@ window.onload = function _onload() {
509
526
if ( messages . length ) {
510
527
let epoch = { fields : { } , ids : { } , info : [ ] } ;
511
528
messages . forEach ( function ( message ) {
512
- if ( ( message . type === 'output' ) && message . protocol . match ( / ^ N M E A | U B X $ / ) && isDef ( message . fields ) ) {
513
- if ( epochCheck ( epoch , message ) ) {
514
- const colorMap = {
515
- 'DR' : 'purple' , '2D' : 'blue' ,
516
- '2D/3D' : 'green' , '3D' : 'green' , 'DGPS' : 'green' ,
517
- '3D+DR' : 'purple' , 'FIXED' : 'green' , 'FLOAT' : 'green'
518
- } ;
519
- if ( isDef ( epoch . fields . lat ) && isDef ( epoch . fields . lon ) && isDef ( epoch . fields . fix ) && isDef ( colorMap [ epoch . fields . fix ] ) ) {
520
- epochs . push ( { color : colorMap [ epoch . fields . fix ] , center : [ epoch . fields . lat , epoch . fields . lon ] , fields : epoch . fields , info : epoch . info } ) ;
521
- epoch . info = [ ] ;
529
+ if ( ( message . type === 'output' ) && message . protocol . match ( / ^ N M E A | U B X $ / ) ) {
530
+ if ( isDef ( message . fields ) ) {
531
+ if ( epochCheck ( epoch , message ) ) {
532
+ const colorMap = {
533
+ 'DR' : 'purple' , '2D' : 'blue' ,
534
+ '2D/3D' : 'green' , '3D' : 'green' , 'DGPS' : 'green' ,
535
+ '3D+DR' : 'purple' , 'FIXED' : 'green' , 'FLOAT' : 'green'
536
+ } ;
537
+ if ( isDef ( epoch . fields . lat ) && isDef ( epoch . fields . lon ) && isDef ( epoch . fields . fix ) && isDef ( colorMap [ epoch . fields . fix ] ) ) {
538
+ epochs . push ( { color : colorMap [ epoch . fields . fix ] , center : [ epoch . fields . lat , epoch . fields . lon ] , fields : epoch . fields , info : epoch . info } ) ;
539
+ epoch . info = [ ] ;
540
+ }
541
+ epoch . fields = { } ;
542
+ epoch . ids = { } ;
522
543
}
523
- epoch . fields = { } ;
524
- epoch . ids = { } ;
544
+ epochFill ( epoch . fields , message . fields ) ;
525
545
}
526
- epochFill ( epoch . fields , message . fields ) ;
527
546
convertMessageExtract ( track , message ) ;
528
547
epoch . ids [ message . id ] = true ;
529
548
let m = message . name . match ( / ^ ( I N F - ( E R R O R | W A R N I N G | N O T I C E ) | ( G [ P N ] T X T ) ) $ / )
@@ -540,7 +559,7 @@ window.onload = function _onload() {
540
559
}
541
560
542
561
function convertMessageExtract ( track , message ) {
543
- if ( message . protocol === 'UBX' ) {
562
+ if ( ( message . protocol === 'UBX' ) && isDef ( message . fields ) ) {
544
563
if ( message . name === 'MON-VER' ) {
545
564
convertSetInfo ( track , 'monFwVer' , message . fields . swVer ) ;
546
565
convertSetInfo ( track , 'monHwVer' , message . fields . hwVer ) ;
@@ -551,8 +570,19 @@ window.onload = function _onload() {
551
570
} else if ( message . name === 'INF-NOTICE' ) {
552
571
convertTextExtract ( track , message . fields . infTxt ) ;
553
572
}
554
- } if ( ( message . protocol === 'NMEA' ) && ( message . id === 'TXT' ) ) {
555
- convertTextExtract ( track , message . fields . infTxt ) ;
573
+ } else if ( message . protocol === 'NMEA' ) {
574
+ if ( ( message . id === 'TXT' ) && isDef ( message . fields ) ) {
575
+ convertTextExtract ( track , message . fields . infTxt ) ;
576
+ } else {
577
+ // $PAIR021,Project,Freq,SWPack,SerVer,SerBuildTime,L1RomVer>,L1ramVer,L5romVer,L5RamVer,KernelVer,KernelBuildTime,KFVersion,KFBuildTime,RTKVersion,RTKBuildTime,...
578
+ // $PAIR021,AG3352Q_V2.3.0.AG3352_20230213,S,N,2b31f59,2209141904,2b9,0,,,d32ef91c,2209141902,571d3e7,2209141904,,,-15.48,-15.48,-14.02,-15.48,0,1,##,0,0*6D
579
+ const m = message . text . match ( / ^ \$ P A I R 0 2 [ 1 | 0 ] , ( [ ^ _ ] * ) _ ( [ ^ \, ] * ) \. ( [ ^ , ] * ) , ( \w ) / ) ;
580
+ if ( m ) {
581
+ convertSetInfo ( track , 'module' , m [ 1 ] ) ;
582
+ convertSetInfo ( track , 'fwVer' , m [ 2 ] ) ;
583
+ convertSetInfo ( track , 'hwVer' , m [ 3 ] ) ;
584
+ }
585
+ }
556
586
}
557
587
}
558
588
@@ -721,23 +751,6 @@ window.onload = function _onload() {
721
751
const dd = String ( d ) . padStart ( 2 , '0' ) ;
722
752
return `${ y } -${ mm } -${ d } ` ;
723
753
}
724
-
725
- function fmtValue ( value ) {
726
- let text = '' ;
727
- if ( isDef ( value ) ) {
728
- if ( typeof value === 'object' ) {
729
- return JSON . stringify ( value , null , 2 ) ;
730
- } else {
731
- const num = Number ( value ) ;
732
- if ( ! isNaN ( num ) ) {
733
- text = Number ( num . toFixed ( 10 ) ) ;
734
- } else {
735
- text = value
736
- }
737
- }
738
- }
739
- return text ;
740
- }
741
754
742
755
function jsonToTable ( json ) {
743
756
const rows = Object . entries ( json ) . map ( ( [ key , value ] ) => {
0 commit comments