package com.ruoyi.test.Geo;
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
import com.ruoyi.utils.gis.Point;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @Description:
|
* @ClassName: main
|
* @Author: 刘苏义
|
* @Date: 2023年08月30日9:55:12
|
**/
|
class Main {
|
public static void main(String[] args) {
|
GeofenceManager geofenceManager = new GeofenceManager();
|
|
GeofenceCallback geofenceCallback= new GeofenceCallback() {
|
@Override
|
public void onEnter(String id,SysUser user) {
|
System.out.println("用户" + user.getUserId() + "进入电子围栏" + id + "区域,触发报警!");
|
}
|
|
@Override
|
public void onExit(String id,SysUser user) {
|
System.out.println("用户" + user.getUserId() + "未在电子围栏" + id + "区域。");
|
}
|
};
|
|
List<Point> polygonVertices = new ArrayList<>();
|
polygonVertices.add(new Point(126.6491, 45.739108));
|
polygonVertices.add(new Point(126.643458, 45.731584));
|
polygonVertices.add(new Point(126.654921, 45.726979));
|
polygonVertices.add(new Point(126.660742, 45.734956));
|
Geofence geofence = new Geofence("1",polygonVertices, geofenceCallback);
|
geofenceManager.addGeofence(geofence);
|
|
List<Point> polygonVertices1 = new ArrayList<>();
|
polygonVertices1.add(new Point(126.655244,45.726576));
|
polygonVertices1.add(new Point(126.67242,45.720586));
|
polygonVertices1.add(new Point(126.679606,45.729143));
|
polygonVertices1.add(new Point(126.660993,45.734881));
|
Geofence geofence1 = new Geofence("2",polygonVertices1,geofenceCallback);
|
geofenceManager.addGeofence(geofence1);
|
|
Point userCoordinates = new Point(126.666455,45.727986);
|
SysUser user = new SysUser();
|
user.setUserId("55555");
|
geofenceManager.checkCoordinates(userCoordinates, user);
|
}
|
}
|