Skip to content

Commit cb2f9dc

Browse files
committed
feat: 신호등 전체 위치 및 반경 기준 출력 API 기능 구현 수정
1 parent 51a9773 commit cb2f9dc

16 files changed

Lines changed: 1123 additions & 24645 deletions
0 Bytes
Binary file not shown.

Capstone/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
urlpatterns = [
2121
path('admin/', admin.site.urls),
2222
path('member/', include('member.urls')),
23-
path('traffic-lights/', include('map.urls')),
23+
path('map/', include('map.urls')),
24+
2425
]
2526

location.csv

Lines changed: 1001 additions & 24416 deletions
Large diffs are not rendered by default.

map/admin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
from django.contrib import admin
2+
from .models import TrafficLight
23

3-
# Register your models here.
4+
admin.site.register(TrafficLight)

map/management/__init__.py

Whitespace-only changes.

map/management/commands/import_signal_poles.py

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import csv
2+
from django.core.management.base import BaseCommand
3+
from map.models import TrafficLight
4+
5+
class Command(BaseCommand):
6+
help = 'Import traffic lights from location.csv file'
7+
8+
def add_arguments(self, parser):
9+
parser.add_argument('csv_file', type=str, help='Path to the location.csv file')
10+
11+
def handle(self, *args, **options):
12+
file_path = options['csv_file']
13+
created_count = 0
14+
15+
with open(file_path, newline='', encoding='utf-8-sig') as csvfile:
16+
reader = csv.DictReader(csvfile)
17+
for row in reader:
18+
try:
19+
itst_id = int(row['itstId'])
20+
name = row['itstNm']
21+
lat = float(row['mapCtptIntLat'])
22+
lon = float(row['mapCtptIntLot'])
23+
24+
obj, created = TrafficLight.objects.update_or_create(
25+
itst_id=itst_id,
26+
defaults={
27+
'name': name,
28+
'latitude': lat,
29+
'longitude': lon,
30+
}
31+
)
32+
if created:
33+
created_count += 1
34+
except Exception as e:
35+
self.stderr.write(f"Error importing row {row}: {e}")
36+
37+
self.stdout.write(self.style.SUCCESS(f"{created_count} traffic lights imported successfully."))

map/migrations/0001_initial.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 5.1.7 on 2025-04-30 23:57
1+
# Generated by Django 5.1.7 on 2025-05-02 03:30
22

33
from django.db import migrations, models
44

@@ -14,12 +14,10 @@ class Migration(migrations.Migration):
1414
migrations.CreateModel(
1515
name='TrafficLight',
1616
fields=[
17-
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18-
('light_id', models.CharField(max_length=50, unique=True)),
19-
('x', models.FloatField()),
20-
('y', models.FloatField()),
21-
('latitude', models.FloatField(blank=True, null=True)),
22-
('longitude', models.FloatField(blank=True, null=True)),
17+
('itst_id', models.IntegerField(primary_key=True, serialize=False)),
18+
('name', models.CharField(max_length=255)),
19+
('latitude', models.FloatField()),
20+
('longitude', models.FloatField()),
2321
],
2422
),
2523
]

map/migrations/0002_signalpole.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

map/migrations/0003_remove_signalpole_direction.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)