Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.back.web7_9_codecrete_be.domain.location.controller;

import com.back.web7_9_codecrete_be.domain.location.dto.KakaoLocalResponse;
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoLocalResponse;
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoMobilityResponse;
import com.back.web7_9_codecrete_be.domain.location.dto.response.KakaoRouteTransitResponse;
import com.back.web7_9_codecrete_be.domain.location.service.KakaoLocalService;
import com.back.web7_9_codecrete_be.global.error.code.LocationErrorCode;
import com.back.web7_9_codecrete_be.global.error.exception.BusinessException;
import com.back.web7_9_codecrete_be.global.rsData.RsData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -32,7 +36,7 @@ public class KakaoApiController {
public List<KakaoLocalResponse.Document> KakaoRestaurants(
@RequestParam double lat,
@RequestParam double lon
){
) {
return kakaoLocalService.searchNearbyRestaurants(lat, lon);
}

Expand All @@ -46,7 +50,7 @@ public List<KakaoLocalResponse.Document> KakaoRestaurants(
public List<KakaoLocalResponse.Document> KakaoCafes(
@RequestParam double lat,
@RequestParam double lon
){
) {
return kakaoLocalService.searchNearbyCafes(lat, lon);
}

Expand All @@ -68,4 +72,74 @@ public RsData<String> coord2Address(
String addressName = kakaoLocalService.coordinateToAddressName(lat, lon);
return RsData.success("좌표를 주소로 변환했습니다.", addressName);
}


@GetMapping("/navigate/guides")
public List<KakaoMobilityResponse.Guide> navigateGuides(
@RequestParam double startX,
@RequestParam double startY,
@RequestParam double endX,
@RequestParam double endY
) {
KakaoMobilityResponse res = kakaoLocalService.NaviSearch(startX, startY, endX, endY);

if (res == null || res.getRoutes() == null || res.getRoutes().isEmpty()) {
return List.of();
}

KakaoMobilityResponse.Route route0 = res.getRoutes().get(0);
if (route0.getSections() == null || route0.getSections().isEmpty()) {
return List.of();
}

return route0.getSections().stream()
.filter(section -> section.getGuides() != null && !section.getGuides().isEmpty())
.flatMap(section -> section.getGuides().stream())
.toList();
}
@GetMapping("/navigate/summary")
public KakaoMobilityResponse.Summary navigateSummary(
@RequestParam double startX,
@RequestParam double startY,
@RequestParam double endX,
@RequestParam double endY
) {
KakaoMobilityResponse res = kakaoLocalService.NaviSearchSummary(startX, startY, endX, endY);

if (res == null || res.getRoutes() == null || res.getRoutes().isEmpty()) {
throw new BusinessException(LocationErrorCode.ROUTE_NOT_FOUND);
}

KakaoMobilityResponse.Route route0 = res.getRoutes().get(0);
if (route0.getSummary() == null) {
throw new BusinessException(LocationErrorCode.ROUTE_NOT_FOUND);
}

return route0.getSummary();

}

@PostMapping("/navigate/onlyguide")
public List<KakaoRouteTransitResponse.Guide> navigateOnlyGuides(
@RequestParam double startX,
@RequestParam double startY,
@RequestParam double endX,
@RequestParam double endY,
@RequestParam double wayX,
@RequestParam double wayY
) {
KakaoRouteTransitResponse res = kakaoLocalService.NaviSearchTransit(startX, startY, endX, endY, wayX, wayY);

if (res == null || res.getRoutes() == null || res.getRoutes().isEmpty()) {
return List.of();
}

KakaoRouteTransitResponse.Route route0 = res.getRoutes().get(0);

return route0.getSections().stream()
.filter(section -> section.getGuides() != null && !section.getGuides().isEmpty())
.flatMap(section -> section.getGuides().stream())
.toList();
}
}

Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.back.web7_9_codecrete_be.domain.location.controller;

import com.back.web7_9_codecrete_be.domain.location.dto.request.TmapSummaryRequest;
import com.back.web7_9_codecrete_be.domain.location.dto.response.TmapSummaryAllResponse;
import com.back.web7_9_codecrete_be.domain.location.dto.response.TmapSummaryResponse;
import com.back.web7_9_codecrete_be.domain.location.service.TmapService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -71,4 +74,9 @@ public String getTransit(
) {
return tmapService.getRoute(startX, startY, endX, endY);
}

@GetMapping("/tmap/summary")
public TmapSummaryAllResponse getSummaryTransit(double startX, double startY, double endX, double endY){
return tmapService.getSummaryRoute(startX, startY, endX, endY);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.back.web7_9_codecrete_be.domain.location.dto;
package com.back.web7_9_codecrete_be.domain.location.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data

@Schema(description = "Tmap 대중교통 경로 조회 요청 DTO")
public class TmapResponse {
public class TmapRequest {

@Schema(description = "출발지 경도 (longitude)", example = "126.9780")
private String startX;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.back.web7_9_codecrete_be.domain.location.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class TmapSummaryRequest {

@Schema(description = "출발지 경도 (longitude)", example = "126.9780")
private double startX;

@Schema(description = "출발지 위도 (latitude)", example = "37.5665")
private double startY;

@Schema(description = "도착지 경도 (longitude)", example = "127.0276")
private double endX;

@Schema(description = "도착지 위도 (latitude)", example = "37.4979")
private double endY;

@Schema(description = "최대 응답 결과 개수", example = "5")
private int count;

@Schema(
description = "응답 포맷 (json / xml)",
example = "json",
allowableValues = {"json", "xml"}
)
private String format;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.back.web7_9_codecrete_be.domain.location.dto;
package com.back.web7_9_codecrete_be.domain.location.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.back.web7_9_codecrete_be.domain.location.dto.response;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;
@Getter
@AllArgsConstructor
public class KakaoMobilityResponse {


private List<Route> routes;

@Getter
public static class Route {
private Summary summary;
private List<Section> sections;
}

@Getter
public static class Summary {
private int distance; // meters
private int duration; // seconds
}

@Getter
public static class Section{
private List<Road> roads;
private List<Guide> guides;
public List<Guide> getGuides() {
return guides;
}
}

@Getter
public static class Road{
private List<Double> vertexes;
}


@Getter
public static class Guide {
private String name;
private double x;
private double y;
private int distance;
private int duration;
private int type;
private String guidance;
private int road_index;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.back.web7_9_codecrete_be.domain.location.dto.response;

import lombok.Getter;
import java.util.List;

@Getter
public class KakaoRouteTransitResponse {

private List<Route> routes;

@Getter
public static class Route {
private Summary summary;
private List<Section> sections;
}

@Getter
public static class Summary {
private Origin origin;
private Destination destination;
private List<Waypoint> waypoints; // ✅ 경유지(요청값)

private String priority;
private Fare fare;

private int distance; // meters
private int duration; // seconds
}

@Getter
public static class Origin {
private String name;
private double x;
private double y;
}

@Getter
public static class Destination {
private String name;
private double x;
private double y;
}

@Getter
public static class Waypoint {
private String name;
private double x;
private double y;
}

@Getter
public static class Fare {
private int taxi;
private int toll;
}

@Getter
public static class Section {
private List<Road> roads;
private List<Guide> guides;
}

@Getter
public static class Road {
private List<Double> vertexes;
}

@Getter
public static class Guide {
private String name;
private double x;
private double y;
private int distance;
private int duration;
private int type;
private String guidance;
private int road_index;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package com.back.web7_9_codecrete_be.domain.location.dto.response;

import lombok.Getter;

import java.util.List;
@Getter
public class TmapSummaryAllResponse {

private MetaData metaData;

// ===================== metaData =====================
@Getter
public static class MetaData {
private Plan plan;
private RequestParameters requestParameters;
}

// ===================== plan =====================
@Getter
public static class Plan {
private List<Itinerary> itineraries;
}

// ===================== itineraries =====================
@Getter
public static class Itinerary {

private int pathType; // 경로 탐색 결과 종류
private int totalTime; // 총 소요시간 (sec)
private int transferCount; // 환승 횟수
private int totalWalkDistance; // 총 보행 거리 (m)
private int totalDistance; // 총 이동 거리 (m)
private int totalWalkTime; // 총 보행 시간 (sec)

private Fare fare; // 요금 정보
}

// ===================== fare =====================
@Getter
public static class Fare {
private Regular regular;
}

// ===================== regular =====================
@Getter
public static class Regular {
private Currency currency;
private int totalFare; // 대중교통 요금
}

// ===================== currency =====================
@Getter
public static class Currency {
private String symbol; // ₩
private String currency; // 원
private String currencyCode; // KRW
}

// ===================== requestParameters =====================
@Getter
public static class RequestParameters {

private String reqDttm; // 요청 시각 (yyyymmddhhmiss)

private String startX; // 출발지 경도
private String startY; // 출발지 위도
private String endX; // 도착지 경도
private String endY; // 도착지 위도
}

}
Loading