package com.tairui.app.cim.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tairui.app.cim.dao.model.AlarmPoint;
import com.tairui.app.cim.dao.model.Elevation;
import com.vividsolutions.jts.geom.Point;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* Mapper 接口
*
*
* @author yw
* @since 2022-05-21
*/
@Mapper
@Repository
public interface ElevationMapper extends BaseMapper {
/**
* 包含面
* select * from (select gid,geom,coor_z,cen_x,cen_y,name from elevation_correction where floor_num='Floor5')
* as xx where ST_Within(st_geomfromtext('Point(124.041948 41.840189)',4326),xx.geom)
*
* @param x
* @param y
* @param floor
* @return
*/
@Select("select gid,to_char(coor_z,'999.999') as high ,name from elevation_correction " +
"where floor_num='${floor_num}' and ST_Within(st_geomfromtext('Point(${x} ${y})',4326),geom) ")
public List queryFloor(@Param("x") double x, @Param("y") double y, @Param("floor_num") String floor_num);
/**
* 查询最近的面
* select * from (select gid,geom,coor_z,cen_x,cen_y,name from elevation_correction
* where floor_num='Floor3') as xx order by (st_geomfromtext('Point(124.04 41.840)',4326)<->xx.geom) asc limit 1
*
* @param x
* @param y
* @param floor
* @return
*/
@Select("select gid,to_char(coor_z,'999.999') as high ,ST_X(ST_AsText(ST_PointOnSurface(geom::geometry))) as cen_x," +
"ST_Y(ST_AsText(ST_PointOnSurface(geom::geometry))) as cen_y,name from elevation_correction " +
"where floor_num='${floor_num}' order by (st_geomfromtext('Point(${x} ${y})',4326)<->geom) asc limit 1")
public List queryMinDistance(@Param("x") double x, @Param("y") double y, @Param("floor_num") String floor_num);
}