diff src/app/services/feature-extraction/feature-extraction.service.ts @ 349:bf038a51f7e3

Restore some of the feature related logic from waveform.component into a utilities module. Introduce some additional types for representing reshaped features. A work in progress.
author Lucas Thompson <dev@lucas.im>
date Thu, 25 May 2017 17:57:03 +0100
parents e401995304a7
children 524f5cd75737
line wrap: on
line diff
--- a/src/app/services/feature-extraction/feature-extraction.service.ts	Thu May 25 17:56:14 2017 +0100
+++ b/src/app/services/feature-extraction/feature-extraction.service.ts	Thu May 25 17:57:03 2017 +0100
@@ -15,6 +15,10 @@
 } from 'piper/client-stubs/WebWorkerStreamingClient';
 import {RequestId} from 'piper/protocols/WebWorkerProtocol';
 import {collect, StreamingConfiguration} from 'piper/StreamingService';
+import {
+  KnownShapedFeature,
+  toKnownShape
+} from '../../visualisations/FeatureUtilities';
 
 type RepoUri = string;
 export interface AvailableLibraries {
@@ -30,8 +34,8 @@
 export class FeatureExtractionService {
 
   private worker: Worker;
-  private featuresExtracted: Subject<SimpleResponse>;
-  featuresExtracted$: Observable<SimpleResponse>;
+  private featuresExtracted: Subject<KnownShapedFeature>;
+  featuresExtracted$: Observable<KnownShapedFeature>;
   private librariesUpdated: Subject<ListResponse>;
   librariesUpdated$: Observable<ListResponse>;
   private progressUpdated: Subject<Progress>;
@@ -41,7 +45,7 @@
   constructor(private http: Http,
               @Inject('PiperRepoUri') private repositoryUri: RepoUri) {
     this.worker = new Worker('bootstrap-feature-extraction-worker.js');
-    this.featuresExtracted = new Subject<SimpleResponse>();
+    this.featuresExtracted = new Subject<KnownShapedFeature>();
     this.featuresExtracted$ = this.featuresExtracted.asObservable();
     this.librariesUpdated = new Subject<ListResponse>();
     this.librariesUpdated$ = this.librariesUpdated.asObservable();
@@ -80,10 +84,12 @@
         });
       }
     }).then(features => {
-      this.featuresExtracted.next({
+      const shaped = toKnownShape({
         features: features,
         outputDescriptor: config.outputDescriptor
       });
+      console.warn(shaped.shape);
+      this.featuresExtracted.next(shaped);
     });
   }
 
@@ -94,7 +100,7 @@
         this.worker.postMessage({
           method: 'addRemoteLibraries',
           params: res.json()
-        })
+        });
       })
       .catch(console.error); // TODO Report error to user
   }