﻿{"id":7923,"date":"2019-01-28T03:54:54","date_gmt":"2019-01-28T02:54:54","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=7923"},"modified":"2022-02-17T09:36:09","modified_gmt":"2022-02-17T08:36:09","slug":"how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper\/","title":{"rendered":"How to develop an application with pgrouting in Windows (5): writing a Wrapper"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A wrapper is a PostgreSQL function that contains pgRouting and <a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/starting-with-postgres-postgis\/\">PostGIS<\/a> features easier to use than pgRouting and PostGIS functions straightaway. <br> The pgRouting native functions have been designed to be generic so they can be used in a wide range of applications . Although this offers flexibility, the disadvantage is that, most likely, you will have to reshape, temporarily, your own data structure before you applying pgRouting functions<br> Writing a wrapper function adapted to your data structure decreases the need to go through cumbersome SQL queries . <br> Another reason to use the wrapper function is to bypass the SQL injection attacks. Building a functional barrier between the &nbsp;user\u2019s input and the function of native pgRouting native functions will allow you clear the user\u2019s input . <\/p>\n\n\n\n<!--more-->\n\n\n\n<p class=\"wp-block-paragraph\">PostgreSQL supports many programming languages for writing functions, but\nSQL and PL \/ pgSQL are the most common . We will discuss an example with PL \/ pgSQL\n. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Until now, in our series of articles , we have restricted ourselves to\nthe network data level, but the final goal is to set up a route search web\napplication. In this case , the idea is to introduce to the user a map , and let\nhim define a starting and an ending point. Among the many possibilities , let&rsquo;s\nremember the simplest: a click on the map to define the starting point and\nanother click to set the finish point . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Our web page submits two pairs of xy coordinates and it is expected to retrieve\nthe advised itinerary connecting these two geographical points . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you have followed the series of articles , you can measure the\ndistance between what the web page results and the itinerary searches we have discussed,\nwhere we have to re-enter as parameters the starting and end nodes identifiers,\nas well as other settings according to the algorithm used . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&rsquo;s not forget that between our web page and our Postgresql \/ Postgis\ndatabase we will, also, have Geoserver . A possibility is to write a complex query\nin Geoserver , but we have a much simpler and more effective solution by using\na wrapper in PostgreSQL. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This wrapper, which constitutes a new function that we will add in our Postgres database, will translate the xy transmitted by the web page in usable parameters by our route search algorithm, optimize its execution , and format the result for displaying in the web page. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The code being used is a variation of an example found in different\nsites dealing with pgrouting under the name pgr_fromAtoB . <\/p>\n\n\n<div class='stb-container stb-style-grey stb-caption-box stb-collapsed'><div class='stb-caption'><div class='stb-logo'><img class='stb-logo__image' src='data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN\/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz\/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH\/w\/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA\/g88wAAKCRFRHgg\/P9eM4Ors7ONo62Dl8t6r8G\/y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cOr9k9K0adOFAwf2x\/r1G9BqNOrfKy4tvWPL1h3ZN06bQXNzI8FgiJk3zGLM2JGo1RqcTqfcvJCoqzuHz+ePzPrqjFt1Ou2OT5sjaVnqokCvHGohoEf2Qj7gAqwylEPOI1EUxSQgVr+7OQmoas+cEVKplABIe\/fukcLhMIDC4XCMvvOuJYq5X5vDiZOH8AdCGIxmotEQsWgIf1CBLTObFCkaG+s4deoUI0aMqNPptBc\/6xElLVs8LANcAE4Ce4Ed8vV94JIMefkU4JD3FQExlUqJslHS4XA4LRtvUCgUGltUmG91u1tpbr7E6Iqx5Lhy6PZ4qGtoI9M1kD5fmAMHDrF7zy5UKjXFJUUHN2x4p\/Gz5MjHYZXyD9AAesAsF8xsefaXPXTZO0a5+6GVp0reQ7isiEajUX377bdb9AaDsrioFHOGkcOHDmPQm5l38zzCsQDZmS6OHz+Gw5GJ290ZjEZD3\/nFo794SxTFz\/Wom5ZvnpItG5e95JHDTC9DWWQhyLgCVCuvq+SckmQ1TITD4axXXnllwn333ZdfPrKMynXr6OkL8M0pM9i4uZJeTy\/\/etcyTtW8z6KFd7KhqvL0unXrW+S9kp+3HSRdMa8Eisoe65Etrr5iauT3tJefRuXvxuVrARDzeDymdWvXOg1anbDg27fR7e6gpqaG225bxNGjx5g0cSrPrF4V3bRpY6fsUeHzhtYnVX6u2Fj42NrfM8TlG2YAo4GvARNXrVo1PJVMalrb2jSTJk0Rurs7EUWJ7du2uHfu2nkI2AjsAtzSVX705wX5JLArX0tXgfl47hlkOS\/Nzc0d0eV2Z40dNz6voCA\/c\/v27b12uz3a2Nh4GtgHnAO8H7XQJL4okGsZSvkclyELhEnOsdgV8t9zZRH8vwpytZIgXCUU+cwgX\/7z4UuQL0H++UD+awDc\/MMFLMO8WgAAAABJRU5ErkJggg==' alt='img'\/><\/div><div class='stb-caption-content'>Wrapper text<\/div><div class='stb-tool'><\/div><\/div><div class='stb-content'><\/p>\n<p>&#8211;DROP FUNCTION pgr_route_entreAetB(varchar, double precision, double precision,<br \/>\n&#8212; double precision, double precision);<\/p>\n<p>CREATE OR REPLACE FUNCTION pgr_route_entreAetB(<br \/>\nIN tbl varchar,<br \/>\nIN x1 double precision,<br \/>\nIN y1 double precision,<br \/>\nIN x2 double precision,<br \/>\nIN y2 double precision,<br \/>\nOUT seq integer,<br \/>\nOUT gid integer,<br \/>\nOUT direction double precision,<br \/>\nOUT cost double precision,<br \/>\nOUT geom geometry)<\/p>\n<p>RETURNS SETOF record AS<\/p>\n<p>$BODY$<br \/>\nDECLARE<br \/>\nsql text;<br \/>\nrec record;<br \/>\nsource integer;<br \/>\ntarget integer;<br \/>\npoint integer;<br \/>\nbuff double precision;<br \/>\ndist double precision;<br \/>\nlegid integer;<\/p>\n<p>BEGIN<\/p>\n<p>&#8212; Trouver le n\u0153ud le plus proche des lat\/lon en entr\u00e9e<\/p>\n<p>EXECUTE &lsquo;SELECT id::integer, the_geom::geometry FROM &lsquo; || tbl || &lsquo;_vertices_pgr<br \/>\nORDER BY the_geom &lt;-&gt;ST_GeometryFromText(\u00a0\u00bbPOINT(&lsquo;<br \/>\n|| x1 || &lsquo; &lsquo; || y1 || &lsquo;)\u00a0\u00bb,4326) LIMIT 1&rsquo; INTO rec;<br \/>\nsource := rec.id;<\/p>\n<p>EXECUTE &lsquo;SELECT id::integer, the_geom::geometry FROM &lsquo; || tbl || &lsquo;_vertices_pgr<br \/>\nORDER BY the_geom &lt;-&gt;ST_GeometryFromText(\u00a0\u00bbPOINT(&lsquo;<br \/>\n|| x2 || &lsquo; &lsquo; || y2 || &lsquo;)\u00a0\u00bb,4326) LIMIT 1&rsquo; INTO rec;<br \/>\ntarget := rec.id;<\/p>\n<p>&#8211;D\u00e9finir une sous-zone de travail<br \/>\nEXECUTE &lsquo;SELECT ST_Distance(ST_GeomFromText(\u00a0\u00bbPOINT(&lsquo; || x1 ||&rsquo; &lsquo; || y1 ||&rsquo;)\u00a0\u00bb,4326),&rsquo;<br \/>\n&lsquo;ST_GeomFromText(\u00a0\u00bbPOINT(&lsquo; || x2 ||&rsquo; &lsquo; || y2 ||&rsquo;)\u00a0\u00bb,4326)) as dist&rsquo; INTO rec;<br \/>\nbuff := GREATEST(rec.dist,0.5);<\/p>\n<p>&#8211;Trouver l&rsquo;identifiant du tron\u00e7on de d\u00e9part<br \/>\nEXECUTE &lsquo;SELECT gid as legid FROM &lsquo; || tbl || &lsquo; WHERE source = &lsquo; || source || &lsquo; LIMIT 1&rsquo; INTO rec;<br \/>\nlegid := rec.legid;<\/p>\n<p>&#8212; Calculer l&rsquo;itin\u00e9raire avec l&rsquo;algorithme A*<\/p>\n<p>seq := 0;<br \/>\nsql := &lsquo;SELECT gid, the_geom,pgr_astar.cost, source, target, ST_Reverse(the_geom) AS flip_geom<br \/>\nFROM &lsquo;<br \/>\n&lsquo;pgr_astar(\u00a0\u00bbSELECT gid as id, source::int, target::int, &lsquo;<br \/>\n&lsquo;length_m * &lsquo; || tbl || &lsquo;.cost as cost, x1, y1, x2, y2 FROM &lsquo;<br \/>\n|| quote_ident(tbl) ||<br \/>\n&lsquo; WHERE the_geom @ (SELECT ST_buffer(the_geom,&rsquo;<br \/>\n|| buff || &lsquo;) FROM &lsquo;<br \/>\n|| quote_ident(tbl) || &lsquo; WHERE gid=&rsquo; || legid || &lsquo;)&rsquo;<br \/>\n\u00a0\u00bb&rsquo;, &lsquo;<br \/>\n|| source || &lsquo;, &lsquo; || target<br \/>\n|| &lsquo; , false, false), &lsquo;<br \/>\n|| quote_ident(tbl) || &lsquo; WHERE id2 = gid ORDER BY seq&rsquo;;<\/p>\n<p>&#8212; m\u00e9moriser la point de d\u00e9part<\/p>\n<p>point := source;<\/p>\n<p>FOR rec IN EXECUTE sql<br \/>\nLOOP<\/p>\n<p>&#8212; Inverser les tron\u00e7ons si n\u00e9cessaire<\/p>\n<p>IF ( point != rec.source ) THEN<br \/>\nrec.the_geom := rec.flip_geom;<br \/>\npoint := rec.source;<br \/>\nELSE<br \/>\npoint := rec.target;<br \/>\nEND IF;<\/p>\n<p>&#8212; Calculer le cap<\/p>\n<p>EXECUTE &lsquo;SELECT degrees( ST_Azimuth(<br \/>\nST_StartPoint(\u00a0\u00bb&rsquo; || rec.the_geom::text ||&rsquo; \u00a0\u00bb),<br \/>\nST_EndPoint(\u00a0\u00bb&rsquo; || rec.the_geom::text || &lsquo; \u00a0\u00bb) ) )&rsquo;<br \/>\nINTO direction;<\/p>\n<p>&#8212; Return<\/p>\n<p>seq := seq + 1;<br \/>\ngid := rec.gid;<br \/>\ncost := rec.cost;<br \/>\ngeom := rec.the_geom;<br \/>\nRETURN NEXT;<\/p>\n<p>END LOOP;<br \/>\nRETURN;<br \/>\nEND;<br \/>\n$BODY$<br \/>\nLANGUAGE &lsquo;plpgsql&rsquo; VOLATILE STRICT;<\/p>\n<p><\/div><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Let&rsquo;s see\nhow this function works . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Setting<\/strong> <strong>up the<\/strong> <strong>function<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First of all we have to set up of the function : <br>\n<em>CREATE OR REPLACE FUNCTION<\/em> <em>pgr_route_entreAetB<\/em> <em>(<\/em> <br>\n<em>IN<\/em> <em>tbl<\/em> <em>varchar,<\/em> <br>\n<em>IN x1 double precision,<\/em> <br>\n<em>IN y1 double precision,<\/em> <br>\n<em>IN x2 double precision,<\/em> <br>\n<em>IN y2 double precision,<\/em> <br>\n<em>OUT<\/em> <em>seq<\/em> <em>integer,<\/em> <br>\n<em>OUT<\/em> <em>gid<\/em> <em>integer,<\/em> <br>\n<em>OUT direction double precision,<\/em> <br>\n<em>OUT cost double precision,<\/em> <br>\n<em>OUT<\/em> <em>geom<\/em> <em>geometry)<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We define 5 input parameters: the table containing the network and the\ncoordinates of the starting and arrival point. <br>\nWe, also, &nbsp;define the output parameters:\na series of sections having a sequence number (seq ), the section identifier (\ngid ), the geographical direction or section cap (direction), the cost\nassociated with the section and its geometry in order to be able to draw it in\nthe resulting map. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Pre-processing<\/strong> <strong>of<\/strong> <strong>parameters<\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we have to prepare the parameters of our algorithm . Here we will\nuse the a-star pgrouting algorithm . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>EXECUTE &lsquo;SELECT id :: integer, the_geom :: geometry\nFROM&rsquo; ||<\/em> <em>tbl<\/em>\n<em>|| &lsquo;_<\/em> <em>vertices_pgr<\/em> <br>\n<em>ORDER BY the_geom<\/em> <em>ST_GeometryFromText<\/em> <em>(<\/em>  <em>\u00ab\u00a0POINT(&lsquo;<\/em>\n<br>\n<em>||<\/em> <em>x1 ||<\/em> <em>\u00a0\u00bb ||<\/em> <em>y1 ||<\/em> <em>&lsquo;)<\/em>  <em>\u00ab\u00a0,\n4326) LIMIT 1 &lsquo;INTO rec;<\/em> <br>\n<em>source: = rec.id;<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>EXECUTE &lsquo;SELECT id :: integer, the_geom :: geometry\nFROM&rsquo; ||<\/em> <em>tbl<\/em>\n<em>||<\/em> <em>&lsquo;_<\/em> <em>vertices_pgr<\/em> <br>\n<em>ORDER BY the_geom<\/em> <em>ST_GeometryFromText<\/em> <em>(<\/em>  <em>\u00ab\u00a0POINT(&lsquo;<\/em>\n<br>\n<em>||<\/em> <em>x2 ||<\/em> <em>\u00a0\u00bb ||<\/em> <em>y2 ||<\/em> <em>&lsquo;)<\/em>  <em>\u00ab\u00a0,\n4326) LIMIT 1 &lsquo;INTO rec;<\/em> <br>\n<em>target: = rec.id;<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">These two paragraphs search the identifiers of the two nearest &nbsp;points &nbsp;to the input coordinates of the node table of\nour network. <br>\nValues between || are replaced when running with the input parameters of the\nfunction . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>&#8211;<\/em> <em>Define<\/em> <em>a<\/em> <em>working<\/em> <em>sub- area<\/em> <br>\n<em>EXECUTE &lsquo;SELECT<\/em> <em>ST_Distance<\/em> <em>(<\/em> <em>ST_GeomFromText<\/em> <em>(<\/em>\n <em>POINT (&lsquo;|| x1 ||&rsquo; &lsquo;|| y1<\/em> <em>||&rsquo;)<\/em>  <em>\u00ab\u00a04326),\n&lsquo;<\/em> <br>\n<em>&lsquo;<\/em> <em>ST_GeomFromText<\/em> <em>(<\/em>  <em>POINT (&lsquo;|| x2 ||&rsquo; &lsquo;||\ny2 ||&rsquo;)<\/em>  <em>\u00ab\u00a0, 4326)) as<\/em> <em>dist<\/em> <em>&lsquo;INTO rec;<\/em>\n<br>\n<em>buff: = GREATEST (rec.dist, 0.5);<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To optimize the routes search, it is strongly recommended to limit the\nsearch to a sub-area ( bbox ) of our network . This paragraph calculates the\ndistance between the departure and arrival points and defines a search area one\nand a half times greater than that distance. The sections located outside this\narea will not be taken in account by the possible route search. &nbsp; In this\ncase, we have used the GREATEST function which allows to define a minimum\nsubfield : if, at a glance, the distance is less than 0.5 \u00b0, by default a 0.5 \u00b0\nsubarea is considered. We could have defined a factor such as : <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>buff: =<\/em> <em>rec.dist<\/em> <em>* 1.5<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It is obvious that this factor (1.5) must be decided knowingly , if not it\ncan preclude the function to find any solution. For example , if you have two\nvalleys separated by a mountain without crossing roads, the calculated distance\nat a glance , cannot include the nearest path . <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>&#8211;<\/em> <em>Find<\/em> <em>the identifier<\/em> <em>of the<\/em> <em>starting<\/em>\n<em>section<\/em> <br>\n<em>EXECUTE &lsquo;SELECT<\/em> <em>gid<\/em> <em>as<\/em> <em>legid<\/em> <em>FROM&rsquo; ||<\/em> <em>tbl<\/em>\n<em>||<\/em> <em>&lsquo;WHERE source =&rsquo; ||<\/em> <em>source ||<\/em> <em>&lsquo;LIMIT 1&rsquo; INTO rec;<\/em>\n<br>\n<em>legid<\/em> <em>: =<\/em> <em>rec.legid<\/em> <em>;<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To exclude the very distant sections, we will use the <strong><em>ST_Buffer<\/em><\/strong>\nfunction applied from the starting section. &nbsp;Then, we must find the identifier of this\nsection , since for the time being, &nbsp;we\nhave just the identifiers of the nodes table. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we can execute the algorithm : <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>sql<\/em> <em>: = &lsquo;SELECT<\/em> <em>gid<\/em> <em>,<\/em> <em>the_geom,\npgr_astar.cost<\/em> <em>, source, target,<\/em> <em>ST_Reverse<\/em> <em>(the_geom) AS<\/em>\n<em>flip_geom<\/em> <br>\n<em>FROM &lsquo;<\/em> <br>\n<em>&lsquo;<\/em> <em>pgr_astar<\/em> <em>(<\/em>  <em>SELECT<\/em> <em>gid<\/em> <em>as\nid, source ::<\/em> <em>int<\/em> <em>, target ::<\/em> <em>int<\/em> <em>, &lsquo;<\/em> <br>\n<em>&lsquo;<\/em> <em>length_m<\/em> <em>*&rsquo; ||<\/em> <em>tbl<\/em> <em>||<\/em> <em>&lsquo;.cost as cost,\nx1, y1, x2, y2 FROM&rsquo;<\/em> <br>\n<em>||<\/em> <em>quote_ident<\/em> <em>(<\/em> <em>tbl<\/em> <em>) ||<\/em> <br>\n<em>&lsquo;WHERE the_geom @ (SELECT<\/em> <em>ST_buffer<\/em> <em>(the_geom,&rsquo;<\/em> <br>\n<em>||<\/em> <em>buff ||<\/em> <em>&lsquo;) FROM&rsquo;<\/em> <br>\n<em>||<\/em> <em>quote_ident<\/em> <em>(<\/em> <em>tbl<\/em> <em>) ||<\/em> <em>&lsquo;WHERE<\/em> <em>gid<\/em>\n<em>=&rsquo; ||<\/em> <em>legid<\/em> <em>||<\/em> <em>&lsquo;)&rsquo;<\/em> <br>\n <em>\u00bb,<\/em> <br>\n<em>||<\/em> <em>source ||<\/em> <em>&lsquo;,&rsquo; ||<\/em> <em>TARGET<\/em> <br>\n<em>||<\/em> <em>&lsquo;, false, false),&rsquo;<\/em> <br>\n<em>||<\/em> <em>quote_ident<\/em> <em>(<\/em> <em>tbl<\/em> <em>) ||<\/em> <em>&lsquo;WHERE id2 =<\/em>\n<em>gid<\/em> <em>ORDER BY<\/em> <em>seq<\/em> <em>&lsquo;;<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The cost in use right here is the length in meters of the section\nmultiplied by the column \u00a0\u00bb &nbsp; cost &nbsp; \u00a0\u00bb of the table. The\nfunction ST_Buffer limits the number of sections of the search to those located\nin the defined area upon generation of the <strong><em>buff<\/em><\/strong> variable. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, reverse the section and calculate the direction all together. They\nare here to show an example of unplanned calculation in the algorithm and how\nto integrate it in the wrapper. If you do not find it useful , erase them from\nthe wrapper, it will not have an effect on the resulting &nbsp;route. The inversion of the section is\nnecessary to calculate the true direction in the case where the section is taken\nin opposite direction (from the target point to the source point). This explains\nthe section \u00a0\u00bb &nbsp; S <em>T_Reverse<\/em> <em>(the_geom) AS<\/em> <em>flip_geom<\/em>\n&nbsp; \u00a0\u00bb in the SELECT clause. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>How to add<\/strong> <strong>the wrapper to the<\/strong> <strong>postgres<\/strong> <strong>database<\/strong> \n\nTo be able to include this new function in your\nPostgreSQL database, simply copy the wrapper text into a SQL window and run the\nquery : &nbsp;&nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"212\" data-attachment-id=\"7925\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper\/282-5\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/282.png?fit=525%2C212&amp;ssl=1\" data-orig-size=\"525,212\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"282\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/282.png?fit=525%2C212&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/282.png?resize=525%2C212&#038;ssl=1\" alt=\"\" class=\"wp-image-7925\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/282.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/282.png?resize=300%2C121&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The new function is, now, in the list of functions of your database. \n\nNow we can test the function with QGis by using\nthe database management window. \n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"277\" data-attachment-id=\"7926\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper\/283-5\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/283.png?fit=525%2C277&amp;ssl=1\" data-orig-size=\"525,277\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"283\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/283.png?fit=525%2C277&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/283.png?resize=525%2C277&#038;ssl=1\" alt=\"\" class=\"wp-image-7926\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/283.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/283.png?resize=300%2C158&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We enter the name of the table containing our network , and the\ncoordinates of the departure and arrival points. \n\nOnce executed , the query returns the list of\nsections of the route . By clicking the button \u201c<strong>Load<\/strong>\u201d&nbsp; we can see\nthe route displayed (against the backdrop of OpensStreetMap):\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"307\" data-attachment-id=\"7927\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper\/284-5\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/284.png?fit=525%2C307&amp;ssl=1\" data-orig-size=\"525,307\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"284\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/284.png?fit=525%2C307&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/284.png?resize=525%2C307&#038;ssl=1\" alt=\"\" class=\"wp-image-7927\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/284.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/284.png?resize=300%2C175&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nWe\ncan also test a request a little more complex , to obtain just one entity as result\n: \n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"277\" data-attachment-id=\"7929\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper\/285-5\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/285.png?fit=525%2C277&amp;ssl=1\" data-orig-size=\"525,277\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"285\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/285.png?fit=525%2C277&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/285.png?resize=525%2C277&#038;ssl=1\" alt=\"\" class=\"wp-image-7929\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/285.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/285.png?resize=300%2C158&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>SELECT<\/em> <em>ST_MakeLine<\/em> <em>(<\/em> <em>route.geom<\/em> <em>)\nFROM (SELECT<\/em> <em>geom<\/em> <em>FROM<\/em> <em>pgr_route_entreAetB<\/em> <em>(&lsquo;ways&rsquo;,\n&#8211; 4.4888433,48.3967909, -4.5267335, 48.403296) ORDER BY<\/em> <em>seq<\/em> <em>) AS\nroute<\/em> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This request uses the sections list resulting from the function\npgr_route_entreAetB and builds an unique entity MultiLine . Notice the name of\nthe generated geometry column. \n\nIf we load this entity in QGis we will notice\nthat, visually, the result is identical . Nevertheless, &nbsp;the quantity of information returned is\noptimized . &nbsp;\n\n\n\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"304\" data-attachment-id=\"7930\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-5-writing-a-wrapper\/286-6\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/286-1.png?fit=525%2C304&amp;ssl=1\" data-orig-size=\"525,304\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"286\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/286-1.png?fit=525%2C304&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/286-1.png?resize=525%2C304&#038;ssl=1\" alt=\"\" class=\"wp-image-7930\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/286-1.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/286-1.png?resize=300%2C174&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We will keep this last request to use it when formatting &nbsp;Geoserver , what we will do in the following article.\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A wrapper is a PostgreSQL function that contains pgRouting and PostGIS features easier to use than pgRouting and PostGIS functions straightaway. The pgRouting native functions have been designed to be generic so they can be used&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"give_campaign_id":0,"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sfsi_plus_gutenberg_text_before_share":"","sfsi_plus_gutenberg_show_text_before_share":"","sfsi_plus_gutenberg_icon_type":"","sfsi_plus_gutenberg_icon_alignemt":"","sfsi_plus_gutenburg_max_per_row":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1260],"tags":[],"class_list":["post-7923","post","type-post","status-publish","format-standard","hentry","category-non-classe-en"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-23N","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/7923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/comments?post=7923"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/7923\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=7923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=7923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=7923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}