@Test public void testCalculateProjections() { Projector projector = new Projector(); projector.setGHStorage(ToyGraphCreationUtil.createMediumGraph2(encodingManager)); Map<Projector.Projection, IntArrayList> projections = projector.calculateProjections(); IntArrayList expected_m00 = new IntArrayList(); expected_m00.add(1, 2, 3, 0, 8, 4, 6, 5, 7); assertEquals(expected_m00, projections.get(Projector.Projection.LINE_M00)); IntArrayList expected_p90 = new IntArrayList(); expected_p90.add(1, 8, 0, 2, 6, 7, 3, 4, 5); assertEquals(expected_p90, projections.get(Projector.Projection.LINE_P90)); IntArrayList expected_p45 = new IntArrayList(); expected_p45.add(1, 2, 8, 0, 3, 6, 4, 7, 5); assertEquals(expected_p45, projections.get(Projector.Projection.LINE_P45)); }
protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; }
Projector { protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; } }
Projector { protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; } Projector(); }
Projector { protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; } Projector(); void setGHStorage(GraphHopperStorage ghStorage); }
Projector { protected Map<Projection, IntArrayList> calculateProjections() { EnumMap<Projection, IntArrayList> nodeListProjMap = new EnumMap<>(Projection.class); Integer[] ids = IntStream.rangeClosed(0, ghStorage.getNodes() - 1).boxed().toArray(Integer[]::new); Double[] values = new Double[ids.length]; Sort sort = new Sort(); for (Projection proj : Projection.values()) { for (int i = 0; i < ids.length; i++) { values[i] = proj.sortValue(ghStorage.getNodeAccess().getLatitude(ids[i]), ghStorage.getNodeAccess().getLongitude(ids[i])); } nodeListProjMap.put(proj, sort.sortByValueReturnList(ids, values)); } boolean valid = false; for (Projection proj : Projection.values()) { if (!nodeListProjMap.get(proj).equals(nodeListProjMap.get(LINE_M00))) valid = true; } if (!valid) throw new IllegalStateException("All projections of the graph are the same. Maybe NodeAccess is faulty or not initialized?"); return nodeListProjMap; } Projector(); void setGHStorage(GraphHopperStorage ghStorage);  }