¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.biz.satellite |
| | | |
| | | /** |
| | | * å«æç½æ ¼ç»çåæ°ï¼ä¸ä¸ªå«æç½æ ¼ç»åºè¯¥ä¸ºç©å½¢å½¢å¼ |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class GridGroupOption( |
| | | // ç½æ ¼å®½åº¦ï¼æä¸è¥¿æ¹åä¸çç½æ ¼æ°é |
| | | val width: Int, |
| | | // ç½æ ¼é«åº¦ï¼æååæ¹åä¸çç½æ ¼æ°é |
| | | val height: Int, |
| | | // ç»åç½æ ¼å®½åº¦ï¼å¦æç½æ ¼ç»æ¯ç»åç½æ ¼ï¼å表示对åºåå§ç½æ ¼ä¸åä¸ªç½æ ¼ä¸ç»åçç½æ ¼æ°é |
| | | val eachWith: Int, |
| | | // ç»åç½æ ¼é«åº¦ï¼å¦æç½æ ¼ç»æ¯ç»åç½æ ¼ï¼å表示对åºåå§ç½æ ¼ä¸åä¸ªç½æ ¼ä¸ç»åçç½æ ¼æ°é |
| | | val eachHeight: Int, |
| | | ) |
| | |
| | | |
| | | import com.flightfeather.uav.common.utils.MapUtil |
| | | import com.flightfeather.uav.domain.entity.* |
| | | import org.springframework.beans.BeanUtils |
| | | import kotlin.math.PI |
| | | import kotlin.math.sqrt |
| | | |
| | |
| | | realTimeDataList.forEach { |
| | | if (it.longitude == null || it.latitude == null) return@forEach |
| | | |
| | | searchGirdIn(it.longitude!!.toDouble() to it.latitude!!.toDouble(), gridCellList)?.let { cell -> |
| | | SatelliteGridUtil.searchGirdIn(it.longitude!!.toDouble() to it.latitude!!.toDouble(), gridCellList) |
| | | ?.let { cell -> |
| | | if (!dataMap.containsKey(cell)) { |
| | | dataMap[cell] = mutableListOf() |
| | | } |
| | |
| | | val gridDataDetailList = mutableListOf<GridDataDetail>() |
| | | dataMap.forEach { (k, v) -> |
| | | val avgData = v.avg() |
| | | val dataDetail = GridDataDetail().apply { |
| | | val dataDetail = GridDataDetail() |
| | | BeanUtils.copyProperties(avgData, dataDetail) |
| | | dataDetail.apply { |
| | | dataId = gridData?.id |
| | | groupId = k.groupId |
| | | cellId = k.cellIndex |
| | | pm25 = avgData.pm25 |
| | | // no2 = avgData.no2 |
| | | // co = avgData.co |
| | | // h2s = avgData.h2s |
| | | // so2 = avgData.so2 |
| | | // o3 = avgData.o3 |
| | | // pm25 = avgData.pm25 |
| | | // pm10 = avgData.pm10 |
| | | // temperature = avgData.temperature |
| | | // humidity = avgData.humidity |
| | | // voc = avgData.voc |
| | | // noi = avgData.noi |
| | | // no = avgData.no |
| | | // windSpeed |
| | | // windDirection |
| | | rank |
| | | } |
| | | gridDataDetailList.add(dataDetail) |
| | |
| | | return gridDataDetailList |
| | | } |
| | | |
| | | /** |
| | | * 计ç®åæ ç¹å¨åªä¸ªå«æç½æ ¼å
|
| | | * @date 2025.2.14 |
| | | * @param point åæ ç¹ |
| | | * @param gridCellList å«æç½æ ¼ |
| | | */ |
| | | fun searchGirdIn(point: Pair<Double, Double>, gridCellList: List<GridCell?>): GridCell? { |
| | | for (i in gridCellList.indices) { |
| | | val gridCell = gridCellList[i] ?: continue |
| | | val polygon = listOf( |
| | | gridCell.point1Lon.toDouble() to gridCell.point1Lat.toDouble(), |
| | | gridCell.point2Lon.toDouble() to gridCell.point2Lat.toDouble(), |
| | | gridCell.point3Lon.toDouble() to gridCell.point3Lat.toDouble(), |
| | | gridCell.point4Lon.toDouble() to gridCell.point4Lat.toDouble(), |
| | | ) |
| | | if (MapUtil.isPointInPolygon(point, polygon)) { |
| | | return gridCell |
| | | } |
| | | } |
| | | |
| | | return null |
| | | } |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.biz.satellite |
| | | |
| | | import com.flightfeather.uav.common.utils.MapUtil |
| | | import com.flightfeather.uav.domain.entity.GridCell |
| | | import kotlin.math.ceil |
| | | |
| | | /** |
| | | * å«æç½æ ¼è®¡ç®å·¥å
· |
| | | */ |
| | | object SatelliteGridUtil { |
| | | |
| | | /** |
| | | * 计ç®åæ ç¹å¨åªä¸ªå«æç½æ ¼å
|
| | | * @date 2025.2.14 |
| | | * @param point åæ ç¹ |
| | | * @param gridCellList å«æç½æ ¼ |
| | | */ |
| | | fun searchGirdIn(point: Pair<Double, Double>, gridCellList: List<GridCell?>): GridCell? { |
| | | for (i in gridCellList.indices) { |
| | | val gridCell = gridCellList[i] ?: continue |
| | | val polygon = listOf( |
| | | gridCell.point1Lon.toDouble() to gridCell.point1Lat.toDouble(), |
| | | gridCell.point2Lon.toDouble() to gridCell.point2Lat.toDouble(), |
| | | gridCell.point3Lon.toDouble() to gridCell.point3Lat.toDouble(), |
| | | gridCell.point4Lon.toDouble() to gridCell.point4Lat.toDouble(), |
| | | ) |
| | | if (MapUtil.isPointInPolygon(point, polygon)) { |
| | | return gridCell |
| | | } |
| | | } |
| | | |
| | | return null |
| | | } |
| | | |
| | | /** |
| | | * è®¡ç®æ©æ£ç½æ ¼ï¼æ ¹æ®ç»å®ç½æ ¼ï¼è®¡ç®å¨å
¶å¨å´åºå®åå¾ä¸çææç½æ ¼ |
| | | * ç½æ ¼çå½¢å¼ä¸ºåå§å«æé¥æµç½æ ¼ä»¥åç»åç½æ ¼ |
| | | * åå§å«æé¥æµç½æ ¼çç¼å·é¡ºåºä¸ºä»å·¦å°å³ï¼ä»ä¸å°ä¸ç¼å·ä¾æ¬¡éå¢ |
| | | * ç»åç½æ ¼å¨åå§å«æé¥æµç½æ ¼çåºç¡ä¸ï¼æ¯ä¸ªç½æ ¼å
鍿ä»å·¦å°å³ï¼ä»ä¸å°ä¸ç¼å·ä¾æ¬¡éå¢ |
| | | * @param gridCellIndex ä¸å¿ç¹ç½æ ¼ç´¢å¼å¼ |
| | | * @param gridCellList ææç½æ ¼æ°ç» |
| | | * @param option ç½æ ¼ç»çåæ°ä¿¡æ¯ |
| | | * @param searchLength æ©æ£çç½æ ¼å徿°é |
| | | * @return 计ç®å¾åºçæ©æ£ç½æ ¼å¯¹è±¡æ°ç» |
| | | */ |
| | | fun searchDiffuseGrid( |
| | | gridCellIndex: Int, |
| | | gridCellList: List<GridCell?>, |
| | | option: GridGroupOption, |
| | | searchLength: Int, |
| | | ): List<GridCell> { |
| | | return emptyList() |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®ç½æ ¼ç´¢å¼ï¼è·åå
¶æå¨ä¸è¥¿æ¹åçç½æ ¼ç´¢å¼èå´ |
| | | * @param cellIndex ç½æ ¼ç´¢å¼ |
| | | * @param width ç½æ ¼å®½åº¦ï¼æä¸è¥¿æ¹åä¸çç½æ ¼æ°é |
| | | * @param height ç½æ ¼é«åº¦ï¼æååæ¹åä¸çç½æ ¼æ°é |
| | | * @return è¿åç½æ ¼ç´¢å¼å¼èå´ |
| | | */ |
| | | fun getCellWidthRange(cellIndex: Int, width: Int, height: Int): Pair<Double, Double>? { |
| | | val total = width * height; |
| | | val x = ceil(cellIndex.toDouble() / total) - 1; |
| | | val first = 1 + x * total |
| | | val last = width + x * total; |
| | | var scale = 0; |
| | | while (scale < height) { |
| | | val min = first + scale * width; |
| | | val max = last + scale * width; |
| | | if (cellIndex >= min && cellIndex <= max) { |
| | | return min to max |
| | | } |
| | | scale++; |
| | | } |
| | | return null |
| | | } |
| | | } |
| | |
| | | @Column(name = "cell_id") |
| | | private Integer cellId; |
| | | |
| | | private Integer rank; |
| | | |
| | | @Column(name = "NO2") |
| | | private Float no2; |
| | | |
| | | @Column(name = "CO") |
| | | private Float co; |
| | | |
| | | @Column(name = "H2S") |
| | | private Float h2s; |
| | | |
| | | @Column(name = "SO2") |
| | | private Float so2; |
| | | |
| | | @Column(name = "O3") |
| | | private Float o3; |
| | | |
| | | @Column(name = "PM25") |
| | | private Float pm25; |
| | | |
| | | private Integer rank; |
| | | @Column(name = "PM10") |
| | | private Float pm10; |
| | | |
| | | private Float temperature; |
| | | |
| | | private Float humidity; |
| | | |
| | | @Column(name = "VOC") |
| | | private Float voc; |
| | | |
| | | @Column(name = "NOI") |
| | | private Float noi; |
| | | |
| | | @Column(name = "NO") |
| | | private Float no; |
| | | |
| | | @Column(name = "wind_speed") |
| | | private Float windSpeed; |
| | | |
| | | @Column(name = "wind_direction") |
| | | private Float windDirection; |
| | | |
| | | /** |
| | | * @return id |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return rank |
| | | */ |
| | | public Integer getRank() { |
| | | return rank; |
| | | } |
| | | |
| | | /** |
| | | * @param rank |
| | | */ |
| | | public void setRank(Integer rank) { |
| | | this.rank = rank; |
| | | } |
| | | |
| | | /** |
| | | * @return NO2 |
| | | */ |
| | | public Float getNo2() { |
| | | return no2; |
| | | } |
| | | |
| | | /** |
| | | * @param no2 |
| | | */ |
| | | public void setNo2(Float no2) { |
| | | this.no2 = no2; |
| | | } |
| | | |
| | | /** |
| | | * @return CO |
| | | */ |
| | | public Float getCo() { |
| | | return co; |
| | | } |
| | | |
| | | /** |
| | | * @param co |
| | | */ |
| | | public void setCo(Float co) { |
| | | this.co = co; |
| | | } |
| | | |
| | | /** |
| | | * @return H2S |
| | | */ |
| | | public Float getH2s() { |
| | | return h2s; |
| | | } |
| | | |
| | | /** |
| | | * @param h2s |
| | | */ |
| | | public void setH2s(Float h2s) { |
| | | this.h2s = h2s; |
| | | } |
| | | |
| | | /** |
| | | * @return SO2 |
| | | */ |
| | | public Float getSo2() { |
| | | return so2; |
| | | } |
| | | |
| | | /** |
| | | * @param so2 |
| | | */ |
| | | public void setSo2(Float so2) { |
| | | this.so2 = so2; |
| | | } |
| | | |
| | | /** |
| | | * @return O3 |
| | | */ |
| | | public Float getO3() { |
| | | return o3; |
| | | } |
| | | |
| | | /** |
| | | * @param o3 |
| | | */ |
| | | public void setO3(Float o3) { |
| | | this.o3 = o3; |
| | | } |
| | | |
| | | /** |
| | | * @return PM25 |
| | | */ |
| | | public Float getPm25() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return rank |
| | | * @return PM10 |
| | | */ |
| | | public Integer getRank() { |
| | | return rank; |
| | | public Float getPm10() { |
| | | return pm10; |
| | | } |
| | | |
| | | /** |
| | | * @param rank |
| | | * @param pm10 |
| | | */ |
| | | public void setRank(Integer rank) { |
| | | this.rank = rank; |
| | | public void setPm10(Float pm10) { |
| | | this.pm10 = pm10; |
| | | } |
| | | |
| | | /** |
| | | * @return temperature |
| | | */ |
| | | public Float getTemperature() { |
| | | return temperature; |
| | | } |
| | | |
| | | /** |
| | | * @param temperature |
| | | */ |
| | | public void setTemperature(Float temperature) { |
| | | this.temperature = temperature; |
| | | } |
| | | |
| | | /** |
| | | * @return humidity |
| | | */ |
| | | public Float getHumidity() { |
| | | return humidity; |
| | | } |
| | | |
| | | /** |
| | | * @param humidity |
| | | */ |
| | | public void setHumidity(Float humidity) { |
| | | this.humidity = humidity; |
| | | } |
| | | |
| | | /** |
| | | * @return VOC |
| | | */ |
| | | public Float getVoc() { |
| | | return voc; |
| | | } |
| | | |
| | | /** |
| | | * @param voc |
| | | */ |
| | | public void setVoc(Float voc) { |
| | | this.voc = voc; |
| | | } |
| | | |
| | | /** |
| | | * @return NOI |
| | | */ |
| | | public Float getNoi() { |
| | | return noi; |
| | | } |
| | | |
| | | /** |
| | | * @param noi |
| | | */ |
| | | public void setNoi(Float noi) { |
| | | this.noi = noi; |
| | | } |
| | | |
| | | /** |
| | | * @return NO |
| | | */ |
| | | public Float getNo() { |
| | | return no; |
| | | } |
| | | |
| | | /** |
| | | * @param no |
| | | */ |
| | | public void setNo(Float no) { |
| | | this.no = no; |
| | | } |
| | | |
| | | /** |
| | | * @return wind_speed |
| | | */ |
| | | public Float getWindSpeed() { |
| | | return windSpeed; |
| | | } |
| | | |
| | | /** |
| | | * @param windSpeed |
| | | */ |
| | | public void setWindSpeed(Float windSpeed) { |
| | | this.windSpeed = windSpeed; |
| | | } |
| | | |
| | | /** |
| | | * @return wind_direction |
| | | */ |
| | | public Float getWindDirection() { |
| | | return windDirection; |
| | | } |
| | | |
| | | /** |
| | | * @param windDirection |
| | | */ |
| | | public void setWindDirection(Float windDirection) { |
| | | this.windDirection = windDirection; |
| | | } |
| | | } |
| | |
| | | package com.flightfeather.uav.lightshare.bean |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore |
| | | import com.fasterxml.jackson.annotation.JsonInclude |
| | | import com.flightfeather.uav.model.BaseMData |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | |
| | | * @param groupId |
| | | */ |
| | | fun dataFusion(missionCode: String, groupId: Int): List<GridDataDetail?> |
| | | |
| | | /** |
| | | * å°èµ°èªç½æ ¼æ°æ®çæå¯¹åºççåç½æ ¼å¾ |
| | | * @param groupId 使ç¨çç½æ ¼ç»id |
| | | * @param gridDataDetail 使ç¨çèµ°èªç½æ ¼æ°æ® |
| | | */ |
| | | fun buildHeatmap(groupId: Int, gridDataDetail: List<GridDataDetail>): List<GridDataDetail> |
| | | } |
| | |
| | | return gridDataDetailList |
| | | } |
| | | } |
| | | |
| | | override fun buildHeatmap(groupId: Int, gridDataDetail: List<GridDataDetail>): List<GridDataDetail> { |
| | | val gridCellList = satelliteGridRep.fetchGridCell(groupId) |
| | | |
| | | } |
| | | } |
| | |
| | | val res = satelliteGridRep.fetchGridDataDetail(dataId, groupId, cellId) |
| | | res.forEach { |
| | | if (it?.pm25 != null) { |
| | | it.pm25 = round(it.pm25 * 100) / 100 |
| | | it.pm25 = round(it.pm25 * 10) / 10 |
| | | } |
| | | } |
| | | return res |
| | |
| | | @ApiParam("ç½æ ¼ç»id") @RequestParam groupId: Int, |
| | | ) = resPack { satelliteDataCalculateService.dataFusion(missionCode, groupId) } |
| | | |
| | | |
| | | @ApiOperation(value = "çæèµ°èªçåå¾") |
| | | @PostMapping("/product/underway/heatmap/build") |
| | | fun buildUnderwayHeatmap( |
| | | @ApiParam("使ç¨çç½æ ¼ç»id") @RequestParam groupId: Int, |
| | | @ApiParam("使ç¨çèµ°èªç½æ ¼æ°æ®") @RequestBody gridDataDetail: List<GridDataDetail> |
| | | ) = resPack { satelliteDataCalculateService.buildHeatmap(groupId, gridDataDetail) } |
| | | } |
| | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.common.utils.ExcelUtil |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook |
| | | import org.apache.poi.xssf.streaming.SXSSFWorkbook |
| | | import java.io.File |
| | | import java.io.FileOutputStream |
| | |
| | | * æ±¡ææºå½±åç¨åº¦æéåææ¨¡å |
| | | * åºç±» |
| | | */ |
| | | abstract class BaseModel<M : BaseMData> { |
| | | abstract class BaseModel<M : BaseMData, S: BaseSOP> { |
| | | |
| | | data class ResultCell( |
| | | var total: Double = 0.0, |
| | |
| | | } |
| | | } |
| | | |
| | | abstract var dataPrep: BaseDataPrep<M, BaseSOP> |
| | | abstract var dataPrep: BaseDataPrep<M, S> |
| | | |
| | | // æéå åï¼å¨è¿è¡è®¡ç®åææ¶ä½¿ç¨ççæµå å |
| | | abstract var factorTypes: List<FactorType> |
| | | |
| | | // æéå¼ï¼å¤ç§æéè¿è¡ä¹ç§¯è®¡ç® |
| | | abstract var weights: List<BaseWeight<M, BaseSOP>> |
| | | abstract var weights: List<BaseWeight<M, S>> |
| | | |
| | | // 计ç®ç»æ |
| | | private val rMap = mutableMapOf<String, MutableMap<String, MutableMap<String, ResultCell>>>() |
| | | |
| | | // ç»æçéæ¹å¼ |
| | | abstract var sections: List<BaseSection<M, BaseSOP>> |
| | | abstract var sections: List<BaseSection<M, S>> |
| | | |
| | | /** |
| | | * æ±¡ææºå½±åç¨åº¦è®¡ç® |
| | | * @param mDataList çæµæ°æ®éå |
| | | * @param sopList æ±¡ææºéå |
| | | */ |
| | | fun execute(mDataList: List<M>, sopList: List<BaseSOP>, hasNext: Boolean = false) { |
| | | open fun execute(mDataList: List<M>, sopList: List<S>, hasNext: Boolean = false) { |
| | | if (!hasNext) rMap.clear() |
| | | |
| | | //1. æ°æ®é¢å¤ç |
| | |
| | | * @param mData çæµæ°æ® |
| | | * @param sop æ±¡ææº |
| | | */ |
| | | private fun weightCompute(mData: M, sop: BaseSOP) { |
| | | private fun weightCompute(mData: M, sop: S) { |
| | | val effect = BaseEffect(sop.sourceId, sop.sourceName, sop.index) |
| | | |
| | | // å°åçæµæ°æ®æç
§æé计ç®åºç»æå¼ |
| | |
| | | val lKey = "$se($factorType)" |
| | | if (lMap.containsKey(lKey)) { |
| | | val resultCell = lMap[lKey] ?: return@type |
| | | val size = resultCell.count |
| | | // val size = resultCell.count |
| | | // æ·»å 该åç±»ä½ä¸ºè¡¨å¤´ |
| | | val h = lKey |
| | | // val h = "$lKey($size)" |
| | |
| | | /** |
| | | * æ±¡ææºæ°æ®åæ³æ§æ£æ¥ |
| | | */ |
| | | abstract fun sopCheck(s: BaseSOP): Boolean |
| | | abstract fun sopCheck(s: S): Boolean |
| | | } |
| | |
| | | * Source of pollution |
| | | * æ±¡ææº åºç±» |
| | | */ |
| | | open class BaseSOP( |
| | | open class BaseSOP() { |
| | | |
| | | // æ±¡ææºæ è¯ |
| | | var sourceId: String, |
| | | var sourceName: String, |
| | | var index: String |
| | | ) { |
| | | lateinit var sourceId: String |
| | | lateinit var sourceName: String |
| | | lateinit var index: String |
| | | |
| | | constructor(sourceId: String, sourceName: String, index: String) : this() { |
| | | this.sourceId = sourceId |
| | | this.sourceName = sourceName |
| | | this.index = index |
| | | } |
| | | /** |
| | | * ä¸å¿ç»åº¦ |
| | | */ |
| | |
| | | * æ ¹æ®èµ°èªçæµæ°æ®ãå®ç¹çæµæ°æ®ï¼ç»åé£éãé£åãçæµç¹ä¸ç½æ ¼ä¸å¿çç¸å¯¹ä½ç½®çå ç´ ï¼è®¡ç®ç½æ ¼åºåå¯¹çæµåºåçå½±åç¨åº¦ |
| | | * @author riku |
| | | */ |
| | | class EPWGridModel : BaseModel<DataVo>() { |
| | | class EPWGridModel : BaseModel<DataVo, BaseSOP>() { |
| | | // é»è®¤çæµç¹ç»çº¬åº¦ |
| | | var defaultLocation: Pair<Double, Double>? = null |
| | | set(value) { |
| | |
| | | package com.flightfeather.uav.model.epw |
| | | |
| | | import com.flightfeather.uav.lightshare.bean.CompanySOP |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.model.* |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | |
| | | * æ ¹æ®èµ°èªçæµæ°æ®ï¼ç»åé£éãé£åãçæµç¹ä¸ä¼ä¸çç¸å¯¹ä½ç½®çå ç´ ï¼è®¡ç®ä¼ä¸å¯¹çæµåºåçå½±åç¨åº¦ |
| | | * @author riku |
| | | */ |
| | | class EPWModel : BaseModel<DataVo>() { |
| | | class EPWModel : BaseModel<DataVo, BaseSOP>() { |
| | | |
| | | // é»è®¤çæµç¹ç»çº¬åº¦ |
| | | var defaultLocation: Pair<Double, Double>? = null |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.model.underwaygrid |
| | | |
| | | import com.flightfeather.uav.domain.entity.GridCell |
| | | import com.flightfeather.uav.domain.entity.GridDataDetail |
| | | import com.flightfeather.uav.model.BaseMData |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import com.flightfeather.uav.socket.eunm.FactorType.* |
| | | |
| | | /** |
| | | * å«æç½æ ¼åæ åçæµæ°æ® |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class GridCellAndData(val gridCell: GridCell, val gridDataDetail: GridDataDetail): BaseMData() { |
| | | |
| | | override fun getFactorData(type: FactorType): Double? { |
| | | return when (type) { |
| | | // NO2 -> NO2 |
| | | // CO -> CO |
| | | // H2S -> H2S |
| | | // SO2 -> SO2 |
| | | // O3 -> O3 |
| | | PM25 -> gridDataDetail.pm25.toDouble() |
| | | // PM10 -> PM10 |
| | | // TEMPERATURE -> TEMPERATURE |
| | | // HUMIDITY -> HUMIDITY |
| | | // VOC -> VOC |
| | | // NOI -> NOI |
| | | // LNG -> LNG |
| | | // LAT -> LAT |
| | | // VELOCITY -> VELOCITY |
| | | // TIME -> TIME |
| | | // WIND_SPEED -> WIND_SPEED |
| | | // WIND_DIRECTION -> WIND_DIRECTION |
| | | // HEIGHT -> HEIGHT |
| | | // NO -> NO |
| | | else -> null |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.model.underwaygrid |
| | | |
| | | import com.flightfeather.uav.domain.entity.GridCell |
| | | import com.flightfeather.uav.model.BaseSOP |
| | | |
| | | /** |
| | | * å«ææ±¡ææºç½æ ¼ |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class GridCellSop : BaseSOP { |
| | | val gridCell:GridCell |
| | | |
| | | constructor(gridCell: GridCell) : super(){ |
| | | this.gridCell = gridCell |
| | | } |
| | | constructor(gridCell: GridCell, sourceId: String, sourceName: String, index: String) : super( |
| | | sourceId, |
| | | sourceName, index |
| | | ){ |
| | | this.gridCell = gridCell |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.model.underwaygrid |
| | | |
| | | import com.flightfeather.uav.model.BaseWeight |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import java.math.BigDecimal |
| | | import kotlin.math.PI |
| | | import kotlin.math.abs |
| | | import kotlin.math.atan2 |
| | | |
| | | /** |
| | | * é£åæé |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class GridWindDirWeight : BaseWeight<GridCellAndData, GridCellSop>() { |
| | | override val tag: String = "é£åæé" |
| | | |
| | | override val sectionValues: List<Double> = listOf(22.5, 67.5, 112.5, 157.5, 180.0) |
| | | |
| | | override val weights: List<Double> = listOf(1.0, 0.8, 0.5, 0.2, 0.1) |
| | | |
| | | override fun onWeightFactor(mData: GridCellAndData, sop: GridCellSop): Double? { |
| | | val p1 = Pair(mData.gridCell.longitude, mData.gridCell.latitude) |
| | | val p2 = Pair(sop.gridCell.longitude, sop.gridCell.latitude) |
| | | val wd = mData.getFactorData(FactorType.WIND_DIRECTION) ?: 0.0 |
| | | return getAngle(p1, p2, wd) |
| | | } |
| | | |
| | | private fun getAngle(p1: Pair<BigDecimal, BigDecimal>, p2: Pair<BigDecimal, BigDecimal>, wd: Double): Double { |
| | | val dx = p2.first - p1.first |
| | | val dy = p2.second - p1.second |
| | | var x1 = atan2(dy.toDouble(), dx.toDouble()) * 180 / PI + 180 |
| | | if (x1 < 0) x1 += 360 |
| | | var x2 = 270 - wd |
| | | if (x2 < 0) x2 += 360 |
| | | x1 = abs(x2 - x1) |
| | | if (x1 > 180) x1 = 360 - x1 |
| | | return x1 |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.model.underwaygrid |
| | | |
| | | import com.flightfeather.uav.model.BaseWeight |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | import java.math.BigDecimal |
| | | import kotlin.math.abs |
| | | import kotlin.math.max |
| | | import kotlin.math.sqrt |
| | | |
| | | /** |
| | | * é£éè·ç¦»æé |
| | | * çæµç¹ä¸æ±¡ææºä¹é´çç©çè·ç¦»ä¸å½åé£éå¾åºçæé |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class GridWindDisWeight : BaseWeight<GridCellAndData, GridCellSop>() { |
| | | |
| | | override val tag: String = "é£éè·ç¦»æé" |
| | | |
| | | override val sectionValues: List<Double> = listOf(2.0, 5.0, 8.0, 12.0, 20.0, 30.0) |
| | | |
| | | override val weights: List<Double> = listOf(1.0, 0.8, 0.6, 0.5, 0.3, 0.0) |
| | | |
| | | override fun onWeightFactor(mData: GridCellAndData, sop: GridCellSop): Double? { |
| | | val p1 = Pair(mData.gridCell.longitude, mData.gridCell.latitude) |
| | | val p2 = Pair(sop.gridCell.longitude, sop.gridCell.latitude) |
| | | val ws = mData.getFactorData(FactorType.WIND_SPEED) |
| | | return if (ws == null) null else getWindSpeed(p1, p2, ws) |
| | | } |
| | | |
| | | private fun getWindSpeed(p1: Pair<BigDecimal, BigDecimal>, p2: Pair<BigDecimal, BigDecimal>, ws: Double): Double { |
| | | val dx = (p2.first - p1.first).toDouble() |
| | | val dy = (p2.second - p1.second).toDouble() |
| | | val dis = sqrt(abs(dx * dx) + abs(dy * dy)) * 100 |
| | | val min = dis * 1000 / max(ws, 1.0) / 60 |
| | | return min |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.model.underwaygrid |
| | | |
| | | import com.flightfeather.uav.model.BaseDataPrep |
| | | |
| | | /** |
| | | * èµ°èªç½æ ¼æ°æ®é¢å¤ç |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class UnderwayGridDataPrep : BaseDataPrep<GridCellAndData, GridCellSop>() { |
| | | override fun mDataPrep(mDataList: List<GridCellAndData>): List<GridCellAndData> { |
| | | return mDataList |
| | | } |
| | | |
| | | override fun sopPrep(sopList: List<GridCellSop>): List<GridCellSop> { |
| | | return sopList |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.flightfeather.uav.model.underwaygrid |
| | | |
| | | import com.flightfeather.uav.model.BaseDataPrep |
| | | import com.flightfeather.uav.model.BaseModel |
| | | import com.flightfeather.uav.model.BaseSection |
| | | import com.flightfeather.uav.model.BaseWeight |
| | | import com.flightfeather.uav.model.epw.WeightType |
| | | import com.flightfeather.uav.socket.eunm.FactorType |
| | | |
| | | /** |
| | | * |
| | | * @date 2025/3/21 |
| | | * @author feiyu02 |
| | | */ |
| | | class UnderwayGridModel : BaseModel<GridCellAndData, GridCellSop>() { |
| | | override var dataPrep: BaseDataPrep<GridCellAndData, GridCellSop> = UnderwayGridDataPrep() |
| | | |
| | | override var factorTypes: List<FactorType> = WeightType.weightType |
| | | |
| | | override var weights: List<BaseWeight<GridCellAndData, GridCellSop>> = listOf(GridWindDirWeight(), GridWindDisWeight()) |
| | | |
| | | override var sections: List<BaseSection<GridCellAndData, GridCellSop>> = emptyList() |
| | | |
| | | override fun mDataCheck(m: GridCellAndData): Boolean { |
| | | return m.gridDataDetail.pm25 != null |
| | | } |
| | | |
| | | override fun sopCheck(s: GridCellSop): Boolean { |
| | | return s.gridCell.longitude != null && s.gridCell.latitude != null |
| | | } |
| | | } |
| | |
| | | <!-- <table tableName="real_time_data_grid_opt" domainObjectName="RealTimeDataGridOpt" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="scene_info" domainObjectName="SceneInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="segment_info" domainObjectName="SegmentInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <table tableName="grid_group" domainObjectName="GridGroup" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> |
| | | <!-- <table tableName="grid_group" domainObjectName="GridGroup" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="grid_cell" domainObjectName="GridCell" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="grid_data" domainObjectName="GridData" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <!-- <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>--> |
| | | <table tableName="grid_data_detail" domainObjectName="GridDataDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> |
| | | </context> |
| | | </generatorConfiguration> |
| | |
| | | <result column="data_id" jdbcType="INTEGER" property="dataId" /> |
| | | <result column="group_id" jdbcType="INTEGER" property="groupId" /> |
| | | <result column="cell_id" jdbcType="INTEGER" property="cellId" /> |
| | | <result column="PM25" jdbcType="REAL" property="pm25" /> |
| | | <result column="rank" jdbcType="INTEGER" property="rank" /> |
| | | <result column="NO2" jdbcType="REAL" property="no2" /> |
| | | <result column="CO" jdbcType="REAL" property="co" /> |
| | | <result column="H2S" jdbcType="REAL" property="h2s" /> |
| | | <result column="SO2" jdbcType="REAL" property="so2" /> |
| | | <result column="O3" jdbcType="REAL" property="o3" /> |
| | | <result column="PM25" jdbcType="REAL" property="pm25" /> |
| | | <result column="PM10" jdbcType="REAL" property="pm10" /> |
| | | <result column="temperature" jdbcType="REAL" property="temperature" /> |
| | | <result column="humidity" jdbcType="REAL" property="humidity" /> |
| | | <result column="VOC" jdbcType="REAL" property="voc" /> |
| | | <result column="NOI" jdbcType="REAL" property="noi" /> |
| | | <result column="NO" jdbcType="REAL" property="no" /> |
| | | <result column="wind_speed" jdbcType="REAL" property="windSpeed" /> |
| | | <result column="wind_direction" jdbcType="REAL" property="windDirection" /> |
| | | </resultMap> |
| | | <sql id="Base_Column_List"> |
| | | <!-- |
| | | WARNING - @mbg.generated |
| | | --> |
| | | id, data_id, group_id, cell_id, PM25, rank |
| | | id, data_id, group_id, cell_id, rank, NO2, CO, H2S, SO2, O3, PM25, PM10, temperature, |
| | | humidity, VOC, NOI, NO, wind_speed, wind_direction |
| | | </sql> |
| | | |
| | | <!-- æ·»å æ¹éæ´æ°PM25ç彿° --> |
| | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.common.utils.FileExchange |
| | | import com.flightfeather.uav.common.utils.FileUtil |
| | | import com.flightfeather.uav.domain.entity.BaseRealTimeData |
| | | import com.flightfeather.uav.domain.entity.Company |
| | | import com.flightfeather.uav.lightshare.eunm.SatelliteDataType |
| | | import com.flightfeather.uav.domain.entity.GridDataDetail |
| | | import com.flightfeather.uav.socket.bean.DataUnit |
| | | import com.flightfeather.uav.socket.decoder.AirDataDecoder |
| | | import com.flightfeather.uav.socket.eunm.AirCommandUnit |
| | | import com.google.gson.Gson |
| | | import org.jetbrains.kotlin.konan.util.visibleName |
| | | import org.junit.Test |
| | | import org.springframework.beans.BeanUtils |
| | | import java.io.File |
| | | import java.io.FileOutputStream |
| | | import java.io.OutputStreamWriter |
| | | import java.math.BigDecimal |
| | | import java.text.SimpleDateFormat |
| | | import java.util.* |
| | | |
| | |
| | | |
| | | @Test |
| | | fun listCopy() { |
| | | val l1 = listOf(Company().apply { ciGuid = "a" }, Company().apply { ciGuid = "b" }, Company().apply { ciGuid = "c" }) |
| | | val l1 = |
| | | listOf(Company().apply { ciGuid = "a" }, Company().apply { ciGuid = "b" }, Company().apply { ciGuid = "c" }) |
| | | val l2 = mutableListOf<Company>().apply { addAll(l1) } |
| | | l2[1].ciGuid = "d" |
| | | println(l1) |
| | |
| | | |
| | | @Test |
| | | fun get_crc16(){ |
| | | val dataSegment = "QN=20210713133901044;ST=22;CN=2011;PW=555555;MN=FYHB0DT0100001;Flag=1;CP=&&DataTime=20210713133800;a34001-Avg=0.017,a34001-CPM=3.9,a34001-Flag=N;a50001-Avg=71.1,a50001-Flag=N;a01001-Avg=34.0,a01001-Flag=N;a01002-Avg=59.3,a01002-Flag=N;a01007-Avg=0.6,a01007-Flag=N;a01008-Avg=256.3,a01008-Flag=N;Period=1;Scale=1.0;SelfTemp=0.0;SelfHum=0.0;IsReplacement=N&&" |
| | | val dataSegment = |
| | | "QN=20210713133901044;ST=22;CN=2011;PW=555555;MN=FYHB0DT0100001;Flag=1;CP=&&DataTime=20210713133800;a34001-Avg=0.017,a34001-CPM=3.9,a34001-Flag=N;a50001-Avg=71.1,a50001-Flag=N;a01001-Avg=34.0,a01001-Flag=N;a01002-Avg=59.3,a01002-Flag=N;a01007-Avg=0.6,a01007-Flag=N;a01008-Avg=256.3,a01008-Flag=N;Period=1;Scale=1.0;SelfTemp=0.0;SelfHum=0.0;IsReplacement=N&&" |
| | | var CRC = 0x0000ffff |
| | | val POLYNOMIAL = 0x0000a001 |
| | | var i: Int |
| | |
| | | |
| | | @Test |
| | | fun foo17() { |
| | | println(SatelliteDataType.Original.name) |
| | | println(SatelliteDataType.Original.value) |
| | | println(SatelliteDataType.Original.ordinal) |
| | | println(SatelliteDataType.Original.toString()) |
| | | println(SatelliteDataType.Original.visibleName) |
| | | println(SatelliteDataType.Original) |
| | | val avgData = BaseRealTimeData().apply { |
| | | no2 = 50f |
| | | co = 50f |
| | | h2s = 50f |
| | | so2 = 50f |
| | | o3 = 50f |
| | | pm25 = 50f |
| | | pm10 = 50f |
| | | temperature = 50f |
| | | humidity = 50f |
| | | voc = 50f |
| | | noi = 50f |
| | | no = 50f |
| | | windSpeed = 2f |
| | | windDirection = 240f |
| | | } |
| | | val dataDetail = GridDataDetail() |
| | | BeanUtils.copyProperties(avgData, dataDetail) |
| | | |
| | | println(dataDetail) |
| | | } |
| | | } |
| | |
| | | @Test |
| | | fun dataFusion() { |
| | | val missionList = |
| | | listOf("SH-CN-20241202", "SH-CN-20241127", "SH-CN-20241126-1", "SH-CN-20241126-2", "SH-CN-20241108", "SH-CN-20240823") |
| | | listOf( |
| | | "SH-CN-20241216", |
| | | "SH-CN-20241202", |
| | | "SH-CN-20241127", |
| | | "SH-CN-20241126-1", |
| | | "SH-CN-20241126-2", |
| | | "SH-CN-20241108", |
| | | "SH-CN-20240823" |
| | | ) |
| | | missionList.forEach { m -> |
| | | satelliteDataCalculateService.dataFusion(m, 3) |
| | | } |