5.10 Network Buffers

Network Data Model (NDM) introduces the network buffer representation that captures the coverage and cost information on top of the network representation. In contrast to the spatial buffer approach, the cost information of network buffers is accurate and efficient.

You can compute a network buffer with the LOD Java API. Each buffer center can either be a node or a point along a link (PointOnNet), and a network buffer can have multiple buffer centers. For large-scale drive time and distance analysis, you can precompute and persist network buffers in the database. Additionally, you can query on coverage, cost, and shortest path on one or multiple network buffers using simple SQL statements and without any spatial operations or network analysis.

The following sections show examples using Java snippets to create and persist a network buffer to the database and then query the coverage and cost information using SQL.

5.10.1 Creating a Network Buffer

You can create a network buffer using the Java API.

The following example shows how to create a network buffer that captures the coverage within a ten-minute drive of a single location using the Network Analyst class. The newly created buffer is then stored in the network buffer tables in the database with the prefix SF. However, note, the writeNetworkBuffer() method creates the network buffer tables only if they are already not existing in the database. Otherwise, the existing tables are used.

Example 5-3 Creating a Network Buffer

PointOnNet[] startPoint = {new PointOnNet(linkId, percent)};
double cost = 600; // 600 seconds

// Creates a network buffer with the given start point and cost
NetworkBuffer buffer = analyst.networkBuffer(startPoint, cost, null);
int bufferId = 0;
String tableNamePrefix = "SF";

// Writes the network buffer tables
networkIO.writeNetworkBuffer(buffer, bufferId, tableNamePrefix);

5.10.2 Analyzing a Network Buffer Using the Java API

You can perform network buffer analysis using the NDM Java API.

The following example obtains the cost associated with a network buffer to a given location in PointOnNet:

Example 5-4 Retrieving Cost Using Java API

// The cost is Double.POSITIVE_INFINITY if not covered
double cost = buffer.getCosts(pt) == null ? Double.POSITIVE_INFINITY : buffer.getCosts(pointOnNet)[0];

// To get the ids and costs of the covered nodes and links from a network buffer:

// Finds all covered nodes
LogicalNode[] nodes = buffer.getElements().getNodes();
for (LogicalNode node : nodes) {
    long nodeId = node.getId();
    // Returns the minimum costs to reach the node from a buffer center
    double[] nodeCosts = buffer.getNodeCosts(node.getId());
}

// Coverage and cost information for covered links stored in LinkIntervals
NetworkBuffer.LinkIntervals[] linkIntervals = buffer.getElements().getLinkIntervals();

// Finds all covered links
for (int i = 0; i < linkIntervals.length; i++) {
    LogicalLink link = linkIntervals[i].getLink();
    long linkId = link.getId(); // link Id
    NetworkBuffer.DoubleInterval[] intervals = linkIntervals[i].getIntervals();
    // Finds costs for the covered links
    for (NetworkBuffer.DoubleInterval interval : intervals) {
        NetworkBuffer.DoubleInterval costs =
                buffer.getLinkIntervalCosts(linkId, interval);
        // Computes the cost of the mid-point of the covered link
        double percentage = 0.5; // range:[0,1]
        double[] cost = buffer.getCosts(new PointOnNet(linkId, percent));
    }
}

Note:

See Oracle Spatial API package for more examples.

5.10.3 Analyzing a Network Buffer Using SQL Queries

You can perform network buffer analysis using SQL queries directly on the network buffer tables.

Example 5-5 Retrieving Cost Using SQL Queries

The following example obtains the costs of all buffers from a center location point (link_id=945669955, percentage=0.95) in an ascending cost order:

SELECT buffer_id, MIN(start_cost+(0.95-start_percentage)*(end_cost-start_cost)/(end_percentage-start_percentage)) cost
FROM SF_NBl$
WHERE link_id=945669955
AND (0.95-start_percentage)*(end_percentage-start_percentage)>=0
GROUP BY buffer_id
ORDER BY cost;

Example 5-6 Retrieving Links of the Shortest Path Using SQL Queries

The following example obtains the links of the shortest path from a given location (link_id =799415310) to a specific buffer center (buffer_id = 1) using a hierarchical query:

SELECT buffer_id, link_id, prev_link_id
FROM SF_NB1$
WHERE buffer_id = 1
START WITH link_id = 799415310
CONNECT BY PRIOR prev_link_id = link_id AND
      PRIOR start_cost = end_cost AND
      PRIOR buffer_id = buffer_id
ORDER BY start_cost;