pgRouting

Changeset 106

Show
Ignore:
Timestamp:
02/14/08 10:42:26 (9 months ago)
Author:
anton
Message:

Last changes date added to SQL wrapper functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/core/sql/routing_core_wrappers.sql

    r105 r106  
    1818 
    1919 
    20 -- TODO: use spatial index when possible 
    21 -- TODO: make variable names more consistent 
    22  
    23 -- Geometry schema description: 
    24 -- gid 
    25 -- source 
    26 -- target 
    27 -- edge_id 
    28  
    2920-- BEGIN; 
    3021 
     
    3930-- For each vertex in the vertices table, set a point geometry which is 
    4031--  the corresponding line start or line end point 
     32-- 
     33-- Last changes: 14.02.2008 
    4134----------------------------------------------------------------------- 
    4235CREATE OR REPLACE FUNCTION add_vertices_geometry(geom_table varchar)  
     
    8174--  of a new point or an existing point. Tolerance is the minimal distance 
    8275--  between existing points and the new point to create a new point. 
     76-- 
     77-- Last changes: 14.02.2008 
    8378----------------------------------------------------------------------- 
    8479CREATE OR REPLACE FUNCTION point_to_id(point geometry,  
     
    198193-- Update the cost column from the edges table, from the length of 
    199194--  all lines which belong to an edge. 
    200 ----------------------------------------------------------------------- 
    201 -- FIXME: directed or not ? 
     195-- 
     196-- Last changes: 14.02.2008 
     197----------------------------------------------------------------------- 
    202198CREATE OR REPLACE FUNCTION update_cost_from_distance(geom_table varchar)  
    203199       RETURNS VOID AS 
     
    236232-- Compute the shortest path using edges table, and return 
    237233--  the result as a set of (gid integer, the_geom geometry) records. 
     234-- 
     235-- Last changes: 14.02.2008 
    238236----------------------------------------------------------------------- 
    239237CREATE OR REPLACE FUNCTION dijkstra_sp( 
     
    277275-- Compute the shortest path using edges table, and return 
    278276--  the result as a set of (gid integer, the_geom geometry) records. 
     277-- 
     278-- Last changes: 14.02.2008 
    279279----------------------------------------------------------------------- 
    280280CREATE OR REPLACE FUNCTION dijkstra_sp_directed( 
     
    326326--  the result as a set of (gid integer, the_geom geometry) records. 
    327327-- Also data clipping added to improve function performance. 
     328-- 
     329-- Last changes: 14.02.2008 
    328330----------------------------------------------------------------------- 
    329331CREATE OR REPLACE FUNCTION astar_sp_delta( 
     
    373375--  the result as a set of (gid integer, the_geom geometry) records. 
    374376-- Also data clipping added to improve function performance. 
     377-- 
     378-- Last changes: 14.02.2008 
    375379----------------------------------------------------------------------- 
    376380CREATE OR REPLACE FUNCTION astar_sp_delta_directed( 
     
    522526-- Also data clipping added to improve function performance. 
    523527-- Cost column name can be specified (last parameter) 
     528-- 
     529-- Last changes: 14.02.2008 
    524530----------------------------------------------------------------------- 
    525531CREATE OR REPLACE FUNCTION astar_sp_delta_cc( 
     
    571577-- Also data clipping added to improve function performance. 
    572578-- Cost column name can be specified (last parameter) 
     579-- 
     580-- Last changes: 14.02.2008 
    573581----------------------------------------------------------------------- 
    574582CREATE OR REPLACE FUNCTION astar_sp_delta_cc_directed( 
     
    711719--  the result as a set of (gid integer, the_geom geometry) records. 
    712720-- Also data clipping added to improve function performance. 
     721-- 
     722-- Last changes: 14.02.2008 
    713723----------------------------------------------------------------------- 
    714724CREATE OR REPLACE FUNCTION dijkstra_sp_delta( 
     
    756766--  the result as a set of (gid integer, the_geom geometry) records. 
    757767-- Also data clipping added to improve function performance. 
     768-- 
     769-- Last changes: 14.02.2008 
    758770----------------------------------------------------------------------- 
    759771CREATE OR REPLACE FUNCTION dijkstra_sp_delta_directed( 
     
    892904-- Also data clipping added to improve function performance 
    893905--  (specified by lower left and upper right box corners). 
     906-- 
     907-- Last changes: 14.02.2008 
    894908----------------------------------------------------------------------- 
    895909CREATE OR REPLACE FUNCTION astar_sp_bbox( 
     
    945959-- Also data clipping added to improve function performance 
    946960--  (specified by lower left and upper right box corners). 
     961-- 
     962-- Last changes: 14.02.2008 
    947963----------------------------------------------------------------------- 
    948964CREATE OR REPLACE FUNCTION astar_sp_bbox_directed( 
     
    10541070--  the result as a set of (gid integer, the_geom geometry) records. 
    10551071-- Also data clipping added to improve function performance. 
     1072-- 
     1073-- Last changes: 14.02.2008 
    10561074----------------------------------------------------------------------- 
    10571075CREATE OR REPLACE FUNCTION astar_sp_directed( 
     
    11061124-- Compute the shortest path using edges table, and return 
    11071125--  the result as a set of (gid integer, the_geom geometry) records. 
     1126-- 
     1127-- Last changes: 14.02.2008 
    11081128----------------------------------------------------------------------- 
    11091129CREATE OR REPLACE FUNCTION shootingstar_sp( 
  • trunk/core/src/boost_wrapper.cpp

    r105 r106  
    189189    return EXIT_SUCCESS; 
    190190} 
    191  
    192 #if 0 
    193  
    194 // Testing function 
    195  
    196 #define NUM_EDGES 100 
    197 int main() { 
    198                  
    199     edge_t *e; 
    200  
    201     e = (edge_t *)malloc(NUM_EDGES * sizeof(edge_t)); 
    202     if (!e) 
    203         return -1; 
    204  
    205     for (int i = 0; i < NUM_EDGES; i++)  
    206     { 
    207         e[i].id = i; 
    208         e[i].source = i; 
    209         e[i].target = (i + 1 > NUM_EDGES) ? 0 : i + 1; 
    210         e[i].cost = 1; 
    211     } 
    212  
    213     char *err_msg = NULL; 
    214     path_element_t *path; 
    215     int ret; 
    216     int path_count; 
    217  
    218     int final_edges = NUM_EDGES - 1; 
    219  
    220     ret = boost_dijkstra(e, NUM_EDGES, 0, final_edges, 1, 0, &path, &path_count, &err_msg); 
    221  
    222     if (ret < 0)  
    223     { 
    224         printf("Error: %s\n", err_msg); 
    225  
    226     } else { 
    227         printf("Path is :\n"); 
    228         for (int i = 0; i < path_count; i++)  
    229         { 
    230             printf("Step %i vertex_id  %i \n", i, path[i].vertex_id); 
    231             printf("        edge_id    %i \n", path[i].edge_id); 
    232             printf("        cost       %f \n", path[i].cost); 
    233         } 
    234         free(path); 
    235     } 
    236     printf("\n"); 
    237     free(e); 
    238 } 
    239 #endif 
  • trunk/core/src/shooting_star_boost_wrapper.cpp

    r92 r106  
    8787}; 
    8888 
    89  
     89// Heuristic function 
    9090template <class Graph, class CostType> 
    9191class distance_heuristic 
     
    112112 
    113113 
     114// Adds an edge to the graph 
     115// Also copies all attributes and adjacent edges 
    114116template <class G, class E> 
    115117static void 
     
    155157} 
    156158 
     159// Main Shooting* function. 
     160// It renumbers vertices, fills the graph with edges, 
     161// calculates a route and return a result. 
    157162int  
    158163boost_shooting_star(edge_shooting_star_t *edges_array, unsigned int count,  
     
    224229                                               edges_array[j].t_x, edges_array[j].t_y, adjacent_edges); 
    225230     
     231      // if the edge is not directed or if it is directed and has reverse cost 
    226232      if (!directed || (directed && has_reverse_cost)) 
    227233      { 
     
    313319  try  
    314320  { 
     321    //calling Shooting* search 
    315322    shooting_star_search 
    316323      (graph, source_edge, 
  • trunk/core/src/shooting_star_search.hpp

    r105 r106  
    231231 
    232232  namespace detail { 
    233      
     233 
     234    // Shooting* visitor 
     235    // based on BFS visitor concept from BGL     
    234236    template <class AStarHeuristic, class UniformCostVisitor, 
    235237              class UpdatableQueue, class PredecessorMap, 
     
    423425    typedef typename graph_traits<VertexAndEdgeListGraph>::edge_descriptor 
    424426      Edge; 
    425  
     427     
     428    // Queue to store the list of edges to examine. 
     429    // I really hate this queue for what it does with the memory sometimes. 
    426430    typedef mutable_queue<Edge, std::vector<Edge>, IndirectCmp, IndexMap> 
    427431      MutableQueue; 
  • trunk/extra/driving_distance/sql/routing_dd_wrappers.sql

    r105 r106  
    2121---------------------------------------------------------- 
    2222-- Draws an alpha shape around given set of points. 
     23-- 
     24-- Last changes: 14.02.2008 
    2325---------------------------------------------------------- 
    2426CREATE OR REPLACE FUNCTION points_as_polygon(query varchar) 
  • trunk/extra/tsp/sql/routing_tsp_wrappers.sql

    r105 r106  
    2222----------------------------------------------------- 
    2323-- Returns TSP solution as a set of vertex ids 
     24-- 
     25-- Last changes: 14.02.2008 
    2426----------------------------------------------------- 
    2527CREATE OR REPLACE FUNCTION tsp_ids(geom_table varchar,  
     
    5254-- Returns TSP solution as a set of vertices connected 
    5355-- with A* paths 
     56-- 
     57-- Last changes: 14.02.2008 
    5458------------------------------------------------------ 
    5559CREATE OR REPLACE FUNCTION tsp_astar( 
     
    96100-- with A* paths. 
    97101-- For directed graphs. 
     102-- 
     103-- Last changes: 14.02.2008 
    98104------------------------------------------------------ 
    99105CREATE OR REPLACE FUNCTION tsp_astar_directed( 
     
    195201-- with Dijkstra paths. 
    196202-- For directed graphs. 
     203-- 
     204-- Last changes: 14.02.2008 
    197205------------------------------------------------------ 
    198206CREATE OR REPLACE FUNCTION tsp_dijkstra_directed(