export function queryFeatures(bbox, features) {
  const [xmin, ymin, xmax, ymax] = bbox.map(Number);
  if (xmin > xmax || ymin > ymax) throw new Error('invalid bbox');
  const matches = features.filter((feature) => xmin <= Number(feature.x) && Number(feature.x) <= xmax && ymin <= Number(feature.y) && Number(feature.y) <= ymax);
  return { type: 'FeatureCollection', count: matches.length, features: matches.map((item) => ({ type: 'Feature', id: item.id, properties: { feature_type: item.type }, geometry: { type: 'Point', coordinates: [item.x, item.y] } })) };
}
