Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions HotCha/HotCha.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"HotCha/Preview Content\"";
DEVELOPMENT_TEAM = UW9295Z57Q;
DEVELOPMENT_TEAM = V9J26YADA8;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HotCha/Info.plist;
Expand Down Expand Up @@ -355,7 +355,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"HotCha/Preview Content\"";
DEVELOPMENT_TEAM = UW9295Z57Q;
DEVELOPMENT_TEAM = V9J26YADA8;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HotCha/Info.plist;
Expand Down Expand Up @@ -389,7 +389,7 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"HotCha/Preview Content\"";
DEVELOPMENT_TEAM = UW9295Z57Q;
DEVELOPMENT_TEAM = V9J26YADA8;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = HotCha/Info.plist;
Expand Down
5 changes: 3 additions & 2 deletions HotCha/HotCha/App/HotChaApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ struct HotChaApp: App {

var body: some Scene {
WindowGroup {
SplashView()
.modelContainer(HotchaContainer)
// SplashView()
// .modelContainer(HotchaContainer)
TestView()
}
}
}
5 changes: 5 additions & 0 deletions HotCha/HotCha/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIAppFonts</key>
<array>
<string>Pretendard-Bold.otf</string>
Expand Down
45 changes: 45 additions & 0 deletions HotCha/HotCha/Models/Bus/BusArrivalInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// BusArrivalInfo.swift
// HotCha
//
// Created by 문호 on 3/14/25.
//

import Foundation

// BusArrivalInfo.swift - 버스 도착 정보 모델
struct BusArrivalInfo: Codable, Identifiable {
let id = UUID()
let routeId: String // 노선 ID
let routeName: String // 노선명
let stationId: String // 정류소 ID
let stationName: String // 정류소 명
let predictTime1: Int // 첫번째 버스 도착 예정 시간(분)
let predictTime2: Int? // 두번째 버스 도착 예정 시간(분)
let locationNo1: Int? // 첫번째 버스 현재 위치(몇 번째 정류소)
let locationNo2: Int? // 두번째 버스 현재 위치(몇 번째 정류소)

enum CodingKeys: String, CodingKey {
case routeId = "routeid"
case routeName = "routeno"
case stationId = "nodeid"
case stationName = "nodenm"
case predictTime1 = "arrtime"
case predictTime2 = "arrtime2"
case locationNo1 = "nodeno"
case locationNo2 = "nodeno2"
}

// 테스트용 초기화 메서드
init(routeId: String, routeName: String, stationId: String, stationName: String, predictTime1: Int, predictTime2: Int? = nil, locationNo1: Int? = nil, locationNo2: Int? = nil) {
self.routeId = routeId
self.routeName = routeName
self.stationId = stationId
self.stationName = stationName
self.predictTime1 = predictTime1
self.predictTime2 = predictTime2
self.locationNo1 = locationNo1
self.locationNo2 = locationNo2
}
}

94 changes: 94 additions & 0 deletions HotCha/HotCha/Models/Bus/BusLocationInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// BusLocationInfo.swift
// HotCha
//
// Created by 문호 on 3/14/25.
//

import Foundation

// BusLocationInfo.swift - 버스 위치 정보 모델
struct BusLocationInfo: Codable, Identifiable {
let id = UUID()
let routeId: String // 노선 ID
let routeName: String // 노선명
let vehicleId: String // 차량 ID
let stationId: String? // 현재/최근 정류소 ID
let stationSeq: Int // 정류소 순번
let stationName: String? // 현재/최근 정류소명
let latitude: Double // 위도
let longitude: Double // 경도

enum CodingKeys: String, CodingKey {
case routeId = "routeid"
case routeName = "routeno"
case vehicleId = "vehicleno"
case stationId = "nodeid"
case stationSeq = "nodeord"
case stationName = "nodenm"
case latitude = "gpslati"
case longitude = "gpslong"
}

// 디코딩 중 데이터 타입 변환을 위한 커스텀 이니셜라이저
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

routeId = try container.decode(String.self, forKey: .routeId)

// routeno가 String 또는 Int로 올 수 있음
if let routeNoStr = try? container.decode(String.self, forKey: .routeName) {
routeName = routeNoStr
} else if let routeNoInt = try? container.decode(Int.self, forKey: .routeName) {
routeName = String(routeNoInt)
} else {
routeName = "알 수 없음"
}

vehicleId = try container.decode(String.self, forKey: .vehicleId)
stationId = try? container.decode(String.self, forKey: .stationId)

// stationSeq가 String 또는 Int로 올 수 있음
if let stationSeqStr = try? container.decode(String.self, forKey: .stationSeq),
let stationSeqInt = Int(stationSeqStr) {
stationSeq = stationSeqInt
} else if let stationSeqInt = try? container.decode(Int.self, forKey: .stationSeq) {
stationSeq = stationSeqInt
} else {
stationSeq = 0
}

stationName = try? container.decode(String.self, forKey: .stationName)

// 위도와 경도 처리
if let latitudeStr = try? container.decode(String.self, forKey: .latitude),
let latitudeDouble = Double(latitudeStr) {
latitude = latitudeDouble
} else if let latitudeDouble = try? container.decode(Double.self, forKey: .latitude) {
latitude = latitudeDouble
} else {
latitude = 0.0
}

if let longitudeStr = try? container.decode(String.self, forKey: .longitude),
let longitudeDouble = Double(longitudeStr) {
longitude = longitudeDouble
} else if let longitudeDouble = try? container.decode(Double.self, forKey: .longitude) {
longitude = longitudeDouble
} else {
longitude = 0.0
}
}

// 테스트용 초기화 메서드
init(routeId: String, routeName: String, vehicleId: String, stationId: String?, stationSeq: Int, stationName: String?, latitude: Double, longitude: Double) {
self.routeId = routeId
self.routeName = routeName
self.vehicleId = vehicleId
self.stationId = stationId
self.stationSeq = stationSeq
self.stationName = stationName
self.latitude = latitude
self.longitude = longitude
}
}
82 changes: 82 additions & 0 deletions HotCha/HotCha/Models/Bus/BusRouteInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//
// BusRouteInfo.swift
// HotCha
//
// Created by 문호 on 3/14/25.
//

import Foundation

// BusRouteInfo.swift - 버스 노선 정보 모델
struct BusRouteInfo: Codable, Identifiable {
let id = UUID()
let routeId: String // 노선 ID
let routeName: String // 노선명
let routeTypeName: String // 노선 유형
let startStationName: String // 기점명
let endStationName: String // 종점명
let firstBusTime: String // 첫차 시간
let lastBusTime: String // 막차 시간

enum CodingKeys: String, CodingKey {
case routeId = "routeid"
case routeName = "routeno"
case routeTypeName = "routetp"
case startStationName = "startnodenm"
case endStationName = "endnodenm"
case firstBusTime = "startvehicletime"
case lastBusTime = "endvehicletime"
}

// 디코딩 중 데이터 타입 변환을 위한 커스텀 이니셜라이저
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

routeId = try container.decode(String.self, forKey: .routeId)

// routeno가 String 또는 Int로 올 수 있음
if let routeNoString = try? container.decode(String.self, forKey: .routeName) {
routeName = routeNoString
} else if let routeNoInt = try? container.decode(Int.self, forKey: .routeName) {
routeName = String(routeNoInt)
} else {
throw DecodingError.valueNotFound(String.self, DecodingError.Context(
codingPath: [CodingKeys.routeName],
debugDescription: "Unable to decode routeName"
))
}

routeTypeName = try container.decode(String.self, forKey: .routeTypeName)
startStationName = try container.decode(String.self, forKey: .startStationName)
endStationName = try container.decode(String.self, forKey: .endStationName)

// firstBusTime이 String 또는 Int로 올 수 있음
if let firstBusTimeString = try? container.decode(String.self, forKey: .firstBusTime) {
firstBusTime = firstBusTimeString
} else if let firstBusTimeInt = try? container.decode(Int.self, forKey: .firstBusTime) {
firstBusTime = String(firstBusTimeInt)
} else {
firstBusTime = "정보 없음"
}

// lastBusTime이 String 또는 Int로 올 수 있음
if let lastBusTimeString = try? container.decode(String.self, forKey: .lastBusTime) {
lastBusTime = lastBusTimeString
} else if let lastBusTimeInt = try? container.decode(Int.self, forKey: .lastBusTime) {
lastBusTime = String(lastBusTimeInt)
} else {
lastBusTime = "정보 없음"
}
}

// 테스트용 초기화 메서드
init(routeId: String, routeName: String, routeTypeName: String, startStationName: String, endStationName: String, firstBusTime: String, lastBusTime: String) {
self.routeId = routeId
self.routeName = routeName
self.routeTypeName = routeTypeName
self.startStationName = startStationName
self.endStationName = endStationName
self.firstBusTime = firstBusTime
self.lastBusTime = lastBusTime
}
}
76 changes: 76 additions & 0 deletions HotCha/HotCha/Models/Bus/BusStopInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// BusStopInfo.swift
// HotCha
//
// Created by 문호 on 3/14/25.
//

import Foundation

// BusStopInfo.swift - 버스 정류소 정보 모델
struct BusStopInfo: Codable, Identifiable {
let id = UUID()
let stationId: String // 정류소 ID
let stationName: String // 정류소 명
let regionName: String // 지역명
let mobileNo: String? // 정류소 고유번호
let latitude: Double // 위도
let longitude: Double // 경도

enum CodingKeys: String, CodingKey {
case stationId = "nodeid"
case stationName = "nodenm"
case regionName = "nodeno"
case mobileNo = "gpslati"
case latitude = "gpslong"
case longitude = "nodeord"
}

// 디코딩 중 데이터 타입 변환을 위한 커스텀 이니셜라이저
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)

stationId = try container.decode(String.self, forKey: .stationId)
stationName = try container.decode(String.self, forKey: .stationName)

// regionName이 문자열 또는 숫자로 올 수 있음
if let regionNameStr = try? container.decode(String.self, forKey: .regionName) {
regionName = regionNameStr
} else if let regionNameInt = try? container.decode(Int.self, forKey: .regionName) {
regionName = String(regionNameInt)
} else {
regionName = "알 수 없음"
}

mobileNo = try? container.decode(String.self, forKey: .mobileNo)

// 위도와 경도 처리
if let latitudeStr = try? container.decode(String.self, forKey: .latitude),
let latitudeDouble = Double(latitudeStr) {
latitude = latitudeDouble
} else if let latitudeDouble = try? container.decode(Double.self, forKey: .latitude) {
latitude = latitudeDouble
} else {
latitude = 0.0
}

if let longitudeStr = try? container.decode(String.self, forKey: .longitude),
let longitudeDouble = Double(longitudeStr) {
longitude = longitudeDouble
} else if let longitudeDouble = try? container.decode(Double.self, forKey: .longitude) {
longitude = longitudeDouble
} else {
longitude = 0.0
}
}

// 테스트용 초기화 메서드
init(stationId: String, stationName: String, regionName: String, mobileNo: String?, latitude: Double, longitude: Double) {
self.stationId = stationId
self.stationName = stationName
self.regionName = regionName
self.mobileNo = mobileNo
self.latitude = latitude
self.longitude = longitude
}
}
Loading