| | |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | |
| | | public int[][] getData(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | try { |
| | | BasMap basMap = basMapService.selectLatestMap(lev); |
| | | String originData = basMap.getOriginData(); |
| | | |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(originData, ArrayList.class); |
| | | List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | int[][] map = new int[lists.size()][]; |
| | | int j = 0; |
| | | for (List<MapNode> list : lists) { |
| | | int[] tmp = new int[list.size()]; |
| | | int i = 0; |
| | | for (MapNode mapNode : list) { |
| | | //将数据添加进二维数组 |
| | | tmp[i++] = mapNode.getValue(); |
| | | } |
| | | //数据添加进一维数组 |
| | | map[j++] = tmp; |
| | | } |
| | | |
| | | return map; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 尝试从redis获取数据 |
| | | */ |
| | | public int[][] getDataFromRedis(Integer lev, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | Object o = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (o == null) { |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) { |
| | | return null; |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(o.toString(), BasMap.class); |
| | | return this.getDataFormString(lev, basMap.getData(), mapTypes, whitePoints, shuttlePoints); |
| | | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; |
| | | return this.getDataFormString(lev, arrayList, mapTypes, whitePoints, shuttlePoints); |
| | | } |
| | | |
| | | /** |
| | | * 从List数据中获取地图 |
| | | */ |
| | | public int[][] getDataFormString(Integer lev, String data, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | ArrayList arrayList = JSON.parseObject(data, ArrayList.class); |
| | | public int[][] getDataFormString(Integer lev, List<List<MapNode>> arrayList, List<NavigationMapType> mapTypes, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | int[][] map = new int[lists.size()][]; |
| | | int j = 0; |
| | |
| | | return null; |
| | | } |
| | | |
| | | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); |
| | | //解析json地图数据 |
| | | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); |
| | | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; |
| | | List<List<MapNode>> lists = filterMap(mapTypes, arrayList, lev, whitePoints, shuttlePoints);//过滤地图数据 |
| | | return lists; |
| | | } catch (Exception e) { |
| | |
| | | * @param whitePoints 白名单节点,不需要被过滤 |
| | | * @param shuttlePoints 穿梭车节点,需要加载进地图 |
| | | */ |
| | | public List<List<MapNode>> filterMap(List<NavigationMapType> mapTypes, List arrayList, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | //重建数据格式 |
| | | List<List<MapNode>> lists = rebuildData(arrayList); |
| | | |
| | | public List<List<MapNode>> filterMap(List<NavigationMapType> mapTypes, List<List<MapNode>> lists, Integer lev, List<int[]> whitePoints, List<int[]> shuttlePoints) { |
| | | List<NavigationMapType> locMapType = new ArrayList<>(); |
| | | locMapType.add(NavigationMapType.NONE); |
| | | locMapType.add(NavigationMapType.DFX); |
| | | locMapType.add(NavigationMapType.NORMAL); |
| | | for (NavigationMapType mapType : mapTypes) { |
| | |
| | | lists = loadPathLock(lists, lev); |
| | | } |
| | | |
| | | // if(mapType.equals(NavigationMapType.TRAFFIC_CONTROL)) { |
| | | // //加载交通管制 |
| | | // lists = loadTrafficControl(lists, lev); |
| | | // } |
| | | if(mapType.equals(NavigationMapType.TRAFFIC_CONTROL)) { |
| | | //加载交通管制 |
| | | lists = loadTrafficControl(lists, lev); |
| | | } |
| | | } |
| | | |
| | | //加载白名单节点 |