package incheon.sgp.thm.service;

import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.databind.ObjectMapper;
import incheon.sgp.thm.dto.SgpThmCategoryDto;
import incheon.sgp.thm.dto.SgpThmLayerDto;
import incheon.sgp.thm.dto.SgpThmSubwayDto;
import incheon.sgp.thm.dto.SgpThmBiotopeGeomDto;
import incheon.sgp.thm.dto.SgpThmTilesetClippingDto;

public interface SgpThmService {
    String getThemeListJson();

    String getThemeJson(String thmId, String q, Integer limit);
    
    List<String> getFilterList(String thmId, String filter);

    List<String> getFilterListByParent(String thmId, String filterName1, String filterValue, String filterName2);
	
	/** 최신이 5분보다 오래됐으면 OpenAPI 적재 후 최신(latest) 반환, 아니면 latest 즉시 반환 */
    List<Map<String, Object>> getLatestTrafficInfo(int roadType, double minX, double minY, double maxX, double maxY);

    List<Map<String, Object>> getCctvList(Integer gid, double minX, double minY, double maxX, double maxY);

    List<Map<String, Object>> getCctvNewList(double minX, double minY, double maxX, double maxY);

    /** 최신이 5분보다 오래됐으면 OpenAPI 적재 후 최신(latest) 반환, 아니면 latest 즉시 반환 */
    int updateTrafficInfo();

    int updateTrafficCctv();

    void updateTrafficInfoBg();

    void updateTrafficCctvBg();

    List<SgpThmCategoryDto> getThemeCategories();

    Map<String, List<SgpThmLayerDto>> getThemeLayersByCategory();

    // roadType 기준으로 도로 이름/도로 종류 리스트 조회
    Map<String, Object> getRoadNames(Integer roadType, String searchName, Integer page, Integer size);

    // 단일 도로이름으로 해당 도로 내 링크 목록 조회
    List<Map<String, Object>> getLinksByRoadName(String roadName);

    // 역사명으로 역사 Geom 데이터를 조회
    SgpThmSubwayDto getSubwayBySubwayName(String subwayName);

    /**
     * sim_id로 시뮬레이션 JSON 조회
     * @param simId 시뮬레이션 ID
     * @return 시뮬레이션 JSON 문자열
     */
    String getSimulationJsonBySimId(String simId);

    /**
     * clip_id로 클리핑 정보 조회
     * @param clipId 클리핑 ID
     * @return 클리핑 정보
     */
    SgpThmTilesetClippingDto getTilesetClippingById(String clipId);

    /**
     * poi_id로 선거구 Geometry 조회
     * 
     * @param poiId 주제도 POI ID
     * @return GeoJSON 문자열 (예: {"type":"Polygon","coordinates":[...]})
     */
    String getElectionGeomByPoiId(String poiId);

    /**
     * 비오톱 전체 Geometry 및 bio_val 조회 (한 번에 전체)
     * 
     * @return List<SgpThmBiotopeGeomDto>
     */
    List<SgpThmBiotopeGeomDto> getAllBiotopeGeoms();

    /**
     * 비오톱 전체 Geometry 스트리밍 조회 (NDJSON 포맷)
     * Cursor 기반으로 row 단위 스트리밍
     * 
     * @param outputStream 출력 스트림
     * @param mapper       JSON 직렬화용 ObjectMapper
     */
    void streamAllBiotopeGeoms(OutputStream outputStream, ObjectMapper mapper);

    /**
     * 종량제봉투 구/군별 가격표
     */
    List<Map<String, Object>> getWasteBagPriceList(String sggName);

    /**
     * thm_wind 메타데이터 생성/갱신 (unique: year,month,day,time)
     */
    Map<String, Object> upsertWindMeta(String date, Integer year, Integer month, Integer day, String time, String filename);

    /**
     * thm_wind 메타데이터 조회
     */
    List<Map<String, Object>> searchWindMeta(String date, String date2, String filename);
}
