-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata-model.ts
73 lines (60 loc) · 2.18 KB
/
data-model.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (c) 2016 - now, David Sehnal, licensed under Apache 2.0, See LICENSE file for more info.
*/
import * as DataFormat from '../../common/data-format'
import * as Coords from '../algebra/coordinate'
import * as Box from '../algebra/box'
import * as CIF from '../../lib/cif-tools'
//////////////////////////////////////
// DATA
//////////////////////////////////////
export interface Sampling {
index: number,
rate: number,
byteOffset: number,
dataDomain: Coords.GridDomain<'Data'>,
blockDomain: Coords.GridDomain<'Block'>
}
export interface DataContext {
file: number,
header: DataFormat.Header,
spacegroup: Coords.Spacegroup,
dataBox: Box.Fractional,
sampling: Sampling[]
}
export interface BlockData {
sampleCount: number[],
values: DataFormat.ValueArray
}
//////////////////////////////////////
// QUERY
//////////////////////////////////////
export type QueryOutputStream = CIF.OutputStream & { end: () => void }
export namespace QueryParamsBox {
export type Cartesian = { kind: 'Cartesian', a: Coords.Cartesian, b: Coords.Cartesian }
export type Fractional = { kind: 'Fractional', a: Coords.Fractional, b: Coords.Fractional }
export type Cell = { kind: 'Cell' }
}
export type QueryParamsBox = QueryParamsBox.Cartesian | QueryParamsBox.Fractional | QueryParamsBox.Cell
export interface QueryParams {
sourceFilename: string,
sourceId: string,
asBinary: boolean,
box: QueryParamsBox,
detail: number,
forcedSamplingLevel?: number
}
export type QueryBlock = { coord: Coords.Grid<'Block'>, offsets: Coords.Fractional[] }
export interface QuerySamplingInfo {
sampling: Sampling,
fractionalBox: Box.Fractional,
gridDomain: Coords.GridDomain<'Query'>,
blocks: QueryBlock[]
}
export type QueryContext = QueryContext.Error | QueryContext.Empty | QueryContext.Data
export namespace QueryContext {
type Base = { guid: string, params: QueryParams }
export type Error = { kind: 'Error', message: string } & Base
export type Empty = { kind: 'Empty', data: DataContext } & Base
export type Data = { kind: 'Data', data: DataContext, samplingInfo: QuerySamplingInfo, values: DataFormat.ValueArray[] } & Base
}