@octostar/map-component 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -8612,6 +8612,25 @@ function geometryEquals(a, b) {
8612
8612
  b.coordinates
8613
8613
  );
8614
8614
  }
8615
+ function isPaintableGeometry(geometry) {
8616
+ switch (geometry.type) {
8617
+ case "Point":
8618
+ return isPosition(geometry.coordinates);
8619
+ case "MultiPoint":
8620
+ case "LineString":
8621
+ return geometry.coordinates.every(isPosition);
8622
+ case "MultiLineString":
8623
+ case "Polygon":
8624
+ return geometry.coordinates.every((line) => line.every(isPosition));
8625
+ case "MultiPolygon":
8626
+ return geometry.coordinates.every((polygon) => polygon.every((ring) => ring.every(isPosition)));
8627
+ case "GeometryCollection":
8628
+ return geometry.geometries.every(isPaintableGeometry);
8629
+ }
8630
+ }
8631
+ function isPosition(position) {
8632
+ return Array.isArray(position) && typeof position[0] === "number" && typeof position[1] === "number";
8633
+ }
8615
8634
  function prepareFeaturesForLayer(input, caller, cap) {
8616
8635
  const logging = mapPerfLogEnabled();
8617
8636
  const started = logging ? performance.now() : 0;
@@ -10265,7 +10284,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10265
10284
  try {
10266
10285
  const source = map.current.getSource("custom-features");
10267
10286
  if (!source) return;
10268
- const drawFeatures = draw.current ? draw.current.getAll() : { type: "FeatureCollection", features: [] };
10287
+ const drawFeatures = (draw.current ? draw.current.getAll().features : []).filter((f) => isPaintableGeometry(f.geometry));
10269
10288
  const timelineWindow = timelineWindowRef.current;
10270
10289
  const currentLayers = layersRef.current;
10271
10290
  const isLayerVisible = (layer) => {
@@ -10278,12 +10297,12 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10278
10297
  if (isShardEligible(layer, count, shardSizeRef.current)) shardedLayerIds.add(layer.id);
10279
10298
  });
10280
10299
  shardedLayerIdsRef.current = shardedLayerIds;
10281
- const allFeatures = [...drawFeatures.features];
10300
+ const allFeatures = [...drawFeatures];
10282
10301
  const sharedSlices = [];
10283
10302
  const addSlice = (features) => {
10284
10303
  if (features.length > 0) sharedSlices.push({ features, start: 0, end: features.length });
10285
10304
  };
10286
- addSlice(drawFeatures.features);
10305
+ addSlice(drawFeatures);
10287
10306
  readOnlyFeatures.current.forEach((features, layerId) => {
10288
10307
  if (shardedLayerIds.has(layerId)) return;
10289
10308
  const layer = currentLayers.find((l) => l.id === layerId);
@@ -10363,7 +10382,7 @@ const MapEditorCanvas = react.forwardRef(function MapEditorCanvas2({
10363
10382
  tracePointIds,
10364
10383
  tracePointColors
10365
10384
  };
10366
- const drawFeatureCount = drawFeatures.features.length;
10385
+ const drawFeatureCount = drawFeatures.length;
10367
10386
  const sourceData = {
10368
10387
  type: "FeatureCollection",
10369
10388
  features: allFeatures.map((f, i) => {