@loaders.gl/parquet 4.0.0-beta.8 → 4.0.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.
- package/dist/index.cjs +7 -203
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/parsers/get-parquet-schema.js +1 -1
- package/dist/lib/parsers/get-parquet-schema.js.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-rows.d.ts.map +1 -1
- package/dist/lib/parsers/parse-parquet-to-rows.js +3 -2
- package/dist/lib/parsers/parse-parquet-to-rows.js.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +0 -8
- package/src/lib/parsers/get-parquet-schema.ts +1 -1
- package/src/lib/parsers/parse-parquet-to-rows.ts +4 -2
- package/dist/lib/geo/decode-geo-column.d.ts +0 -4
- package/dist/lib/geo/decode-geo-column.d.ts.map +0 -1
- package/dist/lib/geo/decode-geo-column.js +0 -47
- package/dist/lib/geo/decode-geo-column.js.map +0 -1
- package/dist/lib/geo/decode-geo-metadata.d.ts +0 -44
- package/dist/lib/geo/decode-geo-metadata.d.ts.map +0 -1
- package/dist/lib/geo/decode-geo-metadata.js +0 -89
- package/dist/lib/geo/decode-geo-metadata.js.map +0 -1
- package/dist/lib/geo/geoparquet-metadata-schema.d.ts +0 -79
- package/dist/lib/geo/geoparquet-metadata-schema.d.ts.map +0 -1
- package/dist/lib/geo/geoparquet-metadata-schema.js +0 -76
- package/dist/lib/geo/geoparquet-metadata-schema.js.map +0 -1
- package/dist/lib/geo/geoparquet-metadata-schema.json +0 -60
- package/src/lib/geo/decode-geo-column.ts +0 -55
- package/src/lib/geo/decode-geo-metadata.ts +0 -177
- package/src/lib/geo/geoparquet-metadata-schema.json +0 -60
- package/src/lib/geo/geoparquet-metadata-schema.ts +0 -70
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
export function parseJSONStringMetadata(schema, metadataKey) {
|
|
2
|
-
const stringifiedMetadata = schema.metadata[metadataKey];
|
|
3
|
-
if (!stringifiedMetadata) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
try {
|
|
7
|
-
const metadata = JSON.parse(stringifiedMetadata);
|
|
8
|
-
if (!metadata || typeof metadata !== 'object') {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return metadata;
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function unpackJSONStringMetadata(schema, metadataKey) {
|
|
17
|
-
const json = parseJSONStringMetadata(schema, metadataKey);
|
|
18
|
-
for (const [key, value] of Object.entries(json || {})) {
|
|
19
|
-
schema.metadata[`${metadataKey}.${key}`] = typeof value === 'string' ? value : JSON.stringify(value);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export function getGeoMetadata(schema) {
|
|
23
|
-
const geoMetadata = parseJSONStringMetadata(schema, 'geo');
|
|
24
|
-
return geoMetadata;
|
|
25
|
-
}
|
|
26
|
-
export function setGeoMetadata(schema, geoMetadata) {
|
|
27
|
-
const stringifiedGeoMetadata = JSON.stringify(geoMetadata);
|
|
28
|
-
schema.metadata.geo = stringifiedGeoMetadata;
|
|
29
|
-
}
|
|
30
|
-
export function unpackGeoMetadata(schema) {
|
|
31
|
-
const geoMetadata = getGeoMetadata(schema);
|
|
32
|
-
if (!geoMetadata) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
const {
|
|
36
|
-
version,
|
|
37
|
-
primary_column,
|
|
38
|
-
columns
|
|
39
|
-
} = geoMetadata;
|
|
40
|
-
if (version) {
|
|
41
|
-
schema.metadata['geo.version'] = version;
|
|
42
|
-
}
|
|
43
|
-
if (primary_column) {
|
|
44
|
-
schema.metadata['geo.primary_column'] = primary_column;
|
|
45
|
-
}
|
|
46
|
-
schema.metadata['geo.columns'] = Object.keys(columns || {}).join('');
|
|
47
|
-
for (const [columnName, columnMetadata] of Object.entries(columns || {})) {
|
|
48
|
-
const field = schema.fields.find(field => field.name === columnName);
|
|
49
|
-
if (field) {
|
|
50
|
-
if (field.name === primary_column) {
|
|
51
|
-
setFieldMetadata(field, 'geo.primary_field', 'true');
|
|
52
|
-
}
|
|
53
|
-
unpackGeoFieldMetadata(field, columnMetadata);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
function unpackGeoFieldMetadata(field, columnMetadata) {
|
|
58
|
-
for (const [key, value] of Object.entries(columnMetadata || {})) {
|
|
59
|
-
switch (key) {
|
|
60
|
-
case 'geometry_type':
|
|
61
|
-
setFieldMetadata(field, `geo.${key}`, value.join(','));
|
|
62
|
-
break;
|
|
63
|
-
case 'bbox':
|
|
64
|
-
setFieldMetadata(field, `geo.crs.${key}`, JSON.stringify(value));
|
|
65
|
-
break;
|
|
66
|
-
case 'crs':
|
|
67
|
-
for (const [crsKey, crsValue] of Object.entries(value || {})) {
|
|
68
|
-
switch (crsKey) {
|
|
69
|
-
case 'id':
|
|
70
|
-
const crsId = typeof crsValue === 'object' ? `${crsValue === null || crsValue === void 0 ? void 0 : crsValue.authority}:${crsValue === null || crsValue === void 0 ? void 0 : crsValue.code}` : JSON.stringify(crsValue);
|
|
71
|
-
setFieldMetadata(field, `geo.crs.${crsKey}`, crsId);
|
|
72
|
-
break;
|
|
73
|
-
default:
|
|
74
|
-
setFieldMetadata(field, `geo.crs.${crsKey}`, typeof crsValue === 'string' ? crsValue : JSON.stringify(crsValue));
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case 'edges':
|
|
80
|
-
default:
|
|
81
|
-
setFieldMetadata(field, `geo.${key}`, typeof value === 'string' ? value : JSON.stringify(value));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function setFieldMetadata(field, key, value) {
|
|
86
|
-
field.metadata = field.metadata || {};
|
|
87
|
-
field.metadata[key] = value;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=decode-geo-metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode-geo-metadata.js","names":["parseJSONStringMetadata","schema","metadataKey","stringifiedMetadata","metadata","JSON","parse","unpackJSONStringMetadata","json","key","value","Object","entries","stringify","getGeoMetadata","geoMetadata","setGeoMetadata","stringifiedGeoMetadata","geo","unpackGeoMetadata","version","primary_column","columns","keys","join","columnName","columnMetadata","field","fields","find","name","setFieldMetadata","unpackGeoFieldMetadata","crsKey","crsValue","crsId","authority","code"],"sources":["../../../src/lib/geo/decode-geo-metadata.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\nimport {Schema, Field} from '@loaders.gl/schema';\n\n/* eslint-disable camelcase */\n\ntype GeometryType =\n | 'Point'\n | 'LineString'\n | 'Polygon'\n | 'MultiPoint'\n | 'MultiLineString'\n | 'MultiPolygon'\n | 'GeometryCollection'\n | 'Point Z'\n | 'LineString Z'\n | 'Polygon Z'\n | 'MultiPoint Z'\n | 'MultiLineString Z'\n | 'MultiPolygon Z'\n | 'GeometryCollection Z';\n\n/**\n * A geoarrow / geoparquet geo metadata object\n * (stored in stringified form in the top level metadata 'geo' key)\n * @see https://github.com/opengeospatial/geoparquet/blob/main/format-specs/geoparquet.md\n * @see https://github.com/geoarrow/geoarrow/blob/main/metadata.md\n * */\nexport type GeoMetadata = {\n version?: string;\n primary_column?: string;\n columns: Record<string, GeoColumnMetadata>;\n [key: string]: unknown;\n};\n\n/** A geoarrow / geoparquet geo metadata for one geometry column */\nexport type GeoColumnMetadata = {\n encoding: 'wkb' | 'wkt';\n geometry_types: GeometryType[];\n crs?: object | null;\n orientation?: 'counterclockwise';\n bbox?: [number, number, number, number] | [number, number, number, number, number, number];\n edges?: 'planar' | 'spherical';\n epoch?: number;\n [key: string]: unknown;\n};\n\n/** Parse a key with stringified arrow metadata */\nexport function parseJSONStringMetadata(\n schema: Schema,\n metadataKey: string\n): Record<string, unknown> | null {\n const stringifiedMetadata = schema.metadata[metadataKey];\n if (!stringifiedMetadata) {\n return null;\n }\n\n try {\n const metadata = JSON.parse(stringifiedMetadata);\n if (!metadata || typeof metadata !== 'object') {\n return null;\n }\n return metadata;\n } catch {\n return null;\n }\n}\n\nexport function unpackJSONStringMetadata(schema: Schema, metadataKey: string): void {\n const json = parseJSONStringMetadata(schema, metadataKey);\n for (const [key, value] of Object.entries(json || {})) {\n schema.metadata[`${metadataKey}.${key}`] =\n typeof value === 'string' ? value : JSON.stringify(value);\n }\n}\n\n// GEO METADATA\n\n/**\n * Reads the GeoMetadata object from the metadata\n * @note geoarrow / parquet schema is stringified into a single key-value pair in the parquet metadata */\nexport function getGeoMetadata(schema: Schema): GeoMetadata | null {\n const geoMetadata = parseJSONStringMetadata(schema, 'geo') as GeoMetadata;\n return geoMetadata;\n}\n\n/**\n * Stores a geoarrow / geoparquet geo metadata object in the schema\n * @note geoarrow / geoparquet geo metadata is a single stringified JSON field\n */\nexport function setGeoMetadata(schema: Schema, geoMetadata: GeoMetadata): void {\n const stringifiedGeoMetadata = JSON.stringify(geoMetadata);\n schema.metadata.geo = stringifiedGeoMetadata;\n}\n\n/**\n * Unpacks geo metadata into separate metadata fields (parses the long JSON string)\n * @note geoarrow / parquet schema is stringified into a single key-value pair in the parquet metadata\n */\nexport function unpackGeoMetadata(schema: Schema): void {\n const geoMetadata = getGeoMetadata(schema);\n if (!geoMetadata) {\n return;\n }\n\n // Store Parquet Schema Level Metadata\n\n const {version, primary_column, columns} = geoMetadata;\n if (version) {\n schema.metadata['geo.version'] = version;\n }\n\n if (primary_column) {\n schema.metadata['geo.primary_column'] = primary_column;\n }\n\n // store column names as comma separated list\n schema.metadata['geo.columns'] = Object.keys(columns || {}).join('');\n\n for (const [columnName, columnMetadata] of Object.entries(columns || {})) {\n const field = schema.fields.find((field) => field.name === columnName);\n if (field) {\n if (field.name === primary_column) {\n setFieldMetadata(field, 'geo.primary_field', 'true');\n }\n unpackGeoFieldMetadata(field, columnMetadata);\n }\n }\n}\n\n// eslint-disable-next-line complexity\nfunction unpackGeoFieldMetadata(field: Field, columnMetadata): void {\n for (const [key, value] of Object.entries(columnMetadata || {})) {\n switch (key) {\n case 'geometry_type':\n setFieldMetadata(field, `geo.${key}`, (value as string[]).join(','));\n break;\n case 'bbox':\n setFieldMetadata(field, `geo.crs.${key}`, JSON.stringify(value));\n break;\n case 'crs':\n // @ts-ignore\n for (const [crsKey, crsValue] of Object.entries(value || {})) {\n switch (crsKey) {\n case 'id':\n const crsId =\n typeof crsValue === 'object'\n ? // @ts-ignore\n `${crsValue?.authority}:${crsValue?.code}`\n : JSON.stringify(crsValue);\n setFieldMetadata(field, `geo.crs.${crsKey}`, crsId);\n break;\n default:\n setFieldMetadata(\n field,\n `geo.crs.${crsKey}`,\n typeof crsValue === 'string' ? crsValue : JSON.stringify(crsValue)\n );\n break;\n }\n }\n break;\n case 'edges':\n default:\n setFieldMetadata(\n field,\n `geo.${key}`,\n typeof value === 'string' ? value : JSON.stringify(value)\n );\n }\n }\n}\n\nfunction setFieldMetadata(field: Field, key: string, value: string): void {\n field.metadata = field.metadata || {};\n field.metadata[key] = value;\n}\n"],"mappings":"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"}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Geoparquet JSON schema for geo metadata
|
|
3
|
-
* @see https://github.com/geoarrow/geoarrow/blob/main/metadata.md
|
|
4
|
-
* @see https://github.com/opengeospatial/geoparquet/blob/main/format-specs/geoparquet.md
|
|
5
|
-
*/
|
|
6
|
-
export declare const GEOPARQUET_METADATA_JSON_SCHEMA: {
|
|
7
|
-
$schema: string;
|
|
8
|
-
title: string;
|
|
9
|
-
description: string;
|
|
10
|
-
type: string;
|
|
11
|
-
required: string[];
|
|
12
|
-
properties: {
|
|
13
|
-
version: {
|
|
14
|
-
type: string;
|
|
15
|
-
const: string;
|
|
16
|
-
};
|
|
17
|
-
primary_column: {
|
|
18
|
-
type: string;
|
|
19
|
-
minLength: number;
|
|
20
|
-
};
|
|
21
|
-
columns: {
|
|
22
|
-
type: string;
|
|
23
|
-
minProperties: number;
|
|
24
|
-
patternProperties: {
|
|
25
|
-
'.+': {
|
|
26
|
-
type: string;
|
|
27
|
-
required: string[];
|
|
28
|
-
properties: {
|
|
29
|
-
encoding: {
|
|
30
|
-
type: string;
|
|
31
|
-
const: string;
|
|
32
|
-
};
|
|
33
|
-
geometry_types: {
|
|
34
|
-
type: string;
|
|
35
|
-
uniqueItems: boolean;
|
|
36
|
-
items: {
|
|
37
|
-
type: string;
|
|
38
|
-
pattern: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
crs: {
|
|
42
|
-
oneOf: ({
|
|
43
|
-
$ref: string;
|
|
44
|
-
type?: undefined;
|
|
45
|
-
} | {
|
|
46
|
-
type: string;
|
|
47
|
-
$ref?: undefined;
|
|
48
|
-
})[];
|
|
49
|
-
};
|
|
50
|
-
edges: {
|
|
51
|
-
type: string;
|
|
52
|
-
enum: string[];
|
|
53
|
-
};
|
|
54
|
-
orientation: {
|
|
55
|
-
type: string;
|
|
56
|
-
const: string;
|
|
57
|
-
};
|
|
58
|
-
bbox: {
|
|
59
|
-
type: string;
|
|
60
|
-
items: {
|
|
61
|
-
type: string;
|
|
62
|
-
};
|
|
63
|
-
oneOf: {
|
|
64
|
-
description: string;
|
|
65
|
-
minItems: number;
|
|
66
|
-
maxItems: number;
|
|
67
|
-
}[];
|
|
68
|
-
};
|
|
69
|
-
epoch: {
|
|
70
|
-
type: string;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
additionalProperties: boolean;
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
//# sourceMappingURL=geoparquet-metadata-schema.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geoparquet-metadata-schema.d.ts","sourceRoot":"","sources":["../../../src/lib/geo/geoparquet-metadata-schema.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2D3C,CAAC"}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export const GEOPARQUET_METADATA_JSON_SCHEMA = {
|
|
2
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
3
|
-
title: 'GeoParquet',
|
|
4
|
-
description: 'Parquet metadata included in the geo field.',
|
|
5
|
-
type: 'object',
|
|
6
|
-
required: ['version', 'primary_column', 'columns'],
|
|
7
|
-
properties: {
|
|
8
|
-
version: {
|
|
9
|
-
type: 'string',
|
|
10
|
-
const: '1.0.0-beta.1'
|
|
11
|
-
},
|
|
12
|
-
primary_column: {
|
|
13
|
-
type: 'string',
|
|
14
|
-
minLength: 1
|
|
15
|
-
},
|
|
16
|
-
columns: {
|
|
17
|
-
type: 'object',
|
|
18
|
-
minProperties: 1,
|
|
19
|
-
patternProperties: {
|
|
20
|
-
'.+': {
|
|
21
|
-
type: 'object',
|
|
22
|
-
required: ['encoding', 'geometry_types'],
|
|
23
|
-
properties: {
|
|
24
|
-
encoding: {
|
|
25
|
-
type: 'string',
|
|
26
|
-
const: 'WKB'
|
|
27
|
-
},
|
|
28
|
-
geometry_types: {
|
|
29
|
-
type: 'array',
|
|
30
|
-
uniqueItems: true,
|
|
31
|
-
items: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
pattern: '^(GeometryCollection|(Multi)?(Point|LineString|Polygon))( Z)?$'
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
crs: {
|
|
37
|
-
oneOf: [{
|
|
38
|
-
$ref: 'https://proj.org/schemas/v0.5/projjson.schema.json'
|
|
39
|
-
}, {
|
|
40
|
-
type: 'null'
|
|
41
|
-
}]
|
|
42
|
-
},
|
|
43
|
-
edges: {
|
|
44
|
-
type: 'string',
|
|
45
|
-
enum: ['planar', 'spherical']
|
|
46
|
-
},
|
|
47
|
-
orientation: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
const: 'counterclockwise'
|
|
50
|
-
},
|
|
51
|
-
bbox: {
|
|
52
|
-
type: 'array',
|
|
53
|
-
items: {
|
|
54
|
-
type: 'number'
|
|
55
|
-
},
|
|
56
|
-
oneOf: [{
|
|
57
|
-
description: '2D bbox consisting of (xmin, ymin, xmax, ymax)',
|
|
58
|
-
minItems: 4,
|
|
59
|
-
maxItems: 4
|
|
60
|
-
}, {
|
|
61
|
-
description: '3D bbox consisting of (xmin, ymin, zmin, xmax, ymax, zmax)',
|
|
62
|
-
minItems: 6,
|
|
63
|
-
maxItems: 6
|
|
64
|
-
}]
|
|
65
|
-
},
|
|
66
|
-
epoch: {
|
|
67
|
-
type: 'number'
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
additionalProperties: false
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
//# sourceMappingURL=geoparquet-metadata-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geoparquet-metadata-schema.js","names":["GEOPARQUET_METADATA_JSON_SCHEMA","$schema","title","description","type","required","properties","version","const","primary_column","minLength","columns","minProperties","patternProperties","encoding","geometry_types","uniqueItems","items","pattern","crs","oneOf","$ref","edges","enum","orientation","bbox","minItems","maxItems","epoch","additionalProperties"],"sources":["../../../src/lib/geo/geoparquet-metadata-schema.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/* eslint-disable camelcase */\n\n/**\n * Geoparquet JSON schema for geo metadata\n * @see https://github.com/geoarrow/geoarrow/blob/main/metadata.md\n * @see https://github.com/opengeospatial/geoparquet/blob/main/format-specs/geoparquet.md\n */\nexport const GEOPARQUET_METADATA_JSON_SCHEMA = {\n $schema: 'http://json-schema.org/draft-07/schema#',\n title: 'GeoParquet',\n description: 'Parquet metadata included in the geo field.',\n type: 'object',\n required: ['version', 'primary_column', 'columns'],\n properties: {\n version: {type: 'string', const: '1.0.0-beta.1'},\n primary_column: {type: 'string', minLength: 1},\n columns: {\n type: 'object',\n minProperties: 1,\n patternProperties: {\n '.+': {\n type: 'object',\n required: ['encoding', 'geometry_types'],\n properties: {\n encoding: {type: 'string', const: 'WKB'},\n geometry_types: {\n type: 'array',\n uniqueItems: true,\n items: {\n type: 'string',\n pattern: '^(GeometryCollection|(Multi)?(Point|LineString|Polygon))( Z)?$'\n }\n },\n crs: {\n oneOf: [\n {\n $ref: 'https://proj.org/schemas/v0.5/projjson.schema.json'\n },\n {type: 'null'}\n ]\n },\n edges: {type: 'string', enum: ['planar', 'spherical']},\n orientation: {type: 'string', const: 'counterclockwise'},\n bbox: {\n type: 'array',\n items: {type: 'number'},\n oneOf: [\n {\n description: '2D bbox consisting of (xmin, ymin, xmax, ymax)',\n minItems: 4,\n maxItems: 4\n },\n {\n description: '3D bbox consisting of (xmin, ymin, zmin, xmax, ymax, zmax)',\n minItems: 6,\n maxItems: 6\n }\n ]\n },\n epoch: {type: 'number'}\n }\n }\n },\n additionalProperties: false\n }\n }\n};\n"],"mappings":"AAUA,OAAO,MAAMA,+BAA+B,GAAG;EAC7CC,OAAO,EAAE,yCAAyC;EAClDC,KAAK,EAAE,YAAY;EACnBC,WAAW,EAAE,6CAA6C;EAC1DC,IAAI,EAAE,QAAQ;EACdC,QAAQ,EAAE,CAAC,SAAS,EAAE,gBAAgB,EAAE,SAAS,CAAC;EAClDC,UAAU,EAAE;IACVC,OAAO,EAAE;MAACH,IAAI,EAAE,QAAQ;MAAEI,KAAK,EAAE;IAAc,CAAC;IAChDC,cAAc,EAAE;MAACL,IAAI,EAAE,QAAQ;MAAEM,SAAS,EAAE;IAAC,CAAC;IAC9CC,OAAO,EAAE;MACPP,IAAI,EAAE,QAAQ;MACdQ,aAAa,EAAE,CAAC;MAChBC,iBAAiB,EAAE;QACjB,IAAI,EAAE;UACJT,IAAI,EAAE,QAAQ;UACdC,QAAQ,EAAE,CAAC,UAAU,EAAE,gBAAgB,CAAC;UACxCC,UAAU,EAAE;YACVQ,QAAQ,EAAE;cAACV,IAAI,EAAE,QAAQ;cAAEI,KAAK,EAAE;YAAK,CAAC;YACxCO,cAAc,EAAE;cACdX,IAAI,EAAE,OAAO;cACbY,WAAW,EAAE,IAAI;cACjBC,KAAK,EAAE;gBACLb,IAAI,EAAE,QAAQ;gBACdc,OAAO,EAAE;cACX;YACF,CAAC;YACDC,GAAG,EAAE;cACHC,KAAK,EAAE,CACL;gBACEC,IAAI,EAAE;cACR,CAAC,EACD;gBAACjB,IAAI,EAAE;cAAM,CAAC;YAElB,CAAC;YACDkB,KAAK,EAAE;cAAClB,IAAI,EAAE,QAAQ;cAAEmB,IAAI,EAAE,CAAC,QAAQ,EAAE,WAAW;YAAC,CAAC;YACtDC,WAAW,EAAE;cAACpB,IAAI,EAAE,QAAQ;cAAEI,KAAK,EAAE;YAAkB,CAAC;YACxDiB,IAAI,EAAE;cACJrB,IAAI,EAAE,OAAO;cACba,KAAK,EAAE;gBAACb,IAAI,EAAE;cAAQ,CAAC;cACvBgB,KAAK,EAAE,CACL;gBACEjB,WAAW,EAAE,gDAAgD;gBAC7DuB,QAAQ,EAAE,CAAC;gBACXC,QAAQ,EAAE;cACZ,CAAC,EACD;gBACExB,WAAW,EAAE,4DAA4D;gBACzEuB,QAAQ,EAAE,CAAC;gBACXC,QAAQ,EAAE;cACZ,CAAC;YAEL,CAAC;YACDC,KAAK,EAAE;cAACxB,IAAI,EAAE;YAAQ;UACxB;QACF;MACF,CAAC;MACDyB,oBAAoB,EAAE;IACxB;EACF;AACF,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "GeoParquet",
|
|
4
|
-
"description": "Parquet metadata included in the geo field.",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"required": ["version", "primary_column", "columns"],
|
|
7
|
-
"properties": {
|
|
8
|
-
"version": {"type": "string", "const": "1.0.0-beta.1"},
|
|
9
|
-
"primary_column": {"type": "string", "minLength": 1},
|
|
10
|
-
"columns": {
|
|
11
|
-
"type": "object",
|
|
12
|
-
"minProperties": 1,
|
|
13
|
-
"patternProperties": {
|
|
14
|
-
".+": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"required": ["encoding", "geometry_types"],
|
|
17
|
-
"properties": {
|
|
18
|
-
"encoding": {"type": "string", "const": "WKB"},
|
|
19
|
-
"geometry_types": {
|
|
20
|
-
"type": "array",
|
|
21
|
-
"uniqueItems": true,
|
|
22
|
-
"items": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"pattern": "^(GeometryCollection|(Multi)?(Point|LineString|Polygon))( Z)?$"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"crs": {
|
|
28
|
-
"oneOf": [
|
|
29
|
-
{
|
|
30
|
-
"$ref": "https://proj.org/schemas/v0.5/projjson.schema.json"
|
|
31
|
-
},
|
|
32
|
-
{"type": "null"}
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
"edges": {"type": "string", "enum": ["planar", "spherical"]},
|
|
36
|
-
"orientation": {"type": "string", "const": "counterclockwise"},
|
|
37
|
-
"bbox": {
|
|
38
|
-
"type": "array",
|
|
39
|
-
"items": {"type": "number"},
|
|
40
|
-
"oneOf": [
|
|
41
|
-
{
|
|
42
|
-
"description": "2D bbox consisting of (xmin, ymin, xmax, ymax)",
|
|
43
|
-
"minItems": 4,
|
|
44
|
-
"maxItems": 4
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"description": "3D bbox consisting of (xmin, ymin, zmin, xmax, ymax, zmax)",
|
|
48
|
-
"minItems": 6,
|
|
49
|
-
"maxItems": 6
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
"epoch": {"type": "number"}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"additionalProperties": false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// loaders.gl, MIT license
|
|
2
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
-
|
|
4
|
-
import type {ArrayRowTable, GeoJSONTable, ObjectRowTable, Schema} from '@loaders.gl/schema';
|
|
5
|
-
import type {Feature, Geometry} from '@loaders.gl/schema';
|
|
6
|
-
import {getTableLength, getTableRowAsObject} from '@loaders.gl/schema';
|
|
7
|
-
// import {binaryToGeometry} from '@loaders.gl/gis';
|
|
8
|
-
import {WKBLoader, WKTLoader} from '@loaders.gl/wkt';
|
|
9
|
-
|
|
10
|
-
import {GeoColumnMetadata, getGeoMetadata} from './decode-geo-metadata';
|
|
11
|
-
|
|
12
|
-
/** TODO - move to loaders.gl/gis? */
|
|
13
|
-
export function convertWKBTableToGeoJSON(
|
|
14
|
-
table: ArrayRowTable | ObjectRowTable,
|
|
15
|
-
schema: Schema
|
|
16
|
-
): GeoJSONTable {
|
|
17
|
-
const geoMetadata = getGeoMetadata(schema);
|
|
18
|
-
const primaryColumn = geoMetadata?.primary_column;
|
|
19
|
-
if (!primaryColumn) {
|
|
20
|
-
throw new Error('no geometry column');
|
|
21
|
-
}
|
|
22
|
-
const columnMetadata = geoMetadata.columns[primaryColumn];
|
|
23
|
-
|
|
24
|
-
const features: Feature[] = [];
|
|
25
|
-
|
|
26
|
-
const length = getTableLength(table);
|
|
27
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
28
|
-
const row = getTableRowAsObject(table, rowIndex);
|
|
29
|
-
const geometry = parseGeometry(row[primaryColumn], columnMetadata);
|
|
30
|
-
delete row[primaryColumn];
|
|
31
|
-
const feature: Feature = {type: 'Feature', geometry: geometry!, properties: row};
|
|
32
|
-
features.push(feature);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return {shape: 'geojson-table', schema, type: 'FeatureCollection', features};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parseGeometry(geometry: unknown, columnMetadata: GeoColumnMetadata): Geometry | null {
|
|
39
|
-
switch (columnMetadata.encoding) {
|
|
40
|
-
case 'wkt':
|
|
41
|
-
return WKTLoader.parseTextSync?.(geometry as string) || null;
|
|
42
|
-
case 'wkb':
|
|
43
|
-
default:
|
|
44
|
-
const arrayBuffer = ArrayBuffer.isView(geometry)
|
|
45
|
-
? geometry.buffer.slice(geometry.byteOffset, geometry.byteOffset + geometry.byteLength)
|
|
46
|
-
: (geometry as ArrayBuffer);
|
|
47
|
-
const geojson = WKBLoader.parseSync?.(arrayBuffer, {
|
|
48
|
-
wkb: {shape: 'geometry'}
|
|
49
|
-
}) as unknown as Geometry;
|
|
50
|
-
return geojson; // binaryGeometry ? binaryToGeometry(binaryGeometry) : null;
|
|
51
|
-
// const binaryGeometry = WKBLoader.parseSync?.(geometry);
|
|
52
|
-
// ts-ignore
|
|
53
|
-
// return binaryGeometry ? binaryToGeometry(binaryGeometry) : null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
// loaders.gl, MIT license
|
|
2
|
-
// Copyright (c) vis.gl contributors
|
|
3
|
-
import {Schema, Field} from '@loaders.gl/schema';
|
|
4
|
-
|
|
5
|
-
/* eslint-disable camelcase */
|
|
6
|
-
|
|
7
|
-
type GeometryType =
|
|
8
|
-
| 'Point'
|
|
9
|
-
| 'LineString'
|
|
10
|
-
| 'Polygon'
|
|
11
|
-
| 'MultiPoint'
|
|
12
|
-
| 'MultiLineString'
|
|
13
|
-
| 'MultiPolygon'
|
|
14
|
-
| 'GeometryCollection'
|
|
15
|
-
| 'Point Z'
|
|
16
|
-
| 'LineString Z'
|
|
17
|
-
| 'Polygon Z'
|
|
18
|
-
| 'MultiPoint Z'
|
|
19
|
-
| 'MultiLineString Z'
|
|
20
|
-
| 'MultiPolygon Z'
|
|
21
|
-
| 'GeometryCollection Z';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* A geoarrow / geoparquet geo metadata object
|
|
25
|
-
* (stored in stringified form in the top level metadata 'geo' key)
|
|
26
|
-
* @see https://github.com/opengeospatial/geoparquet/blob/main/format-specs/geoparquet.md
|
|
27
|
-
* @see https://github.com/geoarrow/geoarrow/blob/main/metadata.md
|
|
28
|
-
* */
|
|
29
|
-
export type GeoMetadata = {
|
|
30
|
-
version?: string;
|
|
31
|
-
primary_column?: string;
|
|
32
|
-
columns: Record<string, GeoColumnMetadata>;
|
|
33
|
-
[key: string]: unknown;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** A geoarrow / geoparquet geo metadata for one geometry column */
|
|
37
|
-
export type GeoColumnMetadata = {
|
|
38
|
-
encoding: 'wkb' | 'wkt';
|
|
39
|
-
geometry_types: GeometryType[];
|
|
40
|
-
crs?: object | null;
|
|
41
|
-
orientation?: 'counterclockwise';
|
|
42
|
-
bbox?: [number, number, number, number] | [number, number, number, number, number, number];
|
|
43
|
-
edges?: 'planar' | 'spherical';
|
|
44
|
-
epoch?: number;
|
|
45
|
-
[key: string]: unknown;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** Parse a key with stringified arrow metadata */
|
|
49
|
-
export function parseJSONStringMetadata(
|
|
50
|
-
schema: Schema,
|
|
51
|
-
metadataKey: string
|
|
52
|
-
): Record<string, unknown> | null {
|
|
53
|
-
const stringifiedMetadata = schema.metadata[metadataKey];
|
|
54
|
-
if (!stringifiedMetadata) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const metadata = JSON.parse(stringifiedMetadata);
|
|
60
|
-
if (!metadata || typeof metadata !== 'object') {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
return metadata;
|
|
64
|
-
} catch {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function unpackJSONStringMetadata(schema: Schema, metadataKey: string): void {
|
|
70
|
-
const json = parseJSONStringMetadata(schema, metadataKey);
|
|
71
|
-
for (const [key, value] of Object.entries(json || {})) {
|
|
72
|
-
schema.metadata[`${metadataKey}.${key}`] =
|
|
73
|
-
typeof value === 'string' ? value : JSON.stringify(value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// GEO METADATA
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Reads the GeoMetadata object from the metadata
|
|
81
|
-
* @note geoarrow / parquet schema is stringified into a single key-value pair in the parquet metadata */
|
|
82
|
-
export function getGeoMetadata(schema: Schema): GeoMetadata | null {
|
|
83
|
-
const geoMetadata = parseJSONStringMetadata(schema, 'geo') as GeoMetadata;
|
|
84
|
-
return geoMetadata;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Stores a geoarrow / geoparquet geo metadata object in the schema
|
|
89
|
-
* @note geoarrow / geoparquet geo metadata is a single stringified JSON field
|
|
90
|
-
*/
|
|
91
|
-
export function setGeoMetadata(schema: Schema, geoMetadata: GeoMetadata): void {
|
|
92
|
-
const stringifiedGeoMetadata = JSON.stringify(geoMetadata);
|
|
93
|
-
schema.metadata.geo = stringifiedGeoMetadata;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Unpacks geo metadata into separate metadata fields (parses the long JSON string)
|
|
98
|
-
* @note geoarrow / parquet schema is stringified into a single key-value pair in the parquet metadata
|
|
99
|
-
*/
|
|
100
|
-
export function unpackGeoMetadata(schema: Schema): void {
|
|
101
|
-
const geoMetadata = getGeoMetadata(schema);
|
|
102
|
-
if (!geoMetadata) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// Store Parquet Schema Level Metadata
|
|
107
|
-
|
|
108
|
-
const {version, primary_column, columns} = geoMetadata;
|
|
109
|
-
if (version) {
|
|
110
|
-
schema.metadata['geo.version'] = version;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (primary_column) {
|
|
114
|
-
schema.metadata['geo.primary_column'] = primary_column;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// store column names as comma separated list
|
|
118
|
-
schema.metadata['geo.columns'] = Object.keys(columns || {}).join('');
|
|
119
|
-
|
|
120
|
-
for (const [columnName, columnMetadata] of Object.entries(columns || {})) {
|
|
121
|
-
const field = schema.fields.find((field) => field.name === columnName);
|
|
122
|
-
if (field) {
|
|
123
|
-
if (field.name === primary_column) {
|
|
124
|
-
setFieldMetadata(field, 'geo.primary_field', 'true');
|
|
125
|
-
}
|
|
126
|
-
unpackGeoFieldMetadata(field, columnMetadata);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// eslint-disable-next-line complexity
|
|
132
|
-
function unpackGeoFieldMetadata(field: Field, columnMetadata): void {
|
|
133
|
-
for (const [key, value] of Object.entries(columnMetadata || {})) {
|
|
134
|
-
switch (key) {
|
|
135
|
-
case 'geometry_type':
|
|
136
|
-
setFieldMetadata(field, `geo.${key}`, (value as string[]).join(','));
|
|
137
|
-
break;
|
|
138
|
-
case 'bbox':
|
|
139
|
-
setFieldMetadata(field, `geo.crs.${key}`, JSON.stringify(value));
|
|
140
|
-
break;
|
|
141
|
-
case 'crs':
|
|
142
|
-
// @ts-ignore
|
|
143
|
-
for (const [crsKey, crsValue] of Object.entries(value || {})) {
|
|
144
|
-
switch (crsKey) {
|
|
145
|
-
case 'id':
|
|
146
|
-
const crsId =
|
|
147
|
-
typeof crsValue === 'object'
|
|
148
|
-
? // @ts-ignore
|
|
149
|
-
`${crsValue?.authority}:${crsValue?.code}`
|
|
150
|
-
: JSON.stringify(crsValue);
|
|
151
|
-
setFieldMetadata(field, `geo.crs.${crsKey}`, crsId);
|
|
152
|
-
break;
|
|
153
|
-
default:
|
|
154
|
-
setFieldMetadata(
|
|
155
|
-
field,
|
|
156
|
-
`geo.crs.${crsKey}`,
|
|
157
|
-
typeof crsValue === 'string' ? crsValue : JSON.stringify(crsValue)
|
|
158
|
-
);
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
break;
|
|
163
|
-
case 'edges':
|
|
164
|
-
default:
|
|
165
|
-
setFieldMetadata(
|
|
166
|
-
field,
|
|
167
|
-
`geo.${key}`,
|
|
168
|
-
typeof value === 'string' ? value : JSON.stringify(value)
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function setFieldMetadata(field: Field, key: string, value: string): void {
|
|
175
|
-
field.metadata = field.metadata || {};
|
|
176
|
-
field.metadata[key] = value;
|
|
177
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "GeoParquet",
|
|
4
|
-
"description": "Parquet metadata included in the geo field.",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"required": ["version", "primary_column", "columns"],
|
|
7
|
-
"properties": {
|
|
8
|
-
"version": {"type": "string", "const": "1.0.0-beta.1"},
|
|
9
|
-
"primary_column": {"type": "string", "minLength": 1},
|
|
10
|
-
"columns": {
|
|
11
|
-
"type": "object",
|
|
12
|
-
"minProperties": 1,
|
|
13
|
-
"patternProperties": {
|
|
14
|
-
".+": {
|
|
15
|
-
"type": "object",
|
|
16
|
-
"required": ["encoding", "geometry_types"],
|
|
17
|
-
"properties": {
|
|
18
|
-
"encoding": {"type": "string", "const": "WKB"},
|
|
19
|
-
"geometry_types": {
|
|
20
|
-
"type": "array",
|
|
21
|
-
"uniqueItems": true,
|
|
22
|
-
"items": {
|
|
23
|
-
"type": "string",
|
|
24
|
-
"pattern": "^(GeometryCollection|(Multi)?(Point|LineString|Polygon))( Z)?$"
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
"crs": {
|
|
28
|
-
"oneOf": [
|
|
29
|
-
{
|
|
30
|
-
"$ref": "https://proj.org/schemas/v0.5/projjson.schema.json"
|
|
31
|
-
},
|
|
32
|
-
{"type": "null"}
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
"edges": {"type": "string", "enum": ["planar", "spherical"]},
|
|
36
|
-
"orientation": {"type": "string", "const": "counterclockwise"},
|
|
37
|
-
"bbox": {
|
|
38
|
-
"type": "array",
|
|
39
|
-
"items": {"type": "number"},
|
|
40
|
-
"oneOf": [
|
|
41
|
-
{
|
|
42
|
-
"description": "2D bbox consisting of (xmin, ymin, xmax, ymax)",
|
|
43
|
-
"minItems": 4,
|
|
44
|
-
"maxItems": 4
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"description": "3D bbox consisting of (xmin, ymin, zmin, xmax, ymax, zmax)",
|
|
48
|
-
"minItems": 6,
|
|
49
|
-
"maxItems": 6
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
"epoch": {"type": "number"}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"additionalProperties": false
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|