@loaders.gl/geoarrow 4.4.0-alpha.1

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.
Files changed (70) hide show
  1. package/LICENSE +41 -0
  2. package/README.md +7 -0
  3. package/dist/geo-column/geo-column-info.d.ts +20 -0
  4. package/dist/geo-column/geo-column-info.d.ts.map +1 -0
  5. package/dist/geo-column/geo-column-info.js +74 -0
  6. package/dist/geo-column/geo-column.d.ts +61 -0
  7. package/dist/geo-column/geo-column.d.ts.map +1 -0
  8. package/dist/geo-column/geo-column.js +4 -0
  9. package/dist/geoarrow-functions.d.ts +131 -0
  10. package/dist/geoarrow-functions.d.ts.map +1 -0
  11. package/dist/geoarrow-functions.js +218 -0
  12. package/dist/geoarrow-types.d.ts +49 -0
  13. package/dist/geoarrow-types.d.ts.map +1 -0
  14. package/dist/geoarrow-types.js +4 -0
  15. package/dist/get-arrow-bounds.d.ts +11 -0
  16. package/dist/get-arrow-bounds.d.ts.map +1 -0
  17. package/dist/get-arrow-bounds.js +34 -0
  18. package/dist/get-geoarrow-geometry-info.d.ts +30 -0
  19. package/dist/get-geoarrow-geometry-info.d.ts.map +1 -0
  20. package/dist/get-geoarrow-geometry-info.js +124 -0
  21. package/dist/index.cjs +430 -0
  22. package/dist/index.cjs.map +7 -0
  23. package/dist/index.d.ts +11 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +12 -0
  26. package/dist/mesharrow/arrow-fixed-size-list-utils.d.ts +11 -0
  27. package/dist/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -0
  28. package/dist/mesharrow/arrow-fixed-size-list-utils.js +39 -0
  29. package/dist/mesharrow/arrow-list-of-fixed-size-list-utils.d.ts +11 -0
  30. package/dist/mesharrow/arrow-list-of-fixed-size-list-utils.d.ts.map +1 -0
  31. package/dist/mesharrow/arrow-list-of-fixed-size-list-utils.js +31 -0
  32. package/dist/mesharrow/get-bounding-box.d.ts +5 -0
  33. package/dist/mesharrow/get-bounding-box.d.ts.map +1 -0
  34. package/dist/mesharrow/get-bounding-box.js +33 -0
  35. package/dist/mesharrow/get-deck-binary-data.d.ts +13 -0
  36. package/dist/mesharrow/get-deck-binary-data.d.ts.map +1 -0
  37. package/dist/mesharrow/get-deck-binary-data.js +24 -0
  38. package/dist/mesharrow/mesh-accessors.d.ts +8 -0
  39. package/dist/mesharrow/mesh-accessors.d.ts.map +1 -0
  40. package/dist/mesharrow/mesh-accessors.js +18 -0
  41. package/dist/metadata/geoarrow-metadata.d.ts +27 -0
  42. package/dist/metadata/geoarrow-metadata.d.ts.map +1 -0
  43. package/dist/metadata/geoarrow-metadata.js +71 -0
  44. package/dist/metadata/geoparquet-metadata-schema.d.ts +79 -0
  45. package/dist/metadata/geoparquet-metadata-schema.d.ts.map +1 -0
  46. package/dist/metadata/geoparquet-metadata-schema.js +69 -0
  47. package/dist/metadata/geoparquet-metadata.d.ts +45 -0
  48. package/dist/metadata/geoparquet-metadata.d.ts.map +1 -0
  49. package/dist/metadata/geoparquet-metadata.js +131 -0
  50. package/dist/metadata/metadata-utils.d.ts +21 -0
  51. package/dist/metadata/metadata-utils.d.ts.map +1 -0
  52. package/dist/metadata/metadata-utils.js +14 -0
  53. package/package.json +63 -0
  54. package/src/geo-column/geo-column-info.ts +114 -0
  55. package/src/geo-column/geo-column.ts +85 -0
  56. package/src/geoarrow-functions.ts +258 -0
  57. package/src/geoarrow-types.ts +72 -0
  58. package/src/get-arrow-bounds.ts +41 -0
  59. package/src/get-geo-column-from-geoarrow.ts.disabled +251 -0
  60. package/src/get-geoarrow-geometry-info.ts +172 -0
  61. package/src/index.ts +57 -0
  62. package/src/mesharrow/arrow-fixed-size-list-utils.ts +62 -0
  63. package/src/mesharrow/arrow-list-of-fixed-size-list-utils.ts +47 -0
  64. package/src/mesharrow/get-bounding-box.ts +39 -0
  65. package/src/mesharrow/get-deck-binary-data.ts +43 -0
  66. package/src/mesharrow/mesh-accessors.ts +27 -0
  67. package/src/metadata/geoarrow-metadata.ts +102 -0
  68. package/src/metadata/geoparquet-metadata-schema.ts +71 -0
  69. package/src/metadata/geoparquet-metadata.ts +195 -0
  70. package/src/metadata/metadata-utils.ts +32 -0
package/LICENSE ADDED
@@ -0,0 +1,41 @@
1
+ loaders.gl is licensed under the MIT license
2
+
3
+ Copyright (c) vis.gl contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ ---
24
+
25
+ Copyright (c) 2015 Uber Technologies, Inc.
26
+
27
+ loaders.gl includes certain files from Cesium (https://github.com/AnalyticalGraphicsInc/cesium)
28
+ under the Apache 2 License (found in the submodule: modules/3d-tiles):)
29
+
30
+ Copyright 2011-2018 CesiumJS Contributors
31
+
32
+ Licensed under the Apache License, Version 2.0 (the "License");
33
+ you may not use this file except in compliance with the License.
34
+ You may obtain a copy of the License at
35
+ http://www.apache.org/licenses/LICENSE-2.0
36
+
37
+ Unless required by applicable law or agreed to in writing, software
38
+ distributed under the License is distributed on an "AS IS" BASIS,
39
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
+ See the License for the specific language governing permissions and limitations under the License.
41
+
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @loaders.gl/geoarrow
2
+
3
+ This module contains support for the Apache Arrow GeoArrow format.
4
+
5
+ [loaders.gl](https://loaders.gl/docs) is a collection of loaders for big data visualizations.
6
+
7
+ For documentation please visit the [website](https://loaders.gl).
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Information about a binary geometry
3
+ */
4
+ export type geoColumnInfo = {
5
+ type: 'Point' | 'LineString' | 'Polygon';
6
+ /** The GeoJSON style geometry type corresponding to this particular binary geometry */
7
+ multiGeometryType: 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon';
8
+ /** Is this a "Multi" version of the binary geometry? */
9
+ isMultiGeometry: boolean;
10
+ /** How many dimensions are the coordinates? */
11
+ dimension: number;
12
+ /** How many points does this geometry have? */
13
+ pointCount: number;
14
+ /** How many coordinates does this geometry have? */
15
+ coordinateCount: number;
16
+ };
17
+ /**
18
+ * @returns information about a binary geometry
19
+ */
20
+ //# sourceMappingURL=geo-column-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-column-info.d.ts","sourceRoot":"","sources":["../../src/geo-column/geo-column-info.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;IACzC,uFAAuF;IACvF,iBAAiB,EACb,OAAO,GACP,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,iBAAiB,GACjB,cAAc,CAAC;IACnB,wDAAwD;IACxD,eAAe,EAAE,OAAO,CAAC;IACzB,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;GAEG"}
@@ -0,0 +1,74 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export {};
5
+ /**
6
+ * @returns information about a binary geometry
7
+ */
8
+ // export function getGeoColumnInfo(geometry: GeoColumn): GeoColumnInfo {
9
+ // }
10
+ // // loaders.gl
11
+ // // SPDX-License-Identifier: MIT
12
+ // // Copyright (c) vis.gl contributors
13
+ // import type {Schema, Field, GeoArrowMetadata, GeoArrowEncoding, Geometry} from '@loaders.gl/schema';
14
+ // import {convertArrowToSchema} from '@loaders.gl/schema-utils';
15
+ // import * as arrow from 'apache-arrow';
16
+ // import {getGeometryColumnsFromSchema, getGeometryMetadataForField} from '../geoarrow/geoarrow-metadata';
17
+ // import { getGeoMetadata as getParquetMe} from './geoparquet-metadata';
18
+ // /**
19
+ // * A geoarrow / geoparquet geo metadata object
20
+ // * (stored in stringified form in the top level metadata 'geo' key)
21
+ // * @see https://github.com/opengeospatial/geoparquet/blob/main/format-specs/geoparquet.md
22
+ // * @see https://github.com/geoarrow/geoarrow
23
+ // * */
24
+ // export type GeoTableMetadata = {
25
+ // version?: string;
26
+ // primaryGeometryColumn?: string;
27
+ // columns: Record<string, GeoColumnInfo>;
28
+ // [key: string]: unknown;
29
+ // };
30
+ // /** A geoarrow / geoparquet geo metadata for one geometry column */
31
+ // export type GeoColumnInfo = {
32
+ // encoding: 'wkb' | 'wkt' | 'none';
33
+ // geometryTypes: Geometry['type'][];
34
+ // dimension: number;
35
+ // crs?: object | null;
36
+ // orientation?: 'counterclockwise';
37
+ // bbox?: [number, number, number, number] | [number, number, number, number, number, number];
38
+ // edges?: 'planar' | 'spherical';
39
+ // epoch?: number;
40
+ // [key: string]: unknown;
41
+ // // geoParquetGeometryType:
42
+ // };
43
+ // export type GeoArrowInfo = {
44
+ // geometryColumns: Record<string, GeometryColumnInfo>
45
+ // };
46
+ // /**
47
+ // * get geometry columns from arrow table
48
+ // */
49
+ // export function getGeoArrowInfo(arrowTable: arrow.Table): GeoArrowInfo {
50
+ // const schema = convertArrowToSchema(arrowTable.schema);
51
+ // const geometryColumns = getGeometryColumnsFromSchema(schema);
52
+ // // get encoding from geometryColumns['geometry']
53
+ // const encoding = geometryColumns.geometry.encoding;
54
+ // // Remove geometry columns
55
+ // const propertyColumnNames = arrowTable.schema.fields
56
+ // .map((field) => field.name)
57
+ // // TODO - this deletes all geometry columns
58
+ // .filter((name) => name in geometryColumns);
59
+ // const propertiesTable = arrowTable.select(propertyColumnNames);
60
+ // const arrowGeometryColumn = arrowTable.getChild('geometry');
61
+ // for (let row = 0; row < arrowTable.numRows; row++) {
62
+ // // get the geometry value from arrow geometry column
63
+ // // Note that type can vary
64
+ // const arrowGeometry = arrowGeometryColumn?.get(row);
65
+ // // parse arrow geometry to geojson feature
66
+ // const feature = convertGeoArrowGeometryToGeoJSON(arrowGeometry, encoding);
67
+ // if (feature) {
68
+ // const properties = propertiesTable.get(row)?.toJSON() || {};
69
+ // features.push({type: 'Feature', geometry: feature, properties});
70
+ // }
71
+ // }
72
+ // return {
73
+ // };
74
+ // }
@@ -0,0 +1,61 @@
1
+ import type { TypedArray } from '@math.gl/types';
2
+ export type GeoColumnType = 'Point' | 'LineString' | 'Polygon';
3
+ /** A geometry column can be built from list of geometry column data chunks */
4
+ export type GeoColumn<MetadataT = Record<string, unknown>> = {
5
+ shape: 'geo-column';
6
+ metadata?: MetadataT;
7
+ data: GeoColumnData[];
8
+ };
9
+ export type GeoColumnData = GeoColumnPointData | GeoColumnLineData | GeoColumnPolygonData;
10
+ /**
11
+ * Describes a single contiguous chunk of geometries in binary columnar format
12
+ * Extracts the nested position and offset arrays from a GeoArrow column
13
+ * @note Designed to be a cheap operation: does not create any new arrays, just holds extracted references the existing arrays
14
+ */
15
+ export type GeoColumnCommonData = {
16
+ shape: 'geo-column-data';
17
+ /** Number of rows geometries (can be less than pointCount if representing multipoints) */
18
+ numRows: number;
19
+ /** Offset to the end of the next geometry (length = rowCount) */
20
+ rowOffsets: Uint32Array;
21
+ /** Number of positions */
22
+ numPositions: number;
23
+ /** Data for coordinates, either interleaved or separate arrays */
24
+ positions: GeoColumnPositions;
25
+ };
26
+ /** Columnar point geometry: an array of positions */
27
+ export type GeoColumnPointData = GeoColumnCommonData & {
28
+ type: 'Point';
29
+ };
30
+ /** Columnar line geometry, array of positions and indices to the start of each line */
31
+ export type GeoColumnLineData = GeoColumnCommonData & {
32
+ type: 'LineString';
33
+ /** Offset to the next path within the multi feature */
34
+ pathOffsets: Uint32Array;
35
+ };
36
+ /** Columnar polygon geometry, an array of positions to each primitite polygon and polygon */
37
+ export type GeoColumnPolygonData = GeoColumnCommonData & {
38
+ type: 'Polygon';
39
+ /** Offset to next polygon */
40
+ polygonOffsets: Uint32Array;
41
+ /** Offset to next primitive polygon */
42
+ ringOffsets: Uint32Array;
43
+ };
44
+ export type GeoColumnPositions = GeoColumnInterleavedPositions | GeoColumnSeparatePositions;
45
+ /** Positions are in a single coordinate array */
46
+ export type GeoColumnInterleavedPositions = {
47
+ layout: 'interleaved';
48
+ /** Dimension, i.e. number of coordinates per position: 2, 3 or 4 */
49
+ stride: 2 | 3 | 4;
50
+ /** Flat array of position coordinates (length = positionCount * positionStride */
51
+ coordinates: TypedArray;
52
+ };
53
+ /** Positions are in separate coordinate arrays */
54
+ export type GeoColumnSeparatePositions = {
55
+ layout: 'separate';
56
+ /** Dimension, i.e. number of coordinates per position: 2, 3 or 4 */
57
+ stride: 2 | 3 | 4;
58
+ /** Flat array of position coordinates (length = positionCount * positionStride */
59
+ coordinates: TypedArray[];
60
+ };
61
+ //# sourceMappingURL=geo-column.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo-column.d.ts","sourceRoot":"","sources":["../../src/geo-column/geo-column.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAI/C,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAE/D,8EAA8E;AAC9E,MAAM,MAAM,SAAS,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAC3D,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,aAAa,EAAE,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;AAE1F;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,iBAAiB,CAAC;IAEzB,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,UAAU,EAAE,WAAW,CAAC;IAExB,0BAA0B;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,SAAS,EAAE,kBAAkB,CAAC;CAM/B,CAAC;AAEF,qDAAqD;AACrD,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG;IACrD,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF,uFAAuF;AACvF,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG;IACpD,IAAI,EAAE,YAAY,CAAC;IAEnB,uDAAuD;IACvD,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,6FAA6F;AAC7F,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG;IACvD,IAAI,EAAE,SAAS,CAAC;IAChB,6BAA6B;IAC7B,cAAc,EAAE,WAAW,CAAC;IAC5B,uCAAuC;IACvC,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,6BAA6B,GAAG,0BAA0B,CAAC;AAE5F,iDAAiD;AACjD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,aAAa,CAAC;IACtB,oEAAoE;IACpE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,kFAAkF;IAClF,WAAW,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF,kDAAkD;AAClD,MAAM,MAAM,0BAA0B,GAAG;IACvC,MAAM,EAAE,UAAU,CAAC;IACnB,oEAAoE;IACpE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,kFAAkF;IAClF,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,4 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export {};
@@ -0,0 +1,131 @@
1
+ /**
2
+ * @note Conforms to the GeoArrow memory layout
3
+ * @see https://geoarrow.org/format.html#memory-layouts
4
+ * @note this is aligned with the geoarrow-js library (MIT license)
5
+ * @see https://github.com/geoarrow/geoarrow-js/
6
+ */
7
+ import { DataType } from 'apache-arrow/type';
8
+ import type { GeoArrowPoint, GeoArrowLineString, GeoArrowPolygon, GeoArrowMultiPoint, GeoArrowMultiLineString, GeoArrowMultiPolygon, GeoArrowGeometry } from "./geoarrow-types.js";
9
+ /** Checks whether the given Apache Arrow JS type is a Point data type */
10
+ export declare function isGeoArrowPoint(type: DataType): type is GeoArrowPoint;
11
+ /** Checks whether the given Apache Arrow JS type is a Point data type */
12
+ export declare function isGeoArrowLineString(type: DataType): type is GeoArrowLineString;
13
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
14
+ export declare function isGeoArrowPolygon(type: DataType): type is GeoArrowPolygon;
15
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
16
+ export declare function isGeoArrowMultiPoint(type: DataType): type is GeoArrowMultiPoint;
17
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
18
+ export declare function isGeoArrowMultiLineString(type: DataType): type is GeoArrowMultiLineString;
19
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
20
+ export declare function isGeoArrowMultiPolygon(type: DataType): type is GeoArrowMultiPolygon;
21
+ /**
22
+ * Checks if a given Arrow data type is a valid GeoArrowGeometry
23
+ * @note this is somewhat inefficient, it checks the same things multiple times
24
+ */
25
+ export declare function isGeoArrowGeometry(type: DataType): type is GeoArrowGeometry;
26
+ /**
27
+ * Strongly typed accessors for children, since arrow.Data.children[] is untyped
28
+
29
+ import { Data } from "apache-arrow/data";
30
+ import { Vector } from "apache-arrow/vector";
31
+ import { Float } from "apache-arrow/type";
32
+ import {
33
+ LineStringData,
34
+ MultiLineStringData,
35
+ MultiPointData,
36
+ MultiPolygonData,
37
+ PointData,
38
+ PolygonData,
39
+ } from "./data";
40
+ import {
41
+ LineStringVector,
42
+ MultiLineStringVector,
43
+ MultiPointVector,
44
+ MultiPolygonVector,
45
+ PointVector,
46
+ PolygonVector,
47
+ } from "./vector";
48
+
49
+ export function getPointChild(input: PointData): Data<Float>;
50
+ export function getPointChild(input: PointVector): Vector<Float>;
51
+
52
+ export function getPointChild(
53
+ input: PointData | PointVector,
54
+ ): Data<Float> | Vector<Float> {
55
+ if ("data" in input) {
56
+ return input.getChildAt(0)!;
57
+ }
58
+
59
+ return input.children[0] as Data<Float>;
60
+ }
61
+
62
+ export function getLineStringChild(input: LineStringData): PointData;
63
+ export function getLineStringChild(input: LineStringVector): PointVector;
64
+
65
+ export function getLineStringChild(
66
+ input: LineStringData | LineStringVector,
67
+ ): PointData | PointVector {
68
+ if ("data" in input) {
69
+ return input.getChildAt(0)!;
70
+ }
71
+
72
+ return input.children[0] as PointData;
73
+ }
74
+
75
+ export function getPolygonChild(input: PolygonData): LineStringData;
76
+ export function getPolygonChild(input: PolygonVector): LineStringVector;
77
+
78
+ export function getPolygonChild(
79
+ input: PolygonData | PolygonVector,
80
+ ): LineStringData | LineStringVector {
81
+ if ("data" in input) {
82
+ return input.getChildAt(0)!;
83
+ }
84
+
85
+ return input.children[0] as LineStringData;
86
+ }
87
+
88
+ export function getMultiPointChild(input: MultiPointData): PointData;
89
+ export function getMultiPointChild(input: MultiPointVector): PointVector;
90
+
91
+ export function getMultiPointChild(
92
+ input: MultiPointData | MultiPointVector,
93
+ ): PointData | PointVector {
94
+ if ("data" in input) {
95
+ return input.getChildAt(0)!;
96
+ }
97
+
98
+ return input.children[0] as PointData;
99
+ }
100
+
101
+ export function getMultiLineStringChild(
102
+ input: MultiLineStringData,
103
+ ): LineStringData;
104
+ export function getMultiLineStringChild(
105
+ input: MultiLineStringVector,
106
+ ): LineStringVector;
107
+
108
+ export function getMultiLineStringChild(
109
+ input: MultiLineStringData | MultiLineStringVector,
110
+ ): LineStringData | LineStringVector {
111
+ if ("data" in input) {
112
+ return input.getChildAt(0)!;
113
+ }
114
+
115
+ return input.children[0] as LineStringData;
116
+ }
117
+
118
+ export function getMultiPolygonChild(input: MultiPolygonData): PolygonData;
119
+ export function getMultiPolygonChild(input: MultiPolygonVector): PolygonVector;
120
+
121
+ export function getMultiPolygonChild(
122
+ input: MultiPolygonData | MultiPolygonVector,
123
+ ): PolygonData | PolygonVector {
124
+ if ("data" in input) {
125
+ return input.getChildAt(0)!;
126
+ }
127
+
128
+ return input.children[0] as PolygonData;
129
+ }
130
+ */
131
+ //# sourceMappingURL=geoarrow-functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geoarrow-functions.d.ts","sourceRoot":"","sources":["../src/geoarrow-functions.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EACjB,4BAAyB;AAE1B,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,aAAa,CAmCrE;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,kBAAkB,CAY/E;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,eAAe,CAYzE;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,kBAAkB,CAY/E;AAED,2EAA2E;AAC3E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,uBAAuB,CAYzF;AAED,2EAA2E;AAC3E,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,oBAAoB,CAYnF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,gBAAgB,CAS3E;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwGE"}
@@ -0,0 +1,218 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /**
5
+ * @note Conforms to the GeoArrow memory layout
6
+ * @see https://geoarrow.org/format.html#memory-layouts
7
+ * @note this is aligned with the geoarrow-js library (MIT license)
8
+ * @see https://github.com/geoarrow/geoarrow-js/
9
+ */
10
+ import { DataType } from 'apache-arrow/type';
11
+ /** Checks whether the given Apache Arrow JS type is a Point data type */
12
+ export function isGeoArrowPoint(type) {
13
+ if (DataType.isFixedSizeList(type)) {
14
+ // Check list size
15
+ if (![2, 3, 4].includes(type.listSize)) {
16
+ return false;
17
+ }
18
+ // Check child of FixedSizeList is floating type
19
+ if (!DataType.isFloat(type.children[0])) {
20
+ return false;
21
+ }
22
+ return true;
23
+ }
24
+ // TODO - support separated coordinates
25
+ // if (DataType.isStruct(type)) {
26
+ // // Check number of children
27
+ // if (![2, 3, 4].includes(type.children.length)) {
28
+ // return false;
29
+ // }
30
+ // // Check that children have correct field names
31
+ // if (!type.children.every((field) => ['x', 'y', 'z', 'm'].includes(field.name))) {
32
+ // return false;
33
+ // }
34
+ // if (!type.children.every((field) => DataType.isFloat(field))) {
35
+ // return false;
36
+ // }
37
+ // return true;
38
+ // }
39
+ return false;
40
+ }
41
+ /** Checks whether the given Apache Arrow JS type is a Point data type */
42
+ export function isGeoArrowLineString(type) {
43
+ // Check the outer type is a List
44
+ if (!DataType.isList(type)) {
45
+ return false;
46
+ }
47
+ // Check the child is a point type
48
+ if (!isGeoArrowPoint(type.children[0].type)) {
49
+ return false;
50
+ }
51
+ return true;
52
+ }
53
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
54
+ export function isGeoArrowPolygon(type) {
55
+ // Check the outer vector is a List
56
+ if (!DataType.isList(type)) {
57
+ return false;
58
+ }
59
+ // Check the child is a linestring vector
60
+ if (!isGeoArrowLineString(type.children[0].type)) {
61
+ return false;
62
+ }
63
+ return true;
64
+ }
65
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
66
+ export function isGeoArrowMultiPoint(type) {
67
+ // Check the outer vector is a List
68
+ if (!DataType.isList(type)) {
69
+ return false;
70
+ }
71
+ // Check the child is a point vector
72
+ if (!isGeoArrowPoint(type.children[0].type)) {
73
+ return false;
74
+ }
75
+ return true;
76
+ }
77
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
78
+ export function isGeoArrowMultiLineString(type) {
79
+ // Check the outer vector is a List
80
+ if (!DataType.isList(type)) {
81
+ return false;
82
+ }
83
+ // Check the child is a linestring vector
84
+ if (!isGeoArrowLineString(type.children[0].type)) {
85
+ return false;
86
+ }
87
+ return true;
88
+ }
89
+ /** Checks whether the given Apache Arrow JS type is a Polygon data type */
90
+ export function isGeoArrowMultiPolygon(type) {
91
+ // Check the outer vector is a List
92
+ if (!DataType.isList(type)) {
93
+ return false;
94
+ }
95
+ // Check the child is a polygon vector
96
+ if (!isGeoArrowPolygon(type.children[0].type)) {
97
+ return false;
98
+ }
99
+ return true;
100
+ }
101
+ /**
102
+ * Checks if a given Arrow data type is a valid GeoArrowGeometry
103
+ * @note this is somewhat inefficient, it checks the same things multiple times
104
+ */
105
+ export function isGeoArrowGeometry(type) {
106
+ return (isGeoArrowPoint(type) ||
107
+ isGeoArrowLineString(type) ||
108
+ isGeoArrowPolygon(type) ||
109
+ isGeoArrowMultiPoint(type) ||
110
+ isGeoArrowMultiLineString(type) ||
111
+ isGeoArrowMultiPolygon(type));
112
+ }
113
+ // CHILD EXTRACTION
114
+ /**
115
+ * Strongly typed accessors for children, since arrow.Data.children[] is untyped
116
+
117
+ import { Data } from "apache-arrow/data";
118
+ import { Vector } from "apache-arrow/vector";
119
+ import { Float } from "apache-arrow/type";
120
+ import {
121
+ LineStringData,
122
+ MultiLineStringData,
123
+ MultiPointData,
124
+ MultiPolygonData,
125
+ PointData,
126
+ PolygonData,
127
+ } from "./data";
128
+ import {
129
+ LineStringVector,
130
+ MultiLineStringVector,
131
+ MultiPointVector,
132
+ MultiPolygonVector,
133
+ PointVector,
134
+ PolygonVector,
135
+ } from "./vector";
136
+
137
+ export function getPointChild(input: PointData): Data<Float>;
138
+ export function getPointChild(input: PointVector): Vector<Float>;
139
+
140
+ export function getPointChild(
141
+ input: PointData | PointVector,
142
+ ): Data<Float> | Vector<Float> {
143
+ if ("data" in input) {
144
+ return input.getChildAt(0)!;
145
+ }
146
+
147
+ return input.children[0] as Data<Float>;
148
+ }
149
+
150
+ export function getLineStringChild(input: LineStringData): PointData;
151
+ export function getLineStringChild(input: LineStringVector): PointVector;
152
+
153
+ export function getLineStringChild(
154
+ input: LineStringData | LineStringVector,
155
+ ): PointData | PointVector {
156
+ if ("data" in input) {
157
+ return input.getChildAt(0)!;
158
+ }
159
+
160
+ return input.children[0] as PointData;
161
+ }
162
+
163
+ export function getPolygonChild(input: PolygonData): LineStringData;
164
+ export function getPolygonChild(input: PolygonVector): LineStringVector;
165
+
166
+ export function getPolygonChild(
167
+ input: PolygonData | PolygonVector,
168
+ ): LineStringData | LineStringVector {
169
+ if ("data" in input) {
170
+ return input.getChildAt(0)!;
171
+ }
172
+
173
+ return input.children[0] as LineStringData;
174
+ }
175
+
176
+ export function getMultiPointChild(input: MultiPointData): PointData;
177
+ export function getMultiPointChild(input: MultiPointVector): PointVector;
178
+
179
+ export function getMultiPointChild(
180
+ input: MultiPointData | MultiPointVector,
181
+ ): PointData | PointVector {
182
+ if ("data" in input) {
183
+ return input.getChildAt(0)!;
184
+ }
185
+
186
+ return input.children[0] as PointData;
187
+ }
188
+
189
+ export function getMultiLineStringChild(
190
+ input: MultiLineStringData,
191
+ ): LineStringData;
192
+ export function getMultiLineStringChild(
193
+ input: MultiLineStringVector,
194
+ ): LineStringVector;
195
+
196
+ export function getMultiLineStringChild(
197
+ input: MultiLineStringData | MultiLineStringVector,
198
+ ): LineStringData | LineStringVector {
199
+ if ("data" in input) {
200
+ return input.getChildAt(0)!;
201
+ }
202
+
203
+ return input.children[0] as LineStringData;
204
+ }
205
+
206
+ export function getMultiPolygonChild(input: MultiPolygonData): PolygonData;
207
+ export function getMultiPolygonChild(input: MultiPolygonVector): PolygonVector;
208
+
209
+ export function getMultiPolygonChild(
210
+ input: MultiPolygonData | MultiPolygonVector,
211
+ ): PolygonData | PolygonVector {
212
+ if ("data" in input) {
213
+ return input.getChildAt(0)!;
214
+ }
215
+
216
+ return input.children[0] as PolygonData;
217
+ }
218
+ */
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @note Conforms to the GeoArrow memory layout
3
+ * @see https://geoarrow.org/format.html#memory-layouts
4
+ * @note this is aligned with the geoarrow-js library (MIT license)
5
+ * @see https://github.com/geoarrow/geoarrow-js/
6
+ */
7
+ import type { Struct, Float, List, FixedSizeList, Utf8, Binary } from 'apache-arrow/type';
8
+ export type GeoArrowWKB = Binary;
9
+ export type GeoArrowWKT = Utf8;
10
+ /**
11
+ * @note arrow.Float (not arrow.Float64) ensures that recreating a data instance with arrow.makeData type checks using the input's data type.
12
+ */
13
+ /** Interleaved GeoArrow coordinates */
14
+ export type GeoArrowCoordInterleaved = FixedSizeList<Float>;
15
+ /** Separated GeoArrow coordinates */
16
+ export type GeoArrowCoordSeparated = Struct<{
17
+ x: Float;
18
+ y: Float;
19
+ }>;
20
+ export type GeoArrowCoord = GeoArrowCoordInterleaved;
21
+ /** Arrow type for GeoArrow geometry */
22
+ export type GeoArrowPoint = GeoArrowCoordInterleaved;
23
+ /** Arrow type for GeoArrow geometry */
24
+ export type GeoArrowLineString = List<GeoArrowCoordInterleaved>;
25
+ /** Arrow type for GeoArrow geometry */
26
+ export type GeoArrowPolygon = List<List<GeoArrowCoordInterleaved>>;
27
+ /** Arrow type for GeoArrow geometry */
28
+ export type GeoArrowMultiPoint = List<GeoArrowCoordInterleaved>;
29
+ /** Arrow type for GeoArrow geometry */
30
+ export type GeoArrowMultiLineString = List<List<GeoArrowCoordInterleaved>>;
31
+ /** Arrow type for GeoArrow geometry */
32
+ export type GeoArrowMultiPolygon = List<List<List<GeoArrowCoordInterleaved>>>;
33
+ /** Arrow type for GeoArrow geometry */
34
+ export type GeoArrowGeometry = GeoArrowPoint | GeoArrowLineString | GeoArrowPolygon | GeoArrowMultiPoint | GeoArrowMultiLineString | GeoArrowMultiPolygon;
35
+ /** Arrow type for GeoArrow geometry */
36
+ export type GeoArrowPointSeparated = GeoArrowCoordSeparated;
37
+ /** Arrow type for GeoArrow geometry */
38
+ export type GeoArrowLineStringSeparated = List<GeoArrowCoordSeparated>;
39
+ /** Arrow type for GeoArrow geometry */
40
+ export type GeoArrowPolygonSeparated = List<List<GeoArrowCoordSeparated>>;
41
+ /** Arrow type for GeoArrow geometry */
42
+ export type GeoArrowMultiPointSeparated = List<GeoArrowCoordSeparated>;
43
+ /** Arrow type for GeoArrow geometry */
44
+ export type GeoArrowMultiLineStringSeparated = List<List<GeoArrowCoordSeparated>>;
45
+ /** Arrow type for GeoArrow geometry */
46
+ export type GeoArrowMultiPolygonSeparated = List<List<List<GeoArrowCoordSeparated>>>;
47
+ /** Arrow type for GeoArrow geometry */
48
+ export type GeoArrowGeometrySeparated = GeoArrowPointSeparated | GeoArrowLineStringSeparated | GeoArrowPolygonSeparated | GeoArrowMultiPointSeparated | GeoArrowMultiLineStringSeparated | GeoArrowMultiPolygonSeparated;
49
+ //# sourceMappingURL=geoarrow-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geoarrow-types.d.ts","sourceRoot":"","sources":["../src/geoarrow-types.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAExF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AACjC,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC;AAC/B;;GAEG;AAEH,uCAAuC;AACvC,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;AAC5D,qCAAqC;AACrC,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC;IAAC,CAAC,EAAE,KAAK,CAAC;IAAC,CAAC,EAAE,KAAK,CAAA;CAAC,CAAC,CAAC;AAIlE,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAErD,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC;AACrD,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAChE,uCAAuC;AACvC,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;AACnE,uCAAuC;AACvC,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,wBAAwB,CAAC,CAAC;AAChE,uCAAuC;AACvC,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAC3E,uCAAuC;AACvC,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAE9E,uCAAuC;AACvC,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,kBAAkB,GAClB,eAAe,GACf,kBAAkB,GAClB,uBAAuB,GACvB,oBAAoB,CAAC;AAGzB,uCAAuC;AACvC,MAAM,MAAM,sBAAsB,GAAG,sBAAsB,CAAC;AAC5D,uCAAuC;AACvC,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,sBAAsB,CAAC,CAAC;AACvE,uCAAuC;AACvC,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC1E,uCAAuC;AACvC,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,sBAAsB,CAAC,CAAC;AACvE,uCAAuC;AACvC,MAAM,MAAM,gCAAgC,GAAG,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAClF,uCAAuC;AACvC,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;AAErF,uCAAuC;AACvC,MAAM,MAAM,yBAAyB,GACjC,sBAAsB,GACtB,2BAA2B,GAC3B,wBAAwB,GACxB,2BAA2B,GAC3B,gCAAgC,GAChC,6BAA6B,CAAC"}
@@ -0,0 +1,4 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Update bounds from geoarrow sample data
3
+ *
4
+ * @param flatCoords the flattend coordinates array from one chunk of geoarrow column
5
+ * @param nDim the number of dimensions of the coordinates
6
+ * @param bounds the bounds to be updated
7
+ * @param sampleSize how many samples to be used to update the bounds, default is 1000 per chunk
8
+ * @returns the updated bounds
9
+ */
10
+ export declare function updateBoundsFromGeoArrowSamples(flatCoords: Float64Array, nDim: number, bounds: [number, number, number, number], sampleSize?: number): [number, number, number, number];
11
+ //# sourceMappingURL=get-arrow-bounds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-arrow-bounds.d.ts","sourceRoot":"","sources":["../src/get-arrow-bounds.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACxC,UAAU,GAAE,MAAY,GACvB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAsBlC"}