13. Appendix: Workshop Solutions

13.1. pgRouting Algorithms Solutions

13.1.1. Solution to Exercise 1

Exercise 1

 seq | path_seq | node | edge |        cost         |      agg_cost       
-----+----------+------+------+---------------------+---------------------
   1 |        1 | 1060 | 1285 | 0.00203726472015596 |                   0
   2 |        2 |  545 | 2044 | 0.00195102527671287 | 0.00203726472015596
   3 |        3 | 1713 | 1989 | 0.00141014024221734 | 0.00398828999686883
   4 |        4 | 1661 |   -1 |                   0 | 0.00539843023908617
(4 rows)

13.1.2. Solution to Exercise 2

Exercise 2

 seq | path_seq | start_vid | node | edge |       cost       |     agg_cost     
-----+----------+-----------+------+------+------------------+------------------
   1 |        1 |      1060 | 1060 | 1285 | 225.258862979722 |                0
   2 |        2 |      1060 |  545 |  649 | 211.661459249381 | 225.258862979722
   3 |        3 |      1060 |  961 | 1156 | 217.965421167396 | 436.920322229102
   4 |        4 |      1060 | 1361 | 1638 | 120.209032368071 | 654.885743396498
   5 |        5 |      1060 | 1466 | 2948 | 158.953675313931 | 775.094775764569
   6 |        6 |      1060 | 2486 | 2947 | 167.449458836267 |   934.0484510785
   7 |        7 |      1060 | 1253 |   -1 |                0 | 1101.49790991477
   8 |        1 |      1661 | 1661 | 1761 | 265.567165528973 |                0
   9 |        2 |      1661 | 1466 | 2948 | 158.953675313931 | 265.567165528973
  10 |        3 |      1661 | 2486 | 2947 | 167.449458836267 | 424.520840842905
  11 |        4 |      1661 | 1253 |   -1 |                0 | 591.970299679172
(11 rows)

13.1.3. Solution to Exercise 3

Exercise 3

 seq | path_seq | end_vid | node | edge |       cost       |     agg_cost     
-----+----------+---------+------+------+------------------+------------------
   1 |        1 |    1060 | 1253 | 2947 | 128.807276027898 |                0
   2 |        2 |    1060 | 2486 | 2948 | 122.272057933793 | 128.807276027898
   3 |        3 |    1060 | 1466 | 1638 | 92.4684864369775 | 251.079333961691
   4 |        4 |    1060 | 1361 | 1156 | 167.665708590305 | 343.547820398669
   5 |        5 |    1060 |  961 |  649 | 162.816507114908 | 511.213528988973
   6 |        6 |    1060 |  545 | 1285 |  173.27604844594 | 674.030036103881
   7 |        7 |    1060 | 1060 |   -1 |                0 | 847.306084549821
   8 |        1 |    1661 | 1253 | 2947 | 128.807276027898 |                0
   9 |        2 |    1661 | 2486 | 2948 | 122.272057933793 | 128.807276027898
  10 |        3 |    1661 | 1466 | 1761 | 204.282435022287 | 251.079333961691
  11 |        4 |    1661 | 1661 |   -1 |                0 | 455.361768983978
(11 rows)

13.1.4. Solution to Exercise 4

Exercise 4

 seq | path_seq | start_vid | end_vid | node | edge |       cost        |     agg_cost     
-----+----------+-----------+---------+------+------+-------------------+------------------
   1 |        1 |      1060 |     115 | 1060 | 1285 |  2.88793414076566 |                0
   2 |        2 |      1060 |     115 |  545 |  649 |  2.71360845191514 | 2.88793414076566
   3 |        3 |      1060 |     115 |  961 | 1157 |  2.09983765887622 |  5.6015425926808
   4 |        4 |      1060 |     115 | 1897 | 2255 |  1.91356518477422 | 7.70138025155702
   5 |        5 |      1060 |     115 | 1477 | 3341 |  2.45447687938298 | 9.61494543633124
   6 |        6 |      1060 |     115 |  368 | 1754 |  2.13676131594056 | 12.0694223157142
   7 |        7 |      1060 |     115 | 1461 | 1755 |  1.71804746216162 | 14.2061836316548
   8 |        8 |      1060 |     115 | 1070 | 1296 |  1.29698598632806 | 15.9242310938164
   9 |        9 |      1060 |     115 | 1659 | 1525 | 0.416463263772614 | 17.2212170801445
  10 |       10 |      1060 |     115 | 1267 | 2667 |  0.71458770101113 | 17.6376803439171
  11 |       11 |      1060 |     115 | 2253 |  530 | 0.305281604994012 | 18.3522680449282
  12 |       12 |      1060 |     115 |  450 | 2047 | 0.640502762968939 | 18.6575496499222
  13 |       13 |      1060 |     115 | 1715 | 3305 |  2.43553647686408 | 19.2980524128912
  14 |       14 |      1060 |     115 |  135 | 3598 |  2.02572210685056 | 21.7335888897552
  15 |       15 |      1060 |     115 | 2091 | 2487 |  3.01748018392712 | 23.7593109966058
  16 |       16 |      1060 |     115 |  115 |   -1 |                 0 | 26.7767911805329
  17 |        1 |      1060 |    1253 | 1060 | 1285 |  2.88793414076566 |                0
  18 |        2 |      1060 |    1253 |  545 |  649 |  2.71360845191514 | 2.88793414076566
  19 |        3 |      1060 |    1253 |  961 | 1156 |  2.79442847650508 |  5.6015425926808
  20 |        4 |      1060 |    1253 | 1361 | 1638 |  1.54114144061629 | 8.39597106918587
  21 |        5 |      1060 |    1253 | 1466 | 2948 |  2.03786763222989 | 9.93711250980217
  22 |        6 |      1060 |    1253 | 2486 | 2947 |   2.1467879337983 | 11.9749801420321
  23 |        7 |      1060 |    1253 | 1253 |   -1 |                 0 | 14.1217680758304
  24 |        1 |      1661 |     115 | 1661 | 1761 |  3.40470725037145 |                0
  25 |        2 |      1661 |     115 | 1466 | 2948 |  2.03786763222989 | 3.40470725037145
  26 |        3 |      1661 |     115 | 2486 | 3693 |  1.93508343932859 | 5.44257488260134
  27 |        4 |      1661 |     115 | 2759 | 1987 |  3.66361602123479 | 7.37765832192994
  28 |        5 |      1661 |     115 | 1659 | 1525 | 0.416463263772614 | 11.0412743431647
  29 |        6 |      1661 |     115 | 1267 | 2667 |  0.71458770101113 | 11.4577376069373
  30 |        7 |      1661 |     115 | 2253 |  530 | 0.305281604994012 | 12.1723253079485
  31 |        8 |      1661 |     115 |  450 | 2047 | 0.640502762968939 | 12.4776069129425
  32 |        9 |      1661 |     115 | 1715 | 3305 |  2.43553647686408 | 13.1181096759114
  33 |       10 |      1661 |     115 |  135 | 3598 |  2.02572210685056 | 15.5536461527755
  34 |       11 |      1661 |     115 | 2091 | 2487 |  3.01748018392712 | 17.5793682596261
  35 |       12 |      1661 |     115 |  115 |   -1 |                 0 | 20.5968484435532
  36 |        1 |      1661 |    1253 | 1661 | 1761 |  3.40470725037145 |                0
  37 |        2 |      1661 |    1253 | 1466 | 2948 |  2.03786763222989 | 3.40470725037145
  38 |        3 |      1661 |    1253 | 2486 | 2947 |   2.1467879337983 | 5.44257488260134
  39 |        4 |      1661 |    1253 | 1253 |   -1 |                 0 | 7.58936281639964
(39 rows)

13.1.5. Solution to Exercise 5

Exercise 5

 start_vid | end_vid |     agg_cost     
-----------+---------+------------------
      1060 |     115 | 26.7767911805329
      1060 |    1253 | 14.1217680758304
      1661 |     115 | 20.5968484435532
      1661 |    1253 | 7.58936281639964
(4 rows)

13.1.6. Solution to Exercise 6

Exercise 6

 end_vid |       sum        
---------+------------------
     115 | 47.3736396240861
    1253 |   21.71113089223
(2 rows)

13.2. Advanced Routing Queries Solutions

13.2.1. Solution to Exercise 7

Exercise 7

 seq | path_seq | node | edge |       cost       |     agg_cost     
-----+----------+------+------+------------------+------------------
   1 |        1 | 1060 | 1285 |   16.21863813454 |                0
   2 |        2 |  545 |  649 | 15.2396250659554 |   16.21863813454
   3 |        3 |  961 | 1157 | 11.7926882922489 | 31.4582632004954
   4 |        4 | 1897 | 2255 |  10.746582077692 | 43.2509514927442
   5 |        5 | 1477 | 3341 | 13.7843421546148 | 53.9975335704362
   6 |        6 |  368 | 1754 | 12.0000515503222 | 67.7818757250511
   7 |        7 | 1461 | 1755 | 9.64855454749966 | 79.7819272753732
   8 |        8 | 1070 | 1296 | 7.28387329921837 | 89.4304818228729
   9 |        9 | 1659 | 1525 |   2.338857689347 | 96.7143551220913
  10 |       10 | 1267 | 2667 | 4.01312452887851 | 99.0532128114383
  11 |       11 | 2253 |  530 | 1.71446149364637 | 103.066337340317
  12 |       12 |  450 | 2047 | 3.59706351683356 | 104.780798833963
  13 |       13 | 1715 | 3305 | 13.6779728540687 | 108.377862350797
  14 |       14 |  135 | 3598 | 11.3764553520728 | 122.055835204865
  15 |       15 | 2091 | 2487 | 16.9461687129347 | 133.432290556938
  16 |       16 |  115 |   -1 |                0 | 150.378459269873
(16 rows)

13.2.2. Solution to Exercise 8

Exercise 8

 seq | path_seq | node | edge |       cost       |     agg_cost     
-----+----------+------+------+------------------+------------------
   1 |        1 |  115 | 2487 | 16.9461687129347 |                0
   2 |        2 | 2091 | 3598 | 11.3764553520728 | 16.9461687129347
   3 |        3 |  135 | 3305 | 13.6779728540687 | 28.3226240650075
   4 |        4 | 1715 | 2047 | 3.59706351683356 | 42.0005969190761
   5 |        5 |  450 |  529 | 7.62056168933039 | 45.5976604359097
   6 |        6 |  641 |  757 | 5.02090630047807 | 53.2182221252401
   7 |        7 |  402 | 4085 | 8.38742205443017 | 58.2391284257181
   8 |        8 | 3940 | 5616 |  2.4740977338142 | 66.6265504801483
   9 |        9 |  388 | 3343 | 9.13457674041318 | 69.1006482139625
  10 |       10 | 1889 | 3568 | 1.86833722718625 | 78.2352249543757
  11 |       11 | 2307 | 3733 | 6.14055277216272 | 80.1035621815619
  12 |       12 | 2877 | 3732 | 10.4943852265419 | 86.2441149537247
  13 |       13 | 1477 | 2255 |  10.746582077692 | 96.7385001802666
  14 |       14 | 1897 | 1157 | 11.7926882922489 | 107.485082257959
  15 |       15 |  961 |  649 | 15.2396250659554 | 119.277770550207
  16 |       16 |  545 | 1285 |   16.21863813454 | 134.517395616163
  17 |       17 | 1060 |   -1 |                0 | 150.736033750703
(17 rows)

13.2.3. Solution to Exercise 9

Exercise 9

 seq | path_seq | node | edge |        cost        |     agg_cost      
-----+----------+------+------+--------------------+-------------------
   1 |        1 |  115 | 2487 |  0.470726908692631 |                 0
   2 |        2 | 2091 | 3598 |  0.316012648668688 | 0.470726908692631
   3 |        3 |  135 | 3305 |  0.379943690390796 | 0.786739557361319
   4 |        4 | 1715 | 2047 | 0.0999184310231545 |  1.16668324775211
   5 |        5 |  450 |  529 |  0.211682269148066 |  1.26660167877527
   6 |        6 |  641 |  757 |  0.139469619457724 |  1.47828394792334
   7 |        7 |  402 | 4085 |  0.232983945956394 |  1.61775356738106
   8 |        8 | 3940 | 5616 | 0.0687249370503943 |  1.85073751333745
   9 |        9 |  388 | 3343 |  0.253738242789255 |  1.91946245038785
  10 |       10 | 1889 | 3568 | 0.0518982563107291 |   2.1732006931771
  11 |       11 | 2307 | 3733 |  0.170570910337853 |  2.22509894948783
  12 |       12 | 2877 | 3732 |  0.291510700737276 |  2.39566985982569
  13 |       13 | 1477 | 2255 |  0.298516168824778 |  2.68718056056296
  14 |       14 | 1897 | 1157 |  0.327574674784691 |  2.98569672938774
  15 |       15 |  961 |  649 |  0.423322918498761 |  3.31327140417243
  16 |       16 |  545 | 1285 |  0.450517725959443 |  3.73659432267119
  17 |       17 | 1060 |   -1 |                  0 |  4.18711204863063
(17 rows)

13.2.4. Solution to Exercise 10

Exercise 10

ALTER TABLE
UPDATE 36
 seq | path_seq | node | edge |       cost       |     agg_cost     
-----+----------+------+------+------------------+------------------
   1 |        1 | 1253 | 2947 | 12.0563610362112 |                0
   2 |        2 | 2486 | 3693 | 10.8674285952694 | 12.0563610362112
   3 |        3 | 2759 |   -1 |                0 | 22.9237896314806
(3 rows)

13.2.5. Solution to Exercise 11

Exercise 11

 seq | path_seq | node | edge |       cost        |     agg_cost     
-----+----------+------+------+-------------------+------------------
   1 |        1 | 1253 | 2947 |  6.02818051810562 |                0
   2 |        2 | 2486 | 3536 |  4.39092341742284 | 6.02818051810562
   3 |        3 | 1636 | 3571 |  7.72021374468571 | 10.4191039355285
   4 |        4 | 1897 | 2255 |  3.22397462330761 | 18.1393176802142
   5 |        5 | 1477 | 3341 |  6.89217107730741 | 21.3632923035218
   6 |        6 |  368 | 3602 | 0.953512053439165 | 28.2554633808292
   7 |        7 | 2117 | 3692 |   4.2974761211037 | 29.2089754342683
   8 |        8 | 2759 |   -1 |                 0 | 33.5064515553721
(8 rows)

13.3. Solutions to Writing a SQL Stored Procedures Chapter

13.3.1. Solution to Chapter 7 Exercise 1

Exercise 1

CREATE VIEW
 count 
-------
  5650
(1 row)

 count 
-------
  3775
(1 row)

13.3.2. Solution to Chapter 7 Exercise 2

Exercise 2

CREATE VIEW
 count 
-------
  1881
(1 row)

13.3.3. Solution to Chapter 7 Exercise 3

Exercise 3

 seq | path_seq | node | edge |       cost        |     agg_cost      
-----+----------+------+------+-------------------+-------------------
   1 |        1 | 1661 | 1989 |  0.18710649413388 |                 0
   2 |        2 | 1713 | 2044 | 0.258853919144829 |  0.18710649413388
   3 |        3 |  545 | 1285 | 0.270310635575666 | 0.445960413278709
   4 |        4 | 1060 |   -1 |                 0 | 0.716271048854375
(4 rows)

13.3.4. Solution to Chapter 7 Exercise 4

Exercise 4

 seq | path_seq | node | edge |       cost        |     agg_cost      |     name     
-----+----------+------+------+-------------------+-------------------+--------------
   1 |        1 | 1661 | 1989 |  0.18710649413388 |                 0 | Ghana street
   2 |        2 | 1713 | 2044 | 0.258853919144829 |  0.18710649413388 | Ghana street
   3 |        3 |  545 | 1285 | 0.270310635575666 | 0.445960413278709 | Ohio Street
   4 |        4 | 1060 |   -1 |                 0 | 0.716271048854375 | 
(4 rows)

13.3.5. Solution to Chapter 7 Exercise 5

Exercise 5

 seq | path_seq | node | edge |       cost        |     agg_cost      |     name     |                                              st_astext                                              
-----+----------+------+------+-------------------+-------------------+--------------+-----------------------------------------------------------------------------------------------------
   1 |        1 | 1661 | 1989 |  0.18710649413388 |                 0 | Ghana street | LINESTRING(39.2902655 -6.8114116,39.2903151 -6.8111861,39.2904794 -6.8109834,39.2910718 -6.8102817)
   2 |        2 | 1713 | 2044 | 0.258853919144829 |  0.18710649413388 | Ghana street | LINESTRING(39.2888771 -6.8127504,39.2895542 -6.8121531,39.2902262 -6.8115544,39.2902655 -6.8114116)
   3 |        3 |  545 | 1285 | 0.270310635575666 | 0.445960413278709 | Ohio Street  | LINESTRING(39.2888771 -6.8127504,39.2875816 -6.8111781)
   4 |        4 | 1060 |   -1 |                 0 | 0.716271048854375 |              | 
(4 rows)

13.3.6. Solution to Chapter 7 Exercise 6

Exercise 6

 seq | path_seq | node | edge |       cost        |     agg_cost      |     name     |                                                                         route_geom                                                                         
-----+----------+------+------+-------------------+-------------------+--------------+------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 |        1 | 1661 | 1989 |  0.18710649413388 |                 0 | Ghana street | 0102000020E6100000040000001BD47E6B27A543405061B6AEE23E1BC07A04920B29A543400FE1A991A73E1BC0B394D16D2EA543404265B26E723E1BC0D8E43AD741A543406B30687CBA3D1BC0
   2 |        2 | 1713 | 2044 | 0.258853919144829 |  0.18710649413388 | Ghana street | 0102000020E6100000040000001B88C0ECF9A44340613E0FA441401BC0B0B5AD1C10A543404C61EF0FA53F1BC09FB8D22126A543401AB3DB1D083F1BC01BD47E6B27A543405061B6AEE23E1BC0
   3 |        3 |  545 | 1285 | 0.270310635575666 | 0.445960413278709 | Ohio Street  | 0102000020E6100000020000001B88C0ECF9A44340613E0FA441401BC037774F79CFA44340F9ECCA78A53E1BC0
   4 |        4 | 1060 |   -1 |                 0 | 0.716271048854375 |              | 
(4 rows)

13.3.7. Solution to Chapter 7 Exercise 7

Exercise 7

 seq |     name     |       cost        |     azimuth      |                                              st_astext                                              |                                                                         route_geom                                                                         
-----+--------------+-------------------+------------------+-----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | Ghana street |  0.18710649413388 | 35.5117668657488 | LINESTRING(39.2902655 -6.8114116,39.2903151 -6.8111861,39.2904794 -6.8109834,39.2910718 -6.8102817) | 0102000020E6100000040000001BD47E6B27A543405061B6AEE23E1BC07A04920B29A543400FE1A991A73E1BC0B394D16D2EA543404265B26E723E1BC0D8E43AD741A543406B30687CBA3D1BC0
   2 | Ghana street | 0.258853919144829 | 46.0419321605528 | LINESTRING(39.2888771 -6.8127504,39.2895542 -6.8121531,39.2902262 -6.8115544,39.2902655 -6.8114116) | 0102000020E6100000040000001B88C0ECF9A44340613E0FA441401BC0B0B5AD1C10A543404C61EF0FA53F1BC09FB8D22126A543401AB3DB1D083F1BC01BD47E6B27A543405061B6AEE23E1BC0
   3 | Ohio Street  | 0.270310635575666 | 320.513109606255 | LINESTRING(39.2888771 -6.8127504,39.2875816 -6.8111781)                                             | 0102000020E6100000020000001B88C0ECF9A44340613E0FA441401BC037774F79CFA44340F9ECCA78A53E1BC0
(3 rows)

13.3.8. Solution to Chapter 7 Exercise 8

Exercise 8

 seq |     name     |       cost        |     azimuth      |                                              st_astext                                              |                                                                         route_geom                                                                         
-----+--------------+-------------------+------------------+-----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | Ghana street |  0.18710649413388 | 215.511766865749 | LINESTRING(39.2910718 -6.8102817,39.2904794 -6.8109834,39.2903151 -6.8111861,39.2902655 -6.8114116) | 0102000020E610000004000000D8E43AD741A543406B30687CBA3D1BC0B394D16D2EA543404265B26E723E1BC07A04920B29A543400FE1A991A73E1BC01BD47E6B27A543405061B6AEE23E1BC0
   2 | Ghana street | 0.258853919144829 | 226.041932160553 | LINESTRING(39.2902655 -6.8114116,39.2902262 -6.8115544,39.2895542 -6.8121531,39.2888771 -6.8127504) | 0102000020E6100000040000001BD47E6B27A543405061B6AEE23E1BC09FB8D22126A543401AB3DB1D083F1BC0B0B5AD1C10A543404C61EF0FA53F1BC01B88C0ECF9A44340613E0FA441401BC0
   3 | Ohio Street  | 0.270310635575666 | 320.513109606255 | LINESTRING(39.2888771 -6.8127504,39.2875816 -6.8111781)                                             | 0102000020E6100000020000001B88C0ECF9A44340613E0FA441401BC037774F79CFA44340F9ECCA78A53E1BC0
(3 rows)

13.3.9. Solution to Chapter 7 Exercise 9

Exercise 9

CREATE FUNCTION

13.3.10. Solution to Chapter 7 Exercise 10

Exercise 10

 seq | gid  |     name     |       cost        |     azimuth      |                                           route_readable                                            |                                                                         route_geom                                                                         
-----+------+--------------+-------------------+------------------+-----------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | 1989 | Ghana street |  0.18710649413388 | 215.511766865749 | LINESTRING(39.2910718 -6.8102817,39.2904794 -6.8109834,39.2903151 -6.8111861,39.2902655 -6.8114116) | 0102000020E610000004000000D8E43AD741A543406B30687CBA3D1BC0B394D16D2EA543404265B26E723E1BC07A04920B29A543400FE1A991A73E1BC01BD47E6B27A543405061B6AEE23E1BC0
   2 | 2044 | Ghana street | 0.258853919144829 | 226.041932160553 | LINESTRING(39.2902655 -6.8114116,39.2902262 -6.8115544,39.2895542 -6.8121531,39.2888771 -6.8127504) | 0102000020E6100000040000001BD47E6B27A543405061B6AEE23E1BC09FB8D22126A543401AB3DB1D083F1BC0B0B5AD1C10A543404C61EF0FA53F1BC01B88C0ECF9A44340613E0FA441401BC0
   3 | 1285 | Ohio Street  | 0.270310635575666 | 320.513109606255 | LINESTRING(39.2888771 -6.8127504,39.2875816 -6.8111781)                                             | 0102000020E6100000020000001B88C0ECF9A44340613E0FA441401BC037774F79CFA44340F9ECCA78A53E1BC0
(3 rows)

13.4. Solutions to Writing a pl/pgsql Stored Procedures Chapter

13.4.1. Solution to Chapter 8 Exercise 1

Exercise 1: Number of Vertices

 count 
-------
  3962
(1 row)

 count 
-------
  2728
(1 row)

 count 
-------
  1228
(1 row)

13.4.2. Solution to Chapter 8 Exercise 2

Exercise 2: Nearest Vertex

  osm_id
-----------
 282841506
(1 row)

  osm_id
-----------
 282841506
(1 row)

  osm_id   
-----------
 282841506
(1 row)

13.4.3. Solution to Chapter 8 Exercise 3

Exercise 3: Creating the function

CREATE FUNCTION

13.4.4. Solution to Chapter 8 Exercise 4

Exercise 4: Using the function

 seq | gid  |     name      |      length       |     the_time      |     azimuth      |                                                            geom                                                            
-----+------+---------------+-------------------+-------------------+------------------+----------------------------------------------------------------------------------------------------------------------------
   1 | 1638 | Garden Avenue | 0.120209032368071 | 0.144250838841685 | 231.186295092475 | 0102000020E610000002000000BB5F05F86EA5434064AF777FBC3F1BC0353A313553A54340B58828266F401BC0
   2 | 1156 | Garden Avenue | 0.217965421167396 | 0.261558505400875 | 229.165120382668 | 0102000020E610000002000000353A313553A54340B58828266F401BC0369EBE5422A543402CE63114C1411BC0
   3 |  649 | Ohio Street   | 0.211661459249381 | 0.253993751099257 | 319.868106058538 | 0102000020E610000003000000369EBE5422A543402CE63114C1411BC0774D486B0CA54340CBD8D0CDFE401BC01B88C0ECF9A44340613E0FA441401BC0
   4 | 1285 | Ohio Street   | 0.225258862979722 | 0.270310635575666 | 320.513109606255 | 0102000020E6100000020000001B88C0ECF9A44340613E0FA441401BC037774F79CFA44340F9ECCA78A53E1BC0
(4 rows)

 seq | gid  |     name      |      length       |     the_time      |     azimuth      |                                                            geom                                                            
-----+------+---------------+-------------------+-------------------+------------------+----------------------------------------------------------------------------------------------------------------------------
   1 | 1638 | Garden Avenue | 0.120209032368071 | 0.144250838841685 | 231.186295092475 | 0102000020E610000002000000BB5F05F86EA5434064AF777FBC3F1BC0353A313553A54340B58828266F401BC0
   2 | 1156 | Garden Avenue | 0.217965421167396 | 0.261558505400875 | 229.165120382668 | 0102000020E610000002000000353A313553A54340B58828266F401BC0369EBE5422A543402CE63114C1411BC0
   3 |  649 | Ohio Street   | 0.211661459249381 | 0.253993751099257 | 319.868106058538 | 0102000020E610000003000000369EBE5422A543402CE63114C1411BC0774D486B0CA54340CBD8D0CDFE401BC01B88C0ECF9A44340613E0FA441401BC0
   4 | 1285 | Ohio Street   | 0.225258862979722 | 0.270310635575666 | 320.513109606255 | 0102000020E6100000020000001B88C0ECF9A44340613E0FA441401BC037774F79CFA44340F9ECCA78A53E1BC0
(4 rows)

SELECT 4