diff --git a/pav-server/src/main/java/com/palnet/comn/utils/FlightUtils.java b/pav-server/src/main/java/com/palnet/comn/utils/FlightUtils.java index ee4160c..8636c7d 100644 --- a/pav-server/src/main/java/com/palnet/comn/utils/FlightUtils.java +++ b/pav-server/src/main/java/com/palnet/comn/utils/FlightUtils.java @@ -158,6 +158,7 @@ public class FlightUtils { return result; } + //좌표의 읍면동 , 리 등 가장 세분화된 법정동 코드를 리턴 public static JSONObject getCoordinateGis(Coordinate coordinate) throws IOException, ParseException { String baseFileName = "all_location.geojson"; @@ -181,6 +182,33 @@ public class FlightUtils { } } + //depth를 통해 좌표의 특정 구간(2 : 광역시, 5 : 시군구, 8 : 읍면동 / 리)에 해당하는 정보를 가져옴 + public static JSONObject getCoordinateGis(Coordinate coordinate, int depth) throws IOException, ParseException { + + String baseFileName = "all_location.geojson"; + + JSONObject obj = new JSONObject(); + + log.info("path >>>>>> {}", basePath); + + String path = basePath; + + while(true) { + + File file = new File(path+baseFileName); + + if(!file.exists()) return obj; + + obj = parseGeoJson(path+baseFileName, coordinate); + + if(obj.get("CD").toString().length() >= depth) return obj; + + path += obj.get("CD")+"/"; + + } + } + + public static JSONObject parseGeoJson(String path, Coordinate coordinate) throws IOException, ParseException { GeometryFactory geometryFactory = new GeometryFactory();