@@ -4,8 +4,8 @@ import { showFilePopup } from '../view/FilePopup';
4
4
import { showConfirmPopup } from '../view/ConfirmPopup' ;
5
5
import { showClipboardPopup } from '../view/ClipboardPopup' ;
6
6
import { showMapSelectPopup , showMapPreviewPopup } from '../view/MapPopup' ;
7
- import { SOURCE , MAP , WATCH_JOB , WATCH_URL , FILE_DEFAULTS , ACTIONS , PAGINATION } from '../constants' ;
8
- import { stateToPTIArray , stateToTransformRequest , stateToKomuRequest , parseKomuResponse , validateFileSettings , validateTransform , validateCoordinate , parseCoordinateValue , is3DSystem , getDimension , getLabelForMarker } from '../helper' ;
7
+ import { SOURCE , MAP , WATCH_JOB , WATCH_URL , FILE_DEFAULTS , ACTIONS , PAGINATION , SRS } from '../constants' ;
8
+ import { stateToPTIArray , stateToTransformRequest , stateToKomuRequest , parseKomuResponse , validateFileSettings , validateTransform , validateCoordinate , parseCoordinateValue , is3DSystem , getDimension , getLabelForMarker , getCoordinatesExtent } from '../helper' ;
9
9
import { parseFile , parseFileContents , parseValue } from './FileParser' ;
10
10
import { exportStateToFile } from './FileWriter' ;
11
11
@@ -45,6 +45,7 @@ class UIHandler extends StateHandler {
45
45
this . baseUrl = conf . url ;
46
46
this . transformFunction = this . getTransformFunction ( conf ) ;
47
47
Oskari . urls . set ( WATCH_JOB , WATCH_URL ) ;
48
+ this . log = Oskari . log ( 'CoordTransHandler' ) ;
48
49
}
49
50
50
51
getTransformFunction ( { url, contentType } ) {
@@ -184,8 +185,8 @@ class UIHandler extends StateHandler {
184
185
. map ( ( [ x , y , z ] ) => ( { x, y, z } ) ) ;
185
186
this . addSourceToState ( 'clipboard' ) ;
186
187
this . updateState ( { coordinates, transformed : false } ) ;
187
- } catch {
188
- // TODO: error handling
188
+ } catch ( err ) {
189
+ this . log . debug ( err ) ;
189
190
Messaging . error ( this . loc ( 'transform.errors.paste' ) ) ;
190
191
}
191
192
}
@@ -299,7 +300,7 @@ class UIHandler extends StateHandler {
299
300
import : newSettings // { ...settings, ...contents.settings }
300
301
} ) ;
301
302
} ) . catch ( err => {
302
- console . log ( err ) ;
303
+ this . log . debug ( err ) ;
303
304
Messaging . error ( this . log ( 'transform.errors.import' ) ) ;
304
305
} ) ;
305
306
}
@@ -517,9 +518,21 @@ class UIHandler extends StateHandler {
517
518
this . showConfirmTransform ( warnings ) ;
518
519
return ;
519
520
}
521
+ if ( this . log . isDebug ( ) ) {
522
+ this . debugTransform ( ) ;
523
+ }
520
524
this . transformFunction ( ) ;
521
525
}
522
526
527
+ debugTransform ( ) {
528
+ const { inputSrs, coordinates } = this . getState ( ) ;
529
+ const { bounds = [ ] } = SRS . find ( s => s . value === inputSrs ) || { } ;
530
+ const info = getCoordinatesExtent ( coordinates , inputSrs ) ;
531
+ this . log . debug ( 'Projected bounds for:' , inputSrs , bounds ) ;
532
+ Object . keys ( info ) . forEach ( key => this . log . debug ( key , '=>' , info [ key ] ) ) ;
533
+ }
534
+
535
+
523
536
importFileContentsToInputTable ( ) {
524
537
const errors = validateFileSettings ( this . getState ( ) , 'import' ) ;
525
538
if ( errors . length ) {
@@ -549,7 +562,7 @@ class UIHandler extends StateHandler {
549
562
try {
550
563
exportStateToFile ( state ) ;
551
564
} catch ( err ) {
552
- console . log ( err ) ;
565
+ this . log . debug ( err ) ;
553
566
Messaging . error ( this . loc ( 'transform.errors.export' ) ) ;
554
567
}
555
568
this . updateState ( { loading : false } ) ;
@@ -702,7 +715,6 @@ class UIHandler extends StateHandler {
702
715
showResponseError ( response ) {
703
716
const { error, info } = response || { } ;
704
717
const key = info ?. errorKey || error ?. errorKey || 'generic' ;
705
- Oskari . log ( 'CoordTransHandler' ) . error ( error ) ;
706
718
Messaging . error ( this . loc ( `transform.errors.${ key } ` ) ) ;
707
719
this . updateState ( { loading : false } ) ;
708
720
}
0 commit comments