Traccar、Docker中一些重要目录笔记

一、Docker
1. mysql(mariadb10)目录: /volume1/@appstore/MariaDB10/usr/local/mariadb10/
2. docker中安装的容器目录:/volume1/@docker/btrfs/subvolumes

原文作者: admin | 查看原帖

此条目发表在学习笔记分类目录。将固定链接加入收藏夹。

《Traccar、Docker中一些重要目录笔记》有3条回应

  1. admin说:

    二、Traccar
    1、/traccar/src/main/java/org/traccar/geocoder 为调用各种地图的逆地址的解码函数目录。
    2、/traccar/src/main/java/org/traccar/protocol 各种GPS设备通讯协议的解码器。
    3、/traccar/traccar-web/web 客户端页面,其中“app.min.js”为编译压缩后的文件,也可通过“debug.html”文件调用未编译版。
    4、/traccar/src/main/java/org/traccar/geofence 电子围栏
    5、/traccar/src/main/java/org/traccar/model/Position.java 存取坐标数据

  2. admin说:

    1、在服务器收到手机发过来的定位数据后,直接在OsmAndProtocolDecoder.java(OSM协议解码文件)中将WGS84坐标,转换为GCJ02、BD09坐标,存入数据库中。

    1. protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
    2.  
    3.         FullHttpRequest request = (FullHttpRequest) msg;
    4.         QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
    5.         Map<String, List<String>> params = decoder.parameters();
    6.         if (params.isEmpty()) {
    7.             decoder = new QueryStringDecoder(request.content().toString(StandardCharsets.US_ASCII), false);
    8.             params = decoder.parameters();
    9.         }
    10.  
    11.         Position position = new Position(getProtocolName());
    12.         position.setValid(true);
    13.  
    14.         /* 坐标转换 WGS84 -> GCJ02  BD09*/
    15.         Double tlat = Double.parseDouble(params.get("lat").get(0));
    16.         Double tlon = Double.parseDouble(params.get("lon").get(0));
    17.         double pos_gcj02[] = GpsCoordinateUtils.calWGS84toGCJ02(tlat, tlon);
    18.         double pos_bd09[]  = GpsCoordinateUtils.calWGS84toBD09(tlat, tlon);
    19.  
    20.         Network network = new Network();
    21.  
    22.         for (Map.Entry<String, List<String>> entry : params.entrySet()) {
    23.             for (String value : entry.getValue()) {
    24.                 switch (entry.getKey()) {
    25.                     case "id":
    26.                     case "deviceid":
    27.                         DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, value);
    28.                         if (deviceSession == null) {
    29.                             sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
    30.                             return null;
    31.                         }
    32.                         position.setDeviceId(deviceSession.getDeviceId());
    33.                         break;
    34.                     case "valid":
    35.                         position.setValid(Boolean.parseBoolean(value) || "1".equals(value));
    36.                         break;
    37.                     case "timestamp":
    38.                         try {
    39.                             long timestamp = Long.parseLong(value);
    40.                             if (timestamp < Integer.MAX_VALUE) {
    41.                                 timestamp *= 1000;
    42.                             }
    43.                             position.setTime(new Date(timestamp));
    44.                         } catch (NumberFormatException error) {
    45.                             if (value.contains("T")) {
    46.                                 position.setTime(DateUtil.parseDate(value));
    47.                             } else {
    48.                                 DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    49.                                 position.setTime(dateFormat.parse(value));
    50.                             }
    51.                         }
    52.                         break;
    53.                     case "lat":
    54.                         position.setLatitude(Double.parseDouble(value));  // WGS84
    55.                         position.setLatitude_gcj02(pos_gcj02[0]);  // GCJ02
    56.                         position.setLatitude_bd09(pos_bd09[0]);  // BD09
    57.                         break;
    58.                     case "lon":
    59.                         position.setLongitude(Double.parseDouble(value));  // WGS84
    60.                         position.setLongitude_gcj02(pos_gcj02[1]);  // GCJ02
    61.                         position.setLongitude_bd09(pos_bd09[1]);  // BD09
    62.                         break;
    63.                     case "location":
    64.                         String[] location = value.split(",");  // WGS84
    65.                         position.setLatitude(Double.parseDouble(location[0]));
    66.                         position.setLongitude(Double.parseDouble(location[1]));
    67.  
    68.                         position.setLatitude_gcj02(pos_gcj02[0]);  // GCJ02
    69.                         position.setLongitude_gcj02(pos_gcj02[1]);  // GCJ02
    70.  
    71.                         position.setLatitude_bd09(pos_bd09[0]);  // BD09
    72.                         position.setLongitude_bd09(pos_bd09[1]);  // BD09
    73.                         break;
    74.                     case "cell":
    75.                         String[] cell = value.split(",");
    76.                         if (cell.length > 4) {
    77.                             network.addCellTower(CellTower.from(
    78.                                     Integer.parseInt(cell[0]), Integer.parseInt(cell[1]),
    79.                                     Integer.parseInt(cell[2]), Integer.parseInt(cell[3]), Integer.parseInt(cell[4])));
    80.                         } else {
    81.                             network.addCellTower(CellTower.from(
    82.                                     Integer.parseInt(cell[0]), Integer.parseInt(cell[1]),
    83.                                     Integer.parseInt(cell[2]), Integer.parseInt(cell[3])));
    84.                         }
    85.                         break;
    86.                     case "wifi":
    87.                         String[] wifi = value.split(",");
    88.                         network.addWifiAccessPoint(WifiAccessPoint.from(
    89.                                 wifi[0].replace(‘-‘, ‘:’), Integer.parseInt(wifi[1])));
    90.                         break;
    91.                     case "speed":
    92.                         position.setSpeed(convertSpeed(Double.parseDouble(value), "kn"));
    93.                         break;
    94.                     case "bearing":
    95.                     case "heading":
    96.                         position.setCourse(Double.parseDouble(value));
    97.                         break;
    98.                     case "altitude":
    99.                         position.setAltitude(Double.parseDouble(value));
    100.                         break;
    101.                     case "accuracy":
    102.                         position.setAccuracy(Double.parseDouble(value));
    103.                         break;
    104.                     case "hdop":
    105.                         position.set(Position.KEY_HDOP, Double.parseDouble(value));
    106.                         break;
    107.                     case "batt":
    108.                         position.set(Position.KEY_BATTERY_LEVEL, Double.parseDouble(value));
    109.                         break;
    110.                     case "driverUniqueId":
    111.                         position.set(Position.KEY_DRIVER_UNIQUE_ID, value);
    112.                         break;
    113.                     default:
    114.                         try {
    115.                             position.set(entry.getKey(), Double.parseDouble(value));
    116.                         } catch (NumberFormatException e) {
    117.                             switch (value) {
    118.                                 case "true":
    119.                                     position.set(entry.getKey(), true);
    120.                                     break;
    121.                                 case "false":
    122.                                     position.set(entry.getKey(), false);
    123.                                     break;
    124.                                 default:
    125.                                     position.set(entry.getKey(), value);
    126.                                     break;
    127.                             }
    128.                         }
    129.                         break;
    130.                 }
    131.             }
    132.         }
    133.  
    134.         if (position.getFixTime() == null) {
    135.             position.setTime(new Date());
    136.         }
    137.  
    138.         if (network.getCellTowers() != null || network.getWifiAccessPoints() != null) {
    139.             position.setNetwork(network);
    140.         }
    141.  
    142.         if (position.getLatitude() == 0 && position.getLongitude() == 0) {
    143.             getLastLocation(position, position.getDeviceTime());
    144.         }
    145.  
    146.         if (position.getDeviceId() != 0) {
    147.             sendResponse(channel, HttpResponseStatus.OK);
    148.             return position;
    149.         } else {
    150.             sendResponse(channel, HttpResponseStatus.BAD_REQUEST);
    151.             return null;
    152.         }
    153.     }
  3. admin说:

    为数据库增加GCJ02 、BD09坐标的字段:changelog-4.8c.xml

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <databaseChangeLog
    3.  logicalFilePath="changelog-4.8c">
    4.  
    5.   <changeSet author="author" id="changelog-4.8c">
    6.  
    7.     <addColumn tableName="tc_positions">
    8.       <column name="latitude_gcj02" type="DOUBLE" />
    9.     </addColumn>
    10.     <addColumn tableName="tc_positions">
    11.       <column name="longitude_gcj02" type="DOUBLE" />
    12.     </addColumn>
    13.  
    14.     <addColumn tableName="tc_positions">
    15.       <column name="latitude_bd09" type="DOUBLE" />
    16.     </addColumn>
    17.     <addColumn tableName="tc_positions">
    18.       <column name="longitude_bd09" type="DOUBLE" />
    19.     </addColumn>
    20.  
    21.   </changeSet>
    22.  
    23. </databaseChangeLog>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。