@loaders.gl/gis
Advanced tools
Comparing version 3.4.8 to 3.4.9
@@ -25,3 +25,4 @@ "use strict"; | ||
numericPropKeys: options && options.numericPropKeys || numericPropKeys, | ||
PositionDataType: options ? options.PositionDataType : Float32Array | ||
PositionDataType: options ? options.PositionDataType : Float32Array, | ||
triangulate: options ? options.triangulate : true | ||
}); | ||
@@ -69,3 +70,5 @@ } | ||
_options$PositionData = options.PositionDataType, | ||
PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData; | ||
PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData, | ||
_options$triangulate = options.triangulate, | ||
triangulate = _options$triangulate === void 0 ? true : _options$triangulate; | ||
var hasGlobalId = features[0] && 'id' in features[0]; | ||
@@ -97,3 +100,2 @@ var GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array; | ||
positions: new PositionDataType(polygonPositionsCount * coordLength), | ||
triangles: [], | ||
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount), | ||
@@ -105,2 +107,5 @@ featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount), | ||
}; | ||
if (triangulate) { | ||
polygons.triangles = []; | ||
} | ||
for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) { | ||
@@ -238,2 +243,5 @@ var object = _arr[_i]; | ||
coordLength = _ref.coordLength; | ||
if (!polygons.triangles) { | ||
return; | ||
} | ||
var start = startPosition * coordLength; | ||
@@ -262,3 +270,3 @@ var end = endPosition * coordLength; | ||
function makeAccessorObjects(points, lines, polygons, coordLength) { | ||
return { | ||
var binaryFeatures = { | ||
points: _objectSpread(_objectSpread({}, points), {}, { | ||
@@ -311,6 +319,2 @@ positions: { | ||
}, | ||
triangles: { | ||
value: new Uint32Array(polygons.triangles), | ||
size: 1 | ||
}, | ||
globalFeatureIds: { | ||
@@ -327,2 +331,9 @@ value: polygons.globalFeatureIds, | ||
}; | ||
if (polygons.triangles) { | ||
binaryFeatures.polygons.triangles = { | ||
value: new Uint32Array(polygons.triangles), | ||
size: 1 | ||
}; | ||
} | ||
return binaryFeatures; | ||
} | ||
@@ -329,0 +340,0 @@ function fillNumericProperties(object, properties, index, length) { |
@@ -12,3 +12,4 @@ "use strict"; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { | ||
fixRingWinding: true | ||
fixRingWinding: true, | ||
triangulate: true | ||
}; | ||
@@ -24,5 +25,6 @@ var geometryInfo = (0, _extractGeometryInfo.extractGeometryInfo)(features); | ||
numericPropKeys: options.numericPropKeys, | ||
PositionDataType: options.PositionDataType || Float32Array | ||
PositionDataType: options.PositionDataType || Float32Array, | ||
triangulate: options.triangulate | ||
}); | ||
} | ||
//# sourceMappingURL=geojson-to-binary.js.map |
@@ -10,3 +10,4 @@ import { earcut } from '@math.gl/polygon'; | ||
numericPropKeys: options && options.numericPropKeys || numericPropKeys, | ||
PositionDataType: options ? options.PositionDataType : Float32Array | ||
PositionDataType: options ? options.PositionDataType : Float32Array, | ||
triangulate: options ? options.triangulate : true | ||
}); | ||
@@ -45,3 +46,4 @@ } | ||
numericPropKeys = [], | ||
PositionDataType = Float32Array | ||
PositionDataType = Float32Array, | ||
triangulate = true | ||
} = options; | ||
@@ -74,3 +76,2 @@ const hasGlobalId = features[0] && 'id' in features[0]; | ||
positions: new PositionDataType(polygonPositionsCount * coordLength), | ||
triangles: [], | ||
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount), | ||
@@ -82,2 +83,5 @@ featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount), | ||
}; | ||
if (triangulate) { | ||
polygons.triangles = []; | ||
} | ||
for (const object of [points, lines, polygons]) { | ||
@@ -198,2 +202,5 @@ for (const propName of numericPropKeys) { | ||
} = _ref; | ||
if (!polygons.triangles) { | ||
return; | ||
} | ||
const start = startPosition * coordLength; | ||
@@ -220,3 +227,3 @@ const end = endPosition * coordLength; | ||
function makeAccessorObjects(points, lines, polygons, coordLength) { | ||
return { | ||
const binaryFeatures = { | ||
points: { | ||
@@ -272,6 +279,2 @@ ...points, | ||
}, | ||
triangles: { | ||
value: new Uint32Array(polygons.triangles), | ||
size: 1 | ||
}, | ||
globalFeatureIds: { | ||
@@ -288,2 +291,9 @@ value: polygons.globalFeatureIds, | ||
}; | ||
if (polygons.triangles) { | ||
binaryFeatures.polygons.triangles = { | ||
value: new Uint32Array(polygons.triangles), | ||
size: 1 | ||
}; | ||
} | ||
return binaryFeatures; | ||
} | ||
@@ -290,0 +300,0 @@ function fillNumericProperties(object, properties, index, length) { |
@@ -6,3 +6,4 @@ import { extractGeometryInfo } from './extract-geometry-info'; | ||
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { | ||
fixRingWinding: true | ||
fixRingWinding: true, | ||
triangulate: true | ||
}; | ||
@@ -20,5 +21,6 @@ const geometryInfo = extractGeometryInfo(features); | ||
numericPropKeys: options.numericPropKeys, | ||
PositionDataType: options.PositionDataType || Float32Array | ||
PositionDataType: options.PositionDataType || Float32Array, | ||
triangulate: options.triangulate | ||
}); | ||
} | ||
//# sourceMappingURL=geojson-to-binary.js.map |
@@ -47,3 +47,3 @@ import type { TypedArray } from '@loaders.gl/schema'; | ||
primitivePolygonIndices: Uint16Array | Uint32Array; | ||
triangles: number[]; | ||
triangles?: number[]; | ||
globalFeatureIds: Uint16Array | Uint32Array; | ||
@@ -50,0 +50,0 @@ featureIds: Uint16Array | Uint32Array; |
@@ -23,2 +23,3 @@ import type { BinaryFeatures, FlatFeature, GeojsonGeometryInfo } from '@loaders.gl/schema'; | ||
PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor; | ||
triangulate?: boolean; | ||
}; | ||
@@ -25,0 +26,0 @@ export declare const TEST_EXPORTS: { |
@@ -27,3 +27,4 @@ "use strict"; | ||
numericPropKeys: (options && options.numericPropKeys) || numericPropKeys, | ||
PositionDataType: options ? options.PositionDataType : Float32Array | ||
PositionDataType: options ? options.PositionDataType : Float32Array, | ||
triangulate: options ? options.triangulate : true | ||
}); | ||
@@ -68,3 +69,3 @@ } | ||
const { pointPositionsCount, pointFeaturesCount, linePositionsCount, linePathsCount, lineFeaturesCount, polygonPositionsCount, polygonObjectsCount, polygonRingsCount, polygonFeaturesCount, propArrayTypes, coordLength } = geometryInfo; | ||
const { numericPropKeys = [], PositionDataType = Float32Array } = options; | ||
const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options; | ||
const hasGlobalId = features[0] && 'id' in features[0]; | ||
@@ -106,3 +107,2 @@ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array; | ||
positions: new PositionDataType(polygonPositionsCount * coordLength), | ||
triangles: [], | ||
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount), | ||
@@ -116,2 +116,5 @@ featureIds: polygonFeaturesCount > 65535 | ||
}; | ||
if (triangulate) { | ||
polygons.triangles = []; | ||
} | ||
// Instantiate numeric properties arrays; one value per vertex | ||
@@ -267,2 +270,5 @@ for (const object of [points, lines, polygons]) { | ||
function triangulatePolygon(polygons, areas, indices, { startPosition, endPosition, coordLength }) { | ||
if (!polygons.triangles) { | ||
return; | ||
} | ||
const start = startPosition * coordLength; | ||
@@ -307,3 +313,3 @@ const end = endPosition * coordLength; | ||
function makeAccessorObjects(points, lines, polygons, coordLength) { | ||
return { | ||
const binaryFeatures = { | ||
points: { | ||
@@ -329,3 +335,2 @@ ...points, | ||
primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 }, | ||
triangles: { value: new Uint32Array(polygons.triangles), size: 1 }, | ||
globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 }, | ||
@@ -336,2 +341,6 @@ featureIds: { value: polygons.featureIds, size: 1 }, | ||
}; | ||
if (polygons.triangles) { | ||
binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 }; | ||
} | ||
return binaryFeatures; | ||
} | ||
@@ -338,0 +347,0 @@ /** |
@@ -10,2 +10,3 @@ import type { Feature } from '@loaders.gl/schema'; | ||
PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor; | ||
triangulate?: boolean; | ||
}; | ||
@@ -12,0 +13,0 @@ /** |
@@ -14,3 +14,3 @@ "use strict"; | ||
*/ | ||
function geojsonToBinary(features, options = { fixRingWinding: true }) { | ||
function geojsonToBinary(features, options = { fixRingWinding: true, triangulate: true }) { | ||
const geometryInfo = (0, extract_geometry_info_1.extractGeometryInfo)(features); | ||
@@ -22,5 +22,6 @@ const coordLength = geometryInfo.coordLength; | ||
numericPropKeys: options.numericPropKeys, | ||
PositionDataType: options.PositionDataType || Float32Array | ||
PositionDataType: options.PositionDataType || Float32Array, | ||
triangulate: options.triangulate | ||
}); | ||
} | ||
exports.geojsonToBinary = geojsonToBinary; |
{ | ||
"name": "@loaders.gl/gis", | ||
"description": "Helpers for GIS category data", | ||
"version": "3.4.8", | ||
"version": "3.4.9", | ||
"license": "MIT", | ||
@@ -27,4 +27,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@loaders.gl/loader-utils": "3.4.8", | ||
"@loaders.gl/schema": "3.4.8", | ||
"@loaders.gl/loader-utils": "3.4.9", | ||
"@loaders.gl/schema": "3.4.9", | ||
"@mapbox/vector-tile": "^1.3.1", | ||
@@ -37,3 +37,3 @@ "@math.gl/polygon": "^3.5.1", | ||
}, | ||
"gitHead": "1c4c0c794713d3701e5fe9a577b51b9b185c2e69" | ||
"gitHead": "8df7484834897fa5ac8e065487d99d02f96e9560" | ||
} |
@@ -50,3 +50,3 @@ import type {TypedArray} from '@loaders.gl/schema'; | ||
primitivePolygonIndices: Uint16Array | Uint32Array; | ||
triangles: number[]; | ||
triangles?: number[]; | ||
globalFeatureIds: Uint16Array | Uint32Array; | ||
@@ -53,0 +53,0 @@ featureIds: Uint16Array | Uint32Array; |
@@ -6,2 +6,3 @@ /* eslint-disable indent */ | ||
BinaryFeatures, | ||
BinaryPolygonFeatures, | ||
FlatFeature, | ||
@@ -44,3 +45,4 @@ FlatPoint, | ||
numericPropKeys: (options && options.numericPropKeys) || numericPropKeys, | ||
PositionDataType: options ? options.PositionDataType : Float32Array | ||
PositionDataType: options ? options.PositionDataType : Float32Array, | ||
triangulate: options ? options.triangulate : true | ||
} | ||
@@ -56,2 +58,3 @@ ); | ||
PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor; | ||
triangulate?: boolean; | ||
}; | ||
@@ -118,3 +121,3 @@ | ||
} = geometryInfo; | ||
const {numericPropKeys = [], PositionDataType = Float32Array} = options; | ||
const {numericPropKeys = [], PositionDataType = Float32Array, triangulate = true} = options; | ||
const hasGlobalId = features[0] && 'id' in features[0]; | ||
@@ -161,3 +164,2 @@ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array; | ||
positions: new PositionDataType(polygonPositionsCount * coordLength), | ||
triangles: [], | ||
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount), | ||
@@ -173,2 +175,6 @@ featureIds: | ||
if (triangulate) { | ||
polygons.triangles = []; | ||
} | ||
// Instantiate numeric properties arrays; one value per vertex | ||
@@ -432,2 +438,6 @@ for (const object of [points, lines, polygons]) { | ||
): void { | ||
if (!polygons.triangles) { | ||
return; | ||
} | ||
const start = startPosition * coordLength; | ||
@@ -486,3 +496,3 @@ const end = endPosition * coordLength; | ||
): BinaryFeatures { | ||
return { | ||
const binaryFeatures = { | ||
points: { | ||
@@ -508,8 +518,13 @@ ...points, | ||
primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1}, | ||
triangles: {value: new Uint32Array(polygons.triangles), size: 1}, | ||
globalFeatureIds: {value: polygons.globalFeatureIds, size: 1}, | ||
featureIds: {value: polygons.featureIds, size: 1}, | ||
numericProps: wrapProps(polygons.numericProps, 1) | ||
} | ||
} as BinaryPolygonFeatures | ||
}; | ||
if (polygons.triangles) { | ||
binaryFeatures.polygons.triangles = {value: new Uint32Array(polygons.triangles), size: 1}; | ||
} | ||
return binaryFeatures; | ||
} | ||
@@ -516,0 +531,0 @@ |
@@ -15,2 +15,3 @@ import type {Feature} from '@loaders.gl/schema'; | ||
PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor; | ||
triangulate?: boolean; | ||
}; | ||
@@ -27,3 +28,3 @@ | ||
features: Feature[], | ||
options: GeojsonToBinaryOptions = {fixRingWinding: true} | ||
options: GeojsonToBinaryOptions = {fixRingWinding: true, triangulate: true} | ||
): BinaryFeatures { | ||
@@ -36,4 +37,5 @@ const geometryInfo = extractGeometryInfo(features); | ||
numericPropKeys: options.numericPropKeys, | ||
PositionDataType: options.PositionDataType || Float32Array | ||
PositionDataType: options.PositionDataType || Float32Array, | ||
triangulate: options.triangulate | ||
}); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
326670
4222
+ Added@loaders.gl/loader-utils@3.4.9(transitive)
+ Added@loaders.gl/schema@3.4.9(transitive)
+ Added@loaders.gl/worker-utils@3.4.9(transitive)
- Removed@loaders.gl/loader-utils@3.4.8(transitive)
- Removed@loaders.gl/schema@3.4.8(transitive)
- Removed@loaders.gl/worker-utils@3.4.8(transitive)
Updated@loaders.gl/schema@3.4.9