@proximap/core 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -114,7 +114,7 @@ function haversineMeters(a2, b) {
114
114
  }
115
115
  function formatDistance(meters) {
116
116
  if (!Number.isFinite(meters) || meters < 0) return "\u2014";
117
- if (meters < 1e3) return `${Math.round(meters)} m`;
117
+ if (Math.round(meters) < 1e3) return `${Math.round(meters)} m`;
118
118
  const km = meters / 1e3;
119
119
  return `${km < 10 ? km.toFixed(1) : Math.round(km)} km`;
120
120
  }
@@ -720,6 +720,7 @@ function hasUnsupported(s) {
720
720
  }
721
721
  function buildSegments(input) {
722
722
  const own = new Array(7).fill(void 0);
723
+ let applied = false;
723
724
  for (const rulePart of input.split(";")) {
724
725
  const rule = rulePart.trim();
725
726
  if (!rule) continue;
@@ -727,7 +728,9 @@ function buildSegments(input) {
727
728
  if (parsed === "unknown") return null;
728
729
  if (parsed === null) continue;
729
730
  for (const day of parsed.days) own[day] = parsed.intervals;
731
+ applied = true;
730
732
  }
733
+ if (!applied) return null;
731
734
  const segments = Array.from({ length: 7 }, () => []);
732
735
  for (let day = 0; day < 7; day++) {
733
736
  const intervals = own[day];
@@ -1251,7 +1254,7 @@ var OsrmRoutingProvider = class {
1251
1254
  var clamp01 = (n) => Math.min(1, Math.max(0, n));
1252
1255
  function defaultScorer(weights) {
1253
1256
  return ({ poi, distanceMeters, radiusMeters }) => {
1254
- const proximity = 1 - clamp01(distanceMeters / radiusMeters);
1257
+ const proximity = 1 - clamp01(distanceMeters / Math.max(radiusMeters, 1));
1255
1258
  const completeness = poi.name ? 0.05 : 0;
1256
1259
  const weight = weights?.[poi.category] ?? 1;
1257
1260
  return (proximity + completeness) * weight;
@@ -1366,10 +1369,10 @@ function matchesFacets(tags, predicates) {
1366
1369
  var clamp012 = (n) => Math.min(1, Math.max(0, n));
1367
1370
  function accessibleScorer() {
1368
1371
  return ({ poi, distanceMeters, radiusMeters }) => {
1369
- const proximity = 1 - clamp012(distanceMeters / radiusMeters);
1372
+ const proximity = 1 - clamp012(distanceMeters / Math.max(radiusMeters, 1));
1370
1373
  const wheelchair = (poi.tags.wheelchair ?? "").toLowerCase();
1371
1374
  const tierBase = wheelchair === "yes" ? 0.66 : wheelchair === "limited" ? 0.33 : 0;
1372
- return tierBase + proximity * 0.33;
1375
+ return tierBase + proximity * 0.32;
1373
1376
  };
1374
1377
  }
1375
1378
 
@@ -1632,7 +1635,9 @@ async function reachableAmenities(query, options) {
1632
1635
  const ranked = {
1633
1636
  ...entry.poi,
1634
1637
  distanceMeters: haversineMeters(origin.location, entry.poi.location),
1635
- score: entry.metric ? Math.round((1 - entry.metric.seconds / budgetSeconds) * 100) / 100 : 0,
1638
+ // Clamp to [0, 1]: an isochrone can enclose a POI whose matrix travel
1639
+ // time still exceeds the budget, which would otherwise score negative.
1640
+ score: entry.metric ? Math.max(0, Math.round((1 - entry.metric.seconds / budgetSeconds) * 100) / 100) : 0,
1636
1641
  rank: index + 1
1637
1642
  };
1638
1643
  if (entry.metric) {
@@ -2158,7 +2163,7 @@ var DatasetPlacesProvider = class {
2158
2163
  };
2159
2164
 
2160
2165
  // src/index.ts
2161
- var VERSION = "1.0.0";
2166
+ var VERSION = "1.0.1";
2162
2167
  // Annotate the CommonJS export names for ESM import in node:
2163
2168
  0 && (module.exports = {
2164
2169
  CATEGORIES,