fix(site-finder): normalize POI weighted score to 0..100 on backend (#1486) #1674
3 changed files with 31 additions and 32 deletions
|
|
@ -373,6 +373,7 @@ def test_routing_decay_empty_db(monkeypatch):
|
||||||
monkeypatch.setattr(ors_client, "is_configured", lambda: True)
|
monkeypatch.setattr(ors_client, "is_configured", lambda: True)
|
||||||
result = compute_poi_routing_decay(db, "cad", 56.838, 60.605)
|
result = compute_poi_routing_decay(db, "cad", 56.838, 60.605)
|
||||||
assert result.top_poi == []
|
assert result.top_poi == []
|
||||||
|
assert result.poi_weighted_score == 0.0
|
||||||
|
|
||||||
|
|
||||||
def test_routing_decay_score_spread_wider_than_straight_line(monkeypatch):
|
def test_routing_decay_score_spread_wider_than_straight_line(monkeypatch):
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,8 @@ interface Props {
|
||||||
// ── Component ─────────────────────────────────────────────────────────────────
|
// ── Component ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
export function PoiList2Gis({ items, totalScore }: Props) {
|
export function PoiList2Gis({ items, totalScore }: Props) {
|
||||||
// POI-weighted score is presented as «X / 100», so clamp to 0..100 defensively:
|
// poi_weighted_score is normalized to 0..100 on the backend (#1486).
|
||||||
// the adapter sums round(weight*100) per POI без нормировки и при достаточном
|
// Clamp defensively in case of floating-point edge cases.
|
||||||
// числе POI может выдать >100 → бессмысленное «137 / 100» (#1470). Корневую
|
|
||||||
// нормировку нужно чинить в site-finder-api.ts (useParcelPoiScoreQuery).
|
|
||||||
const displayScore = Math.min(100, Math.max(0, totalScore));
|
const displayScore = Math.min(100, Math.max(0, totalScore));
|
||||||
|
|
||||||
// Top-7, sorted by score_contribution desc
|
// Top-7, sorted by score_contribution desc
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
{
|
{
|
||||||
"cad_num": "66:41:0701045:42",
|
"cad_num": "66:41:0701045:42",
|
||||||
"radius_m": 2000,
|
"radius_m": 2000,
|
||||||
"poi_weighted_score": 72,
|
"poi_weighted_score": 19.9,
|
||||||
"top_poi": [
|
"items": [
|
||||||
|
{
|
||||||
|
"category": "park",
|
||||||
|
"name": "Сквер Попова",
|
||||||
|
"distance_m": 150,
|
||||||
|
"weight": 0.014,
|
||||||
|
"score_contribution": 4.4,
|
||||||
|
"address": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "metro_stop",
|
"category": "metro_stop",
|
||||||
"name": "Площадь 1905 года",
|
"name": "Площадь 1905 года",
|
||||||
"distance_m": 340,
|
"distance_m": 340,
|
||||||
"weight": 0.013559,
|
"weight": 0.013636,
|
||||||
"score_contribution": 22.3,
|
"score_contribution": 4.3,
|
||||||
"address": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"category": "school",
|
|
||||||
"name": "Школа № 32",
|
|
||||||
"distance_m": 480,
|
|
||||||
"weight": 0.00885,
|
|
||||||
"score_contribution": 14.5,
|
|
||||||
"address": null
|
"address": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -24,15 +24,15 @@
|
||||||
"name": "Детский сад № 111",
|
"name": "Детский сад № 111",
|
||||||
"distance_m": 260,
|
"distance_m": 260,
|
||||||
"weight": 0.0125,
|
"weight": 0.0125,
|
||||||
"score_contribution": 12.7,
|
"score_contribution": 4.0,
|
||||||
"address": null
|
"address": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"category": "park",
|
"category": "school",
|
||||||
"name": "Сквер Попова",
|
"name": "Школа № 32",
|
||||||
"distance_m": 150,
|
"distance_m": 480,
|
||||||
"weight": 0.014,
|
"weight": 0.008621,
|
||||||
"score_contribution": 10.8,
|
"score_contribution": 2.7,
|
||||||
"address": null
|
"address": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -40,15 +40,7 @@
|
||||||
"name": "Городская больница № 7",
|
"name": "Городская больница № 7",
|
||||||
"distance_m": 650,
|
"distance_m": 650,
|
||||||
"weight": 0.005333,
|
"weight": 0.005333,
|
||||||
"score_contribution": 8.8,
|
"score_contribution": 1.7,
|
||||||
"address": null
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"category": "shop_mall",
|
|
||||||
"name": "МЕГА Екатеринбург",
|
|
||||||
"distance_m": 1200,
|
|
||||||
"weight": 0.003077,
|
|
||||||
"score_contribution": 5.0,
|
|
||||||
"address": null
|
"address": null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -56,7 +48,15 @@
|
||||||
"name": "Гимназия № 9",
|
"name": "Гимназия № 9",
|
||||||
"distance_m": 820,
|
"distance_m": 820,
|
||||||
"weight": 0.005435,
|
"weight": 0.005435,
|
||||||
"score_contribution": 4.4,
|
"score_contribution": 1.7,
|
||||||
|
"address": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"category": "shop_mall",
|
||||||
|
"name": "МЕГА Екатеринбург",
|
||||||
|
"distance_m": 1200,
|
||||||
|
"weight": 0.003077,
|
||||||
|
"score_contribution": 1.0,
|
||||||
"address": null
|
"address": null
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue