com.graphhopper.storage.Graph.getNodeAccess()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中com.graphhopper.storage.Graph.getNodeAccess()方法的一些代码示例,展示了Graph.getNodeAccess()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graph.getNodeAccess()方法的具体详情如下:
包路径:com.graphhopper.storage.Graph
类名称:Graph
方法名:getNodeAccess

Graph.getNodeAccess介绍

[英]Creates a node explorer to access node properties.
[中]创建节点资源管理器以访问节点属性。

代码示例

代码示例来源:origin: graphhopper/graphhopper

/**
 * See 'lookup' for further variables that are initialized
 */
private QueryGraph(Graph graph, QueryGraph superQueryGraph) {
  mainGraph = graph;
  baseGraph = this;
  wrappedExtension = superQueryGraph.wrappedExtension;
  mainNodeAccess = graph.getNodeAccess();
  mainNodes = superQueryGraph.mainNodes;
  mainEdges = superQueryGraph.mainEdges;
}

代码示例来源:origin: graphhopper/graphhopper

public DebugDijkstraBidirection(Graph graph, Weighting type, TraversalMode tMode, GraphicsWrapper mg) {
  super(graph, type, tMode);
  this.mg = mg;
  na = graph.getNodeAccess();
}

代码示例来源:origin: graphhopper/graphhopper

public DebugAStar(Graph graph, Weighting type, TraversalMode tMode, GraphicsWrapper mg) {
  super(graph, type, tMode);
  this.mg = mg;
  na = graph.getNodeAccess();
}

代码示例来源:origin: graphhopper/graphhopper

public Location2IDFullWithEdgesIndex(Graph g) {
  this.graph = g;
  this.nodeAccess = g.getNodeAccess();
}

代码示例来源:origin: graphhopper/graphhopper

public GraphicsWrapper(Graph g) {
  this.na = g.getNodeAccess();
  BBox b = g.getBounds();
  scaleX = scaleY = 0.002 * (b.maxLat - b.minLat);
  offsetY = b.maxLat - 90;
  offsetX = -b.minLon;
}

代码示例来源:origin: graphhopper/graphhopper

@Override
public void init(Graph graph, Directory dir) {
  if (turnCostsCount > 0)
    throw new AssertionError("The turn cost storage must be initialized only once.");
  this.nodeAccess = graph.getNodeAccess();
  this.turnCosts = dir.find("turn_costs");
}

代码示例来源:origin: graphhopper/graphhopper

public Location2IDQuadtree(Graph g, Directory dir) {
  this.graph = g;
  this.nodeAccess = g.getNodeAccess();
  index = dir.find("loc2id_index");
  setResolution(100 * 100);
}

代码示例来源:origin: graphhopper/graphhopper

public Path(Graph graph, Weighting weighting) {
  this.weight = Double.MAX_VALUE;
  this.graph = graph;
  this.nodeAccess = graph.getNodeAccess();
  this.weighting = weighting;
  this.encoder = weighting.getFlagEncoder();
  this.edgeIds = new GHIntArrayList();
}

代码示例来源:origin: graphhopper/graphhopper

/**
 * @param g the graph for which this index should do the lookup based on latitude,longitude.
 */
public LocationIndexTree(Graph g, Directory dir) {
  if (g instanceof CHGraph)
    throw new IllegalArgumentException("Use base graph for LocationIndexTree instead of CHGraph");
  MAGIC_INT = Integer.MAX_VALUE / 22316;
  this.graph = g;
  this.nodeAccess = g.getNodeAccess();
  dataAccess = dir.find("location_index", DAType.getPreferredInt(dir.getDefaultType()));
}

代码示例来源:origin: graphhopper/graphhopper

public static int getIdOf(Graph g, double latitude) {
  int s = g.getNodes();
  NodeAccess na = g.getNodeAccess();
  for (int i = 0; i < s; i++) {
    if (Math.abs(na.getLatitude(i) - latitude) < 1e-4) {
      return i;
    }
  }
  return -1;
}

代码示例来源:origin: graphhopper/graphhopper

public static int getIdOf(Graph g, double latitude, double longitude) {
  int s = g.getNodes();
  NodeAccess na = g.getNodeAccess();
  for (int i = 0; i < s; i++) {
    if (Math.abs(na.getLatitude(i) - latitude) < 1e-4 && Math.abs(na.getLongitude(i) - longitude) < 1e-4) {
      return i;
    }
  }
  throw new IllegalArgumentException("did not find node with location " + (float) latitude + "," + (float) longitude);
}

代码示例来源:origin: graphhopper/graphhopper

public boolean containsLatitude(Graph g, EdgeIterator iter, double latitude) {
  NodeAccess na = g.getNodeAccess();
  while (iter.next()) {
    if (Math.abs(na.getLatitude(iter.getAdjNode()) - latitude) < 1e-4)
      return true;
  }
  return false;
}

代码示例来源:origin: graphhopper/graphhopper

public OSMReader(GraphHopperStorage ghStorage) {
  this.ghStorage = ghStorage;
  this.graph = ghStorage;
  this.nodeAccess = graph.getNodeAccess();
  this.encodingManager = ghStorage.getEncodingManager();
  osmNodeIdToInternalNodeMap = new GHLongIntBTree(200);
  osmNodeIdToNodeFlagsMap = new GHLongLongHashMap(200, .5f);
  osmWayIdToRouteWeightMap = new GHLongLongHashMap(200, .5f);
  pillarInfo = new PillarInfo(nodeAccess.is3D(), ghStorage.getDirectory());
}

代码示例来源:origin: graphhopper/graphhopper

private String getCoords(EdgeIteratorState edge, Graph graph) {
  NodeAccess na = graph.getNodeAccess();
  int base = edge.getBaseNode();
  int adj = edge.getAdjNode();
  return base + "->" + adj + " (" + edge.getEdge() + "); "
      + na.getLat(base) + "," + na.getLon(base) + " -> " + na.getLat(adj) + "," + na.getLon(adj);
}

代码示例来源:origin: graphhopper/graphhopper

@Test
public void testNoErrorOnEdgeCase_lastIndex() {
  final EncodingManager encodingManager = new EncodingManager("car");
  int locs = 10000;
  Graph g = AbstractLocationIndexTester.this.createGHStorage(new MMapDirectory(location), encodingManager, false);
  NodeAccess na = g.getNodeAccess();
  Random rand = new Random(12);
  for (int i = 0; i < locs; i++) {
    na.setNode(i, (float) rand.nextDouble() * 10 + 10, (float) rand.nextDouble() * 10 + 10);
  }
  idx = createIndex(g, 200);
  Helper.close((Closeable) g);
}

代码示例来源:origin: graphhopper/graphhopper

private void initHorseshoeGraph(Graph g) {
  // setup graph
  //   ____
  //  |    |
  //  |    |
  //  0    1
  NodeAccess na = g.getNodeAccess();
  na.setNode(0, 0, 0);
  na.setNode(1, 0, 2);
  g.edge(0, 1, 10, true).setWayGeometry(Helper.createPointList(2, 0, 2, 2));
}

代码示例来源:origin: graphhopper/graphhopper

public static String getNodeInfo(Graph g, int nodeId, EdgeFilter filter) {
  EdgeIterator iter = g.createEdgeExplorer(filter).setBaseNode(nodeId);
  NodeAccess na = g.getNodeAccess();
  String str = nodeId + ":" + na.getLatitude(nodeId) + "," + na.getLongitude(nodeId) + "\n";
  while (iter.next()) {
    str += "  ->" + iter.getAdjNode() + " (" + iter.getDistance() + ") pillars:"
        + iter.fetchWayGeometry(0).getSize() + ", edgeId:" + iter.getEdge()
        + "\t" + BitUtil.BIG.toBitString(iter.getFlags(), 8) + "\n";
  }
  return str;
}

代码示例来源:origin: graphhopper/graphhopper

public static void updateDistancesFor(Graph g, int node, double lat, double lon) {
  NodeAccess na = g.getNodeAccess();
  na.setNode(node, lat, lon);
  EdgeIterator iter = g.createEdgeExplorer().setBaseNode(node);
  while (iter.next()) {
    iter.setDistance(iter.fetchWayGeometry(3).calcDistance(distCalc));
    // System.out.println(node + "->" + adj + ": " + iter.getDistance());
  }
}

代码示例来源:origin: graphhopper/graphhopper

@Test
public void testSortDirected() {
  Graph g = createGraph();
  NodeAccess na = g.getNodeAccess();
  na.setNode(0, 0, 1);
  na.setNode(1, 2.5, 2);
  na.setNode(2, 3.5, 3);
  g.edge(0, 1, 1.1, false);
  g.edge(2, 1, 1.1, false);
  GHUtility.sortDFS(g, createGraph());
}

代码示例来源:origin: graphhopper/graphhopper

@Test
public void testSort2() {
  Graph g = initUnsorted(createGraph());
  Graph newG = GHUtility.sortDFS(g, createGraph());
  assertEquals(g.getNodes(), newG.getNodes());
  NodeAccess na = newG.getNodeAccess();
  assertEquals(0, na.getLatitude(0), 1e-4); // 0
  assertEquals(2.5, na.getLatitude(1), 1e-4); // 1
  assertEquals(4.5, na.getLatitude(2), 1e-4); // 2
  assertEquals(4.6, na.getLatitude(3), 1e-4); // 8        
}

相关文章