tkadkghdlf commited on
Commit
57d915f
ยท
verified ยท
1 Parent(s): b867b42

Sync DemoService b69959fb13a3a76d8fbee18060c65e6359b49d95

Browse files
api/ai-service/app/api/v1/endpoints/route_generation.py CHANGED
@@ -22,7 +22,7 @@ from app.services.route_display_orientation import attach_card_display_orientati
22
  from app.api.v1.endpoints.route_library import active_outlines
23
 
24
  router = APIRouter(prefix="/ai", tags=["ai"])
25
- SHAPE_DISCOVERY_LABELS = ("dog", "symbol_star", "t_shirt", "heart", "candle", "christmas_tree_trunk", "long_pants")
26
  # Use Uvicorn's configured application logger so generation QA is available
27
  # in container logs without changing the deployment-wide logging setup.
28
  logger = logging.getLogger("uvicorn.error")
@@ -417,7 +417,7 @@ def _run_fast_road_pipeline(
417
  template_kwargs["template_examples"] = examples
418
  elif screened_templates is not None:
419
  template_kwargs["template_examples"] = screened_templates
420
- elif (catalog_entry or selected_label in {"symbol_star", "dog", "heart", "candle", "christmas_tree_trunk", "long_pants"}) and callable(rank_projections):
421
  # Screen every supplied animal/shape outline against this road graph;
422
  # only the best fits enter the expensive shortest-path stage.
423
  template_kwargs["template_examples"] = rank_projections(
@@ -508,7 +508,7 @@ def _run_fast_road_pipeline(
508
  "art_ready": generation_mode == "fast_walk_roads" and bool(selected_label),
509
  "road_connection": route.get("road_connection", "shortest"),
510
  **({"shape_similarity": similarity, "shape_example_index": example_index} if examples else {}),
511
- **({"gpx_similarity": similarity, "gpx_example_index": example_index} if examples and selected_label in {"dog", "symbol_star", "heart", "candle", "christmas_tree_trunk", "long_pants"} else {}),
512
  "target_shape": {
513
  "score": shape_quality,
514
  "route_coverage": shape_quality,
 
22
  from app.api.v1.endpoints.route_library import active_outlines
23
 
24
  router = APIRouter(prefix="/ai", tags=["ai"])
25
+ SHAPE_DISCOVERY_LABELS = ("dog", "symbol_star", "t_shirt", "heart", "candle", "christmas_tree_trunk")
26
  # Use Uvicorn's configured application logger so generation QA is available
27
  # in container logs without changing the deployment-wide logging setup.
28
  logger = logging.getLogger("uvicorn.error")
 
417
  template_kwargs["template_examples"] = examples
418
  elif screened_templates is not None:
419
  template_kwargs["template_examples"] = screened_templates
420
+ elif (catalog_entry or selected_label in {"symbol_star", "dog", "heart", "candle", "christmas_tree_trunk"}) and callable(rank_projections):
421
  # Screen every supplied animal/shape outline against this road graph;
422
  # only the best fits enter the expensive shortest-path stage.
423
  template_kwargs["template_examples"] = rank_projections(
 
508
  "art_ready": generation_mode == "fast_walk_roads" and bool(selected_label),
509
  "road_connection": route.get("road_connection", "shortest"),
510
  **({"shape_similarity": similarity, "shape_example_index": example_index} if examples else {}),
511
+ **({"gpx_similarity": similarity, "gpx_example_index": example_index} if examples and selected_label in {"dog", "symbol_star", "heart", "candle", "christmas_tree_trunk"} else {}),
512
  "target_shape": {
513
  "score": shape_quality,
514
  "route_coverage": shape_quality,
api/ai-service/tests/test_route_generation_recovery.py CHANGED
@@ -242,7 +242,7 @@ def test_shape_priority_uses_road_selected_scales_when_available(monkeypatch):
242
  assert searched == [(7200.0, [outline]), (12400.0, [outline])]
243
 
244
 
245
- @pytest.mark.parametrize("label", ["dog", "heart", "candle", "christmas_tree_trunk", "long_pants"])
246
  def test_opt_in_ranker_only_reorders_near_equal_road_routes(monkeypatch, label):
247
  sys.path.insert(0, str(ROOT / "router" / "ai" / "scripts"))
248
  import gpx_candidate_ranker_runtime as ranker_runtime
@@ -268,7 +268,7 @@ def test_opt_in_ranker_only_reorders_near_equal_road_routes(monkeypatch, label):
268
  assert [route["route_quality"]["shape_similarity"] for route in result["routes"]] == [.948, .95, .8]
269
 
270
 
271
- @pytest.mark.parametrize("label", ["symbol_star", "dog", "heart", "long_pants"])
272
  def test_gpx_search_screens_all_outlines_before_road_routing(monkeypatch, label):
273
  examples = [[(index, 0), (index, 1), (index + 1, 1), (index, 0)] for index in range(1000)]
274
  screened = []
 
242
  assert searched == [(7200.0, [outline]), (12400.0, [outline])]
243
 
244
 
245
+ @pytest.mark.parametrize("label", ["dog", "heart", "candle", "christmas_tree_trunk"])
246
  def test_opt_in_ranker_only_reorders_near_equal_road_routes(monkeypatch, label):
247
  sys.path.insert(0, str(ROOT / "router" / "ai" / "scripts"))
248
  import gpx_candidate_ranker_runtime as ranker_runtime
 
268
  assert [route["route_quality"]["shape_similarity"] for route in result["routes"]] == [.948, .95, .8]
269
 
270
 
271
+ @pytest.mark.parametrize("label", ["symbol_star", "dog", "heart"])
272
  def test_gpx_search_screens_all_outlines_before_road_routing(monkeypatch, label):
273
  examples = [[(index, 0), (index, 1), (index + 1, 1), (index, 0)] for index in range(1000)]
274
  screened = []
main/app/_components/ManualRouteMap.tsx CHANGED
@@ -9,7 +9,6 @@ export type ManualRouteMapProps = {
9
  currentPosition?: ManualRoutePoint | null;
10
  drawnRoutes: ManualRoutePoint[][];
11
  snappedRoutes: ManualRoutePoint[][];
12
- snappedWaypoints?: ManualRoutePoint[];
13
  drawingEnabled: boolean;
14
  onDrawStart?: () => void;
15
  onDrawPoint: (point: ManualRoutePoint) => void;
 
9
  currentPosition?: ManualRoutePoint | null;
10
  drawnRoutes: ManualRoutePoint[][];
11
  snappedRoutes: ManualRoutePoint[][];
 
12
  drawingEnabled: boolean;
13
  onDrawStart?: () => void;
14
  onDrawPoint: (point: ManualRoutePoint) => void;
main/app/_components/ManualRouteMapClient.tsx CHANGED
@@ -217,7 +217,6 @@ export default function ManualRouteMapClient({
217
  currentPosition,
218
  drawnRoutes,
219
  snappedRoutes,
220
- snappedWaypoints = [],
221
  drawingEnabled,
222
  onDrawStart,
223
  onDrawPoint,
@@ -237,18 +236,6 @@ export default function ManualRouteMapClient({
237
  []
238
  );
239
 
240
- const waypointIcon = useMemo(
241
- () =>
242
- divIcon({
243
- className: "manual-waypoint-marker",
244
- html:
245
- '<div style="height:9px;width:9px;border-radius:9999px;background:#c11f1f;border:2px solid white;box-shadow:0 0 0 1px rgba(193,31,31,0.25);"></div>',
246
- iconSize: [9, 9],
247
- iconAnchor: [4.5, 4.5],
248
- }),
249
- []
250
- );
251
-
252
  const hasSnappedRoute = snappedRoutes.some((route) => route.length > 1);
253
  const fitRoutes = useMemo(
254
  () => snappedRoutes.filter((route) => route.length > 1),
@@ -312,14 +299,6 @@ export default function ManualRouteMapClient({
312
  <Marker position={currentPosition} icon={currentLocationIcon} />
313
  )}
314
 
315
- {hasSnappedRoute &&
316
- snappedWaypoints.slice(0, 32).map((point, index) => (
317
- <Marker
318
- key={`${point[0]}_${point[1]}_${index}`}
319
- position={point}
320
- icon={waypointIcon}
321
- />
322
- ))}
323
  </MapContainer>
324
  );
325
  }
 
217
  currentPosition,
218
  drawnRoutes,
219
  snappedRoutes,
 
220
  drawingEnabled,
221
  onDrawStart,
222
  onDrawPoint,
 
236
  []
237
  );
238
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  const hasSnappedRoute = snappedRoutes.some((route) => route.length > 1);
240
  const fitRoutes = useMemo(
241
  () => snappedRoutes.filter((route) => route.length > 1),
 
299
  <Marker position={currentPosition} icon={currentLocationIcon} />
300
  )}
301
 
 
 
 
 
 
 
 
 
302
  </MapContainer>
303
  );
304
  }
main/app/_utils/generatedRouteDetails.ts CHANGED
@@ -72,7 +72,6 @@ const ROUTE_LABELS: Record<string, string> = {
72
  apple: "์‚ฌ๊ณผ",
73
  candle: "์–‘์ดˆ",
74
  christmas_tree_trunk: "ํŠธ๋ฆฌ",
75
- long_pants: "๊ธด๋ฐ”์ง€",
76
  dog: "๊ฐ•์•„์ง€",
77
  cloud: "๊ตฌ๋ฆ„",
78
  cup: "์ปต",
 
72
  apple: "์‚ฌ๊ณผ",
73
  candle: "์–‘์ดˆ",
74
  christmas_tree_trunk: "ํŠธ๋ฆฌ",
 
75
  dog: "๊ฐ•์•„์ง€",
76
  cloud: "๊ตฌ๋ฆ„",
77
  cup: "์ปต",
main/app/_utils/routeSearchDiscoverySession.ts CHANGED
@@ -1,7 +1,7 @@
1
  export type DiscoveryPoint = [number, number];
2
 
3
  export type DiscoveryCandidate = {
4
- label: "dog" | "symbol_star" | "t_shirt" | "heart" | "candle" | "christmas_tree_trunk" | "long_pants";
5
  score: number;
6
  shape_similarity: number;
7
  available: boolean;
 
1
  export type DiscoveryPoint = [number, number];
2
 
3
  export type DiscoveryCandidate = {
4
+ label: "dog" | "symbol_star" | "t_shirt" | "heart" | "candle" | "christmas_tree_trunk";
5
  score: number;
6
  shape_similarity: number;
7
  available: boolean;
main/app/manual-route/page.tsx CHANGED
@@ -121,7 +121,6 @@ function ManualRoutePageContent() {
121
  const [center, setCenter] = useState<ManualRoutePoint>(DEFAULT_CENTER);
122
  const [currentPosition, setCurrentPosition] = useState<ManualRoutePoint | null>(null);
123
  const [strokes, setStrokesState] = useState<ManualRouteStroke[]>([]);
124
- const [snappedWaypoints, setSnappedWaypoints] = useState<ManualRoutePoint[]>([]);
125
  const [drawingEnabled, setDrawingEnabled] = useState(true);
126
  const [isLocating, setIsLocating] = useState(false);
127
  const [locationError, setLocationError] = useState<string | null>(null);
@@ -218,19 +217,6 @@ function ManualRoutePageContent() {
218
  [strokes]
219
  );
220
 
221
- const syncWaypointMarkers = useCallback((nextStrokes: ManualRouteStroke[]) => {
222
- setSnappedWaypoints(
223
- nextStrokes
224
- .flatMap((stroke) => {
225
- if (stroke.snapped.length < 2) {
226
- return [];
227
- }
228
- return [stroke.snapped[0], stroke.snapped[stroke.snapped.length - 1]];
229
- })
230
- .slice(0, 32)
231
- );
232
- }, []);
233
-
234
  const alignStrokeToRoad = useCallback(
235
  async (strokeId: string) => {
236
  const stroke = strokesRef.current.find((item) => item.id === strokeId);
@@ -285,7 +271,7 @@ function ManualRoutePageContent() {
285
  ? data.length_km
286
  : polylineLengthKm(nextRoute);
287
 
288
- const nextStrokes = updateStrokes((current) =>
289
  current.map((item) =>
290
  item.id === strokeId
291
  ? {
@@ -298,7 +284,6 @@ function ManualRoutePageContent() {
298
  : item
299
  )
300
  );
301
- syncWaypointMarkers(nextStrokes);
302
  setSnapStatus("aligned");
303
  } catch (error) {
304
  if (strokeRequestIdsRef.current[strokeId] !== requestId) {
@@ -317,7 +302,7 @@ function ManualRoutePageContent() {
317
  setSnapError(message);
318
  }
319
  },
320
- [center, currentPosition, syncWaypointMarkers, updateStrokes]
321
  );
322
 
323
  const flattenRoutes = (routes: ManualRoutePoint[][]): ManualRoutePoint[] => {
@@ -472,7 +457,6 @@ function ManualRoutePageContent() {
472
  finalRouteRequestIdRef.current += 1;
473
  strokesRef.current = [];
474
  setStrokesState([]);
475
- setSnappedWaypoints([]);
476
  setIsCreatingRoute(false);
477
  setSnapStatus("idle");
478
  setSnapError(null);
@@ -626,7 +610,6 @@ function ManualRoutePageContent() {
626
  currentPosition={currentPosition}
627
  drawnRoutes={drawnRoutes}
628
  snappedRoutes={snappedRoutes}
629
- snappedWaypoints={snappedWaypoints}
630
  drawingEnabled={drawingEnabled}
631
  onDrawStart={handleDrawStart}
632
  onDrawPoint={handleDrawPoint}
 
121
  const [center, setCenter] = useState<ManualRoutePoint>(DEFAULT_CENTER);
122
  const [currentPosition, setCurrentPosition] = useState<ManualRoutePoint | null>(null);
123
  const [strokes, setStrokesState] = useState<ManualRouteStroke[]>([]);
 
124
  const [drawingEnabled, setDrawingEnabled] = useState(true);
125
  const [isLocating, setIsLocating] = useState(false);
126
  const [locationError, setLocationError] = useState<string | null>(null);
 
217
  [strokes]
218
  );
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  const alignStrokeToRoad = useCallback(
221
  async (strokeId: string) => {
222
  const stroke = strokesRef.current.find((item) => item.id === strokeId);
 
271
  ? data.length_km
272
  : polylineLengthKm(nextRoute);
273
 
274
+ updateStrokes((current) =>
275
  current.map((item) =>
276
  item.id === strokeId
277
  ? {
 
284
  : item
285
  )
286
  );
 
287
  setSnapStatus("aligned");
288
  } catch (error) {
289
  if (strokeRequestIdsRef.current[strokeId] !== requestId) {
 
302
  setSnapError(message);
303
  }
304
  },
305
+ [center, currentPosition, updateStrokes]
306
  );
307
 
308
  const flattenRoutes = (routes: ManualRoutePoint[][]): ManualRoutePoint[] => {
 
457
  finalRouteRequestIdRef.current += 1;
458
  strokesRef.current = [];
459
  setStrokesState([]);
 
460
  setIsCreatingRoute(false);
461
  setSnapStatus("idle");
462
  setSnapError(null);
 
610
  currentPosition={currentPosition}
611
  drawnRoutes={drawnRoutes}
612
  snappedRoutes={snappedRoutes}
 
613
  drawingEnabled={drawingEnabled}
614
  onDrawStart={handleDrawStart}
615
  onDrawPoint={handleDrawPoint}
main/app/route-results/page.tsx CHANGED
@@ -51,7 +51,7 @@ type GeneratedRoutesResponse = {
51
  };
52
 
53
  const apiBase = process.env.NEXT_PUBLIC_API_BASE_URL ?? "";
54
- const AVAILABLE_LABELS = ["dog", "symbol_star", "t_shirt", "heart", "candle", "christmas_tree_trunk", "long_pants"];
55
  const ROUTE_GENERATION_ERROR_MESSAGE =
56
  "์ถ”์ฒœ ๊ฒฝ๋กœ๋ฅผ ๋งŒ๋“ค์ง€ ๋ชปํ–ˆ์–ด์š”. ์ž ์‹œ ํ›„ ๋‹ค์‹œ ์ฐพ๊ธฐ๋ฅผ ๋ˆŒ๋Ÿฌ ์ฃผ์„ธ์š”.";
57
  const ROUTE_ART_QUALITY_NOTICE =
 
51
  };
52
 
53
  const apiBase = process.env.NEXT_PUBLIC_API_BASE_URL ?? "";
54
+ const AVAILABLE_LABELS = ["dog", "symbol_star", "t_shirt", "heart", "candle", "christmas_tree_trunk"];
55
  const ROUTE_GENERATION_ERROR_MESSAGE =
56
  "์ถ”์ฒœ ๊ฒฝ๋กœ๋ฅผ ๋งŒ๋“ค์ง€ ๋ชปํ–ˆ์–ด์š”. ์ž ์‹œ ํ›„ ๋‹ค์‹œ ์ฐพ๊ธฐ๋ฅผ ๋ˆŒ๋Ÿฌ ์ฃผ์„ธ์š”.";
57
  const ROUTE_ART_QUALITY_NOTICE =
main/app/route-search/page.tsx CHANGED
@@ -340,15 +340,6 @@ const SHAPE_OPTIONS: ShapeOption[] = [
340
  [0.0032, -0.0022],
341
  ],
342
  },
343
- {
344
- key: "long_pants",
345
- label: "๊ธด๋ฐ”์ง€",
346
- offsets: [
347
- [-0.0016, -0.003], [0.0016, -0.003], [0.0013, 0.003],
348
- [0.0002, 0.003], [0, -0.0003], [-0.0002, -0.0003],
349
- [-0.0002, 0.003], [-0.0013, 0.003], [-0.0016, -0.003],
350
- ],
351
- },
352
  {
353
  key: "heart",
354
  label: "ํ•˜ํŠธ",
@@ -942,10 +933,7 @@ function RouteSearchPageContent() {
942
  center={mapCenter}
943
  routes={selectedMapRoutes}
944
  displayRotationDeg={selectedSample?.displayRotationDeg}
945
- markers={[...sampleMarkers, ...postMarkers, ...(selectedMapPoint ? [{
946
- id: "picked-route-origin", position: selectedMapPoint,
947
- title: "์„ ํƒํ•œ ์ถœ๋ฐœ ์ง€์ ", kind: "routeStart" as const,
948
- }] : [])]}
949
  onMapClick={(point) => {
950
  mapPickedAt.current = performance.now();
951
  setMapPoint(point);
 
340
  [0.0032, -0.0022],
341
  ],
342
  },
 
 
 
 
 
 
 
 
 
343
  {
344
  key: "heart",
345
  label: "ํ•˜ํŠธ",
 
933
  center={mapCenter}
934
  routes={selectedMapRoutes}
935
  displayRotationDeg={selectedSample?.displayRotationDeg}
936
+ markers={[...sampleMarkers, ...postMarkers]}
 
 
 
937
  onMapClick={(point) => {
938
  mapPickedAt.current = performance.now();
939
  setMapPoint(point);