@loaders.gl/gis 4.0.0-alpha.8 → 4.0.0-beta.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/es5/index.js +0 -6
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/binary-to-geojson.js +23 -57
- package/dist/es5/lib/binary-to-geojson.js.map +1 -1
- package/dist/es5/lib/flat-geojson-to-binary-types.js.map +1 -1
- package/dist/es5/lib/flat-geojson-to-binary.js +19 -8
- package/dist/es5/lib/flat-geojson-to-binary.js.map +1 -1
- package/dist/es5/lib/geojson-to-binary.js +4 -2
- package/dist/es5/lib/geojson-to-binary.js.map +1 -1
- package/dist/es5/lib/transform.js +1 -1
- package/dist/es5/lib/transform.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/binary-to-geojson.js +0 -25
- package/dist/esm/lib/binary-to-geojson.js.map +1 -1
- package/dist/esm/lib/flat-geojson-to-binary-types.js.map +1 -1
- package/dist/esm/lib/flat-geojson-to-binary.js +18 -8
- package/dist/esm/lib/flat-geojson-to-binary.js.map +1 -1
- package/dist/esm/lib/geojson-to-binary.js +4 -2
- package/dist/esm/lib/geojson-to-binary.js.map +1 -1
- package/dist/esm/lib/transform.js +1 -1
- package/dist/esm/lib/transform.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/binary-to-geojson.d.ts +2 -4
- package/dist/lib/binary-to-geojson.d.ts.map +1 -1
- package/dist/lib/flat-geojson-to-binary-types.d.ts +1 -1
- package/dist/lib/flat-geojson-to-binary-types.d.ts.map +1 -1
- package/dist/lib/flat-geojson-to-binary.d.ts +3 -2
- package/dist/lib/flat-geojson-to-binary.d.ts.map +1 -1
- package/dist/lib/geojson-to-binary.d.ts +3 -2
- package/dist/lib/geojson-to-binary.d.ts.map +1 -1
- package/dist/lib/transform.d.ts +3 -3
- package/dist/lib/transform.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +1 -1
- package/src/lib/binary-to-geojson.ts +25 -43
- package/src/lib/flat-geojson-to-binary-types.ts +1 -1
- package/src/lib/flat-geojson-to-binary.ts +24 -9
- package/src/lib/geojson-to-binary.ts +6 -4
- package/src/lib/transform.ts +10 -10
- package/dist/bundle.js +0 -5
- package/dist/index.js +0 -18
- package/dist/lib/binary-to-geojson.js +0 -233
- package/dist/lib/extract-geometry-info.js +0 -96
- package/dist/lib/flat-geojson-to-binary-types.js +0 -2
- package/dist/lib/flat-geojson-to-binary.js +0 -376
- package/dist/lib/geojson-to-binary.js +0 -24
- package/dist/lib/geojson-to-flat-geojson.js +0 -128
- package/dist/lib/transform.js +0 -59
|
@@ -5,17 +5,6 @@ export function binaryToGeojson(data, options) {
|
|
|
5
5
|
}
|
|
6
6
|
return parseFeatures(data, options === null || options === void 0 ? void 0 : options.type);
|
|
7
7
|
}
|
|
8
|
-
export function binaryToGeoJson(data, type) {
|
|
9
|
-
let format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'feature';
|
|
10
|
-
switch (format) {
|
|
11
|
-
case 'feature':
|
|
12
|
-
return parseFeatures(data, type);
|
|
13
|
-
case 'geometry':
|
|
14
|
-
return binaryToGeometry(data);
|
|
15
|
-
default:
|
|
16
|
-
throw new Error(format);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
8
|
function getSingleFeature(data, globalFeatureId) {
|
|
20
9
|
const dataArray = normalizeInput(data);
|
|
21
10
|
for (const data of dataArray) {
|
|
@@ -56,11 +45,6 @@ export function binaryToGeometry(data, startIndex, endIndex) {
|
|
|
56
45
|
}
|
|
57
46
|
}
|
|
58
47
|
function normalizeInput(data, type) {
|
|
59
|
-
const isHeterogeneousType = Boolean(data.points || data.lines || data.polygons);
|
|
60
|
-
if (!isHeterogeneousType) {
|
|
61
|
-
data.type = type || parseType(data);
|
|
62
|
-
return [data];
|
|
63
|
-
}
|
|
64
48
|
const features = [];
|
|
65
49
|
if (data.points) {
|
|
66
50
|
data.points.type = 'Point';
|
|
@@ -211,13 +195,4 @@ function ringToGeoJson(positions, startIndex, endIndex) {
|
|
|
211
195
|
}
|
|
212
196
|
return ringCoordinates;
|
|
213
197
|
}
|
|
214
|
-
function parseType(data) {
|
|
215
|
-
if (data.pathIndices) {
|
|
216
|
-
return 'LineString';
|
|
217
|
-
}
|
|
218
|
-
if (data.polygonIndices) {
|
|
219
|
-
return 'Polygon';
|
|
220
|
-
}
|
|
221
|
-
return 'Point';
|
|
222
|
-
}
|
|
223
198
|
//# sourceMappingURL=binary-to-geojson.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-to-geojson.js","names":["binaryToGeojson","data","options","globalFeatureId","undefined","getSingleFeature","parseFeatures","type","binaryToGeoJson","format","arguments","length","binaryToGeometry","Error","dataArray","normalizeInput","lastIndex","lastValue","featureIds","value","i","currValue","globalFeatureIds","parseFeature","concat","parseFeatureCollection","startIndex","endIndex","pointToGeoJson","lineStringToGeoJson","polygonToGeoJson","unexpectedInput","isHeterogeneousType","Boolean","points","lines","polygons","parseType","features","push","geometry","properties","parseProperties","fields","parseFields","Object","assign","key","numericProps","Infinity","positions","polygonIndices","filter","x","primitivePolygonIndices","multi","coordinates","startRingIndex","endRingIndex","ringCoordinates","ringToGeoJson","startPolygonIndex","endPolygonIndex","polygonCoordinates","pathIndices","size","j","coord","Array","k","Number"],"sources":["../../../src/lib/binary-to-geojson.ts"],"sourcesContent":["import type {\n BinaryGeometry,\n BinaryFeatures,\n BinaryGeometryType,\n BinaryPointFeatures,\n BinaryLineFeatures,\n BinaryPolygonFeatures,\n BinaryAttribute\n} from '@loaders.gl/schema';\nimport type {Feature, Geometry, Position, GeoJsonProperties} from '@loaders.gl/schema';\nimport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon\n} from '@loaders.gl/schema';\n\n// Note:L We do not handle GeometryCollection, define a limited Geometry type that always has coordinates.\n// type FeatureGeometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;\n\ntype BinaryToGeoJsonOptions = {\n type?: BinaryGeometryType;\n globalFeatureId?: number;\n};\n\n/**\n * Convert binary geometry representation to GeoJSON\n * @param data geometry data in binary representation\n * @param options\n * @param options.type Input data type: Point, LineString, or Polygon\n * @param options.featureId Global feature id. If specified, only a single feature is extracted\n * @return GeoJSON objects\n */\nexport function binaryToGeojson(\n data: BinaryFeatures,\n options?: BinaryToGeoJsonOptions\n): Feature[] | Feature {\n const globalFeatureId = options?.globalFeatureId;\n if (globalFeatureId !== undefined) {\n return getSingleFeature(data, globalFeatureId);\n }\n return parseFeatures(data, options?.type);\n}\n\n/** @deprecated use `binaryToGeojson` or `binaryToGeometry` instead */\nexport function binaryToGeoJson(\n data: BinaryGeometry | BinaryFeatures,\n type?: BinaryGeometryType,\n format: 'feature' | 'geometry' = 'feature'\n): Geometry | Feature[] {\n switch (format) {\n case 'feature':\n return parseFeatures(data as BinaryFeatures, type);\n case 'geometry':\n return binaryToGeometry(data as BinaryGeometry);\n default:\n throw new Error(format);\n }\n}\n\n/**\n * Return a single feature from a binary geometry representation as GeoJSON\n * @param data geometry data in binary representation\n * @return GeoJSON feature\n */\nfunction getSingleFeature(data: BinaryFeatures, globalFeatureId: number): Feature {\n const dataArray = normalizeInput(data);\n for (const data of dataArray) {\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Scan through data until we find matching feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, i);\n }\n lastIndex = i;\n lastValue = currValue;\n }\n\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, data.featureIds.value.length);\n }\n }\n\n throw new Error(`featureId:${globalFeatureId} not found`);\n}\n\nfunction parseFeatures(data: BinaryFeatures, type?: BinaryGeometryType): Feature[] {\n const dataArray = normalizeInput(data, type);\n return parseFeatureCollection(dataArray);\n}\n\n/** Parse input binary data and return a valid GeoJSON geometry object */\nexport function binaryToGeometry(\n data: BinaryGeometry,\n startIndex?: number,\n endIndex?: number\n): Geometry {\n switch (data.type) {\n case 'Point':\n return pointToGeoJson(data, startIndex, endIndex);\n case 'LineString':\n return lineStringToGeoJson(data, startIndex, endIndex);\n case 'Polygon':\n return polygonToGeoJson(data, startIndex, endIndex);\n default:\n const unexpectedInput: never = data;\n throw new Error(`Unsupported geometry type: ${(unexpectedInput as any)?.type}`);\n }\n}\n\ntype BinaryFeature = BinaryPointFeatures | BinaryLineFeatures | BinaryPolygonFeatures;\ntype BinaryFeaturesArray = BinaryFeature[];\n\n// Normalize features\n// Return an array of data objects, each of which have a type key\nfunction normalizeInput(data: BinaryFeatures, type?: BinaryGeometryType): BinaryFeaturesArray {\n const isHeterogeneousType = Boolean(data.points || data.lines || data.polygons);\n\n if (!isHeterogeneousType) {\n // @ts-expect-error This is a legacy check which allowed `data` to be an instance of the values\n // here. Aka the new data.points, data.lines, or data.polygons.\n data.type = type || parseType(data);\n return [data] as BinaryFeaturesArray;\n }\n\n const features: BinaryFeaturesArray = [];\n if (data.points) {\n data.points.type = 'Point';\n features.push(data.points);\n }\n if (data.lines) {\n data.lines.type = 'LineString';\n features.push(data.lines);\n }\n if (data.polygons) {\n data.polygons.type = 'Polygon';\n features.push(data.polygons);\n }\n\n return features;\n}\n\n/** Parse input binary data and return an array of GeoJSON Features */\nfunction parseFeatureCollection(dataArray): Feature[] {\n const features: Feature[] = [];\n for (const data of dataArray) {\n if (data.featureIds.value.length === 0) {\n // eslint-disable-next-line no-continue\n continue;\n }\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Need to deduce start, end indices of each feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n features.push(parseFeature(data, lastIndex, i));\n lastIndex = i;\n lastValue = currValue;\n }\n\n // Last feature\n features.push(parseFeature(data, lastIndex, data.featureIds.value.length));\n }\n return features;\n}\n\n/** Parse input binary data and return a single GeoJSON Feature */\nfunction parseFeature(data, startIndex?: number, endIndex?: number): Feature {\n const geometry = binaryToGeometry(data, startIndex, endIndex);\n const properties = parseProperties(data, startIndex, endIndex);\n const fields = parseFields(data, startIndex, endIndex);\n return {type: 'Feature', geometry, properties, ...fields};\n}\n\n/** Parse input binary data and return an object of fields */\nfunction parseFields(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n return data.fields && data.fields[data.featureIds.value[startIndex]];\n}\n\n/** Parse input binary data and return an object of properties */\nfunction parseProperties(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);\n for (const key in data.numericProps) {\n properties[key] = data.numericProps[key].value[startIndex];\n }\n return properties;\n}\n\n/** Parse binary data of type Polygon */\nfunction polygonToGeoJson(\n data,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): Polygon | MultiPolygon {\n const {positions} = data;\n const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const primitivePolygonIndices = data.primitivePolygonIndices.value.filter(\n (x) => x >= startIndex && x <= endIndex\n );\n const multi = polygonIndices.length > 2;\n\n // Polygon\n if (!multi) {\n const coordinates: Position[][] = [];\n for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {\n const startRingIndex = primitivePolygonIndices[i];\n const endRingIndex = primitivePolygonIndices[i + 1];\n const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'Polygon', coordinates};\n }\n\n // MultiPolygon\n const coordinates: Position[][][] = [];\n for (let i = 0; i < polygonIndices.length - 1; i++) {\n const startPolygonIndex = polygonIndices[i];\n const endPolygonIndex = polygonIndices[i + 1];\n const polygonCoordinates = polygonToGeoJson(\n data,\n startPolygonIndex,\n endPolygonIndex\n ).coordinates;\n coordinates.push(polygonCoordinates as Position[][]);\n }\n\n return {type: 'MultiPolygon', coordinates};\n}\n\n/** Parse binary data of type LineString */\nfunction lineStringToGeoJson(\n data,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): LineString | MultiLineString {\n const {positions} = data;\n const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const multi = pathIndices.length > 2;\n\n if (!multi) {\n const coordinates = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);\n return {type: 'LineString', coordinates};\n }\n\n const coordinates: Position[][] = [];\n for (let i = 0; i < pathIndices.length - 1; i++) {\n const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'MultiLineString', coordinates};\n}\n\n/** Parse binary data of type Point */\nfunction pointToGeoJson(data, startIndex, endIndex): Point | MultiPoint {\n const {positions} = data;\n const coordinates = ringToGeoJson(positions, startIndex, endIndex);\n const multi = coordinates.length > 1;\n\n if (multi) {\n return {type: 'MultiPoint', coordinates};\n }\n\n return {type: 'Point', coordinates: coordinates[0]};\n}\n\n/**\n * Parse a linear ring of positions to a GeoJSON linear ring\n *\n * @param positions Positions TypedArray\n * @param startIndex Start index to include in ring\n * @param endIndex End index to include in ring\n * @returns GeoJSON ring\n */\nfunction ringToGeoJson(\n positions: BinaryAttribute,\n startIndex?: number,\n endIndex?: number\n): Position[] {\n startIndex = startIndex || 0;\n endIndex = endIndex || positions.value.length / positions.size;\n\n const ringCoordinates: Position[] = [];\n for (let j = startIndex; j < endIndex; j++) {\n const coord = Array<number>();\n for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {\n coord.push(Number(positions.value[k]));\n }\n ringCoordinates.push(coord);\n }\n return ringCoordinates;\n}\n\n// Deduce geometry type of data object\nfunction parseType(data) {\n if (data.pathIndices) {\n return 'LineString';\n }\n\n if (data.polygonIndices)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C,IAAI4C,KAAK,EAAE;IACT,OAAO;MAAChD,IAAI,EAAE,YAAY;MAAEiD;IAAW,CAAC;EAC1C;EAEA,OAAO;IAACjD,IAAI,EAAE,OAAO;IAAEiD,WAAW,EAAEA,WAAW,CAAC,CAAC;EAAC,CAAC;AACrD;AAUA,SAASI,aAAaA,CACpBV,SAA0B,EAC1BxB,UAAmB,EACnBC,QAAiB,EACL;EACZD,UAAU,GAAGA,UAAU,IAAI,CAAC;EAC5BC,QAAQ,GAAGA,QAAQ,IAAIuB,SAAS,CAAC/B,KAAK,CAACR,MAAM,GAAGuC,SAAS,CAACe,IAAI;EAE9D,MAAMN,eAA2B,GAAG,EAAE;EACtC,KAAK,IAAIO,CAAC,GAAGxC,UAAU,EAAEwC,CAAC,GAAGvC,QAAQ,EAAEuC,CAAC,EAAE,EAAE;IAC1C,MAAMC,KAAK,GAAGC,KAAK,CAAS,CAAC;IAC7B,KAAK,IAAIC,CAAC,GAAGH,CAAC,GAAGhB,SAAS,CAACe,IAAI,EAAEI,CAAC,GAAG,CAACH,CAAC,GAAG,CAAC,IAAIhB,SAAS,CAACe,IAAI,EAAEI,CAAC,EAAE,EAAE;MAClEF,KAAK,CAAC5B,IAAI,CAAC+B,MAAM,CAACpB,SAAS,CAAC/B,KAAK,CAACkD,CAAC,CAAC,CAAC,CAAC;IACxC;IACAV,eAAe,CAACpB,IAAI,CAAC4B,KAAK,CAAC;EAC7B;EACA,OAAOR,eAAe;AACxB;AAGA,SAAStB,SAASA,CAACpC,IAAI,EAAE;EACvB,IAAIA,IAAI,CAAC+D,WAAW,EAAE;IACpB,OAAO,YAAY;EACrB;EAEA,IAAI/D,IAAI,CAACkD,cAAc,EAAE;IACvB,OAAO,SAAS;EAClB;EAEA,OAAO,OAAO;AAChB"}
|
|
1
|
+
{"version":3,"file":"binary-to-geojson.js","names":["binaryToGeojson","data","options","globalFeatureId","undefined","getSingleFeature","parseFeatures","type","dataArray","normalizeInput","lastIndex","lastValue","featureIds","value","i","length","currValue","globalFeatureIds","parseFeature","Error","concat","parseFeatureCollection","binaryToGeometry","startIndex","endIndex","pointToGeoJson","lineStringToGeoJson","polygonToGeoJson","unexpectedInput","features","points","push","lines","polygons","geometry","properties","parseProperties","fields","parseFields","arguments","Object","assign","key","numericProps","Infinity","positions","polygonIndices","filter","x","primitivePolygonIndices","multi","coordinates","startRingIndex","endRingIndex","ringCoordinates","ringToGeoJson","startPolygonIndex","endPolygonIndex","polygonCoordinates","pathIndices","size","j","coord","Array","k","Number"],"sources":["../../../src/lib/binary-to-geojson.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {\n BinaryGeometry,\n BinaryGeometryType,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryFeatureCollection,\n BinaryFeature,\n // BinaryPointFeature,\n // BinaryLineFeature,\n // BinaryPolygonFeature,\n BinaryAttribute\n} from '@loaders.gl/schema';\nimport type {Feature, Geometry, Position, GeoJsonProperties} from '@loaders.gl/schema';\nimport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon\n} from '@loaders.gl/schema';\n\n// Note:L We do not handle GeometryCollection, define a limited Geometry type that always has coordinates.\n// type FeatureGeometry = Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon;\n\ntype BinaryToGeoJsonOptions = {\n type?: BinaryGeometryType;\n globalFeatureId?: number;\n};\n\n/**\n * Convert binary geometry representation to GeoJSON\n * @param data geometry data in binary representation\n * @param options\n * @param options.type Input data type: Point, LineString, or Polygon\n * @param options.featureId Global feature id. If specified, only a single feature is extracted\n * @return GeoJSON objects\n */\nexport function binaryToGeojson(\n data: BinaryFeatureCollection,\n options?: BinaryToGeoJsonOptions\n): Feature[] | Feature {\n const globalFeatureId = options?.globalFeatureId;\n if (globalFeatureId !== undefined) {\n return getSingleFeature(data, globalFeatureId);\n }\n return parseFeatures(data, options?.type);\n}\n\n/** @deprecated use `binaryToGeojson` or `binaryToGeometry` instead *\nexport function binaryToGeoJson(\n data: BinaryGeometry | BinaryFeatureCollection,\n type?: BinaryGeometryType,\n format: 'feature' | 'geometry' = 'feature'\n): Geometry | Feature[] {\n switch (format) {\n case 'feature':\n return parseFeatures(data as BinaryFeatureCollection, type);\n case 'geometry':\n return binaryToGeometry(data as any);\n default:\n throw new Error(format);\n }\n}\n*/\n\n/**\n * Return a single feature from a binary geometry representation as GeoJSON\n * @param data geometry data in binary representation\n * @return GeoJSON feature\n */\nfunction getSingleFeature(data: BinaryFeatureCollection, globalFeatureId: number): Feature {\n const dataArray = normalizeInput(data);\n for (const data of dataArray) {\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Scan through data until we find matching feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, i);\n }\n lastIndex = i;\n lastValue = currValue;\n }\n\n if (globalFeatureId === data.globalFeatureIds.value[lastIndex]) {\n return parseFeature(data, lastIndex, data.featureIds.value.length);\n }\n }\n\n throw new Error(`featureId:${globalFeatureId} not found`);\n}\n\nfunction parseFeatures(data: BinaryFeatureCollection, type?: BinaryGeometryType): Feature[] {\n const dataArray = normalizeInput(data, type);\n return parseFeatureCollection(dataArray);\n}\n\n/** Parse input binary data and return a valid GeoJSON geometry object */\nexport function binaryToGeometry(\n data: BinaryGeometry,\n startIndex?: number,\n endIndex?: number\n): Geometry {\n switch (data.type) {\n case 'Point':\n return pointToGeoJson(data, startIndex, endIndex);\n case 'LineString':\n return lineStringToGeoJson(data, startIndex, endIndex);\n case 'Polygon':\n return polygonToGeoJson(data, startIndex, endIndex);\n default:\n const unexpectedInput: never = data;\n throw new Error(`Unsupported geometry type: ${(unexpectedInput as any)?.type}`);\n }\n}\n\n// Normalize features\n// Return an array of data objects, each of which have a type key\nfunction normalizeInput(data: BinaryFeatureCollection, type?: BinaryGeometryType): BinaryFeature[] {\n const features: BinaryFeature[] = [];\n if (data.points) {\n data.points.type = 'Point';\n features.push(data.points);\n }\n if (data.lines) {\n data.lines.type = 'LineString';\n features.push(data.lines);\n }\n if (data.polygons) {\n data.polygons.type = 'Polygon';\n features.push(data.polygons);\n }\n\n return features;\n}\n\n/** Parse input binary data and return an array of GeoJSON Features */\nfunction parseFeatureCollection(dataArray: BinaryFeature[]): Feature[] {\n const features: Feature[] = [];\n for (const data of dataArray) {\n if (data.featureIds.value.length === 0) {\n // eslint-disable-next-line no-continue\n continue;\n }\n let lastIndex = 0;\n let lastValue = data.featureIds.value[0];\n\n // Need to deduce start, end indices of each feature\n for (let i = 0; i < data.featureIds.value.length; i++) {\n const currValue = data.featureIds.value[i];\n if (currValue === lastValue) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n features.push(parseFeature(data, lastIndex, i));\n lastIndex = i;\n lastValue = currValue;\n }\n\n // Last feature\n features.push(parseFeature(data, lastIndex, data.featureIds.value.length));\n }\n return features;\n}\n\n/** Parse input binary data and return a single GeoJSON Feature */\nfunction parseFeature(data: BinaryFeature, startIndex?: number, endIndex?: number): Feature {\n const geometry = binaryToGeometry(data, startIndex, endIndex);\n const properties = parseProperties(data, startIndex, endIndex);\n const fields = parseFields(data, startIndex, endIndex);\n return {type: 'Feature', geometry, properties, ...fields};\n}\n\n/** Parse input binary data and return an object of fields */\nfunction parseFields(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n return data.fields && data.fields[data.featureIds.value[startIndex]];\n}\n\n/** Parse input binary data and return an object of properties */\nfunction parseProperties(data, startIndex: number = 0, endIndex?: number): GeoJsonProperties {\n const properties = Object.assign({}, data.properties[data.featureIds.value[startIndex]]);\n for (const key in data.numericProps) {\n properties[key] = data.numericProps[key].value[startIndex];\n }\n return properties;\n}\n\n/** Parse binary data of type Polygon */\nfunction polygonToGeoJson(\n data: BinaryPolygonGeometry,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): Polygon | MultiPolygon {\n const {positions} = data;\n const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const primitivePolygonIndices = data.primitivePolygonIndices.value.filter(\n (x) => x >= startIndex && x <= endIndex\n );\n const multi = polygonIndices.length > 2;\n\n // Polygon\n if (!multi) {\n const coordinates: Position[][] = [];\n for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {\n const startRingIndex = primitivePolygonIndices[i];\n const endRingIndex = primitivePolygonIndices[i + 1];\n const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'Polygon', coordinates};\n }\n\n // MultiPolygon\n const coordinates: Position[][][] = [];\n for (let i = 0; i < polygonIndices.length - 1; i++) {\n const startPolygonIndex = polygonIndices[i];\n const endPolygonIndex = polygonIndices[i + 1];\n const polygonCoordinates = polygonToGeoJson(\n data,\n startPolygonIndex,\n endPolygonIndex\n ).coordinates;\n coordinates.push(polygonCoordinates as Position[][]);\n }\n\n return {type: 'MultiPolygon', coordinates};\n}\n\n/** Parse binary data of type LineString */\nfunction lineStringToGeoJson(\n data: BinaryLineGeometry,\n startIndex: number = -Infinity,\n endIndex: number = Infinity\n): LineString | MultiLineString {\n const {positions} = data;\n const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);\n const multi = pathIndices.length > 2;\n\n if (!multi) {\n const coordinates = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);\n return {type: 'LineString', coordinates};\n }\n\n const coordinates: Position[][] = [];\n for (let i = 0; i < pathIndices.length - 1; i++) {\n const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);\n coordinates.push(ringCoordinates);\n }\n\n return {type: 'MultiLineString', coordinates};\n}\n\n/** Parse binary data of type Point */\nfunction pointToGeoJson(data: BinaryPointGeometry, startIndex, endIndex): Point | MultiPoint {\n const {positions} = data;\n const coordinates = ringToGeoJson(positions, startIndex, endIndex);\n const multi = coordinates.length > 1;\n\n if (multi) {\n return {type: 'MultiPoint', coordinates};\n }\n\n return {type: 'Point', coordinates: coordinates[0]};\n}\n\n/**\n * Parse a linear ring of positions to a GeoJSON linear ring\n *\n * @param positions Positions TypedArray\n * @param startIndex Start index to include in ring\n * @param endIndex End index to include in ring\n * @returns GeoJSON ring\n */\nfunction ringToGeoJson(\n positions: BinaryAttribute,\n startIndex?: number,\n endIndex?: number\n): Position[] {\n startIndex = startIndex || 0;\n endIndex = endIndex || positions.value.length / positions.size;\n\n const ringCoordinates: Position[] = [];\n for (let j = startIndex; j < endIndex; j++) {\n const coord = Array<number>();\n for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {\n coord.push(Number(positions.value[k]));\n }\n ringCoordinates.push(coord);\n }\n return ringCoordinates;\n}\n"],"mappings":"AAyCA,OAAO,SAASA,eAAeA,CAC7BC,IAA6B,EAC7BC,OAAgC,EACX;EACrB,MAAMC,eAAe,GAAGD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,eAAe;EAChD,IAAIA,eAAe,KAAKC,SAAS,EAAE;IACjC,OAAOC,gBAAgB,CAACJ,IAAI,EAAEE,eAAe,CAAC;EAChD;EACA,OAAOG,aAAa,CAACL,IAAI,EAAEC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEK,IAAI,CAAC;AAC3C;AAwBA,SAASF,gBAAgBA,CAACJ,IAA6B,EAAEE,eAAuB,EAAW;EACzF,MAAMK,SAAS,GAAGC,cAAc,CAACR,IAAI,CAAC;EACtC,KAAK,MAAMA,IAAI,IAAIO,SAAS,EAAE;IAC5B,IAAIE,SAAS,GAAG,CAAC;IACjB,IAAIC,SAAS,GAAGV,IAAI,CAACW,UAAU,CAACC,KAAK,CAAC,CAAC,CAAC;IAGxC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGb,IAAI,CAACW,UAAU,CAACC,KAAK,CAACE,MAAM,EAAED,CAAC,EAAE,EAAE;MACrD,MAAME,SAAS,GAAGf,I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AaA,CACpBV,SAA0B,EAC1BtB,UAAmB,EACnBC,QAAiB,EACL;EACZD,UAAU,GAAGA,UAAU,IAAI,CAAC;EAC5BC,QAAQ,GAAGA,QAAQ,IAAIqB,SAAS,CAAChC,KAAK,CAACE,MAAM,GAAG8B,SAAS,CAACe,IAAI;EAE9D,MAAMN,eAA2B,GAAG,EAAE;EACtC,KAAK,IAAIO,CAAC,GAAGtC,UAAU,EAAEsC,CAAC,GAAGrC,QAAQ,EAAEqC,CAAC,EAAE,EAAE;IAC1C,MAAMC,KAAK,GAAGC,KAAK,CAAS,CAAC;IAC7B,KAAK,IAAIC,CAAC,GAAGH,CAAC,GAAGhB,SAAS,CAACe,IAAI,EAAEI,CAAC,GAAG,CAACH,CAAC,GAAG,CAAC,IAAIhB,SAAS,CAACe,IAAI,EAAEI,CAAC,EAAE,EAAE;MAClEF,KAAK,CAAC/B,IAAI,CAACkC,MAAM,CAACpB,SAAS,CAAChC,KAAK,CAACmD,CAAC,CAAC,CAAC,CAAC;IACxC;IACAV,eAAe,CAACvB,IAAI,CAAC+B,KAAK,CAAC;EAC7B;EACA,OAAOR,eAAe;AACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary-types.js","names":[],"sources":["../../../src/lib/flat-geojson-to-binary-types.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\n\n/**\n * Permissable constructor for numeric props\n */\nexport type PropArrayConstructor =\n | Float32ArrayConstructor\n | Float64ArrayConstructor\n | ArrayConstructor;\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryPointGeometry`\n */\nexport type Points = {\n type: 'Point';\n positions: Float32Array | Float64Array;\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryLineStringGeometry`\n */\nexport type Lines = {\n type: 'LineString';\n positions: Float32Array | Float64Array;\n pathIndices: Uint16Array | Uint32Array;\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryPolygonGeometry`\n */\nexport type Polygons = {\n type: 'Polygon';\n positions: Float32Array | Float64Array;\n polygonIndices: Uint16Array | Uint32Array;\n primitivePolygonIndices: Uint16Array | Uint32Array;\n triangles
|
|
1
|
+
{"version":3,"file":"flat-geojson-to-binary-types.js","names":[],"sources":["../../../src/lib/flat-geojson-to-binary-types.ts"],"sourcesContent":["import type {TypedArray} from '@loaders.gl/schema';\n\n/**\n * Permissable constructor for numeric props\n */\nexport type PropArrayConstructor =\n | Float32ArrayConstructor\n | Float64ArrayConstructor\n | ArrayConstructor;\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryPointGeometry`\n */\nexport type Points = {\n type: 'Point';\n positions: Float32Array | Float64Array;\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryLineStringGeometry`\n */\nexport type Lines = {\n type: 'LineString';\n positions: Float32Array | Float64Array;\n pathIndices: Uint16Array | Uint32Array;\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n\n/**\n * Collection type for holding intermediate binary data before conversion to `BinaryPolygonGeometry`\n */\nexport type Polygons = {\n type: 'Polygon';\n positions: Float32Array | Float64Array;\n polygonIndices: Uint16Array | Uint32Array;\n primitivePolygonIndices: Uint16Array | Uint32Array;\n triangles?: number[];\n globalFeatureIds: Uint16Array | Uint32Array;\n featureIds: Uint16Array | Uint32Array;\n numericProps: {[key: string]: TypedArray};\n properties: {}[];\n fields: {\n id?: string | number;\n }[];\n};\n"],"mappings":""}
|
|
@@ -7,7 +7,8 @@ export function flatGeojsonToBinary(features, geometryInfo, options) {
|
|
|
7
7
|
...geometryInfo
|
|
8
8
|
}, {
|
|
9
9
|
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
10
|
-
PositionDataType: options ? options.PositionDataType : Float32Array
|
|
10
|
+
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
11
|
+
triangulate: options ? options.triangulate : true
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
export const TEST_EXPORTS = {
|
|
@@ -41,7 +42,8 @@ function fillArrays(features, geometryInfo, options) {
|
|
|
41
42
|
} = geometryInfo;
|
|
42
43
|
const {
|
|
43
44
|
numericPropKeys = [],
|
|
44
|
-
PositionDataType = Float32Array
|
|
45
|
+
PositionDataType = Float32Array,
|
|
46
|
+
triangulate = true
|
|
45
47
|
} = options;
|
|
46
48
|
const hasGlobalId = features[0] && 'id' in features[0];
|
|
47
49
|
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
@@ -69,13 +71,15 @@ function fillArrays(features, geometryInfo, options) {
|
|
|
69
71
|
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
70
72
|
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
71
73
|
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
72
|
-
triangles: [],
|
|
73
74
|
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
74
75
|
featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
|
|
75
76
|
numericProps: {},
|
|
76
77
|
properties: [],
|
|
77
78
|
fields: []
|
|
78
79
|
};
|
|
80
|
+
if (triangulate) {
|
|
81
|
+
polygons.triangles = [];
|
|
82
|
+
}
|
|
79
83
|
for (const object of [points, lines, polygons]) {
|
|
80
84
|
for (const propName of numericPropKeys) {
|
|
81
85
|
const T = propArrayTypes[propName];
|
|
@@ -191,6 +195,9 @@ function triangulatePolygon(polygons, areas, indices, _ref) {
|
|
|
191
195
|
endPosition,
|
|
192
196
|
coordLength
|
|
193
197
|
} = _ref;
|
|
198
|
+
if (!polygons.triangles) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
194
201
|
const start = startPosition * coordLength;
|
|
195
202
|
const end = endPosition * coordLength;
|
|
196
203
|
const polygonPositions = polygons.positions.subarray(start, end);
|
|
@@ -212,7 +219,7 @@ function wrapProps(obj, size) {
|
|
|
212
219
|
return returnObj;
|
|
213
220
|
}
|
|
214
221
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
215
|
-
|
|
222
|
+
const binaryFeatures = {
|
|
216
223
|
points: {
|
|
217
224
|
...points,
|
|
218
225
|
positions: {
|
|
@@ -263,10 +270,6 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
263
270
|
value: polygons.primitivePolygonIndices,
|
|
264
271
|
size: 1
|
|
265
272
|
},
|
|
266
|
-
triangles: {
|
|
267
|
-
value: new Uint32Array(polygons.triangles),
|
|
268
|
-
size: 1
|
|
269
|
-
},
|
|
270
273
|
globalFeatureIds: {
|
|
271
274
|
value: polygons.globalFeatureIds,
|
|
272
275
|
size: 1
|
|
@@ -278,6 +281,13 @@ function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
|
278
281
|
numericProps: wrapProps(polygons.numericProps, 1)
|
|
279
282
|
}
|
|
280
283
|
};
|
|
284
|
+
if (binaryFeatures.polygons && polygons.triangles) {
|
|
285
|
+
binaryFeatures.polygons.triangles = {
|
|
286
|
+
value: new Uint32Array(polygons.triangles),
|
|
287
|
+
size: 1
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
return binaryFeatures;
|
|
281
291
|
}
|
|
282
292
|
function fillNumericProperties(object, properties, index, length) {
|
|
283
293
|
for (const numericPropName in object.numericProps) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary.js","names":["earcut","flatGeojsonToBinary","features","geometryInfo","options","propArrayTypes","extractNumericPropTypes","numericPropKeys","Object","keys","filter","k","Array","fillArrays","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","val","deduceArrayType","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLength","hasGlobalId","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","type","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","T","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","indices","start","end","l","ll","startPosition","areas","nextIndices","undefined","endPosition","triangulatePolygon","_ref","polygonPositions","subarray","offset","holes","slice","map","n","t","tl","wrapProps","obj","size","returnObj","value","index","numericPropName","numericKeys","props","includes","x","constructor","Number","isFinite","Float64Array","Math","fround"],"sources":["../../../src/lib/flat-geojson-to-binary.ts"],"sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport type {\n BinaryAttribute,\n BinaryFeatures,\n FlatFeature,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n GeojsonGeometryInfo,\n TypedArray\n} from '@loaders.gl/schema';\nimport {PropArrayConstructor, Lines, Points, Polygons} from './flat-geojson-to-binary-types';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns filled arrays\n */\nexport function flatGeojsonToBinary(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo,\n options?: FlatGeojsonToBinaryOptions\n) {\n const propArrayTypes = extractNumericPropTypes(features);\n const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);\n return fillArrays(\n features,\n {\n propArrayTypes,\n ...geometryInfo\n },\n {\n numericPropKeys: (options && options.numericPropKeys) || numericPropKeys,\n PositionDataType: options ? options.PositionDataType : Float32Array\n }\n );\n}\n\n/**\n * Options for `flatGeojsonToBinary`\n */\nexport type FlatGeojsonToBinaryOptions = {\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n};\n\nexport const TEST_EXPORTS = {\n extractNumericPropTypes\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric types\n */\nfunction extractNumericPropTypes(features: FlatFeature[]): {\n [key: string]: PropArrayConstructor;\n} {\n const propArrayTypes = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, Array is stored to prevent rechecking in the future\n // Additionally, detects if 64 bit precision is required\n const val = feature.properties[key];\n propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);\n }\n }\n }\n\n return propArrayTypes;\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity\nfunction fillArrays(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo & {\n propArrayTypes: {[key: string]: PropArrayConstructor};\n },\n options: FlatGeojsonToBinaryOptions\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount,\n propArrayTypes,\n coordLength\n } = geometryInfo;\n const {numericPropKeys = [], PositionDataType = Float32Array} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points: Points = {\n type: 'Point',\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines: Lines = {\n type: 'LineString',\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons: Polygons = {\n type: 'Polygon',\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n triangles: [],\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n const T = propArrayTypes[propName];\n object.numericProps[propName] = new T(object.positions.length / coordLength) as TypedArray;\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: FlatPoint,\n points: Points,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: FlatLineString,\n lines: Lines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.indices.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.indices[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.indices[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: FlatPolygon,\n polygons: Polygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.indices is a 2D array\n for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas[l];\n const indices = geometry.indices[l];\n const nextIndices = geometry.indices[l + 1];\n\n for (let i = 0, il = indices.length; i < il; ++i) {\n const start = indices[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextIndices === undefined\n ? geometry.data.length // end of data (no next indices)\n : nextIndices[0] // start of first line in nextIndices\n : indices[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, indices, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n *\n * @param polygons\n * @param areas\n * @param indices\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: Polygons,\n areas: number[],\n indices: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = indices[0];\n const holes = indices.slice(1).map((n: number) => (n - offset) / coordLength);\n\n // Compute triangulation\n // @ts-expect-error TODO can earcut handle binary arrays? Add tests?\n const triangles = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = triangles.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + triangles[t]);\n }\n}\n\n/**\n * Wraps an object containing array into accessors\n *\n * @param obj\n * @param size\n */\nfunction wrapProps(\n obj: {[key: string]: TypedArray},\n size: number\n): {[key: string]: BinaryAttribute} {\n const returnObj = {};\n for (const key in obj) {\n returnObj[key] = {value: obj[key], size};\n }\n return returnObj;\n}\n\n/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: Points,\n lines: Lines,\n polygons: Polygons,\n coordLength: number\n): BinaryFeatures {\n return {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1},\n numericProps: wrapProps(points.numericProps, 1)\n },\n lines: {\n ...lines,\n positions: {value: lines.positions, size: coordLength},\n pathIndices: {value: lines.pathIndices, size: 1},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1},\n numericProps: wrapProps(lines.numericProps, 1)\n },\n polygons: {\n ...polygons,\n positions: {value: polygons.positions, size: coordLength},\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n triangles: {value: new Uint32Array(polygons.triangles), size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1},\n numericProps: wrapProps(polygons.numericProps, 1)\n }\n };\n}\n\n/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: Points | Lines | Polygons,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n const value = properties[numericPropName] as number;\n object.numericProps[numericPropName].fill(value, index, index + length);\n }\n }\n}\n\n/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\n/**\n *\n * Deduce correct array constructor to use for a given value\n *\n * @param x value to test\n * @param constructor previous constructor deduced\n * @returns PropArrayConstructor\n */\nfunction deduceArrayType(x: any, constructor: PropArrayConstructor): PropArrayConstructor {\n if (constructor === Array || !Number.isFinite(x)) {\n return Array;\n }\n\n // If this or previous value required 64bits use Float64Array\n return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;\n}\n"],"mappings":"AACA,SAAQA,MAAM,QAAO,kBAAkB;AA0BvC,OAAO,SAASC,mBAAmBA,CACjCC,QAAuB,EACvBC,YAAiC,EACjCC,OAAoC,EACpC;EACA,MAAMC,cAAc,GAAGC,uBAAuB,CAACJ,QAAQ,CAAC;EACxD,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACJ,cAAc,CAAC,CAACK,MAAM,CAAEC,CAAC,IAAKN,cAAc,CAACM,CAAC,CAAC,KAAKC,KAAK,CAAC;EAC9F,OAAOC,UAAU,CACfX,QAAQ,EACR;IACEG,cAAc;IACd,GAAGF;EACL,CAAC,EACD;IACEI,eAAe,EAAGH,OAAO,IAAIA,OAAO,CAACG,eAAe,IAAKA,eAAe;IACxEO,gBAAgB,EAAEV,OAAO,GAAGA,OAAO,CAACU,gBAAgB,GAAGC;EACzD,CACF,CAAC;AACH;AAUA,OAAO,MAAMC,YAAY,GAAG;EAC1BV;AACF,CAAC;AAQD,S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K,IAAI,CAACoG,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,EAAE;IAChD,OAAOlG,KAAK;EACd;EAGA,OAAOmG,WAAW,KAAKG,YAAY,IAAIC,IAAI,CAACC,MAAM,CAACN,CAAC,CAAC,KAAKA,CAAC,GAAGI,YAAY,GAAGnG,YAAY;AAC3F"}
|
|
1
|
+
{"version":3,"file":"flat-geojson-to-binary.js","names":["earcut","flatGeojsonToBinary","features","geometryInfo","options","propArrayTypes","extractNumericPropTypes","numericPropKeys","Object","keys","filter","k","Array","fillArrays","PositionDataType","Float32Array","triangulate","TEST_EXPORTS","feature","properties","key","val","deduceArrayType","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLength","hasGlobalId","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","type","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","T","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","indices","start","end","l","ll","startPosition","areas","nextIndices","undefined","endPosition","triangulatePolygon","_ref","polygonPositions","subarray","offset","holes","slice","map","n","t","tl","wrapProps","obj","size","returnObj","value","binaryFeatures","index","numericPropName","numericKeys","props","includes","x","constructor","Number","isFinite","Float64Array","Math","fround"],"sources":["../../../src/lib/flat-geojson-to-binary.ts"],"sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport type {\n BinaryAttribute,\n BinaryFeatureCollection,\n BinaryPolygonFeature,\n FlatFeature,\n FlatPoint,\n FlatLineString,\n FlatPolygon,\n GeojsonGeometryInfo,\n TypedArray\n} from '@loaders.gl/schema';\nimport {PropArrayConstructor, Lines, Points, Polygons} from './flat-geojson-to-binary-types';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns filled arrays\n */\nexport function flatGeojsonToBinary(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo,\n options?: FlatGeojsonToBinaryOptions\n) {\n const propArrayTypes = extractNumericPropTypes(features);\n const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);\n return fillArrays(\n features,\n {\n propArrayTypes,\n ...geometryInfo\n },\n {\n numericPropKeys: (options && options.numericPropKeys) || numericPropKeys,\n PositionDataType: options ? options.PositionDataType : Float32Array,\n triangulate: options ? options.triangulate : true\n }\n );\n}\n\n/**\n * Options for `flatGeojsonToBinary`\n */\nexport type FlatGeojsonToBinaryOptions = {\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n triangulate?: boolean;\n};\n\nexport const TEST_EXPORTS = {\n extractNumericPropTypes\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric types\n */\nfunction extractNumericPropTypes(features: FlatFeature[]): {\n [key: string]: PropArrayConstructor;\n} {\n const propArrayTypes = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, Array is stored to prevent rechecking in the future\n // Additionally, detects if 64 bit precision is required\n const val = feature.properties[key];\n propArrayTypes[key] = deduceArrayType(val, propArrayTypes[key]);\n }\n }\n }\n\n return propArrayTypes;\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param geometryInfo\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity, max-statements\nfunction fillArrays(\n features: FlatFeature[],\n geometryInfo: GeojsonGeometryInfo & {\n propArrayTypes: {[key: string]: PropArrayConstructor};\n },\n options: FlatGeojsonToBinaryOptions\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount,\n propArrayTypes,\n coordLength\n } = geometryInfo;\n const {numericPropKeys = [], PositionDataType = Float32Array, triangulate = true} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points: Points = {\n type: 'Point',\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines: Lines = {\n type: 'LineString',\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons: Polygons = {\n type: 'Polygon',\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n if (triangulate) {\n polygons.triangles = [];\n }\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n const T = propArrayTypes[propName];\n object.numericProps[propName] = new T(object.positions.length / coordLength) as TypedArray;\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: FlatPoint,\n points: Points,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: FlatLineString,\n lines: Lines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.indices.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.indices[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.indices[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: FlatPolygon,\n polygons: Polygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.indices is a 2D array\n for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas[l];\n const indices = geometry.indices[l];\n const nextIndices = geometry.indices[l + 1];\n\n for (let i = 0, il = indices.length; i < il; ++i) {\n const start = indices[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextIndices === undefined\n ? geometry.data.length // end of data (no next indices)\n : nextIndices[0] // start of first line in nextIndices\n : indices[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, indices, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n *\n * @param polygons\n * @param areas\n * @param indices\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: Polygons,\n areas: number[],\n indices: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\n if (!polygons.triangles) {\n return;\n }\n\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = indices[0];\n const holes = indices.slice(1).map((n: number) => (n - offset) / coordLength);\n\n // Compute triangulation\n // @ts-expect-error TODO can earcut handle binary arrays? Add tests?\n const triangles = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = triangles.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + triangles[t]);\n }\n}\n\n/**\n * Wraps an object containing array into accessors\n *\n * @param obj\n * @param size\n */\nfunction wrapProps(\n obj: {[key: string]: TypedArray},\n size: number\n): {[key: string]: BinaryAttribute} {\n const returnObj = {};\n for (const key in obj) {\n returnObj[key] = {value: obj[key], size};\n }\n return returnObj;\n}\n\n/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: Points,\n lines: Lines,\n polygons: Polygons,\n coordLength: number\n): BinaryFeatureCollection {\n const binaryFeatures: BinaryFeatureCollection = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1},\n numericProps: wrapProps(points.numericProps, 1)\n },\n lines: {\n ...lines,\n positions: {value: lines.positions, size: coordLength},\n pathIndices: {value: lines.pathIndices, size: 1},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1},\n numericProps: wrapProps(lines.numericProps, 1)\n },\n polygons: {\n ...polygons,\n positions: {value: polygons.positions, size: coordLength},\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1},\n numericProps: wrapProps(polygons.numericProps, 1)\n } as BinaryPolygonFeature // triangles not expected\n };\n\n if (binaryFeatures.polygons && polygons.triangles) {\n binaryFeatures.polygons.triangles = {value: new Uint32Array(polygons.triangles), size: 1};\n }\n\n return binaryFeatures;\n}\n\n/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: Points | Lines | Polygons,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n const value = properties[numericPropName] as number;\n object.numericProps[numericPropName].fill(value, index, index + length);\n }\n }\n}\n\n/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\n/**\n *\n * Deduce correct array constructor to use for a given value\n *\n * @param x value to test\n * @param constructor previous constructor deduced\n * @returns PropArrayConstructor\n */\nfunction deduceArrayType(x: any, constructor: PropArrayConstructor): PropArrayConstructor {\n if (constructor === Array || !Number.isFinite(x)) {\n return Array;\n }\n\n // If this or previous value required 64bits use Float64Array\n return constructor === Float64Array || Math.fround(x) !== x ? Float64Array : Float32Array;\n}\n"],"mappings":"AACA,SAAQA,MAAM,QAAO,kBAAkB;AA2BvC,OAAO,SAASC,mBAAmBA,CACjCC,QAAuB,EACvBC,YAAiC,EACjCC,OAAoC,EACpC;EACA,MAAMC,cAAc,GAAGC,uBAAuB,CAACJ,QAAQ,CAAC;EACxD,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACJ,cAAc,CAAC,CAACK,MAAM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Ac,EACR;EACN,KAAK,MAAMyE,eAAe,IAAIzD,MAAM,CAACR,YAAY,EAAE;IACjD,IAAIiE,eAAe,IAAIzF,UAAU,EAAE;MACjC,MAAMsF,KAAK,GAAGtF,UAAU,CAACyF,eAAe,CAAW;MACnDzD,MAAM,CAACR,YAAY,CAACiE,eAAe,CAAC,CAAC/B,IAAI,CAAC4B,KAAK,EAAEE,KAAK,EAAEA,KAAK,GAAGxE,MAAM,CAAC;IACzE;EACF;AACF;AASA,SAASgC,oBAAoBA,CAC3BhD,UAA2D,EAC3D0F,WAAqB,EACrB;EACA,MAAMC,KAAK,GAAG,CAAC,CAAC;EAChB,KAAK,MAAM1F,GAAG,IAAID,UAAU,EAAE;IAC5B,IAAI,CAAC0F,WAAW,CAACE,QAAQ,CAAC3F,GAAG,CAAC,EAAE;MAC9B0F,KAAK,CAAC1F,GAAG,CAAC,GAAGD,UAAU,CAACC,GAAG,CAAC;IAC9B;EACF;EACA,OAAO0F,KAAK;AACd;AAUA,SAASxF,eAAeA,CAAC0F,CAAM,EAAEC,WAAiC,EAAwB;EACxF,IAAIA,WAAW,KAAKrG,KAAK,IAAI,CAACsG,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,EAAE;IAChD,OAAOpG,KAAK;EACd;EAGA,OAAOqG,WAAW,KAAKG,YAAY,IAAIC,IAAI,CAACC,MAAM,CAACN,CAAC,CAAC,KAAKA,CAAC,GAAGI,YAAY,GAAGrG,YAAY;AAC3F"}
|
|
@@ -3,7 +3,8 @@ import { geojsonToFlatGeojson } from './geojson-to-flat-geojson';
|
|
|
3
3
|
import { flatGeojsonToBinary } from './flat-geojson-to-binary';
|
|
4
4
|
export function geojsonToBinary(features) {
|
|
5
5
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
6
|
-
fixRingWinding: true
|
|
6
|
+
fixRingWinding: true,
|
|
7
|
+
triangulate: true
|
|
7
8
|
};
|
|
8
9
|
const geometryInfo = extractGeometryInfo(features);
|
|
9
10
|
const coordLength = geometryInfo.coordLength;
|
|
@@ -16,7 +17,8 @@ export function geojsonToBinary(features) {
|
|
|
16
17
|
});
|
|
17
18
|
return flatGeojsonToBinary(flatFeatures, geometryInfo, {
|
|
18
19
|
numericPropKeys: options.numericPropKeys,
|
|
19
|
-
PositionDataType: options.PositionDataType || Float32Array
|
|
20
|
+
PositionDataType: options.PositionDataType || Float32Array,
|
|
21
|
+
triangulate: options.triangulate
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
//# sourceMappingURL=geojson-to-binary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-binary.js","names":["extractGeometryInfo","geojsonToFlatGeojson","flatGeojsonToBinary","geojsonToBinary","features","options","arguments","length","undefined","fixRingWinding","geometryInfo","coordLength","flatFeatures","numericPropKeys","PositionDataType","Float32Array"],"sources":["../../../src/lib/geojson-to-binary.ts"],"sourcesContent":["import type {Feature} from '@loaders.gl/schema';\nimport type {
|
|
1
|
+
{"version":3,"file":"geojson-to-binary.js","names":["extractGeometryInfo","geojsonToFlatGeojson","flatGeojsonToBinary","geojsonToBinary","features","options","arguments","length","undefined","fixRingWinding","triangulate","geometryInfo","coordLength","flatFeatures","numericPropKeys","PositionDataType","Float32Array"],"sources":["../../../src/lib/geojson-to-binary.ts"],"sourcesContent":["import type {Feature} from '@loaders.gl/schema';\nimport type {BinaryFeatureCollection} from '@loaders.gl/schema';\n\nimport {extractGeometryInfo} from './extract-geometry-info';\nimport {geojsonToFlatGeojson} from './geojson-to-flat-geojson';\nimport {flatGeojsonToBinary} from './flat-geojson-to-binary';\n\n/**\n * Options for `geojsonToBinary`\n */\nexport type GeojsonToBinaryOptions = {\n fixRingWinding: boolean;\n numericPropKeys?: string[];\n PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;\n triangulate?: boolean;\n};\n\n/**\n * Convert GeoJSON features to flat binary arrays\n *\n * @param features\n * @param options\n * @returns features in binary format, grouped by geometry type\n */\nexport function geojsonToBinary(\n features: Feature[],\n options: GeojsonToBinaryOptions = {fixRingWinding: true, triangulate: true}\n): BinaryFeatureCollection {\n const geometryInfo = extractGeometryInfo(features);\n const coordLength = geometryInfo.coordLength;\n const {fixRingWinding} = options;\n const flatFeatures = geojsonToFlatGeojson(features, {coordLength, fixRingWinding});\n return flatGeojsonToBinary(flatFeatures, geometryInfo, {\n numericPropKeys: options.numericPropKeys,\n PositionDataType: options.PositionDataType || Float32Array,\n triangulate: options.triangulate\n });\n}\n"],"mappings":"AAGA,SAAQA,mBAAmB,QAAO,yBAAyB;AAC3D,SAAQC,oBAAoB,QAAO,2BAA2B;AAC9D,SAAQC,mBAAmB,QAAO,0BAA0B;AAmB5D,OAAO,SAASC,eAAeA,CAC7BC,QAAmB,EAEM;EAAA,IADzBC,OAA+B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IAACG,cAAc,EAAE,IAAI;IAAEC,WAAW,EAAE;EAAI,CAAC;EAE3E,MAAMC,YAAY,GAAGX,mBAAmB,CAACI,QAAQ,CAAC;EAClD,MAAMQ,WAAW,GAAGD,YAAY,CAACC,WAAW;EAC5C,MAAM;IAACH;EAAc,CAAC,GAAGJ,OAAO;EAChC,MAAMQ,YAAY,GAAGZ,oBAAoB,CAACG,QAAQ,EAAE;IAACQ,WAAW;IAAEH;EAAc,CAAC,CAAC;EAClF,OAAOP,mBAAmB,CAACW,YAAY,EAAEF,YAAY,EAAE;IACrDG,eAAe,EAAET,OAAO,CAACS,eAAe;IACxCC,gBAAgB,EAAEV,OAAO,CAACU,gBAAgB,IAAIC,YAAY;IAC1DN,WAAW,EAAEL,OAAO,CAACK;EACvB,CAAC,CAAC;AACJ"}
|
|
@@ -35,6 +35,6 @@ function coordMap(array, fn) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
function isCoord(array) {
|
|
38
|
-
return Number.isFinite(array[0]) && Number.isFinite(array[1]);
|
|
38
|
+
return Array.isArray(array) && Number.isFinite(array[0]) && Number.isFinite(array[1]);
|
|
39
39
|
}
|
|
40
40
|
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","names":["transformBinaryCoords","binaryFeatures","transformCoordinate","points","transformBinaryGeometryPositions","lines","polygons","binaryGeometry","fn","positions","i","value","length","size","coord","Array","from","subarray","transformedCoord","set","transformGeoJsonCoords","features","feature","geometry","coordinates","coordMap","array","isCoord","map","item","Number","isFinite"],"sources":["../../../src/lib/transform.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"transform.js","names":["transformBinaryCoords","binaryFeatures","transformCoordinate","points","transformBinaryGeometryPositions","lines","polygons","binaryGeometry","fn","positions","i","value","length","size","coord","Array","from","subarray","transformedCoord","set","transformGeoJsonCoords","features","feature","geometry","coordinates","coordMap","array","isCoord","map","item","isArray","Number","isFinite"],"sources":["../../../src/lib/transform.ts"],"sourcesContent":["import type {BinaryFeatureCollection, BinaryGeometry, Feature} from '@loaders.gl/schema';\n\ntype TransformCoordinate = (coord: number[]) => number[];\n\n/**\n * Apply transformation to every coordinate of binary features\n * @param binaryFeatures binary features\n * @param transformCoordinate Function to call on each coordinate\n * @return Transformed binary features\n */\nexport function transformBinaryCoords(\n binaryFeatures: BinaryFeatureCollection,\n transformCoordinate: TransformCoordinate\n): BinaryFeatureCollection {\n if (binaryFeatures.points) {\n transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);\n }\n if (binaryFeatures.lines) {\n transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);\n }\n if (binaryFeatures.polygons) {\n transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);\n }\n return binaryFeatures;\n}\n\n/** Transform one binary geometry */\nfunction transformBinaryGeometryPositions(binaryGeometry: BinaryGeometry, fn: TransformCoordinate) {\n const {positions} = binaryGeometry;\n for (let i = 0; i < positions.value.length; i += positions.size) {\n // @ts-ignore inclusion of bigint causes problems\n const coord: Array<number> = Array.from(positions.value.subarray(i, i + positions.size));\n const transformedCoord = fn(coord);\n // @ts-ignore typescript typing for .set seems to require bigint?\n positions.value.set(transformedCoord, i);\n }\n}\n\n/**\n * Apply transformation to every coordinate of GeoJSON features\n *\n * @param features Array of GeoJSON features\n * @param fn Function to call on each coordinate\n * @return Transformed GeoJSON features\n */\nexport function transformGeoJsonCoords(\n features: Feature[],\n fn: (coord: number[]) => number[]\n): Feature[] {\n for (const feature of features) {\n // @ts-ignore\n feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);\n }\n return features;\n}\n\nfunction coordMap(array: unknown, fn: (coord: number[]) => number[]): unknown[] {\n if (isCoord(array)) {\n return fn(array as number[]);\n }\n\n return (array as unknown[]).map((item) => {\n return coordMap(item, fn);\n });\n}\n\nfunction isCoord(array: unknown) {\n return Array.isArray(array) && Number.isFinite(array[0]) && Number.isFinite(array[1]);\n}\n"],"mappings":"AAUA,OAAO,SAASA,qBAAqBA,CACnCC,cAAuC,EACvCC,mBAAwC,EACf;EACzB,IAAID,cAAc,CAACE,MAAM,EAAE;IACzBC,gCAAgC,CAACH,cAAc,CAACE,MAAM,EAAED,mBAAmB,CAAC;EAC9E;EACA,IAAID,cAAc,CAACI,KAAK,EAAE;IACxBD,gCAAgC,CAACH,cAAc,CAACI,KAAK,EAAEH,mBAAmB,CAAC;EAC7E;EACA,IAAID,cAAc,CAACK,QAAQ,EAAE;IAC3BF,gCAAgC,CAACH,cAAc,CAACK,QAAQ,EAAEJ,mBAAmB,CAAC;EAChF;EACA,OAAOD,cAAc;AACvB;AAGA,SAASG,gCAAgCA,CAACG,cAA8B,EAAEC,EAAuB,EAAE;EACjG,MAAM;IAACC;EAAS,CAAC,GAAGF,cAAc;EAClC,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACE,KAAK,CAACC,MAAM,EAAEF,CAAC,IAAID,SAAS,CAACI,IAAI,EAAE;IAE/D,MAAMC,KAAoB,GAAGC,KAAK,CAACC,IAAI,CAACP,SAAS,CAACE,KAAK,CAACM,QAAQ,CAACP,CAAC,EAAEA,CAAC,GAAGD,SAAS,CAACI,IAAI,CAAC,CAAC;IACxF,MAAMK,gBAAgB,GAAGV,EAAE,CAACM,KAAK,CAAC;IAElCL,SAAS,CAACE,KAAK,CAACQ,GAAG,CAACD,gBAAgB,EAAER,CAAC,CAAC;EAC1C;AACF;AASA,OAAO,SAASU,sBAAsBA,CACpCC,QAAmB,EACnBb,EAAiC,EACtB;EACX,KAAK,MAAMc,OAAO,IAAID,QAAQ,EAAE;IAE9BC,OAAO,CAACC,QAAQ,CAACC,WAAW,GAAGC,QAAQ,CAACH,OAAO,CAACC,QAAQ,CAACC,WAAW,EAAEhB,EAAE,CAAC;EAC3E;EACA,OAAOa,QAAQ;AACjB;AAEA,SAASI,QAAQA,CAACC,KAAc,EAAElB,EAAiC,EAAa;EAC9E,IAAImB,OAAO,CAACD,KAAK,CAAC,EAAE;IAClB,OAAOlB,EAAE,CAACkB,KAAiB,CAAC;EAC9B;EAEA,OAAQA,KAAK,CAAeE,GAAG,CAAEC,IAAI,IAAK;IACxC,OAAOJ,QAAQ,CAACI,IAAI,EAAErB,EAAE,CAAC;EAC3B,CAAC,CAAC;AACJ;AAEA,SAASmB,OAAOA,CAACD,KAAc,EAAE;EAC/B,OAAOX,KAAK,CAACe,OAAO,CAACJ,KAAK,CAAC,IAAIK,MAAM,CAACC,QAAQ,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC,IAAIK,MAAM,CAACC,QAAQ,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC;AACvF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { flatGeojsonToBinary } from './lib/flat-geojson-to-binary';
|
|
2
2
|
export { geojsonToBinary } from './lib/geojson-to-binary';
|
|
3
3
|
export { geojsonToFlatGeojson } from './lib/geojson-to-flat-geojson';
|
|
4
|
-
export { binaryToGeojson,
|
|
4
|
+
export { binaryToGeojson, binaryToGeometry } from './lib/binary-to-geojson';
|
|
5
5
|
export { transformBinaryCoords, transformGeoJsonCoords } from './lib/transform';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAC,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAC,qBAAqB,EAAE,sBAAsB,EAAC,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryGeometry,
|
|
1
|
+
import type { BinaryGeometry, BinaryGeometryType, BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
2
2
|
import type { Feature, Geometry } from '@loaders.gl/schema';
|
|
3
3
|
type BinaryToGeoJsonOptions = {
|
|
4
4
|
type?: BinaryGeometryType;
|
|
@@ -12,9 +12,7 @@ type BinaryToGeoJsonOptions = {
|
|
|
12
12
|
* @param options.featureId Global feature id. If specified, only a single feature is extracted
|
|
13
13
|
* @return GeoJSON objects
|
|
14
14
|
*/
|
|
15
|
-
export declare function binaryToGeojson(data:
|
|
16
|
-
/** @deprecated use `binaryToGeojson` or `binaryToGeometry` instead */
|
|
17
|
-
export declare function binaryToGeoJson(data: BinaryGeometry | BinaryFeatures, type?: BinaryGeometryType, format?: 'feature' | 'geometry'): Geometry | Feature[];
|
|
15
|
+
export declare function binaryToGeojson(data: BinaryFeatureCollection, options?: BinaryToGeoJsonOptions): Feature[] | Feature;
|
|
18
16
|
/** Parse input binary data and return a valid GeoJSON geometry object */
|
|
19
17
|
export declare function binaryToGeometry(data: BinaryGeometry, startIndex?: number, endIndex?: number): Geometry;
|
|
20
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary-to-geojson.d.ts","sourceRoot":"","sources":["../../src/lib/binary-to-geojson.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"binary-to-geojson.d.ts","sourceRoot":"","sources":["../../src/lib/binary-to-geojson.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAIlB,uBAAuB,EAMxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,OAAO,EAAE,QAAQ,EAA8B,MAAM,oBAAoB,CAAC;AAavF,KAAK,sBAAsB,GAAG;IAC5B,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,uBAAuB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,EAAE,GAAG,OAAO,CAMrB;AAyDD,yEAAyE;AACzE,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,QAAQ,CAYV"}
|
|
@@ -44,7 +44,7 @@ export type Polygons = {
|
|
|
44
44
|
positions: Float32Array | Float64Array;
|
|
45
45
|
polygonIndices: Uint16Array | Uint32Array;
|
|
46
46
|
primitivePolygonIndices: Uint16Array | Uint32Array;
|
|
47
|
-
triangles
|
|
47
|
+
triangles?: number[];
|
|
48
48
|
globalFeatureIds: Uint16Array | Uint32Array;
|
|
49
49
|
featureIds: Uint16Array | Uint32Array;
|
|
50
50
|
numericProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary-types.d.ts","sourceRoot":"","sources":["../../src/lib/flat-geojson-to-binary-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GACvB,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IACvC,gBAAgB,EAAE,WAAW,GAAG,WAAW,CAAC;IAC5C,UAAU,EAAE,WAAW,GAAG,WAAW,CAAC;IACtC,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAC;IAC1C,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB,EAAE,CAAC;CACL,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IACvC,WAAW,EAAE,WAAW,GAAG,WAAW,CAAC;IACvC,gBAAgB,EAAE,WAAW,GAAG,WAAW,CAAC;IAC5C,UAAU,EAAE,WAAW,GAAG,WAAW,CAAC;IACtC,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAC;IAC1C,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,MAAM,EAAE;QACN,E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AE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAC;IAC1C,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB,EAAE,CAAC;CACL,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IACvC,cAAc,EAAE,WAAW,GAAG,WAAW,CAAC;IAC1C,uBAAuB,EAAE,WAAW,GAAG,WAAW,CAAC;IACnD,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,gBAAgB,EAAE,WAAW,GAAG,WAAW,CAAC;IAC5C,UAAU,EAAE,WAAW,GAAG,WAAW,CAAC;IACtC,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAC;IAC1C,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB,EAAE,CAAC;CACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BinaryFeatureCollection, FlatFeature, GeojsonGeometryInfo } from '@loaders.gl/schema';
|
|
2
2
|
import { PropArrayConstructor } from './flat-geojson-to-binary-types';
|
|
3
3
|
/**
|
|
4
4
|
* Convert binary features to flat binary arrays. Similar to
|
|
@@ -13,13 +13,14 @@ import { PropArrayConstructor } from './flat-geojson-to-binary-types';
|
|
|
13
13
|
* @param options
|
|
14
14
|
* @returns filled arrays
|
|
15
15
|
*/
|
|
16
|
-
export declare function flatGeojsonToBinary(features: FlatFeature[], geometryInfo: GeojsonGeometryInfo, options?: FlatGeojsonToBinaryOptions):
|
|
16
|
+
export declare function flatGeojsonToBinary(features: FlatFeature[], geometryInfo: GeojsonGeometryInfo, options?: FlatGeojsonToBinaryOptions): BinaryFeatureCollection;
|
|
17
17
|
/**
|
|
18
18
|
* Options for `flatGeojsonToBinary`
|
|
19
19
|
*/
|
|
20
20
|
export type FlatGeojsonToBinaryOptions = {
|
|
21
21
|
numericPropKeys?: string[];
|
|
22
22
|
PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;
|
|
23
|
+
triangulate?: boolean;
|
|
23
24
|
};
|
|
24
25
|
export declare const TEST_EXPORTS: {
|
|
25
26
|
extractNumericPropTypes: typeof extractNumericPropTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary.d.ts","sourceRoot":"","sources":["../../src/lib/flat-geojson-to-binary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,
|
|
1
|
+
{"version":3,"file":"flat-geojson-to-binary.d.ts","sourceRoot":"","sources":["../../src/lib/flat-geojson-to-binary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,WAAW,EAIX,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,oBAAoB,EAA0B,MAAM,gCAAgC,CAAC;AAE7F;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,0BAA0B,2BAgBrC;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,CAAC;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF;;;;;GAKG;AACH,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG;IACzD,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACrC,CAgBA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Feature } from '@loaders.gl/schema';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BinaryFeatureCollection } from '@loaders.gl/schema';
|
|
3
3
|
/**
|
|
4
4
|
* Options for `geojsonToBinary`
|
|
5
5
|
*/
|
|
@@ -7,6 +7,7 @@ export type GeojsonToBinaryOptions = {
|
|
|
7
7
|
fixRingWinding: boolean;
|
|
8
8
|
numericPropKeys?: string[];
|
|
9
9
|
PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;
|
|
10
|
+
triangulate?: boolean;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
12
13
|
* Convert GeoJSON features to flat binary arrays
|
|
@@ -15,5 +16,5 @@ export type GeojsonToBinaryOptions = {
|
|
|
15
16
|
* @param options
|
|
16
17
|
* @returns features in binary format, grouped by geometry type
|
|
17
18
|
*/
|
|
18
|
-
export declare function geojsonToBinary(features: Feature[], options?: GeojsonToBinaryOptions):
|
|
19
|
+
export declare function geojsonToBinary(features: Feature[], options?: GeojsonToBinaryOptions): BinaryFeatureCollection;
|
|
19
20
|
//# sourceMappingURL=geojson-to-binary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-binary.d.ts","sourceRoot":"","sources":["../../src/lib/geojson-to-binary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"geojson-to-binary.d.ts","sourceRoot":"","sources":["../../src/lib/geojson-to-binary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAMhE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,CAAC;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,sBAAkE,GAC1E,uBAAuB,CAUzB"}
|
package/dist/lib/transform.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BinaryFeatureCollection, Feature } from '@loaders.gl/schema';
|
|
2
2
|
type TransformCoordinate = (coord: number[]) => number[];
|
|
3
3
|
/**
|
|
4
4
|
* Apply transformation to every coordinate of binary features
|
|
@@ -6,7 +6,7 @@ type TransformCoordinate = (coord: number[]) => number[];
|
|
|
6
6
|
* @param transformCoordinate Function to call on each coordinate
|
|
7
7
|
* @return Transformed binary features
|
|
8
8
|
*/
|
|
9
|
-
export declare function transformBinaryCoords(binaryFeatures:
|
|
9
|
+
export declare function transformBinaryCoords(binaryFeatures: BinaryFeatureCollection, transformCoordinate: TransformCoordinate): BinaryFeatureCollection;
|
|
10
10
|
/**
|
|
11
11
|
* Apply transformation to every coordinate of GeoJSON features
|
|
12
12
|
*
|
|
@@ -14,6 +14,6 @@ export declare function transformBinaryCoords(binaryFeatures: BinaryFeatures, tr
|
|
|
14
14
|
* @param fn Function to call on each coordinate
|
|
15
15
|
* @return Transformed GeoJSON features
|
|
16
16
|
*/
|
|
17
|
-
export declare function transformGeoJsonCoords(features:
|
|
17
|
+
export declare function transformGeoJsonCoords(features: Feature[], fn: (coord: number[]) => number[]): Feature[];
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/lib/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/lib/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAkB,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAEzF,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,uBAAuB,EACvC,mBAAmB,EAAE,mBAAmB,GACvC,uBAAuB,CAWzB;AAcD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,OAAO,EAAE,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,GAChC,OAAO,EAAE,CAMX"}
|