|
|
@ -23,6 +23,9 @@ import org.locationtech.jts.geom.GeometryFactory; |
|
|
|
import org.locationtech.jts.geom.Point; |
|
|
|
import org.locationtech.jts.geom.Point; |
|
|
|
import org.locationtech.jts.geom.Polygon; |
|
|
|
import org.locationtech.jts.geom.Polygon; |
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
import org.springframework.core.io.ClassPathResource; |
|
|
|
|
|
|
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; |
|
|
|
|
|
|
|
import org.springframework.core.io.support.ResourcePatternResolver; |
|
|
|
|
|
|
|
import org.springframework.util.FileCopyUtils; |
|
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
|
|
@ -33,7 +36,7 @@ public class CoordUtils { |
|
|
|
|
|
|
|
|
|
|
|
private static final CoordUtils INSTANCE = new CoordUtils(); |
|
|
|
private static final CoordUtils INSTANCE = new CoordUtils(); |
|
|
|
|
|
|
|
|
|
|
|
private String baseFileName = "/all_location.geojson"; |
|
|
|
private String baseFileName = "all_location.geojson"; |
|
|
|
|
|
|
|
|
|
|
|
private List<JSONObject> allLocation; |
|
|
|
private List<JSONObject> allLocation; |
|
|
|
|
|
|
|
|
|
|
@ -97,19 +100,17 @@ public class CoordUtils { |
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
|
|
|
|
|
|
|
String path = basePath + coords + baseFileName; |
|
|
|
String path = basePath + coords + "/" + baseFileName; |
|
|
|
|
|
|
|
|
|
|
|
try(InputStream inputStream = new ClassPathResource(path).getInputStream(); |
|
|
|
try (InputStream inputStream = new ClassPathResource(path).getInputStream()) { |
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8192)) { |
|
|
|
byte[] binaryData = FileCopyUtils.copyToByteArray(inputStream); |
|
|
|
|
|
|
|
String content = new String(binaryData, "UTF-8"); |
|
|
|
|
|
|
|
|
|
|
|
JSONParser jsonParser = new JSONParser(); |
|
|
|
JSONParser jsonParser = new JSONParser(); |
|
|
|
|
|
|
|
jsonObject = (JSONObject) jsonParser.parse(content); |
|
|
|
|
|
|
|
|
|
|
|
jsonObject = (JSONObject) jsonParser.parse(reader); |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
}catch(Exception e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e.getStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return jsonObject; |
|
|
|
return jsonObject; |
|
|
|
} |
|
|
|
} |
|
|
@ -257,21 +258,20 @@ public class CoordUtils { |
|
|
|
|
|
|
|
|
|
|
|
Point point = null; |
|
|
|
Point point = null; |
|
|
|
|
|
|
|
|
|
|
|
try(InputStream inputStream = new ClassPathResource(path).getInputStream(); |
|
|
|
try (InputStream inputStream = new ClassPathResource(path).getInputStream()) { |
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"), 8192)) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONParser jsonParser = new JSONParser(); |
|
|
|
byte[] binaryData = FileCopyUtils.copyToByteArray(inputStream); |
|
|
|
|
|
|
|
String content = new String(binaryData, "UTF-8"); |
|
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader); |
|
|
|
JSONParser jsonParser = new JSONParser(); |
|
|
|
|
|
|
|
JSONObject jsonObject = (JSONObject) jsonParser.parse(content); |
|
|
|
|
|
|
|
|
|
|
|
point = geometryFactory.createPoint(coordinate); |
|
|
|
point = geometryFactory.createPoint(coordinate); |
|
|
|
|
|
|
|
|
|
|
|
features = (List<JSONObject>) jsonObject.get("features"); |
|
|
|
features = (List<JSONObject>) jsonObject.get("features"); |
|
|
|
|
|
|
|
|
|
|
|
}catch(Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
e.getStackTrace(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.contains(features, point); |
|
|
|
return this.contains(features, point); |
|
|
|