@@ -376,27 +376,35 @@ export async function to_geojson(cot: CoT): Promise<Static<typeof Feature>> {
376376 && raw . event . detail . shape . link ?. Style
377377 ) {
378378 if ( raw . event . detail . shape . link . Style . LineStyle ?. color ) {
379- const rawColor = raw . event . detail . shape . link . Style . LineStyle . color . _text . startsWith ( '#' )
380- ? raw . event . detail . shape . link . Style . LineStyle . color . _text
381- : '#' + raw . event . detail . shape . link . Style . LineStyle . color . _text ;
379+ let rawColor = raw . event . detail . shape . link . Style . LineStyle . color . _text ;
380+ if ( rawColor . startsWith ( '#' ) ) rawColor = rawColor . substring ( 1 ) ;
382381
383- const strokeColor = new Color ( rawColor ) ;
382+ const a = parseInt ( rawColor . substring ( 0 , 2 ) , 16 ) ;
383+ const b = parseInt ( rawColor . substring ( 2 , 4 ) , 16 ) ;
384+ const g = parseInt ( rawColor . substring ( 4 , 6 ) , 16 ) ;
385+ const r = parseInt ( rawColor . substring ( 6 , 8 ) , 16 ) ;
386+
387+ const strokeColor = new Color ( [ a , r , g , b ] ) ;
384388 feat . properties . stroke = strokeColor . as_hex ( ) ;
385389
386- feat . properties [ 'stroke-opacity' ] = strokeColor . as_opacity ( ) ;
390+ feat . properties [ 'stroke-opacity' ] = strokeColor . as_opacity ( ) / 255 ;
387391 }
388392
389393 if ( raw . event . detail . shape . link . Style . LineStyle ?. width ) {
390394 feat . properties [ 'stroke-width' ] = Number ( raw . event . detail . shape . link . Style . LineStyle . width . _text ) ;
391395 }
392396
393397 if ( raw . event . detail . shape . link . Style . PolyStyle ?. color ) {
394- const rawColor = raw . event . detail . shape . link . Style . PolyStyle . color . _text . startsWith ( '#' )
395- ? raw . event . detail . shape . link . Style . PolyStyle . color . _text
396- : '#' + raw . event . detail . shape . link . Style . PolyStyle . color . _text ;
398+ let rawColor = raw . event . detail . shape . link . Style . PolyStyle . color . _text ;
399+ if ( rawColor . startsWith ( '#' ) ) rawColor = rawColor . substring ( 1 ) ;
400+
401+ const a = parseInt ( rawColor . substring ( 0 , 2 ) , 16 ) ;
402+ const b = parseInt ( rawColor . substring ( 2 , 4 ) , 16 ) ;
403+ const g = parseInt ( rawColor . substring ( 4 , 6 ) , 16 ) ;
404+ const r = parseInt ( rawColor . substring ( 6 , 8 ) , 16 ) ;
397405
398- const fillColor = new Color ( rawColor ) ;
399- feat . properties [ 'fill-opacity' ] = fillColor . as_opacity ( ) ;
406+ const fillColor = new Color ( [ a , r , g , b ] ) ;
407+ feat . properties [ 'fill-opacity' ] = fillColor . as_opacity ( ) / 255 ;
400408 feat . properties [ 'fill' ] = fillColor . as_hex ( ) ;
401409 }
402410 }
0 commit comments