src/main/kotlin/com/flightfeather/uav/biz/dataprocess/RoadSegment.kt
@@ -63,7 +63,7 @@ districtName = address.district townCode = address.towncode towmName = address.township street = address.street street = address.address }) } // 结果入库 src/main/kotlin/com/flightfeather/uav/biz/report/MissionGridFusion.kt
@@ -94,7 +94,7 @@ highRiskGrid!!.cell.longitude.toDouble() to highRiskGrid!!.cell.latitude.toDouble() )) town = address.township + address.street town = address.township + address.address } val polygon = listOf( highRiskGrid!!.cell.point1Lon.toDouble() to highRiskGrid!!.cell.point1Lat.toDouble(), src/main/kotlin/com/flightfeather/uav/biz/report/MissionRiskArea.kt
@@ -15,7 +15,12 @@ class ClueByArea { var sceneInfo: SceneInfo? = null // 所属街镇 var township:String? = null // 格式化地址 var address: String? = null // 交叉路段信息 var roadinter:String? = null var clueByFactorList: MutableList<ClueByFactor>? = null } @@ -104,12 +109,14 @@ val dataList = pollutedClue.pollutedData?.dataList ?: emptyList() if (dataList.isEmpty()) return@forEach // 按污染溯源地址和因子分组线索 pollutedClue.pollutedArea?.address?.let { address -> var clueByArea = result.find { it.address == address } // 按污染溯源地址街镇和因子分组线索 pollutedClue.pollutedArea?.township?.let { township -> var clueByArea = result.find { it.township == township } if (clueByArea == null) { clueByArea = ClueByArea().apply { this.address = address this.township = township this.address = pollutedClue.pollutedArea?.address this.roadinter = pollutedClue.pollutedArea?.roadinter this.clueByFactorList = mutableListOf() } result.add(clueByArea) src/main/kotlin/com/flightfeather/uav/biz/sourcetrace/model/PollutedArea.kt
@@ -31,7 +31,12 @@ windLevelCondition?.let { sourceTrace(historyData, exceptionData, config, it) } } // 所属街镇 var township:String? = null // 格式化地址 var address: String? = null // 交叉路段信息 var roadinter:String? = null // 污染范围扇形区域(经纬度多边形) var polygon: List<Pair<Double, Double>>? = null @@ -80,7 +85,9 @@ if (config.isSearchAddress) { try { val address = AMapService.reGeo(MapUtil.wgs84ToGcj02(pair)) this.address = address.district + address.township + address.street this.township = address.province+address.district+address.township this.address = address.address + address.streetNumber this.roadinter = address.roadinter // Thread.sleep(100) } catch (e: Exception) { e.printStackTrace() src/main/kotlin/com/flightfeather/uav/common/net/AMapService.kt
@@ -1,13 +1,11 @@ package com.flightfeather.uav.common.net import com.flightfeather.uav.common.exception.BizException import com.google.gson.Gson import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.JsonParser import org.apache.http.util.EntityUtils import java.net.URLEncoder import java.nio.charset.Charset /** * 高德地图Web服务API @@ -29,7 +27,9 @@ val adcode: String, val township: String, val towncode: String, val street: String, val address: String, val streetNumber: String, val roadinter: String, ) data class AMapDirection( @@ -86,17 +86,21 @@ * @return 所在街道 */ fun reGeo(location:Pair<Double, Double>):AMapAddress { val res = httpMethod.get("/v3/geocode/regeo", listOf( val res = httpMethod.get( "/v3/geocode/regeo", listOf( "key" to KEY, "location" to "${location.first},${location.second}", "extensions" to "all" )) ) ) val obj = handleRes(res) try { val regeocode = obj["regeocode"].asJsonObject val a = regeocode["addressComponent"].asJsonObject val streetNumber = a["streetNumber"].asJsonObject val roads = regeocode["roads"].asJsonArray val roadinters = regeocode["roadinters"].asJsonArray val roadinter = if (roadinters.size() > 0) roadinters.get(0).asJsonObject else null return AMapAddress( a["country"].asString, a["province"].asString, @@ -106,7 +110,11 @@ a["adcode"].asString, a["township"].asString, a["towncode"].asString, a["streetNumber"].asJsonObject["street"].asString, regeocode["formatted_address"].asString, streetNumber["street"].asString + streetNumber["number"].asString + streetNumber["direction"].asString + streetNumber["distance"].asDouble.toInt() + "米", if(roadinter == null) "" else roadinter.get("first_name")?.asString +"和" + roadinter.get("second_name")?.asString + "交叉口" + roadinter.get("direction")?.asString + roadinter.get("distance")?.asDouble?.toInt() + "米", ) } catch (e: Exception) { throw BizException("高德API坐标转换错误,${e.message}", e.cause) @@ -120,11 +128,13 @@ */ fun coordinateConvert(locations: List<Pair<Double, Double>>, coordsys:String="gps"): List<Pair<Double, Double>> { val locationsStr = URLEncoder.encode(locations.joinToString("|") { "${it.first},${it.second}" }, "UTF-8") val res = httpMethod.get("/v3/assistant/coordinate/convert", listOf( val res = httpMethod.get( "/v3/assistant/coordinate/convert", listOf( "key" to KEY, "locations" to locationsStr, "coordsys" to coordsys )) ) ) val obj = handleRes(res) try { return obj["locations"].asString.split(";").map { src/test/kotlin/com/flightfeather/uav/Test.kt
@@ -202,6 +202,7 @@ @Test fun reGeo() { AMapService.reGeo(MapUtil.wgs84ToGcj02(121.461753 to 31.252426)) val a = AMapService.reGeo(MapUtil.wgs84ToGcj02(121.45017 to 31.274426)) println(a) } }