@loaders.gl/schema 4.0.0-alpha.9 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +558 -943
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js +4 -3
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/es5/lib/table/simple-table/convert-table.js +24 -0
- package/dist/es5/lib/table/simple-table/convert-table.js.map +1 -1
- package/dist/es5/lib/table/simple-table/table-accessors.js +69 -42
- package/dist/es5/lib/table/simple-table/table-accessors.js.map +1 -1
- package/dist/es5/types/batch.js +2 -0
- package/dist/es5/types/batch.js.map +1 -0
- package/dist/es5/types/binary-geometries.js +2 -0
- package/dist/es5/types/binary-geometries.js.map +1 -0
- package/dist/es5/types/category-gis.js.map +1 -1
- package/dist/es5/types/category-image.js.map +1 -1
- package/dist/es5/types/category-table.js.map +1 -1
- package/dist/es5/types/flat-geometries.js +2 -0
- package/dist/es5/types/flat-geometries.js.map +1 -0
- package/dist/es5/types/schema.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js +4 -3
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +1 -1
- package/dist/esm/lib/table/simple-table/convert-table.js +22 -0
- package/dist/esm/lib/table/simple-table/convert-table.js.map +1 -1
- package/dist/esm/lib/table/simple-table/table-accessors.js +49 -22
- package/dist/esm/lib/table/simple-table/table-accessors.js.map +1 -1
- package/dist/esm/types/batch.js +2 -0
- package/dist/esm/types/batch.js.map +1 -0
- package/dist/esm/types/binary-geometries.js +2 -0
- package/dist/esm/types/binary-geometries.js.map +1 -0
- package/dist/esm/types/category-gis.js.map +1 -1
- package/dist/esm/types/category-image.js.map +1 -1
- package/dist/esm/types/category-table.js.map +1 -1
- package/dist/esm/types/flat-geometries.js +2 -0
- package/dist/esm/types/flat-geometries.js.map +1 -0
- package/dist/esm/types/schema.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts +1 -5
- package/dist/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts +3 -3
- package/dist/lib/table/batches/row-table-batch-aggregator.d.ts.map +1 -1
- package/dist/lib/table/simple-table/convert-table.d.ts +34 -1
- package/dist/lib/table/simple-table/convert-table.d.ts.map +1 -1
- package/dist/lib/table/simple-table/table-accessors.d.ts.map +1 -1
- package/dist/types/batch.d.ts +34 -0
- package/dist/types/batch.d.ts.map +1 -0
- package/dist/types/binary-geometries.d.ts +56 -0
- package/dist/types/binary-geometries.d.ts.map +1 -0
- package/dist/types/category-gis.d.ts +3 -84
- package/dist/types/category-gis.d.ts.map +1 -1
- package/dist/types/category-image.d.ts +1 -1
- package/dist/types/category-image.d.ts.map +1 -1
- package/dist/types/category-table.d.ts +42 -22
- package/dist/types/category-table.d.ts.map +1 -1
- package/dist/types/flat-geometries.d.ts +30 -0
- package/dist/types/flat-geometries.d.ts.map +1 -0
- package/dist/types/schema.d.ts +0 -15
- package/dist/types/schema.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +13 -7
- package/src/lib/table/arrow-api/arrow-like-table.ts +3 -2
- package/src/lib/table/batches/row-table-batch-aggregator.ts +2 -2
- package/src/lib/table/simple-table/convert-table.ts +73 -1
- package/src/lib/table/simple-table/table-accessors.ts +56 -22
- package/src/types/batch.ts +41 -0
- package/src/types/binary-geometries.ts +62 -0
- package/src/types/category-gis.ts +30 -104
- package/src/types/category-image.ts +1 -1
- package/src/types/category-table.ts +49 -27
- package/src/types/flat-geometries.ts +40 -0
- package/src/types/schema.ts +0 -17
- package/dist/bundle.js +0 -5
- package/dist/index.js +0 -92
- package/dist/lib/mesh/convert-mesh.js +0 -40
- package/dist/lib/mesh/deduce-mesh-schema.js +0 -66
- package/dist/lib/mesh/mesh-to-arrow-table.js +0 -44
- package/dist/lib/mesh/mesh-utils.js +0 -51
- package/dist/lib/table/arrow/arrow-type-utils.js +0 -53
- package/dist/lib/table/arrow/convert-schema-arrow.js +0 -187
- package/dist/lib/table/arrow/convert-table-to-arrow.js +0 -57
- package/dist/lib/table/arrow-api/arrow-like-field.js +0 -34
- package/dist/lib/table/arrow-api/arrow-like-schema.js +0 -81
- package/dist/lib/table/arrow-api/arrow-like-table.js +0 -53
- package/dist/lib/table/arrow-api/arrow-like-type.js +0 -463
- package/dist/lib/table/arrow-api/enum.js +0 -97
- package/dist/lib/table/arrow-api/get-type-info.js +0 -29
- package/dist/lib/table/arrow-api/index.js +0 -25
- package/dist/lib/table/batches/base-table-batch-aggregator.js +0 -60
- package/dist/lib/table/batches/columnar-table-batch-aggregator.js +0 -92
- package/dist/lib/table/batches/row-table-batch-aggregator.js +0 -81
- package/dist/lib/table/batches/table-batch-aggregator.js +0 -3
- package/dist/lib/table/batches/table-batch-builder.js +0 -152
- package/dist/lib/table/simple-table/convert-table.js +0 -65
- package/dist/lib/table/simple-table/data-type.js +0 -93
- package/dist/lib/table/simple-table/make-table.js +0 -95
- package/dist/lib/table/simple-table/row-utils.js +0 -33
- package/dist/lib/table/simple-table/table-accessors.js +0 -319
- package/dist/lib/table/simple-table/table-column.js +0 -41
- package/dist/lib/table/simple-table/table-schema.js +0 -85
- package/dist/lib/utils/assert.js +0 -12
- package/dist/lib/utils/async-queue.js +0 -92
- package/dist/types/category-gis.js +0 -2
- package/dist/types/category-image.js +0 -2
- package/dist/types/category-mesh.js +0 -3
- package/dist/types/category-table.js +0 -3
- package/dist/types/category-texture.js +0 -3
- package/dist/types/schema.js +0 -3
- package/dist/types/types.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-gis.js","names":[],"sources":["../../../src/types/category-gis.ts"],"sourcesContent":["// GIS\
|
|
1
|
+
{"version":3,"file":"category-gis.js","names":[],"sources":["../../../src/types/category-gis.ts"],"sourcesContent":["// GIS\n\n// NORMAL GEOJSON FORMAT GEOMETRY\nexport type {\n GeoJSON,\n Feature,\n FeatureCollection,\n Geometry,\n Position,\n GeoJsonProperties\n} from 'geojson';\n\nexport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon,\n GeometryCollection\n} from 'geojson';\n\n// FLAT GEOJSON FORMAT GEOMETRY\nexport type {\n FlatGeometryType,\n FlatIndexedGeometry,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n FlatGeometry,\n FlatFeature\n} from './flat-geometries';\n\n// BINARY FORMAT GEOMETRY\nexport type {\n BinaryAttribute,\n BinaryGeometryType,\n BinaryGeometry,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryProperties,\n BinaryFeatureCollection,\n BinaryFeature,\n BinaryPointFeature,\n BinaryLineFeature,\n BinaryPolygonFeature\n} from './binary-geometries';\n\n/** Aggregate information for converting GeoJSON into other formats */\nexport type GeojsonGeometryInfo = {\n coordLength: number;\n pointPositionsCount: number;\n pointFeaturesCount: number;\n linePositionsCount: number;\n linePathsCount: number;\n lineFeaturesCount: number;\n polygonPositionsCount: number;\n polygonObjectsCount: number;\n polygonRingsCount: number;\n polygonFeaturesCount: number;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-image.js","names":[],"sources":["../../../src/types/category-image.ts"],"sourcesContent":["/**\n * data images\n */\nexport type ImageDataType = {\n data: Uint8Array;\n width: number;\n height: number;\n compressed?: boolean;\n};\n\n/**\n * Supported Image Types\n */\nexport type ImageType = ImageBitmap |
|
|
1
|
+
{"version":3,"file":"category-image.js","names":[],"sources":["../../../src/types/category-image.ts"],"sourcesContent":["/**\n * data images\n */\nexport type ImageDataType = {\n data: Uint8Array;\n width: number;\n height: number;\n compressed?: boolean;\n};\n\n/**\n * Supported Image Types\n */\nexport type ImageType = ImageBitmap | ImageDataType | HTMLImageElement;\n\n/**\n * Image type string used to control or determine the type of images returned from ImageLoader\n */\nexport type ImageTypeEnum = 'imagebitmap' | 'image' | 'data';\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-table.js","names":[],"sources":["../../../src/types/category-table.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {
|
|
1
|
+
{"version":3,"file":"category-table.js","names":[],"sources":["../../../src/types/category-table.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from './schema';\nimport type {Batch} from './batch';\nimport type {Feature} from './category-gis';\n\n// Avoid a big dependency, apparently even a type import can pull in a lot of code\n// import type {Table as ApacheArrowTable} from 'apache-arrow';\n\ntype ApacheArrowTable = unknown;\ntype ApacheRecordBatch = unknown;\n\n/** A general table */\nexport type Table =\n | RowTable\n | ArrayRowTable\n | ObjectRowTable\n | GeoJSONTable\n | ColumnarTable\n | ArrowTable;\n\n/** A table organized as an array of rows */\nexport type RowTable = ArrayRowTable | ObjectRowTable | GeoJSONTable;\n\n/** A table organized as an array of rows, each row is an array of values */\nexport type ArrayRowTable = {\n shape: 'array-row-table';\n schema?: Schema;\n data: any[][];\n};\n\n/** A table organized as an array of rows, each row is an object mapping columns to values */\nexport type ObjectRowTable = {\n shape: 'object-row-table';\n schema?: Schema;\n data: {[columnName: string]: any}[];\n};\n\n/**\n * A table organized as an array of rows, each row is a GeoJSON Feature\n * @note For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data`\n */\nexport type GeoJSONTable = {\n shape: 'geojson-table';\n schema?: Schema;\n /** For compatibility with GeoJSON, the type field must always be set to `FeatureCollection` */\n type: 'FeatureCollection';\n /** For compatibility with GeoJSON, rows are stored in `table.features` instead of `table.data` */\n features: Feature[];\n};\n\n/** A table organized as a map of columns, each column is an array of value */\nexport type ColumnarTable = {\n shape: 'columnar-table';\n schema?: Schema;\n data: {[columnName: string]: ArrayLike<unknown>};\n};\n\n/** A table organized as an Apache Arrow table */\nexport type ArrowTable = {\n shape: 'arrow-table';\n schema?: Schema;\n data: ApacheArrowTable;\n};\n\n/** A collection of tables */\nexport type Tables<TableType = Table> = {\n shape: 'tables';\n tables: {name: string; table: TableType}[];\n};\n\n// Batches\n\n/** Batch for a general table */\nexport type TableBatch =\n | ArrayRowTableBatch\n | ObjectRowTableBatch\n | GeoJSONTableBatch\n | ColumnarTableBatch\n | ArrowTableBatch;\n\n/** Batch for a table organized as an array of rows, each row is an array of values */\nexport type ArrayRowTableBatch = Batch & {\n shape: 'array-row-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n data: any[][];\n length: number;\n};\n\n/** Batch for a table organized as an array of rows, each row is an object mapping columns to values */\nexport type ObjectRowTableBatch = Batch & {\n shape: 'object-row-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n data: {[columnName: string]: any}[];\n length: number;\n};\n\n/** Batch for a table organized as an array of rows, each row is an array of values */\nexport type GeoJSONTableBatch = Batch & {\n shape: 'geojson-table';\n schema?: Schema;\n schemaType?: 'explicit' | 'deduced';\n type: 'FeatureCollection';\n features: Feature[];\n length: number;\n};\n\n/** Batch for a table organized as a map of columns, each column is an array of value */\nexport type ColumnarTableBatch = Batch & {\n shape: 'columnar-table';\n schemaType?: 'explicit' | 'deduced';\n schema?: Schema;\n data: {[columnName: string]: ArrayLike<unknown>};\n length: number;\n};\n\n/** Batch for a table organized as an Apache Arrow table */\nexport type ArrowTableBatch = Batch & {\n shape: 'arrow-table';\n schemaType?: 'explicit' | 'deduced';\n schema?: Schema;\n data: ApacheRecordBatch;\n length: number;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flat-geometries.js","names":[],"sources":["../../../src/types/flat-geometries.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n// FLAT GEOJSON FORMAT GEOMETRY\nimport type {Feature, Geometry, Point, LineString, Polygon} from 'geojson';\n\n/** Flat geometry type */\nexport type FlatGeometryType = 'Point' | 'LineString' | 'Polygon';\n\ntype RemoveCoordinatesField<Type> = {\n [Property in keyof Type as Exclude<Property, 'coordinates'>]: Type[Property];\n};\n\n/** Generic flat geometry data storage type */\nexport type FlatIndexedGeometry = {\n data: number[];\n indices: number[];\n};\n\n/** GeoJSON (Multi)Point geometry with coordinate data flattened into `data` array and indexed by `indices` */\nexport type FlatPoint = RemoveCoordinatesField<Point> & FlatIndexedGeometry;\n\n/** GeoJSON (Multi)LineString geometry with coordinate data flattened into `data` array and indexed by `indices` */\nexport type FlatLineString = RemoveCoordinatesField<LineString> & FlatIndexedGeometry;\n\n/** GeoJSON (Multi)Polygon geometry with coordinate data flattened into `data` array and indexed by 2D `indices` */\nexport type FlatPolygon = RemoveCoordinatesField<Polygon> & {\n data: number[];\n indices: number[][];\n areas: number[][];\n};\n\n/** GeoJSON geometry with coordinate data flattened into `data` array and indexed by 2D `indices` */\nexport type FlatGeometry = FlatPoint | FlatLineString | FlatPolygon;\n\ntype FlattenGeometry<Type> = {\n [Property in keyof Type]: Type[Property] extends Geometry ? FlatGeometry : Type[Property];\n};\n\n/** GeoJSON Feature with Geometry replaced by FlatGeometry */\nexport type FlatFeature = FlattenGeometry<Feature>;\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":[],"sources":["../../../src/types/schema.ts"],"sourcesContent":["// loaders.gl, MIT license\n\
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../../src/types/schema.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/** For dictionary type */\nexport type KeyType = 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32';\n\n/** ArrowLike DataType class */\nexport type DataType =\n | 'null'\n // Primitive types\n | 'bool'\n | 'int'\n | 'int8'\n | 'int16'\n | 'int32'\n | 'int64'\n | 'uint8'\n | 'uint16'\n | 'uint32'\n | 'uint64'\n | 'float'\n | 'float16'\n | 'float32'\n | 'float64'\n | 'binary'\n | 'utf8'\n | 'date-day'\n | 'date-millisecond'\n | 'time-second'\n | 'time-millisecond'\n | 'time-microsecond'\n | 'time-nanosecond'\n | 'timestamp-second'\n | 'timestamp-millisecond'\n | 'timestamp-microsecond'\n | 'timestamp-nanosecond'\n | 'interval-daytime'\n | 'interval-yearmonth'\n // Composite types\n | {type: 'list'; children: Field[]} // one child only\n | {type: 'struct'; children: Field[]}\n | {\n type: 'sparse-union';\n typeIds: Int32Array;\n children: Field[];\n typeIdToChildIndex: {[key: number]: number};\n }\n | {\n type: 'dense-union';\n typeIds: Int32Array;\n children: Field[];\n typeIdToChildIndex: {[key: number]: number};\n }\n | {type: 'fixed-size-binary'; byteWidth: number}\n | {type: 'fixed-size-list'; listSize: number; children: Field[]}\n | {type: 'map'; keysSorted: boolean; children: Field[]} // Field is \"struct\"\n | {type: 'dictionary'; id: number; indices: KeyType; dictionary: DataType; isOrdered: boolean};\n// TODO - unions etc\n\n/**\n * SchemaMetadata\n */\nexport type SchemaMetadata = Record<string, string>;\nexport type FieldMetadata = Record<string, string>;\n\nexport type Field = {\n name: string;\n type: DataType;\n nullable?: boolean;\n metadata?: FieldMetadata;\n};\n\n/**\n * `Schema` type that that can hold all data required by an Arrow Schema\n * but is fully serializable. Helper functions make it easy to convert to and from arrow schemas\n * https://loaders.gl/arrowjs/docs/api-reference/schema\n */\nexport type Schema = {\n fields: Field[];\n metadata: SchemaMetadata;\n};\n"],"mappings":""}
|
package/dist/esm/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { ColumnarTableBatchAggregator } from './lib/table/batches/columnar-table
|
|
|
4
4
|
export { getTableLength, getTableNumCols, getTableCell, getTableRowShape, getTableColumnIndex, getTableColumnName, getTableRowAsObject, getTableRowAsArray, makeRowIterator, makeArrayRowIterator, makeObjectRowIterator } from './lib/table/simple-table/table-accessors';
|
|
5
5
|
export { ArrowLikeTable } from './lib/table/arrow-api/arrow-like-table';
|
|
6
6
|
export { makeTableFromData } from './lib/table/simple-table/make-table';
|
|
7
|
+
export { convertTable } from './lib/table/simple-table/convert-table';
|
|
7
8
|
export { deduceTableSchema } from './lib/table/simple-table/table-schema';
|
|
8
9
|
export { convertToObjectRow, convertToArrayRow } from './lib/table/simple-table/row-utils';
|
|
9
10
|
export { getDataTypeFromArray } from './lib/table/simple-table/data-type';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TableBatchBuilder","RowTableBatchAggregator","ColumnarTableBatchAggregator","getTableLength","getTableNumCols","getTableCell","getTableRowShape","getTableColumnIndex","getTableColumnName","getTableRowAsObject","getTableRowAsArray","makeRowIterator","makeArrayRowIterator","makeObjectRowIterator","ArrowLikeTable","makeTableFromData","deduceTableSchema","convertToObjectRow","convertToArrayRow","getDataTypeFromArray","getMeshSize","getMeshBoundingBox","deduceMeshSchema","deduceMeshField","makeMeshAttributeMetadata","Schema","ArrowLikeSchema","Field","ArrowLikeField","DataType","ArrowLikeDataType","Null","Binary","Bool","Int","Int8","Int16","Int32","Int64","Uint8","Uint16","Uint32","Uint64","Float","Float16","Float32","Float64","Utf8","Date","DateDay","DateMillisecond","Time","TimeMillisecond","TimeSecond","Timestamp","TimestampSecond","TimestampMillisecond","TimestampMicrosecond","TimestampNanosecond","Interval","IntervalDayTime","IntervalYearMonth","FixedSizeList","Struct","getTypeInfo","getArrowType","default","AsyncQueue"],"sources":["../../src/index.ts"],"sourcesContent":["// COMMON CATEGORY\nexport type {\n TypedArray,\n TypedArrayConstructor,\n NumberArray,\n ArrayType,\n AnyArray\n} from './types/types';\n\nexport type {Schema, Field, DataType,
|
|
1
|
+
{"version":3,"file":"index.js","names":["TableBatchBuilder","RowTableBatchAggregator","ColumnarTableBatchAggregator","getTableLength","getTableNumCols","getTableCell","getTableRowShape","getTableColumnIndex","getTableColumnName","getTableRowAsObject","getTableRowAsArray","makeRowIterator","makeArrayRowIterator","makeObjectRowIterator","ArrowLikeTable","makeTableFromData","convertTable","deduceTableSchema","convertToObjectRow","convertToArrayRow","getDataTypeFromArray","getMeshSize","getMeshBoundingBox","deduceMeshSchema","deduceMeshField","makeMeshAttributeMetadata","Schema","ArrowLikeSchema","Field","ArrowLikeField","DataType","ArrowLikeDataType","Null","Binary","Bool","Int","Int8","Int16","Int32","Int64","Uint8","Uint16","Uint32","Uint64","Float","Float16","Float32","Float64","Utf8","Date","DateDay","DateMillisecond","Time","TimeMillisecond","TimeSecond","Timestamp","TimestampSecond","TimestampMillisecond","TimestampMicrosecond","TimestampNanosecond","Interval","IntervalDayTime","IntervalYearMonth","FixedSizeList","Struct","getTypeInfo","getArrowType","default","AsyncQueue"],"sources":["../../src/index.ts"],"sourcesContent":["// COMMON CATEGORY\nexport type {\n TypedArray,\n BigTypedArray,\n TypedArrayConstructor,\n BigTypedArrayConstructor,\n NumberArray,\n ArrayType,\n AnyArray\n} from './types/types';\n\nexport type {Schema, Field, DataType, SchemaMetadata, FieldMetadata} from './types/schema';\n\nexport type {Batch} from './types/batch';\n\n// TABLE CATEGORY TYPES\nexport type {\n Table,\n RowTable,\n ArrayRowTable,\n ObjectRowTable,\n GeoJSONTable,\n ColumnarTable,\n ArrowTable,\n Tables\n} from './types/category-table';\nexport type {\n TableBatch,\n ArrayRowTableBatch,\n ObjectRowTableBatch,\n GeoJSONTableBatch,\n ColumnarTableBatch,\n ArrowTableBatch\n} from './types/category-table';\n\n// TABLE CATEGORY UTILS\nexport {TableBatchBuilder} from './lib/table/batches/table-batch-builder';\nexport type {TableBatchAggregator} from './lib/table/batches/table-batch-aggregator';\nexport {RowTableBatchAggregator} from './lib/table/batches/row-table-batch-aggregator';\nexport {ColumnarTableBatchAggregator} from './lib/table/batches/columnar-table-batch-aggregator';\n\nexport {\n getTableLength,\n getTableNumCols,\n getTableCell,\n getTableRowShape,\n getTableColumnIndex,\n getTableColumnName,\n getTableRowAsObject,\n getTableRowAsArray,\n makeRowIterator,\n makeArrayRowIterator,\n makeObjectRowIterator\n} from './lib/table/simple-table/table-accessors';\n\nexport {ArrowLikeTable} from './lib/table/arrow-api/arrow-like-table';\n\nexport {makeTableFromData} from './lib/table/simple-table/make-table';\nexport {convertTable} from './lib/table/simple-table/convert-table';\nexport {deduceTableSchema} from './lib/table/simple-table/table-schema';\nexport {convertToObjectRow, convertToArrayRow} from './lib/table/simple-table/row-utils';\nexport {getDataTypeFromArray} from './lib/table/simple-table/data-type';\n\n// MESH CATEGORY\nexport type {\n MeshTable,\n MeshArrowTable,\n Mesh,\n MeshGeometry,\n MeshAttribute,\n MeshAttributes\n} from './types/category-mesh';\n\nexport {getMeshSize, getMeshBoundingBox} from './lib/mesh/mesh-utils';\n// Commented out due to https://github.com/visgl/deck.gl/issues/6906 and https://github.com/visgl/loaders.gl/issues/2177\n// export {convertMesh} from './category/mesh/convert-mesh';\nexport {\n deduceMeshSchema,\n deduceMeshField,\n makeMeshAttributeMetadata\n} from './lib/mesh/deduce-mesh-schema';\n\n// TEXTURES\nexport type {TextureLevel, GPUTextureFormat} from './types/category-texture';\n\n// IMAGES\nexport type {ImageDataType, ImageType, ImageTypeEnum} from './types/category-image';\n\n// TYPES\n// GIS CATEGORY - GEOJSON\nexport type {\n GeoJSON,\n Feature,\n FeatureCollection,\n Geometry,\n Position,\n GeoJsonProperties,\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon,\n GeometryCollection\n} from './types/category-gis';\n\nexport type {GeojsonGeometryInfo} from './types/category-gis';\n\n// GIS CATEGORY - FLAT GEOJSON\nexport type {\n FlatFeature,\n FlatIndexedGeometry,\n FlatGeometry,\n FlatGeometryType,\n FlatPoint,\n FlatLineString,\n FlatPolygon\n} from './types/category-gis';\n\n// GIS CATEGORY - BINARY\nexport type {\n BinaryGeometryType,\n BinaryGeometry,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryAttribute\n} from './types/category-gis';\nexport type {\n BinaryFeatureCollection,\n BinaryFeature,\n BinaryPointFeature,\n BinaryLineFeature,\n BinaryPolygonFeature\n} from './types/category-gis';\n\n// SCHEMA\nexport {\n Schema as ArrowLikeSchema,\n Field as ArrowLikeField,\n DataType as ArrowLikeDataType,\n Null,\n Binary,\n Bool,\n Int,\n Int8,\n Int16,\n Int32,\n Int64,\n Uint8,\n Uint16,\n Uint32,\n Uint64,\n Float,\n Float16,\n Float32,\n Float64,\n Utf8,\n Date,\n DateDay,\n DateMillisecond,\n Time,\n TimeMillisecond,\n TimeSecond,\n Timestamp,\n TimestampSecond,\n TimestampMillisecond,\n TimestampMicrosecond,\n TimestampNanosecond,\n Interval,\n IntervalDayTime,\n IntervalYearMonth,\n FixedSizeList,\n Struct\n} from './lib/table/arrow-api';\n\n// EXPERIMENTAL APIs\n\n// SCHEMA UTILS\nexport {getTypeInfo} from './lib/table/arrow-api/get-type-info';\nexport {getArrowType} from './lib/table/arrow/arrow-type-utils';\n\nexport {default as AsyncQueue} from './lib/utils/async-queue';\n"],"mappings":"AAoCA,SAAQA,iBAAiB,QAAO,yCAAyC;AAEzE,SAAQC,uBAAuB,QAAO,gDAAgD;AACtF,SAAQC,4BAA4B,QAAO,qDAAqD;AAEhG,SACEC,cAAc,EACdC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,mBAAmB,EACnBC,kBAAkB,EAClBC,mBAAmB,EACnBC,kBAAkB,EAClBC,eAAe,EACfC,oBAAoB,EACpBC,qBAAqB,QAChB,0CAA0C;AAEjD,SAAQC,cAAc,QAAO,wCAAwC;AAErE,SAAQC,iBAAiB,QAAO,qCAAqC;AACrE,SAAQC,YAAY,QAAO,wCAAwC;AACnE,SAAQC,iBAAiB,QAAO,uCAAuC;AACvE,SAAQC,kBAAkB,EAAEC,iBAAiB,QAAO,oCAAoC;AACxF,SAAQC,oBAAoB,QAAO,oCAAoC;AAYvE,SAAQC,WAAW,EAAEC,kBAAkB,QAAO,uBAAuB;AAGrE,SACEC,gBAAgB,EAChBC,eAAe,EACfC,yBAAyB,QACpB,+BAA+B;AAyDtC,SACEC,MAAM,IAAIC,eAAe,EACzBC,KAAK,IAAIC,cAAc,EACvBC,QAAQ,IAAIC,iBAAiB,EAC7BC,IAAI,EACJC,MAAM,EACNC,IAAI,EACJC,GAAG,EACHC,IAAI,EACJC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,KAAK,EACLC,OAAO,EACPC,OAAO,EACPC,OAAO,EACPC,IAAI,EACJC,IAAI,EACJC,OAAO,EACPC,eAAe,EACfC,IAAI,EACJC,eAAe,EACfC,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,oBAAoB,EACpBC,oBAAoB,EACpBC,mBAAmB,EACnBC,QAAQ,EACRC,eAAe,EACfC,iBAAiB,EACjBC,aAAa,EACbC,MAAM,QACD,uBAAuB;AAK9B,SAAQC,WAAW,QAAO,qCAAqC;AAC/D,SAAQC,YAAY,QAAO,oCAAoC;AAE/D,SAAQC,OAAO,IAAIC,UAAU,QAAO,yBAAyB"}
|
|
@@ -13,10 +13,11 @@ class ArrowLikeVector {
|
|
|
13
13
|
return getTableCell(this.table, rowIndex, this.columnName);
|
|
14
14
|
}
|
|
15
15
|
toArray() {
|
|
16
|
-
var
|
|
16
|
+
var _arrowTable$getChild;
|
|
17
17
|
switch (this.table.shape) {
|
|
18
18
|
case 'arrow-table':
|
|
19
|
-
|
|
19
|
+
const arrowTable = this.table.data;
|
|
20
|
+
return (_arrowTable$getChild = arrowTable.getChild(this.columnName)) === null || _arrowTable$getChild === void 0 ? void 0 : _arrowTable$getChild.toArray();
|
|
20
21
|
case 'columnar-table':
|
|
21
22
|
return this.table.data[this.columnName];
|
|
22
23
|
default:
|
|
@@ -36,7 +37,7 @@ export class ArrowLikeTable {
|
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
get data() {
|
|
39
|
-
return this.table.data;
|
|
40
|
+
return this.table.shape === 'geojson-table' ? this.table.features : this.table.data;
|
|
40
41
|
}
|
|
41
42
|
get numCols() {
|
|
42
43
|
return getTableNumCols(this.table);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-like-table.js","names":["ArrowLikeSchema","deduceTableSchema","getTableCell","getTableLength","getTableNumCols","ArrowLikeVector","constructor","table","columnName","_defineProperty","get","rowIndex","toArray","
|
|
1
|
+
{"version":3,"file":"arrow-like-table.js","names":["ArrowLikeSchema","deduceTableSchema","getTableCell","getTableLength","getTableNumCols","ArrowLikeVector","constructor","table","columnName","_defineProperty","get","rowIndex","toArray","_arrowTable$getChild","shape","arrowTable","data","getChild","Error","ArrowLikeTable","schema","fields","metadata","features","numCols","length"],"sources":["../../../../../src/lib/table/arrow-api/arrow-like-table.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Table} from '../../../types/category-table';\n\nimport {ArrowLikeSchema} from './arrow-like-schema';\n\nimport {deduceTableSchema} from '../simple-table/table-schema';\n\nimport {\n getTableCell,\n getTableLength,\n getTableNumCols\n // getTableCell,\n // getTableRowShape,\n // getTableColumnIndex,\n // getTableColumnName,\n // getTableRowAsObject,\n // getTableRowAsArray\n} from '../simple-table/table-accessors';\n\nclass ArrowLikeVector {\n table: Table;\n columnName: string;\n\n constructor(table: Table, columnName: string) {\n this.table = table;\n this.columnName = columnName;\n }\n\n get(rowIndex: number): unknown {\n return getTableCell(this.table, rowIndex, this.columnName);\n }\n\n toArray(): ArrayLike<unknown> {\n switch (this.table.shape) {\n case 'arrow-table':\n const arrowTable = this.table.data as any;\n return arrowTable.getChild(this.columnName)?.toArray();\n case 'columnar-table':\n return this.table.data[this.columnName];\n default:\n throw new Error(this.table.shape);\n }\n }\n}\n\n/**\n * Class that provides an API similar to Apache Arrow Table class\n * Forwards methods directly if the underlying table is Arrow, otherwise calls accessor functions\n */\nexport class ArrowLikeTable {\n schema: ArrowLikeSchema;\n table: Table;\n\n constructor(table: Table) {\n const schema = table.schema || deduceTableSchema(table);\n this.schema = new ArrowLikeSchema(schema.fields, schema.metadata);\n this.table = {...table, schema};\n }\n\n // get schema() {\n // return this.table.schema;\n // }\n\n get data() {\n return this.table.shape === 'geojson-table' ? this.table.features : this.table.data;\n }\n\n get numCols(): number {\n return getTableNumCols(this.table);\n }\n\n get length(): number {\n return getTableLength(this.table);\n }\n\n getChild(columnName: string): ArrowLikeVector {\n return new ArrowLikeVector(this.table, columnName);\n }\n\n // getChildAt(columnIndex: number): ArrowLikeVector {\n // return\n // }\n}\n"],"mappings":";AAIA,SAAQA,eAAe,QAAO,qBAAqB;AAEnD,SAAQC,iBAAiB,QAAO,8BAA8B;AAE9D,SACEC,YAAY,EACZC,cAAc,EACdC,eAAe,QAOV,iCAAiC;AAExC,MAAMC,eAAe,CAAC;EAIpBC,WAAWA,CAACC,KAAY,EAAEC,UAAkB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAC5C,IAAI,CAACF,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,UAAU,GAAGA,UAAU;EAC9B;EAEAE,GAAGA,CAACC,QAAgB,EAAW;IAC7B,OAAOT,YAAY,CAAC,IAAI,CAACK,KAAK,EAAEI,QAAQ,EAAE,IAAI,CAACH,UAAU,CAAC;EAC5D;EAEAI,OAAOA,CAAA,EAAuB;IAAA,IAAAC,oBAAA;IAC5B,QAAQ,IAAI,CAACN,KAAK,CAACO,KAAK;MACtB,KAAK,aAAa;QAChB,MAAMC,UAAU,GAAG,IAAI,CAACR,KAAK,CAACS,IAAW;QACzC,QAAAH,oBAAA,GAAOE,UAAU,CAACE,QAAQ,CAAC,IAAI,CAACT,UAAU,CAAC,cAAAK,oBAAA,uBAApCA,oBAAA,CAAsCD,OAAO,CAAC,CAAC;MACxD,KAAK,gBAAgB;QACnB,OAAO,IAAI,CAACL,KAAK,CAACS,IAAI,CAAC,IAAI,CAACR,UAAU,CAAC;MACzC;QACE,MAAM,IAAIU,KAAK,CAAC,IAAI,CAACX,KAAK,CAACO,KAAK,CAAC;IACrC;EACF;AACF;AAMA,OAAO,MAAMK,cAAc,CAAC;EAI1Bb,WAAWA,CAACC,KAAY,EAAE;IAAAE,eAAA;IAAAA,eAAA;IACxB,MAAMW,MAAM,GAAGb,KAAK,CAACa,MAAM,IAAInB,iBAAiB,CAACM,KAAK,CAAC;IACvD,IAAI,CAACa,MAAM,GAAG,IAAIpB,eAAe,CAACoB,MAAM,CAACC,MAAM,EAAED,MAAM,CAACE,QAAQ,CAAC;IACjE,IAAI,CAACf,KAAK,GAAG;MAAC,GAAGA,KAAK;MAAEa;IAAM,CAAC;EACjC;EAMA,IAAIJ,IAAIA,CAAA,EAAG;IACT,OAAO,IAAI,CAACT,KAAK,CAACO,KAAK,KAAK,eAAe,GAAG,IAAI,CAACP,KAAK,CAACgB,QAAQ,GAAG,IAAI,CAAChB,KAAK,CAACS,IAAI;EACrF;EAEA,IAAIQ,OAAOA,CAAA,EAAW;IACpB,OAAOpB,eAAe,CAAC,IAAI,CAACG,KAAK,CAAC;EACpC;EAEA,IAAIkB,MAAMA,CAAA,EAAW;IACnB,OAAOtB,cAAc,CAAC,IAAI,CAACI,KAAK,CAAC;EACnC;EAEAU,QAAQA,CAACT,UAAkB,EAAmB;IAC5C,OAAO,IAAIH,eAAe,CAAC,IAAI,CAACE,KAAK,EAAEC,UAAU,CAAC;EACpD;AAKF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-table-batch-aggregator.js","names":["convertToArrayRow","convertToObjectRow","DEFAULT_ROW_COUNT","RowTableBatchAggregator","constructor","schema","options","_defineProperty","Array","isArray","_headers","key","index","name","rowCount","length","addArrayRow","row","cursor","Number","isFinite","shape","rowObject","addObjectRow","arrayRows","rowArray","objectRows","getBatch","rows","slice","batchType","data"],"sources":["../../../../../src/lib/table/batches/row-table-batch-aggregator.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from '../../../types/schema';\nimport type {TableBatch} from '../../../types/category-table';\n// import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';\nimport {convertToArrayRow, convertToObjectRow} from '../simple-table/row-utils';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n objectRows: {[columnName: string]:
|
|
1
|
+
{"version":3,"file":"row-table-batch-aggregator.js","names":["convertToArrayRow","convertToObjectRow","DEFAULT_ROW_COUNT","RowTableBatchAggregator","constructor","schema","options","_defineProperty","Array","isArray","_headers","key","index","name","rowCount","length","addArrayRow","row","cursor","Number","isFinite","shape","rowObject","addObjectRow","arrayRows","rowArray","objectRows","getBatch","rows","slice","batchType","data"],"sources":["../../../../../src/lib/table/batches/row-table-batch-aggregator.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Schema} from '../../../types/schema';\nimport type {TableBatch} from '../../../types/category-table';\n// import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';\nimport {convertToArrayRow, convertToObjectRow} from '../simple-table/row-utils';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n objectRows: {[columnName: string]: unknown}[] | null = null;\n arrayRows: unknown[][] | null = null;\n cursor: number = 0;\n private _headers: string[] = [];\n\n constructor(schema: Schema, options: TableBatchOptions) {\n this.options = options;\n this.schema = schema;\n\n // schema is an array if there're no headers\n // object if there are headers\n if (!Array.isArray(schema)) {\n this._headers = [];\n for (const key in schema) {\n this._headers[schema[key].index] = schema[key].name;\n }\n }\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[], cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'object-row-table':\n const rowObject = convertToObjectRow(row, this._headers);\n this.addObjectRow(rowObject, cursor);\n break;\n case 'array-row-table':\n this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT);\n this.arrayRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n addObjectRow(row: {[columnName: string]: any}, cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'array-row-table':\n const rowArray = convertToArrayRow(row, this._headers);\n this.addArrayRow(rowArray, cursor);\n break;\n case 'object-row-table':\n this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT);\n this.objectRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n getBatch(): TableBatch | null {\n let rows = this.arrayRows || this.objectRows;\n if (!rows) {\n return null;\n }\n\n rows = rows.slice(0, this.length);\n this.arrayRows = null;\n this.objectRows = null;\n\n return {\n shape: this.options.shape,\n batchType: 'data',\n data: rows,\n length: this.length,\n schema: this.schema,\n cursor: this.cursor\n };\n }\n}\n"],"mappings":";AAKA,SAAQA,iBAAiB,EAAEC,kBAAkB,QAAO,2BAA2B;AAG/E,MAAMC,iBAAiB,GAAG,GAAG;AAE7B,OAAO,MAAMC,uBAAuB,CAAiC;EAUnEC,WAAWA,CAACC,MAAc,EAAEC,OAA0B,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA,iBANvC,CAAC;IAAAA,eAAA,qBACqC,IAAI;IAAAA,eAAA,oBAC3B,IAAI;IAAAA,eAAA,iBACnB,CAAC;IAAAA,eAAA,mBACW,EAAE;IAG7B,IAAI,CAACD,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACD,MAAM,GAAGA,MAAM;IAIpB,IAAI,CAACG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,EAAE;MAC1B,IAAI,CAACK,QAAQ,GAAG,EAAE;MAClB,KAAK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A,UAAU,IAAI,IAAIlB,KAAK,CAACN,iBAAiB,CAAC;QACjE,IAAI,CAACwB,UAAU,CAAC,IAAI,CAACX,MAAM,CAAC,GAAGE,GAAG;QAClC,IAAI,CAACF,MAAM,EAAE;QACb;IACJ;EACF;EAEAY,QAAQA,CAAA,EAAsB;IAC5B,IAAIC,IAAI,GAAG,IAAI,CAACJ,SAAS,IAAI,IAAI,CAACE,UAAU;IAC5C,IAAI,CAACE,IAAI,EAAE;MACT,OAAO,IAAI;IACb;IAEAA,IAAI,GAAGA,IAAI,CAACC,KAAK,CAAC,CAAC,EAAE,IAAI,CAACd,MAAM,CAAC;IACjC,IAAI,CAACS,SAAS,GAAG,IAAI;IACrB,IAAI,CAACE,UAAU,GAAG,IAAI;IAEtB,OAAO;MACLL,KAAK,EAAE,IAAI,CAACf,OAAO,CAACe,KAAK;MACzBS,SAAS,EAAE,MAAM;MACjBC,IAAI,EAAEH,IAAI;MACVb,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBV,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBa,MAAM,EAAE,IAAI,CAACA;IACf,CAAC;EACH;AACF"}
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import { getTableCell, getTableLength, getTableRowAsArray, getTableRowAsObject } from './table-accessors';
|
|
2
2
|
import { deduceTableSchema } from './table-schema';
|
|
3
3
|
import { makeColumnFromField } from './table-column';
|
|
4
|
+
export function convertTable(table, shape) {
|
|
5
|
+
switch (shape) {
|
|
6
|
+
case 'object-row-table':
|
|
7
|
+
return makeObjectRowTable(table);
|
|
8
|
+
case 'array-row-table':
|
|
9
|
+
return makeArrayRowTable(table);
|
|
10
|
+
case 'columnar-table':
|
|
11
|
+
return makeColumnarTable(table);
|
|
12
|
+
case 'arrow-table':
|
|
13
|
+
return makeArrowTable(table);
|
|
14
|
+
default:
|
|
15
|
+
throw new Error(shape);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export function makeArrowTable(table) {
|
|
19
|
+
var _globalThis$__luma;
|
|
20
|
+
const _makeArrowTable = (_globalThis$__luma = globalThis.__luma) === null || _globalThis$__luma === void 0 ? void 0 : _globalThis$__luma._makeArrowTable;
|
|
21
|
+
if (!_makeArrowTable) {
|
|
22
|
+
throw new Error('');
|
|
23
|
+
}
|
|
24
|
+
return _makeArrowTable(table);
|
|
25
|
+
}
|
|
4
26
|
export function makeColumnarTable(table) {
|
|
5
27
|
var _table$schema;
|
|
6
28
|
const schema = table.schema || deduceTableSchema(table);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-table.js","names":["getTableCell","getTableLength","getTableRowAsArray","getTableRowAsObject","deduceTableSchema","makeColumnFromField","
|
|
1
|
+
{"version":3,"file":"convert-table.js","names":["getTableCell","getTableLength","getTableRowAsArray","getTableRowAsObject","deduceTableSchema","makeColumnFromField","convertTable","table","shape","makeObjectRowTable","makeArrayRowTable","makeColumnarTable","makeArrowTable","Error","_globalThis$__luma","_makeArrowTable","globalThis","__luma","_table$schema","schema","fields","length","columns","field","column","name","rowIndex","data","Array"],"sources":["../../../../../src/lib/table/simple-table/convert-table.ts"],"sourcesContent":["// loaders.gl, MIT license\nimport {\n getTableCell,\n getTableLength,\n getTableRowAsArray,\n getTableRowAsObject\n} from './table-accessors';\nimport {\n Table,\n ArrayRowTable,\n ObjectRowTable,\n ColumnarTable,\n ArrowTable\n} from '../../../types/category-table';\nimport {deduceTableSchema} from './table-schema';\nimport {makeColumnFromField} from './table-column';\n\nexport function convertTable(table: Table, shape: 'object-row-table'): ObjectRowTable;\nexport function convertTable(table: Table, shape: 'array-row-table'): ArrayRowTable;\nexport function convertTable(table: Table, shape: 'columnar-table'): ColumnarTable;\nexport function convertTable(table: Table, shape: 'arrow-table'): ArrowTable;\n\n/**\n * Convert a table to a different shape\n * @param table\n * @param shape\n * @returns\n */\nexport function convertTable(\n table: Table,\n shape: 'object-row-table' | 'array-row-table' | 'columnar-table' | 'arrow-table'\n) {\n switch (shape) {\n case 'object-row-table':\n return makeObjectRowTable(table);\n case 'array-row-table':\n return makeArrayRowTable(table);\n case 'columnar-table':\n return makeColumnarTable(table);\n case 'arrow-table':\n return makeArrowTable(table);\n default:\n throw new Error(shape);\n }\n}\n\n/**\n * Convert a table to apache arrow format\n * @note this depends on the `@loaders.gl/arrow module being imported\n */\nexport function makeArrowTable(table: Table): Table {\n const _makeArrowTable = globalThis.__luma?._makeArrowTable;\n if (!_makeArrowTable) {\n throw new Error('');\n }\n return _makeArrowTable(table);\n}\n\n/** Convert any simple table into columnar format */\nexport function makeColumnarTable(table: Table): ColumnarTable {\n // TODO - should schema really be optional?\n const schema = table.schema || deduceTableSchema(table);\n const fields = table.schema?.fields || [];\n\n if (table.shape === 'columnar-table') {\n return {...table, schema};\n }\n\n const length = getTableLength(table);\n\n const columns: {[column: string]: ArrayLike<unknown>} = {};\n for (const field of fields) {\n const column = makeColumnFromField(field, length);\n columns[field.name] = column;\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n column[rowIndex] = getTableCell(table, rowIndex, field.name);\n }\n }\n\n return {\n shape: 'columnar-table',\n schema,\n data: columns\n };\n}\n\n/** Convert any table into array row format */\nexport function makeArrayRowTable(table: Table): ArrayRowTable {\n if (table.shape === 'array-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<unknown[]>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsArray(table, rowIndex);\n }\n return {\n shape: 'array-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeObjectRowTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n/**\n/**\n *\n * @note - should be part of schema module\nexport function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable {\n const tableKeys = ;\n const tableRowsCount = columnarTable[tableKeys[0]].length;\n\n const objectRows: ObjectRowTable['data'] = [];\n\n for (let index = 0; index < tableRowsCount; index++) {\n const objectRow = {};\n for (const fieldName of Object.keys(columnarTable.data)) {\n objectRow[fieldName] = columnarTable[fieldName][index];\n }\n objectRows.push(objectRow);\n }\n\n return {\n shape: 'object-row-table',\n data: objectRows\n };\n}\n */\n"],"mappings":"AACA,SACEA,YAAY,EACZC,cAAc,EACdC,kBAAkB,EAClBC,mBAAmB,QACd,mBAAmB;AAQ1B,SAAQC,iBAAiB,QAAO,gBAAgB;AAChD,SAAQC,mBAAmB,QAAO,gBAAgB;AAalD,OAAO,SAASC,YAAYA,CAC1BC,KAAY,EACZC,KAAgF,EAChF;EACA,QAAQA,KAAK;IACX,KAAK,kBAAkB;MACrB,OAAOC,kBAAkB,CAACF,KAAK,CAAC;IAClC,KAAK,iBAAiB;MACpB,OAAOG,iBAAiB,CAACH,KAAK,CAAC;IACjC,KAAK,gBAAgB;MACnB,OAAOI,iBAAiB,CAACJ,KAAK,CAAC;IACjC,KAAK,aAAa;MAChB,OAAOK,cAAc,CAACL,KAAK,CAAC;IAC9B;MACE,MAAM,IAAIM,KAAK,CAACL,KAAK,CAAC;EAC1B;AACF;AAMA,OAAO,SAASI,cAAcA,CAACL,KAAY,EAAS;EAAA,IAAAO,kBAAA;EAClD,MAAMC,eAAe,IAAAD,kBAAA,GAAGE,UAAU,CAACC,MAAM,cAAAH,kBAAA,uBAAjBA,kBAAA,CAAmBC,eAAe;EAC1D,IAAI,CAACA,eAAe,EAAE;IACpB,MAAM,IAAIF,KAAK,CAAC,EAAE,CAAC;EACrB;EACA,OAAOE,eAAe,CAACR,KAAK,CAAC;AAC/B;AAGA,OAAO,SAASI,iBAAiBA,CAACJ,KAAY,EAAiB;EAAA,IAAAW,aAAA;EAE7D,MAAMC,MAAM,GAAGZ,KAAK,CAACY,MAAM,IAA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ACtD;EACA,OAAO;IACLlB,KAAK,EAAE,iBAAiB;IACxBW,MAAM,EAAEZ,KAAK,CAACY,MAAM;IACpBQ;EACF,CAAC;AACH;AAGA,OAAO,SAASlB,kBAAkBA,CAACF,KAAY,EAAkB;EAC/D,IAAIA,KAAK,CAACC,KAAK,KAAK,kBAAkB,EAAE;IACtC,OAAOD,KAAK;EACd;EACA,MAAMc,MAAM,GAAGpB,cAAc,CAACM,KAAK,CAAC;EACpC,MAAMoB,IAAI,GAAG,IAAIC,KAAK,CAA2BP,MAAM,CAAC;EACxD,KAAK,IAAIK,QAAQ,GAAG,CAAC,EAAEA,QAAQ,GAAGL,MAAM,EAAEK,QAAQ,EAAE,EAAE;IACpDC,IAAI,CAACD,QAAQ,CAAC,GAAGvB,mBAAmB,CAACI,KAAK,EAAEmB,QAAQ,CAAC;EACvD;EACA,OAAO;IACLlB,KAAK,EAAE,kBAAkB;IACzBW,MAAM,EAAEZ,KAAK,CAACY,MAAM;IACpBQ;EACF,CAAC;AACH"}
|
|
@@ -2,10 +2,12 @@ export function getTableLength(table) {
|
|
|
2
2
|
switch (table.shape) {
|
|
3
3
|
case 'array-row-table':
|
|
4
4
|
case 'object-row-table':
|
|
5
|
-
case 'geojson-row-table':
|
|
6
5
|
return table.data.length;
|
|
6
|
+
case 'geojson-table':
|
|
7
|
+
return table.features.length;
|
|
7
8
|
case 'arrow-table':
|
|
8
|
-
|
|
9
|
+
const arrowTable = table.data;
|
|
10
|
+
return arrowTable.numRows;
|
|
9
11
|
case 'columnar-table':
|
|
10
12
|
for (const column of Object.values(table.data)) {
|
|
11
13
|
return column.length || 0;
|
|
@@ -26,50 +28,57 @@ export function getTableNumCols(table) {
|
|
|
26
28
|
case 'array-row-table':
|
|
27
29
|
return table.data[0].length;
|
|
28
30
|
case 'object-row-table':
|
|
29
|
-
case 'geojson-row-table':
|
|
30
31
|
return Object.keys(table.data[0]).length;
|
|
32
|
+
case 'geojson-table':
|
|
33
|
+
return Object.keys(table.features[0]).length;
|
|
31
34
|
case 'columnar-table':
|
|
32
35
|
return Object.keys(table.data).length;
|
|
33
36
|
case 'arrow-table':
|
|
34
|
-
|
|
37
|
+
const arrowTable = table.data;
|
|
38
|
+
return arrowTable.numCols;
|
|
35
39
|
default:
|
|
36
40
|
throw new Error('table');
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
export function getTableCell(table, rowIndex, columnName) {
|
|
40
|
-
var
|
|
44
|
+
var _arrowTable$getChildA;
|
|
41
45
|
switch (table.shape) {
|
|
42
46
|
case 'array-row-table':
|
|
43
47
|
const columnIndex = getTableColumnIndex(table, columnName);
|
|
44
48
|
return table.data[rowIndex][columnIndex];
|
|
45
49
|
case 'object-row-table':
|
|
46
|
-
case 'geojson-row-table':
|
|
47
50
|
return table.data[rowIndex][columnName];
|
|
51
|
+
case 'geojson-table':
|
|
52
|
+
return table.features[rowIndex][columnName];
|
|
48
53
|
case 'columnar-table':
|
|
49
54
|
const column = table.data[columnName];
|
|
50
55
|
return column[rowIndex];
|
|
51
56
|
case 'arrow-table':
|
|
52
|
-
const
|
|
53
|
-
|
|
57
|
+
const arrowTable = table.data;
|
|
58
|
+
const arrowColumnIndex = arrowTable.schema.fields.findIndex(field => field.name === columnName);
|
|
59
|
+
return (_arrowTable$getChildA = arrowTable.getChildAt(arrowColumnIndex)) === null || _arrowTable$getChildA === void 0 ? void 0 : _arrowTable$getChildA.get(rowIndex);
|
|
54
60
|
default:
|
|
55
61
|
throw new Error('todo');
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
export function getTableCellAt(table, rowIndex, columnIndex) {
|
|
59
|
-
var
|
|
65
|
+
var _arrowTable$getChildA2;
|
|
60
66
|
switch (table.shape) {
|
|
61
67
|
case 'array-row-table':
|
|
62
68
|
return table.data[rowIndex][columnIndex];
|
|
63
69
|
case 'object-row-table':
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
const columnName1 = getTableColumnName(table, columnIndex);
|
|
71
|
+
return table.data[rowIndex][columnName1];
|
|
72
|
+
case 'geojson-table':
|
|
73
|
+
const columnName2 = getTableColumnName(table, columnIndex);
|
|
74
|
+
return table.features[rowIndex][columnName2];
|
|
67
75
|
case 'columnar-table':
|
|
68
|
-
|
|
69
|
-
const column = table.data[
|
|
76
|
+
const columnName3 = getTableColumnName(table, columnIndex);
|
|
77
|
+
const column = table.data[columnName3];
|
|
70
78
|
return column[rowIndex];
|
|
71
79
|
case 'arrow-table':
|
|
72
|
-
|
|
80
|
+
const arrowTable = table.data;
|
|
81
|
+
return (_arrowTable$getChildA2 = arrowTable.getChildAt(columnIndex)) === null || _arrowTable$getChildA2 === void 0 ? void 0 : _arrowTable$getChildA2.get(rowIndex);
|
|
73
82
|
default:
|
|
74
83
|
throw new Error('todo');
|
|
75
84
|
}
|
|
@@ -79,7 +88,7 @@ export function getTableRowShape(table) {
|
|
|
79
88
|
case 'array-row-table':
|
|
80
89
|
case 'object-row-table':
|
|
81
90
|
return table.shape;
|
|
82
|
-
case 'geojson-
|
|
91
|
+
case 'geojson-table':
|
|
83
92
|
return 'object-row-table';
|
|
84
93
|
case 'columnar-table':
|
|
85
94
|
default:
|
|
@@ -107,7 +116,6 @@ export function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
|
107
116
|
case 'object-row-table':
|
|
108
117
|
return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];
|
|
109
118
|
case 'array-row-table':
|
|
110
|
-
case 'geojson-row-table':
|
|
111
119
|
if (table.schema) {
|
|
112
120
|
const objectRow = target || {};
|
|
113
121
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
@@ -116,6 +124,15 @@ export function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
|
116
124
|
return objectRow;
|
|
117
125
|
}
|
|
118
126
|
throw new Error('no schema');
|
|
127
|
+
case 'geojson-table':
|
|
128
|
+
if (table.schema) {
|
|
129
|
+
const objectRow = target || {};
|
|
130
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
131
|
+
objectRow[table.schema.fields[i].name] = table.features[rowIndex][i];
|
|
132
|
+
}
|
|
133
|
+
return objectRow;
|
|
134
|
+
}
|
|
135
|
+
throw new Error('no schema');
|
|
119
136
|
case 'columnar-table':
|
|
120
137
|
if (table.schema) {
|
|
121
138
|
const objectRow = target || {};
|
|
@@ -131,9 +148,10 @@ export function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
|
131
148
|
return objectRow;
|
|
132
149
|
}
|
|
133
150
|
case 'arrow-table':
|
|
151
|
+
const arrowTable = table.data;
|
|
134
152
|
const objectRow = target || {};
|
|
135
|
-
const row =
|
|
136
|
-
const schema =
|
|
153
|
+
const row = arrowTable.get(rowIndex);
|
|
154
|
+
const schema = arrowTable.schema;
|
|
137
155
|
for (let i = 0; i < schema.fields.length; i++) {
|
|
138
156
|
objectRow[schema.fields[i].name] = row === null || row === void 0 ? void 0 : row[schema.fields[i].name];
|
|
139
157
|
}
|
|
@@ -147,7 +165,6 @@ export function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
|
147
165
|
case 'array-row-table':
|
|
148
166
|
return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];
|
|
149
167
|
case 'object-row-table':
|
|
150
|
-
case 'geojson-row-table':
|
|
151
168
|
if (table.schema) {
|
|
152
169
|
const arrayRow = target || [];
|
|
153
170
|
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
@@ -156,6 +173,15 @@ export function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
|
156
173
|
return arrayRow;
|
|
157
174
|
}
|
|
158
175
|
return Object.values(table.data[rowIndex]);
|
|
176
|
+
case 'geojson-table':
|
|
177
|
+
if (table.schema) {
|
|
178
|
+
const arrayRow = target || [];
|
|
179
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
180
|
+
arrayRow[i] = table.features[rowIndex][table.schema.fields[i].name];
|
|
181
|
+
}
|
|
182
|
+
return arrayRow;
|
|
183
|
+
}
|
|
184
|
+
return Object.values(table.features[rowIndex]);
|
|
159
185
|
case 'columnar-table':
|
|
160
186
|
if (table.schema) {
|
|
161
187
|
const arrayRow = target || [];
|
|
@@ -173,9 +199,10 @@ export function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
|
173
199
|
return arrayRow;
|
|
174
200
|
}
|
|
175
201
|
case 'arrow-table':
|
|
202
|
+
const arrowTable = table.data;
|
|
176
203
|
const arrayRow = target || [];
|
|
177
|
-
const row =
|
|
178
|
-
const schema =
|
|
204
|
+
const row = arrowTable.get(rowIndex);
|
|
205
|
+
const schema = arrowTable.schema;
|
|
179
206
|
for (let i = 0; i < schema.fields.length; i++) {
|
|
180
207
|
arrayRow[i] = row === null || row === void 0 ? void 0 : row[schema.fields[i].name];
|
|
181
208
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-accessors.js","names":["getTableLength","table","shape","data","length","numRows","column","Object","values","Error","getTableNumCols","schema","fields","keys","numCols","getTableCell","rowIndex","columnName","_table$data$getChildA","columnIndex","getTableColumnIndex","arrowColumnIndex","findIndex","field","name","getChildAt","get","getTableCellAt","_table$data$getChildA2","getTableColumnName","getTableRowShape","_table$schema","undefined","_table$schema2","_table$schema2$fields","concat","getTableRowAsObject","target","copy","fromEntries","entries","objectRow","i","row","getTableRowAsArray","Array","from","arrayRow","makeArrayRowTable","makeObjectRowTable","makeColumnarTable","makeRowIterator","makeArrayRowIterator","makeObjectRowIterator","arguments"],"sources":["../../../../../src/lib/table/simple-table/table-accessors.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/* eslint-disable no-else-return */\n\nimport {Table, ArrayRowTable, ObjectRowTable} from '../../../types/category-table';\n\n/**\n * Returns the length of the table (i.e. the number of rows)\n */\nexport function getTableLength(table: Table): number {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n case 'geojson-row-table':\n return table.data.length;\n\n case 'arrow-table':\n return table.data.numRows;\n\n case 'columnar-table':\n for (const column of Object.values(table.data)) {\n return column.length || 0;\n }\n return 0;\n default:\n throw new Error('table');\n }\n}\n\n/**\n * Returns the number of columns in the table\n * @throws Fails to deduce number of columns if the table has no schema and is empty\n */\nexport function getTableNumCols(table: Table): number {\n if (table.schema) {\n return table.schema.fields.length;\n }\n if (getTableLength(table) === 0) {\n throw new Error('empty table');\n }\n switch (table.shape) {\n case 'array-row-table':\n return table.data[0].length;\n case 'object-row-table':\n case 'geojson-row-table':\n return Object.keys(table.data[0]).length;\n\n case 'columnar-table':\n return Object.keys(table.data).length;\n\n case 'arrow-table':\n return table.data.numCols;\n default:\n throw new Error('table');\n }\n}\n\n/** Get a table cell value at row index and column name */\nexport function getTableCell(table: Table, rowIndex: number, columnName: string): unknown {\n switch (table.shape) {\n case 'array-row-table':\n const columnIndex = getTableColumnIndex(table, columnName);\n return table.data[rowIndex][columnIndex];\n\n case 'object-row-table':\n case 'geojson-row-table':\n return table.data[rowIndex][columnName];\n\n case 'columnar-table':\n const column = table.data[columnName];\n return column[rowIndex];\n\n case 'arrow-table':\n const arrowColumnIndex = table.data.schema.fields.findIndex(\n (field) => field.name === columnName\n );\n return table.data.getChildAt(arrowColumnIndex)?.get(rowIndex);\n\n default:\n throw new Error('todo');\n }\n}\n\n/** Get a table cell value at row index and column name */\nexport function getTableCellAt(table: Table, rowIndex: number, columnIndex: number): unknown {\n switch (table.shape) {\n case 'array-row-table':\n return table.data[rowIndex][columnIndex];\n\n case 'object-row-table':\n case 'geojson-row-table':\n let columnName = getTableColumnName(table, columnIndex);\n return table.data[rowIndex][columnName];\n\n case 'columnar-table':\n columnName = getTableColumnName(table, columnIndex);\n const column = table.data[columnName];\n return column[rowIndex];\n\n case 'arrow-table':\n return table.data.getChildAt(columnIndex)?.get(rowIndex);\n\n default:\n throw new Error('todo');\n }\n}\n\n/** Deduce the table row shape */\nexport function getTableRowShape(table: Table): 'array-row-table' | 'object-row-table' {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n return table.shape;\n\n case 'geojson-row-table':\n return 'object-row-table';\n\n case 'columnar-table':\n default:\n throw new Error('Not a row table');\n }\n}\n\n/** Get the index of a named table column. Requires the table to have a schema */\nexport function getTableColumnIndex(table: Table, columnName: string): number {\n const columnIndex = table.schema?.fields.findIndex((field) => field.name === columnName);\n if (columnIndex === undefined) {\n throw new Error(columnName);\n }\n return columnIndex;\n}\n\n/** Get the name of a table column by index. Requires the table to have a schema */\nexport function getTableColumnName(table: Table, columnIndex: number): string {\n const columnName = table.schema?.fields[columnIndex]?.name;\n if (!columnName) {\n throw new Error(`${columnIndex}`);\n }\n return columnName;\n}\n\n/**\n * Returns one row of the table in object format.\n * @param target Optional parameter will be used if needed to store the row. Can be reused between calls to improve performance\n * @returns an array representing the row. May be the original array in the row, a new object, or the target parameter\n */\n// eslint-disable-next-line complexity\nexport function getTableRowAsObject(\n table: Table,\n rowIndex: number,\n target?: {[columnName: string]: unknown},\n copy?: 'copy'\n): {[columnName: string]: unknown} {\n switch (table.shape) {\n case 'object-row-table':\n return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];\n\n case 'array-row-table':\n case 'geojson-row-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] = table.data[rowIndex][i];\n }\n return objectRow;\n }\n throw new Error('no schema');\n\n case 'columnar-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] =\n table.data[table.schema.fields[i].name][rowIndex];\n }\n return objectRow;\n } else {\n // eslint-disable-line no-else-return\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (const [name, column] of Object.entries(table.data)) {\n objectRow[name] = column[rowIndex];\n }\n return objectRow;\n }\n\n case 'arrow-table':\n const objectRow: {[columnName: string]: unknown} = target || {};\n const row = table.data.get(rowIndex);\n const schema = table.data.schema;\n for (let i = 0; i < schema.fields.length; i++) {\n objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];\n }\n return objectRow;\n\n default:\n throw new Error('shape');\n }\n}\n\n/**\n * Returns one row of the table in array format.\n * @param target Optional parameter will be used if needed to store the row. Can be reused between calls to improve performance.\n * @returns an array representing the row. May be the original array in the row, a new object, or the target parameter\n */\n// eslint-disable-next-line complexity\nexport function getTableRowAsArray(\n table: Table,\n rowIndex: number,\n target?: unknown[],\n copy?: 'copy'\n): unknown[] {\n switch (table.shape) {\n case 'array-row-table':\n return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];\n\n case 'object-row-table':\n case 'geojson-row-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.data[rowIndex][table.schema.fields[i].name];\n }\n return arrayRow;\n }\n // Warning: just slap on the values, this risks mismatches between rows\n return Object.values(table.data[rowIndex]);\n\n case 'columnar-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.data[table.schema.fields[i].name][rowIndex];\n }\n return arrayRow;\n } else {\n // eslint-disable-line no-else-return\n const arrayRow: unknown[] = target || [];\n let i = 0;\n for (const column of Object.values(table.data)) {\n arrayRow[i] = column[rowIndex];\n i++;\n }\n return arrayRow;\n }\n\n case 'arrow-table':\n const arrayRow: unknown[] = target || [];\n const row = table.data.get(rowIndex);\n const schema = table.data.schema;\n for (let i = 0; i < schema.fields.length; i++) {\n arrayRow[i] = row?.[schema.fields[i].name];\n }\n return arrayRow;\n\n default:\n throw new Error('shape');\n }\n}\n\n/** Convert any table into array row format */\nexport function makeArrayRowTable(table: Table): ArrayRowTable {\n if (table.shape === 'array-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<unknown[]>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsArray(table, rowIndex);\n }\n return {\n shape: 'array-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeObjectRowTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeColumnarTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n// Row Iterators\n\n/**\n * Iterate over table rows\n * @param table\n * @param shape\n */\nexport function* makeRowIterator(\n table: Table,\n shape: 'object-row-table' | 'array-row-table'\n): Iterable<unknown[] | {[key: string]: unknown}> {\n switch (shape) {\n case 'array-row-table':\n yield* makeArrayRowIterator(table);\n break;\n case 'object-row-table':\n yield* makeObjectRowIterator(table);\n break;\n\n default:\n throw new Error(`Unknown row type ${shape}`);\n }\n}\n\n/**\n * Streaming processing: Iterate over table, yielding array rows\n * @param table\n * @param shape\n */\nexport function* makeArrayRowIterator(table: Table, target: unknown[] = []): Iterable<unknown[]> {\n const length = getTableLength(table);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n yield getTableRowAsArray(table, rowIndex, target);\n }\n}\n\n/**\n * Streaming processing: Iterate over table, yielding object rows\n * @param table\n * @param shape\n */\nexport function* makeObjectRowIterator(\n table: Table,\n target: {[key: string]: unknown} = {}\n): Iterable<{[key: string]: unknown}> {\n const length = getTableLength(table);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n yield getTableRowAsObject(table, rowIndex, target);\n }\n}\n"],"mappings":"AASA,OAAO,SAASA,cAAcA,CAACC,KAAY,EAAU;EACnD,QA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F,KAAK,kBAAkB;MACrB,OAAOoD,qBAAqB,CAACpD,KAAK,CAAC;MACnC;IAEF;MACE,MAAM,IAAIQ,KAAK,qBAAA0B,MAAA,CAAqBjC,KAAK,CAAE,CAAC;EAChD;AACF;AAOA,OAAO,SAAUkD,oBAAoBA,CAACnD,KAAY;EAAA,IAAEoC,MAAiB,GAAAiB,SAAA,CAAAlD,MAAA,QAAAkD,SAAA,QAAAtB,SAAA,GAAAsB,SAAA,MAAG,EAAE;EAAA,oBAAuB;IAC/F,MAAMlD,MAAM,GAAGJ,cAAc,CAACC,KAAK,CAAC;IACpC,KAAK,IAAIe,QAAQ,GAAG,CAAC,EAAEA,QAAQ,GAAGZ,MAAM,EAAEY,QAAQ,EAAE,EAAE;MACpD,MAAM4B,kBAAkB,CAAC3C,KAAK,EAAEe,QAAQ,EAAEqB,MAAM,CAAC;IACnD;EACF,CAAC;AAAA;AAOD,OAAO,SAAUgB,qBAAqBA,CACpCpD,KAAY;EAAA,IACZoC,MAAgC,GAAAiB,SAAA,CAAAlD,MAAA,QAAAkD,SAAA,QAAAtB,SAAA,GAAAsB,SAAA,MAAG,CAAC,CAAC;EAAA,oBACD;IACpC,MAAMlD,MAAM,GAAGJ,cAAc,CAACC,KAAK,CAAC;IACpC,KAAK,IAAIe,QAAQ,GAAG,CAAC,EAAEA,QAAQ,GAAGZ,MAAM,EAAEY,QAAQ,EAAE,EAAE;MACpD,MAAMoB,mBAAmB,CAACnC,KAAK,EAAEe,QAAQ,EAAEqB,MAAM,CAAC;IACpD;EACF,CAAC;AAAA"}
|
|
1
|
+
{"version":3,"file":"table-accessors.js","names":["getTableLength","table","shape","data","length","features","arrowTable","numRows","column","Object","values","Error","getTableNumCols","schema","fields","keys","numCols","getTableCell","rowIndex","columnName","_arrowTable$getChildA","columnIndex","getTableColumnIndex","arrowColumnIndex","findIndex","field","name","getChildAt","get","getTableCellAt","_arrowTable$getChildA2","columnName1","getTableColumnName","columnName2","columnName3","getTableRowShape","_table$schema","undefined","_table$schema2","_table$schema2$fields","concat","getTableRowAsObject","target","copy","fromEntries","entries","objectRow","i","row","getTableRowAsArray","Array","from","arrayRow","makeArrayRowTable","makeObjectRowTable","makeColumnarTable","makeRowIterator","makeArrayRowIterator","makeObjectRowIterator","arguments"],"sources":["../../../../../src/lib/table/simple-table/table-accessors.ts"],"sourcesContent":["// loaders.gl, MIT license\n\n/* eslint-disable no-else-return */\n\nimport {Table, ArrayRowTable, ObjectRowTable} from '../../../types/category-table';\n\n/**\n * Returns the length of the table (i.e. the number of rows)\n */\nexport function getTableLength(table: Table): number {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n return table.data.length;\n\n case 'geojson-table':\n return table.features.length;\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n return arrowTable.numRows;\n\n case 'columnar-table':\n for (const column of Object.values(table.data)) {\n return column.length || 0;\n }\n return 0;\n default:\n throw new Error('table');\n }\n}\n\n/**\n * Returns the number of columns in the table\n * @throws Fails to deduce number of columns if the table has no schema and is empty\n */\nexport function getTableNumCols(table: Table): number {\n if (table.schema) {\n return table.schema.fields.length;\n }\n if (getTableLength(table) === 0) {\n throw new Error('empty table');\n }\n switch (table.shape) {\n case 'array-row-table':\n return table.data[0].length;\n case 'object-row-table':\n return Object.keys(table.data[0]).length;\n case 'geojson-table':\n return Object.keys(table.features[0]).length;\n case 'columnar-table':\n return Object.keys(table.data).length;\n case 'arrow-table':\n const arrowTable = table.data as any;\n return arrowTable.numCols;\n default:\n throw new Error('table');\n }\n}\n\n/** Get a table cell value at row index and column name */\nexport function getTableCell(table: Table, rowIndex: number, columnName: string): unknown {\n switch (table.shape) {\n case 'array-row-table':\n const columnIndex = getTableColumnIndex(table, columnName);\n return table.data[rowIndex][columnIndex];\n\n case 'object-row-table':\n return table.data[rowIndex][columnName];\n\n case 'geojson-table':\n return table.features[rowIndex][columnName];\n\n case 'columnar-table':\n const column = table.data[columnName];\n return column[rowIndex];\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n const arrowColumnIndex = arrowTable.schema.fields.findIndex(\n (field) => field.name === columnName\n );\n return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);\n\n default:\n throw new Error('todo');\n }\n}\n\n/** Get a table cell value at row index and column name */\nexport function getTableCellAt(table: Table, rowIndex: number, columnIndex: number): unknown {\n switch (table.shape) {\n case 'array-row-table':\n return table.data[rowIndex][columnIndex];\n\n case 'object-row-table':\n const columnName1 = getTableColumnName(table, columnIndex);\n return table.data[rowIndex][columnName1];\n\n case 'geojson-table':\n const columnName2 = getTableColumnName(table, columnIndex);\n return table.features[rowIndex][columnName2];\n\n case 'columnar-table':\n const columnName3 = getTableColumnName(table, columnIndex);\n const column = table.data[columnName3];\n return column[rowIndex];\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n return arrowTable.getChildAt(columnIndex)?.get(rowIndex);\n\n default:\n throw new Error('todo');\n }\n}\n\n/** Deduce the table row shape */\nexport function getTableRowShape(table: Table): 'array-row-table' | 'object-row-table' {\n switch (table.shape) {\n case 'array-row-table':\n case 'object-row-table':\n return table.shape;\n\n case 'geojson-table':\n // TODO - this is not correct, geojson-table is not a row table\n return 'object-row-table';\n\n case 'columnar-table':\n default:\n throw new Error('Not a row table');\n }\n}\n\n/** Get the index of a named table column. Requires the table to have a schema */\nexport function getTableColumnIndex(table: Table, columnName: string): number {\n const columnIndex = table.schema?.fields.findIndex((field) => field.name === columnName);\n if (columnIndex === undefined) {\n throw new Error(columnName);\n }\n return columnIndex;\n}\n\n/** Get the name of a table column by index. Requires the table to have a schema */\nexport function getTableColumnName(table: Table, columnIndex: number): string {\n const columnName = table.schema?.fields[columnIndex]?.name;\n if (!columnName) {\n throw new Error(`${columnIndex}`);\n }\n return columnName;\n}\n\n/**\n * Returns one row of the table in object format.\n * @param target Optional parameter will be used if needed to store the row. Can be reused between calls to improve performance\n * @returns an array representing the row. May be the original array in the row, a new object, or the target parameter\n */\n// eslint-disable-next-line complexity\nexport function getTableRowAsObject(\n table: Table,\n rowIndex: number,\n target?: {[columnName: string]: unknown},\n copy?: 'copy'\n): {[columnName: string]: unknown} {\n switch (table.shape) {\n case 'object-row-table':\n return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];\n\n case 'array-row-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] = table.data[rowIndex][i];\n }\n return objectRow;\n }\n throw new Error('no schema');\n\n case 'geojson-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n // TODO - should lift properties to top level\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] = table.features[rowIndex][i];\n }\n return objectRow;\n }\n throw new Error('no schema');\n\n case 'columnar-table':\n if (table.schema) {\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (let i = 0; i < table.schema.fields.length; i++) {\n objectRow[table.schema.fields[i].name] =\n table.data[table.schema.fields[i].name][rowIndex];\n }\n return objectRow;\n } else {\n // eslint-disable-line no-else-return\n const objectRow: {[columnName: string]: unknown} = target || {};\n for (const [name, column] of Object.entries(table.data)) {\n objectRow[name] = column[rowIndex];\n }\n return objectRow;\n }\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n const objectRow: {[columnName: string]: unknown} = target || {};\n const row = arrowTable.get(rowIndex);\n const schema = arrowTable.schema;\n for (let i = 0; i < schema.fields.length; i++) {\n objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];\n }\n return objectRow;\n\n default:\n throw new Error('shape');\n }\n}\n\n/**\n * Returns one row of the table in array format.\n * @param target Optional parameter will be used if needed to store the row. Can be reused between calls to improve performance.\n * @returns an array representing the row. May be the original array in the row, a new object, or the target parameter\n */\n// eslint-disable-next-line complexity\nexport function getTableRowAsArray(\n table: Table,\n rowIndex: number,\n target?: unknown[],\n copy?: 'copy'\n): unknown[] {\n switch (table.shape) {\n case 'array-row-table':\n return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];\n\n case 'object-row-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.data[rowIndex][table.schema.fields[i].name];\n }\n return arrayRow;\n }\n // Warning: just slap on the values, this risks mismatches between rows\n return Object.values(table.data[rowIndex]);\n\n case 'geojson-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n // TODO - should lift properties to top level\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.features[rowIndex][table.schema.fields[i].name];\n }\n return arrayRow;\n }\n // Warning: just slap on the values, this risks mismatches between rows\n return Object.values(table.features[rowIndex]);\n\n case 'columnar-table':\n if (table.schema) {\n const arrayRow: unknown[] = target || [];\n for (let i = 0; i < table.schema.fields.length; i++) {\n arrayRow[i] = table.data[table.schema.fields[i].name][rowIndex];\n }\n return arrayRow;\n } else {\n // eslint-disable-line no-else-return\n const arrayRow: unknown[] = target || [];\n let i = 0;\n for (const column of Object.values(table.data)) {\n arrayRow[i] = column[rowIndex];\n i++;\n }\n return arrayRow;\n }\n\n case 'arrow-table':\n const arrowTable = table.data as any;\n const arrayRow: unknown[] = target || [];\n const row = arrowTable.get(rowIndex);\n const schema = arrowTable.schema;\n for (let i = 0; i < schema.fields.length; i++) {\n arrayRow[i] = row?.[schema.fields[i].name];\n }\n return arrayRow;\n\n default:\n throw new Error('shape');\n }\n}\n\n/** Convert any table into array row format */\nexport function makeArrayRowTable(table: Table): ArrayRowTable {\n if (table.shape === 'array-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<unknown[]>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsArray(table, rowIndex);\n }\n return {\n shape: 'array-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeObjectRowTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n/** Convert any table into object row format */\nexport function makeColumnarTable(table: Table): ObjectRowTable {\n if (table.shape === 'object-row-table') {\n return table;\n }\n const length = getTableLength(table);\n const data = new Array<{[key: string]: unknown}>(length);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n data[rowIndex] = getTableRowAsObject(table, rowIndex);\n }\n return {\n shape: 'object-row-table',\n schema: table.schema,\n data\n };\n}\n\n// Row Iterators\n\n/**\n * Iterate over table rows\n * @param table\n * @param shape\n */\nexport function* makeRowIterator(\n table: Table,\n shape: 'object-row-table' | 'array-row-table'\n): Iterable<unknown[] | {[key: string]: unknown}> {\n switch (shape) {\n case 'array-row-table':\n yield* makeArrayRowIterator(table);\n break;\n case 'object-row-table':\n yield* makeObjectRowIterator(table);\n break;\n\n default:\n throw new Error(`Unknown row type ${shape}`);\n }\n}\n\n/**\n * Streaming processing: Iterate over table, yielding array rows\n * @param table\n * @param shape\n */\nexport function* makeArrayRowIterator(table: Table, target: unknown[] = []): Iterable<unknown[]> {\n const length = getTableLength(table);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n yield getTableRowAsArray(table, rowIndex, target);\n }\n}\n\n/**\n * Streaming processing: Iterate over table, yielding object rows\n * @param table\n * @param shape\n */\nexport function* makeObjectRowIterator(\n table: Table,\n target: {[key: string]: unknown} = {}\n): Iterable<{[key: string]: unknown}> {\n const length = getTableLength(table);\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n yield getTableRowAsObject(table, rowIndex, target);\n }\n}\n"],"mappings":"AASA,OAAO,SAASA,cAAcA,CAACC,KAAY,EAAU;EACnD,QAAQA,KAAK,CAACC,KAAK;IACjB,KAAK,iBAAiB;IACtB,KAAK,kBAAkB;MACrB,OAAOD,KAAK,CAACE,IAAI,CAACC,MAAM;I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,KAAY,EACZC,KAA6C,EACG;EAChD,QAAQA,KAAK;IACX,KAAK,iBAAiB;MACpB,OAAOuD,oBAAoB,CAACxD,KAAK,CAAC;MAClC;IACF,KAAK,kBAAkB;MACrB,OAAOyD,qBAAqB,CAACzD,KAAK,CAAC;MACnC;IAEF;MACE,MAAM,IAAIU,KAAK,qBAAA6B,MAAA,CAAqBtC,KAAK,CAAE,CAAC;EAChD;AACF;AAOA,OAAO,SAAUuD,oBAAoBA,CAACxD,KAAY;EAAA,IAAEyC,MAAiB,GAAAiB,SAAA,CAAAvD,MAAA,QAAAuD,SAAA,QAAAtB,SAAA,GAAAsB,SAAA,MAAG,EAAE;EAAA,oBAAuB;IAC/F,MAAMvD,MAAM,GAAGJ,cAAc,CAACC,KAAK,CAAC;IACpC,KAAK,IAAIiB,QAAQ,GAAG,CAAC,EAAEA,QAAQ,GAAGd,MAAM,EAAEc,QAAQ,EAAE,EAAE;MACpD,MAAM+B,kBAAkB,CAAChD,KAAK,EAAEiB,QAAQ,EAAEwB,MAAM,CAAC;IACnD;EACF,CAAC;AAAA;AAOD,OAAO,SAAUgB,qBAAqBA,CACpCzD,KAAY;EAAA,IACZyC,MAAgC,GAAAiB,SAAA,CAAAvD,MAAA,QAAAuD,SAAA,QAAAtB,SAAA,GAAAsB,SAAA,MAAG,CAAC,CAAC;EAAA,oBACD;IACpC,MAAMvD,MAAM,GAAGJ,cAAc,CAACC,KAAK,CAAC;IACpC,KAAK,IAAIiB,QAAQ,GAAG,CAAC,EAAEA,QAAQ,GAAGd,MAAM,EAAEc,QAAQ,EAAE,EAAE;MACpD,MAAMuB,mBAAmB,CAACxC,KAAK,EAAEiB,QAAQ,EAAEwB,MAAM,CAAC;IACpD;EACF,CAAC;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.js","names":[],"sources":["../../../src/types/batch.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {Schema} from './schema';\nimport type {RecordBatch} from 'apache-arrow';\n\n/**\n * A batch of data (or metadata/schema), from a streaming loader\n * @see parseInBatches()\n * @see loadInBatches()\n */\nexport type Batch = {\n /** A batch can contain metadata, data, or in case of unstructured data (JSON) */\n batchType: 'data' | 'metadata' | 'partial-result' | 'final-result';\n /** A string identifying the shape of data in this batch (table, etc) */\n shape: string;\n /** Schema of the data in this batch */\n schema?: Schema;\n /** Data in this batch */\n data: unknown;\n /** If this is an arrow table. @deprecated Use `data` */\n recordBatch?: RecordBatch;\n /** Length of data in this batch */\n length: number;\n\n /** A count of batches received */\n batch?: number;\n\n /** A count of batches received */\n count?: number;\n\n /** Bytes used so far */\n bytesUsed?: number;\n /** cursor is the */\n cursor?: number;\n\n /** MIME type of the data generating this batch */\n mimeType?: string;\n\n /** Any other data */\n [key: string]: unknown;\n};\n"],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binary-geometries.js","names":[],"sources":["../../../src/types/binary-geometries.ts"],"sourcesContent":["// GIS\nimport type {TypedArray} from './types';\n\n// BINARY FORMAT GEOMETRY\n\nexport type BinaryAttribute = {value: TypedArray; size: number};\nexport type BinaryGeometryType = 'Point' | 'LineString' | 'Polygon';\n\ntype NumericProps = {[key: string]: BinaryAttribute};\ntype Properties = object[];\n\n/**\n * Represent a single Geometry, similar to a GeoJSON Geometry\n */\nexport type BinaryGeometry = BinaryPointGeometry | BinaryLineGeometry | BinaryPolygonGeometry;\n\n/** Binary point geometry: an array of positions */\nexport type BinaryPointGeometry = {\n type: 'Point';\n positions: BinaryAttribute;\n};\n\n/** Binary line geometry, array of positions and indices to the start of each line */\nexport type BinaryLineGeometry = {\n type: 'LineString';\n positions: BinaryAttribute;\n pathIndices: BinaryAttribute;\n};\n\n/** Binary polygon geometry, an array of positions to each primitite polygon and polygon */\nexport type BinaryPolygonGeometry = {\n type: 'Polygon';\n positions: BinaryAttribute;\n polygonIndices: BinaryAttribute;\n primitivePolygonIndices: BinaryAttribute;\n triangles?: BinaryAttribute;\n};\n\n/** Common properties for binary geometries */\nexport type BinaryProperties = {\n featureIds: BinaryAttribute;\n globalFeatureIds: BinaryAttribute;\n numericProps: NumericProps;\n properties: Properties;\n fields?: Properties;\n};\n\n/** Binary feature + binary attributes */\nexport type BinaryFeature = BinaryPointFeature | BinaryLineFeature | BinaryPolygonFeature;\n\nexport type BinaryPointFeature = BinaryPointGeometry & BinaryProperties;\nexport type BinaryLineFeature = BinaryLineGeometry & BinaryProperties;\nexport type BinaryPolygonFeature = BinaryPolygonGeometry & BinaryProperties;\n\n/**\n * Represent a collection of Features, similar to a GeoJSON FeatureCollection\n */\nexport type BinaryFeatureCollection = {\n points?: BinaryPointFeature;\n lines?: BinaryLineFeature;\n polygons?: BinaryPolygonFeature;\n};\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category-gis.js","names":[],"sources":["../../../src/types/category-gis.ts"],"sourcesContent":["// GIS\
|
|
1
|
+
{"version":3,"file":"category-gis.js","names":[],"sources":["../../../src/types/category-gis.ts"],"sourcesContent":["// GIS\n\n// NORMAL GEOJSON FORMAT GEOMETRY\nexport type {\n GeoJSON,\n Feature,\n FeatureCollection,\n Geometry,\n Position,\n GeoJsonProperties\n} from 'geojson';\n\nexport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon,\n GeometryCollection\n} from 'geojson';\n\n// FLAT GEOJSON FORMAT GEOMETRY\nexport type {\n FlatGeometryType,\n FlatIndexedGeometry,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n FlatGeometry,\n FlatFeature\n} from './flat-geometries';\n\n// BINARY FORMAT GEOMETRY\nexport type {\n BinaryAttribute,\n BinaryGeometryType,\n BinaryGeometry,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryProperties,\n BinaryFeatureCollection,\n BinaryFeature,\n BinaryPointFeature,\n BinaryLineFeature,\n BinaryPolygonFeature\n} from './binary-geometries';\n\n/** Aggregate information for converting GeoJSON into other formats */\nexport type GeojsonGeometryInfo = {\n coordLength: number;\n pointPositionsCount: number;\n pointFeaturesCount: number;\n linePositionsCount: number;\n linePathsCount: number;\n lineFeaturesCount: number;\n polygonPositionsCount: number;\n polygonObjectsCount: number;\n polygonRingsCount: number;\n polygonFeaturesCount: number;\n};\n"],"mappings":""}
|