Skip to content

Commit

Permalink
partial isochrones backport
Browse files Browse the repository at this point in the history
  • Loading branch information
vjeranc committed Jun 8, 2020
1 parent bcd0d4c commit 5b902d5
Show file tree
Hide file tree
Showing 8 changed files with 591 additions and 0 deletions.
1 change: 1 addition & 0 deletions configuration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ vrppdtw | N | Y | Y
withPoints | Y | Y | Y
lineGraph | Y | Y | Y
components | Y | Y | Y
isochrones | Y | Y | N
#----------------------
# SQL only directories
#----------------------
Expand Down
53 changes: 53 additions & 0 deletions include/drivers/isochrones/isochrones_driver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*PGR-GNU*****************************************************************
File: isochrones_driver.h
Copyright (c) 2020 Vjeran Crnjak
vjeran@crnjak.xyz
------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/

#ifndef INCLUDE_DRIVERS_ISOCHRONES_MANY_TO_ISOCHRONES_H_
#define INCLUDE_DRIVERS_ISOCHRONES_MANY_TO_ISOCHRONES_H_

/* for size_t */
#ifdef __cplusplus
#include <cstddef>
#else
#include <stddef.h>
#endif

#include "c_types/general_path_element_t.h"
#include "c_types/pgr_edge_t.h"

#ifdef __cplusplus
extern "C" {
#endif

void do_pgr_many_to_isochrones(pgr_edge_t *edges, size_t total_edges,
int64_t *start_vertex, size_t s_len,
double distance, bool directed, bool equicost,
General_path_element_t **return_tuples,
size_t *return_count, char **log_msg,
char **notice_msg, char **err_msg);

#ifdef __cplusplus
}
#endif

#endif // INCLUDE_DRIVERS_ISOCHRONES_MANY_TO_ISOCHRONES_H_
12 changes: 12 additions & 0 deletions sql/isochrones/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

SET(LOCAL_FILES
isochrones.sql
)

foreach (f ${LOCAL_FILES})
configure_file(${f} ${f})
list(APPEND PACKAGE_SQL_FILES ${CMAKE_CURRENT_BINARY_DIR}/${f})
endforeach()

set(PgRouting_SQL_FILES ${PgRouting_SQL_FILES} ${PACKAGE_SQL_FILES} PARENT_SCOPE)

61 changes: 61 additions & 0 deletions sql/isochrones/isochrones.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*PGR-GNU*****************************************************************
Copyright (c) 2020 Vjeran Crnjak
Mail: vjeran@crnjak.xyz
------
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
********************************************************************PGR-GNU*/

CREATE OR REPLACE FUNCTION pgr_isochrones(
edges_sql text,
start_vids anyarray,
distance FLOAT,
directed BOOLEAN DEFAULT TRUE,
equicost BOOLEAN DEFAULT FALSE,
OUT seq integer,
OUT from_v bigint,
OUT node bigint,
OUT edge bigint,
OUT cost FLOAT,
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
'${MODULE_PATHNAME}', 'many_to_isochrones'
LANGUAGE c VOLATILE STRICT;


CREATE OR REPLACE FUNCTION pgr_isochrones(
edges_sql text,
start_vid bigint,
distance FLOAT8,
directed BOOLEAN DEFAULT TRUE,
OUT seq integer,
OUT node bigint,
OUT edge bigint,
OUT cost FLOAT,
OUT agg_cost FLOAT)
RETURNS SETOF RECORD AS
$BODY$
SELECT a.seq, a.node, a.edge, a.cost, a.agg_cost
FROM pgr_isochrones($1, ARRAY[$2]::BIGINT[], $3, $4, false) a;
$BODY$
LANGUAGE SQL VOLATILE STRICT
COST 100
ROWS 1000;



2 changes: 2 additions & 0 deletions sql/sigs/pgrouting--2.6.3.sig
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ pgr_dijkstravia(text,anyarray,boolean,boolean,boolean)
pgr_drivingdistance(text,anyarray,double precision,boolean,boolean)
pgr_drivingdistance(text,bigint,double precision,boolean)
pgr_drivingdistance(text,bigint,double precision,boolean,boolean)
pgr_isochrones(text,anyarray,double precision,boolean,boolean)
pgr_isochrones(text,bigint,double precision,boolean)
pgr_edgedisjointpaths(text,anyarray,anyarray,boolean)
pgr_edgedisjointpaths(text,anyarray,bigint,boolean)
pgr_edgedisjointpaths(text,bigint,anyarray,boolean)
Expand Down
4 changes: 4 additions & 0 deletions src/isochrones/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ADD_LIBRARY(isochrones OBJECT
many_to_isochrones.c
isochrones_driver.cpp
)
Loading

0 comments on commit 5b902d5

Please sign in to comment.