﻿{"id":7881,"date":"2019-01-23T01:18:49","date_gmt":"2019-01-23T00:18:49","guid":{"rendered":"http:\/\/www.sigterritoires.fr\/?p=7881"},"modified":"2025-08-25T09:20:46","modified_gmt":"2025-08-25T07:20:46","slug":"how-to-develop-an-application-with-pgrouting-in-windows-1","status":"publish","type":"post","link":"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/","title":{"rendered":"How to develop an application with pgrouting in Windows (1)"},"content":{"rendered":"\n<p>Here starts a series of articles to set up a routing web application (route\ncalculation) completely autonomous, ie using no web service or API for\ncalculating the route. <br>\nWe will set up the database including the route network (or fluvial, etc.) with\nPostgresql, then we will set up a wms flow with Geoserver, and finally we will\ndevelop a calculation page with OpenLayers 3. All using Windows . <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>In this first article we will discuss the setting up of the network\ndatabase. <br>\nYou will need to have an operational installation of PostreSQL \/ <a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/starting-with-postgres-postgis\/\">Postgis<\/a>. If\nthis is not the case, refer to the article <a href=\"https:\/\/translate.google.com\/translate?hl=fr&amp;prev=_t&amp;sl=fr&amp;tl=en&amp;u=http:\/\/wp.me\/p6XU0A-LQ\">Starting with PostgreSQL \/ Postgis.<\/a> <\/p>\n\n\n\n<p><strong>Pgrouting installation<\/strong> <\/p>\n\n\n\n<p>For routing calculations, we will use the Postgis pgrouting extension. It\nis installed, in theory, with the new Postgis versions. To be on the safe side,\nopen pgAdmin III and run the following SQL query: <\/p>\n\n\n\n<p>SELECT pgr_version (); \n\nYou must have a result like this: &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=\"350\" data-attachment-id=\"7882\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/231-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/231.png?fit=525%2C350&amp;ssl=1\" data-orig-size=\"525,350\" 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=\"231\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/231.png?fit=525%2C350&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/231.png?resize=525%2C350&#038;ssl=1\" alt=\"\" class=\"wp-image-7882\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/231.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/231.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>If pgrouting is not installed: <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Download the zipped pgRouting file zip file for your system (32 or 64<br>bit) from Winnie . <\/li>\n\n\n\n<li>Unzip the<br>file. You will find three directories: bin, lib and share folders and two text<br>files. <\/li>\n\n\n\n<li>Copy<br>these files and directories into the directory of your Postgres installation<br>(in my case C: \\<br>Programs \\ PostgreSQL \\ 9.5 ) <\/li>\n\n\n\n<li>In<br>pgAdmin III select your Postgis database and run the following SQL query: <\/li>\n<\/ol>\n\n\n\n<p>CREATE EXTENSION pgrouting; <\/p>\n\n\n\n<p>Check with the following query that the installation has been completed\nsuccessfully <\/p>\n\n\n\n<p>SELECT pgr_version (); \n\nIf the version you have is\nnot the last (2.2.3), download and update your version. The whole series of\nthese articles is achieved with this version and be aware that the syntax of\nmany pgrouting commands has been modified. If\nyou try to run the queries shown here with older versions you risk error\nmessages like this: &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=\"247\" data-attachment-id=\"7883\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/232-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/232.png?fit=525%2C247&amp;ssl=1\" data-orig-size=\"525,247\" 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=\"232\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/232.png?fit=525%2C247&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/232.png?resize=525%2C247&#038;ssl=1\" alt=\"\" class=\"wp-image-7883\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/232.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/232.png?resize=300%2C141&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p><strong>Setting up the data<\/strong> <\/p>\n\n\n\n<p>We will take the simplest case, but if you already have a network\ndatabase, you will need to take inspiration from this example to do the necessary\n&nbsp;adaptation for its use with pgrouting. <\/p>\n\n\n\n<p>In our case, we will download openStreetMap data from Brittany. <\/p>\n\n\n\n<p>We download them from Geofabrik (<a href=\"https:\/\/translate.google.com\/translate?hl=fr&amp;prev=_t&amp;sl=fr&amp;tl=en&amp;u=http:\/\/download.geofabrik.de\/europe\/france\/bretagne.html\">http:\/\/download.geofabrik.de\/europe\/france\/bretagne.html<\/a>\n). <\/p>\n\n\n\n<p>You have several available formats (osm, shp, pbf). Whichever your\nchoice, there will be work to be done to make the data usable once loaded into\nyour Postgis database. The format that gives the least work and the best final\nresults is the osm .In addition, there is a tool (osm2pgrouting) that allows\nthe loading and creation of the topology in, just, one path. <\/p>\n\n\n<div class='stb-container stb-style-warning stb-caption-box'><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+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABR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ZSH1hDq2AWr8cTxYcN+9uOqqqov2lTGjy4qKh48ZPCQhAf+ljfxt60FM3ru0\/QB20bP6Ufo3hcgpzd0zMUsmoMxoBiSja1bQw8jh2vwVpfiCsQ7deowfsKE+9tsWnfdffcYQUcl6nHX\/QEhFGTlc\/mGAnE96JyPpEQRO0iMyvfQcnojnrRuDR\/EjOJuXoU6UE3Cdhkx4pbbYhkZ6a0GycjIyOjbp+9AW4GqLkfVfHrKvs8RrVBaUMLvr4bkicAUzTAYJmpPZVBctmYNpQEGnDiG2rIaVzRyc3O75\/fI793qJnZ+fv4Pu+Tk5HhKUF9WB8nPSG1D4RPG31eF86eHMG+aAGYK6pN38Ta\/FVyDVVuaWDr+vioM3yOSmqp3u6rbj4CKVoE0NDT4lmV5KSnRkBhhcBWk0Kwr0ophpOJv\/Dt+xargnu5akBIJHL0tIJ4C9CCxiuDYtrTatHbs2LFn7549+0Liow8YgZbdA2mo\/+alqDU2bqQheijI5qHoqcq3tWs4Qd7Rry9CE6GhocGvrv5sd6tBPM9rfOONFStTwwbEryB0\/ysY\/YYHdZKVhGRbxALLauOcJFgWWkYXQr9ahDagkGhIo6Ji46adO3dUtimPhMPh+GuvLVt9e1HRkGMNieCSd\/ALpO4g+N6F\/xdUSgStaz7EOhE1Nb766lB90e2331FZWVnW4p7P1tdKT0+\/8okn5i4aN25cSWpaGo4SXF+h1IV\/ycA0dMK6hmlobN68ZcekSRN\/8+m2bW+dqa\/VmgZd2jXXXHNzYeHNhTcMvWFIz55X58ViseiFemNCC2KKOnDgwNFPtm6tWrNmzftvv\/3W67Zt7zpbg66tncYO8Xi8SywWizXNkwvE4h86dOioZVmHALs1nUbt8rsol0Eug1wG+Z8a\/x0A3thDl\/BwJ7kAAAAASUVORK5CYII=' alt='img'\/><\/div><div class='stb-caption-content'> **Update (2025)** <\/div><div class='stb-tool'><\/div><\/div><div class='stb-content'><\/p>\n\n\n\n<p>Since this article was written, Geofabrik no longer offers files in `.osm` format, but only compressed `.osm.pbf` files.<\/p>\n\n\n\n<p>The problem is that the Windows version of **osm2pgrouting** used in 2019 cannot read the `.pbf` format directly and returns the error: *\u201cnot well formed (invalid token)\u201d*.<\/p>\n\n\n\n<p>Two possible solutions:<\/p>\n\n\n\n<p>1. **Convert the `.osm.pbf` file to `.osm`**<\/p>\n\n\n\n<p>With a tool such as [Osmconvert](https:\/\/wiki.openstreetmap.org\/wiki\/Osmconvert) or [Osmium](https:\/\/osmcode.org\/osmium-tool\/):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>osmconvert bretagne-latest.osm.pbf -o=bretagne-latest.osm<\/code><\/pre>\n\n\n\n<p>You can then use `osm2pgrouting` on the `.osm` file.<\/p>\n\n\n\n<p>2. **Use a recent version of osm2pgrouting**<\/p>\n\n\n\n<p>Recent versions (provided with **pgRouting \u2265 2.6** or via **OSGeo4W** on Windows) directly support the `.pbf` format.<\/p>\n\n\n\n<p>In this case, it is no longer necessary to convert the file.<\/p>\n\n\n\n<p>In summary: if you have an old installation, convert `.pbf` \u2192 `.osm`.<\/p>\n\n\n\n<p>Otherwise, update your pgRouting\/osm2pgrouting environment to read `.pbf` directly.<\/p>\n\n\n\n<p><\/div><\/div>\n\n\n\n<p><strong>How to import the OSM data with osm2pgrouting<\/strong> <\/p>\n\n\n\n<p>In the latest Postgis versions, this tool is installed automatically. Check\nthat the C: \\ Program Files \\ PostgreSQL \\ 9.5 \\ bin \\ osm2pgrouting.exe file\nis present in your installation. <\/p>\n\n\n\n<p>If this is not the case, download the tool version corresponding to your\ninstallation &nbsp; from winnie. Unzip the file and follow the installation\ninstructions included in the osm2pgrouting_Readme.txt file. <\/p>\n\n\n\n<p>To simplify your command lines, add the \\ Program Files \\ PostgreSQL \\\n9.5 \\ bin directory to your PATH environment variable. <\/p>\n\n\n\n<p>To use the tool you will need to open a prompts command window. <\/p>\n\n\n\n<p>To get the complete syntax of the tool you can enter <\/p>\n\n\n\n<p><strong><em>osm2pgrouting.exe -help<\/em><\/strong> <\/p>\n\n\n\n<p>The essential elements to launch the tool: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>the name of the osm file to be loaded<br>( <em>bretagne-latest.osm<\/em> ) <\/li>\n\n\n\n<li>the name of the postgis database<br>( <em>postgis_22_sample<\/em> ) <\/li>\n\n\n\n<li>the listening port of your<br>Postgresql installation ( <em>5432<\/em> ) <\/li>\n\n\n\n<li>the name of the host ( <em>localhost<\/em> ) <\/li>\n\n\n\n<li>the name of the config xml file:<br>two files are provided with <em>mapconfig.xml<\/em> (generic) and <em>mapconfif_for_cars.xml<\/em> (for cars) <\/li>\n<\/ul>\n\n\n\n<p>Here is an example of a command line <\/p>\n\n\n\n<p>osm2pgrouting.exe -clean = 1 -f <em>bretagne-latest.osm<\/em> -d <em>postgis_22_sample<\/em>\n-p <em>5432<\/em> -h <em>localhost<\/em> -c <em>mapconfig_for_cars.xml<\/em> \n\nThe clean parameter= 1 indicates to overwrite\nexisting tables. This command loads data into multiple tables, but also\ngenerates the corresponding topology. For pgrouting the base table is the <em>ways<\/em>\ntable and the topology created the <em>ways_vertices_pgr<\/em> table <em>.<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"487\" data-attachment-id=\"7884\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/233-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/233.png?fit=525%2C487&amp;ssl=1\" data-orig-size=\"525,487\" 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=\"233\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/233.png?fit=525%2C487&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/233.png?resize=525%2C487&#038;ssl=1\" alt=\"\" class=\"wp-image-7884\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/233.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/233.png?resize=300%2C278&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nOnce\nthe command is executed, you will find a series of new tables in your database \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=\"397\" data-attachment-id=\"7885\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/234-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/234.png?fit=525%2C397&amp;ssl=1\" data-orig-size=\"525,397\" 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=\"234\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/234.png?fit=525%2C397&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/234.png?resize=525%2C397&#038;ssl=1\" alt=\"\" class=\"wp-image-7885\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/234.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/234.png?resize=300%2C227&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>The only tables you will use for your routing application are <strong><em>ways<\/em><\/strong>\n(linear network) and <strong><em>ways_vertices_pg<\/em><\/strong> r (network nodes). <\/p>\n\n\n\n<p><strong>How to import the data without osm2pgrouting<\/strong> <\/p>\n\n\n\n<p>If you download the Geofabrik data in <a href=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/shapefile-vs-geopackage\/\">shapefile<\/a> format or if you have\ndata with this format, it&rsquo;s a bit lengthier. <\/p>\n\n\n\n<p>You must start by loading your shapefile including the linear network\ninto your PostgreSQL \/ Postgis database. If necessary, relaunch your data in\nGeographic WGS84 because all pgrouting routing tools work on latitude \/\nlongitude data. <\/p>\n\n\n\n<p>Refer to the article <a href=\"https:\/\/translate.google.com\/translate?hl=fr&amp;prev=_t&amp;sl=fr&amp;tl=en&amp;u=http:\/\/wp.me\/p6XU0A-Mx\">Starting with PostgrSQL \/ Postgis -Introduction to pgAdmin3<\/a>\nfor loading a shape into Postgis. <\/p>\n\n\n\n<p>The created table corresponds to the <strong><em>ways<\/em><\/strong> table from the\nprevious chapter. Therefore, it is necessary to create the nodes table( <strong><em>ways_vertices_pg<\/em><\/strong>\nr) through the generation of the network topology. In order to make the following\nsimpler, we will consider that you named your table <strong><em>ways<\/em><\/strong> and that\nyou placed it in the <strong><em>public<\/em><\/strong> database <strong><em>.<\/em><\/strong> <\/p>\n\n\n\n<p>This is executed by the SQL command pgr_createTopology . But\nthis command assumes that your table contains two columns named <strong><em>source<\/em><\/strong>\nand <strong><em>target<\/em><\/strong> . \n\nHere are the commands to enter in the pgAdmin\nIII SQL 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=\"298\" data-attachment-id=\"7886\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/235-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/235.png?fit=525%2C298&amp;ssl=1\" data-orig-size=\"525,298\" 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=\"235\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/235.png?fit=525%2C298&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/235.png?resize=525%2C298&#038;ssl=1\" alt=\"\" class=\"wp-image-7886\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/235.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/235.png?resize=300%2C170&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>The value 0.00001 is equivalent to the tolerance in degrees, <em>geom<\/em>\nto the name of the geometry field and <em>gid<\/em> to the table identifier field.\n<\/p>\n\n\n\n<p>At the exit of this command you will find the table <strong><em>ways_vertices_pg<\/em><\/strong>\nr in your PostgreSQL database. <\/p>\n\n\n\n<p><strong>How to validate your data in Postgis<\/strong> <\/p>\n\n\n\n<p>In an ideal world, you could go directly to setting up your data server with\nGeoserver. But, there is a good chance that things will not work out properly\n&#8230; <\/p>\n\n\n\n<p>We will discuss the most common problems, letting you discover by yourself\na lot of additional problems! <\/p>\n\n\n\n<p>Firstly, we will use QGis to test our database and the operation of\ndifferent routing algorithms. <\/p>\n\n\n\n<p><strong>Pgrouting tests with QGis<\/strong> \n\nYou will will start by connecting&nbsp; with your Postgis database and loading the <strong><em>ways<\/em><\/strong>\nlayer : &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=\"273\" data-attachment-id=\"7887\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/236-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/236.png?fit=525%2C273&amp;ssl=1\" data-orig-size=\"525,273\" 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=\"236\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/236.png?fit=525%2C273&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/236.png?resize=525%2C273&#038;ssl=1\" alt=\"\" class=\"wp-image-7887\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/236.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/236.png?resize=300%2C156&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"294\" data-attachment-id=\"7888\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/237-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/237.png?fit=525%2C294&amp;ssl=1\" data-orig-size=\"525,294\" 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=\"237\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/237.png?fit=525%2C294&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/237.png?resize=525%2C294&#038;ssl=1\" alt=\"\" class=\"wp-image-7888\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/237.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/237.png?resize=300%2C168&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nTo\nrun the pgrouting sql commands on your database, from QGis, open the Database\nManager &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=\"84\" data-attachment-id=\"7889\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/238-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/238.png?fit=525%2C84&amp;ssl=1\" data-orig-size=\"525,84\" 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=\"238\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/238.png?fit=525%2C84&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/238.png?resize=525%2C84&#038;ssl=1\" alt=\"\" class=\"wp-image-7889\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/238.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/238.png?resize=300%2C48&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nThen,\nselect your Postgis database from the databases list, and open a SQL window &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=\"354\" data-attachment-id=\"7890\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/239-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/239.png?fit=525%2C354&amp;ssl=1\" data-orig-size=\"525,354\" 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=\"239\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/239.png?fit=525%2C354&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/239.png?resize=525%2C354&#038;ssl=1\" alt=\"\" class=\"wp-image-7890\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/239.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/239.png?resize=300%2C202&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>It is in this upper window that we will enter the pgrouting sql\ncommands. <\/p>\n\n\n\n<p>The lower window will list the table records resulting from the sql\ncommand. <\/p>\n\n\n\n<p>By checking the box on the bottom <em>Load as new layer<\/em> , we will\nload the result in the QGis map window. \n\nExample: \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=\"377\" data-attachment-id=\"7891\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/2310-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2310.png?fit=525%2C377&amp;ssl=1\" data-orig-size=\"525,377\" 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=\"2310\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2310.png?fit=525%2C377&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2310.png?resize=525%2C377&#038;ssl=1\" alt=\"\" class=\"wp-image-7891\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2310.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2310.png?resize=300%2C215&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>The SQL command corresponds to the route search in pgrouting using the\nalgorithm A *, starting from node 69072 and arriving to node 64204 <\/p>\n\n\n\n<p>The <strong>Run<\/strong> button sends the command to the Postgres database and\nretrieves the number of lines (30 lines in this example) corresponding to the\nroute and displays in the bottom window these lines in the order for the route.\n<\/p>\n\n\n\n<p>If we now ask to load the layer in QGis, it is the data of this lower\nwindow that will be displayed in the map window. <\/p>\n\n\n\n<p>Problem: There is no geometry column in the result. We will not be able\nto view the route as a layer. <\/p>\n\n\n\n<p>To get around this problem, we will add the geometry in the command\nresults. It&rsquo;s a little complicated to explain, so let&rsquo;s go straight to discuss\nhow to do it: <\/p>\n\n\n\n<p>We will make a join between the algorithm pgr_astar result (&#8230;) (All\nthat is in parentheses are the algorithm parameters), which does not return in\nthe result the geometries but only nodes identifiers (edges) , and the node table,\nthen with the ways table: <\/p>\n\n\n\n<p>SELECT seq, id1 AS node, id2 AS edge, &nbsp; the_geom <br>\nFROM pgr_astar (&lsquo;SELECT gid as id, source, target, cost, x1, y1, x2, y2 &nbsp; FROM\npublic.ways&rsquo;, 69072, 64204, false, false) <strong><em>as res<\/em><\/strong> <br>\n <strong><em>JOIN public.ways ways_vertices_pgr<\/em><\/strong> <br>\n <strong><em>ON res.id2 = ways_vertices_pgr.gid;<\/em><\/strong> \n\nIn short, we look for the node corresponding to\nthe edge of the result and we recover the linear section which is joined to it\nby the topology. Now we can add in the result fields of &nbsp;the selected &nbsp;field the_geom which will allow us to trace\nthe result in QGis. \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=\"378\" data-attachment-id=\"7892\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/attachment\/2311\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2311.png?fit=525%2C378&amp;ssl=1\" data-orig-size=\"525,378\" 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=\"2311\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2311.png?fit=525%2C378&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2311.png?resize=525%2C378&#038;ssl=1\" alt=\"\" class=\"wp-image-7892\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2311.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2311.png?resize=300%2C216&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>To load the layer in QGis, select the <strong><em>Load\nas new layer<\/em><\/strong> checkbox , select the geometry field, and click the <strong><em>Load<\/em><\/strong>\nbutton . \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=\"287\" data-attachment-id=\"7893\" data-permalink=\"https:\/\/www.sigterritoires.fr\/index.php\/en\/how-to-develop-an-application-with-pgrouting-in-windows-1\/attachment\/2312\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2312.png?fit=525%2C287&amp;ssl=1\" data-orig-size=\"525,287\" 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=\"2312\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2312.png?fit=525%2C287&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2312.png?resize=525%2C287&#038;ssl=1\" alt=\"\" class=\"wp-image-7893\" srcset=\"https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2312.png?w=525&amp;ssl=1 525w, https:\/\/i0.wp.com\/www.sigterritoires.fr\/wp-content\/uploads\/2019\/01\/2312.png?resize=300%2C164&amp;ssl=1 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p>Now that we have discussed how to test our database, we will discuss the\nmain algorithms proposed by pgrouting, and which changes in the data must be\nmade in order to work properly &#8230; but all this in the next article. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here starts a series of articles to set up a routing web application (route calculation) completely autonomous, ie using no web service or API for calculating the route. We will set up the database including the&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_post_was_ever_published":false,"_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":""},"categories":[1260],"tags":[],"class_list":["post-7881","post","type-post","status-publish","format-standard","hentry","category-non-classe-en"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6XU0A-237","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/7881","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=7881"}],"version-history":[{"count":0,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/posts\/7881\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/media?parent=7881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/categories?post=7881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sigterritoires.fr\/index.php\/wp-json\/wp\/v2\/tags?post=7881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}