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 |  9411 | 13014 | 0.000261339572452971 |                    0
   2 |        2 |  5080 | 13015 | 0.000122967068757988 | 0.000261339572452971
   3 |        3 | 13059 | 12988 | 0.000194746085681759 | 0.000384306641210959
   4 |        4 | 10292 |  6580 | 0.000378739436897062 | 0.000579052726892717
   5 |        5 |  9686 | 18214 | 0.000122198404250062 |  0.00095779216378978
   6 |        6 | 14296 | 19710 |  0.00193083142281014 |  0.00107999056803984
   7 |        7 | 11992 | 19257 | 0.000498343546164985 |  0.00301082199084998
   8 |        8 |   220 |  9292 | 0.000829624264347135 |  0.00350916553701497
   9 |        9 | 11385 |  9271 | 0.000418441011372923 |   0.0043387898013621
  10 |       10 |  5108 |  8365 | 0.000196121110545352 |  0.00475723081273502
  11 |       11 | 11738 |  8366 |  0.00099456476912791 |  0.00495335192328038
  12 |       12 |  3986 |    -1 |                    0 |  0.00594791669240829
(12 rows)

13.1.2. Solution to Exercise 2

Exercise 2

 seq | path_seq | start_vid | node  | edge  |       cost       |     agg_cost     
-----+----------+-----------+-------+-------+------------------+------------------
   1 |        1 |      3986 |  3986 |  8366 | 101.056235984316 |                0
   2 |        2 |      3986 | 11738 | 13323 | 14.1412297001033 | 101.056235984316
   3 |        3 |      3986 |   642 | 13320 |  13.554520377154 | 115.197465684419
   4 |        4 |      3986 |  3523 | 13321 | 61.7862974939716 | 128.751986061573
   5 |        5 |      3986 |  4884 | 16021 | 54.4018918131038 | 190.538283555545
   6 |        6 |      3986 |  8478 | 16020 | 24.4306792056242 | 244.940175368648
   7 |        7 |      3986 |  4209 | 16019 | 107.980544511826 | 269.370854574273
   8 |        8 |      3986 |  6991 |  1432 | 59.7676259547896 | 377.351399086099
   9 |        9 |      3986 | 10006 |  1433 | 70.6138177158884 | 437.119025040888
  10 |       10 |      3986 |  2617 |  1434 | 66.4171716546773 | 507.732842756777
  11 |       11 |      3986 |   628 |  1435 | 55.1605609775843 | 574.150014411454
  12 |       12 |      3986 |  8158 | 15565 | 58.5737233451319 | 629.310575389038
  13 |       13 |      3986 |  8630 | 15956 | 6.47161622947678 |  687.88429873417
  14 |       14 |      3986 | 12243 | 15957 | 17.1557112983927 | 694.355914963647
  15 |       15 |      3986 |   157 | 15958 | 5.47854504899092 |  711.51162626204
  16 |       16 |      3986 |  9016 |  4007 | 55.6720507198261 | 716.990171311031
  17 |       17 |      3986 |  7444 |  8374 | 90.4337668533131 | 772.662222030857
  18 |       18 |      3986 | 13009 |    -1 |                0 |  863.09598888417
  19 |        1 |      9411 |  9411 | 13014 | 24.4859378144242 |                0
  20 |        2 |      9411 |  5080 | 13015 | 11.4539784310738 | 24.4859378144242
  21 |        3 |      9411 | 13059 | 12988 | 19.2467486406913 |  35.939916245498
  22 |        4 |      9411 | 10292 |  6580 | 40.4519653708227 | 55.1866648861893
  23 |        5 |      9411 |  9686 | 17997 |  15.572047805712 |  95.638630257012
  24 |        6 |      9411 | 15211 | 17456 | 80.1511640740896 | 111.210678062724
  25 |        7 |      9411 | 11151 |  9276 | 61.3198154368986 | 191.361842136814
  26 |        8 |      9411 |  8484 | 15633 | 12.2922395906126 | 252.681657573712
  27 |        9 |      9411 | 11769 | 17447 | 48.3004422098051 | 264.973897164325
  28 |       10 |      9411 | 14938 | 18001 | 19.1171248052624 |  313.27433937413
  29 |       11 |      9411 |  3809 | 15632 | 26.0385485657095 | 332.391464179392
  30 |       12 |      9411 |   830 | 16397 | 7.13738085494851 | 358.430012745102
  31 |       13 |      9411 |  2968 | 18758 | 19.3343863739773 |  365.56739360005
  32 |       14 |      9411 |  3209 |  9394 | 57.1521505307681 | 384.901779974028
  33 |       15 |      9411 |  3723 |  9290 | 15.0779394106244 | 442.053930504796
  34 |       16 |      9411 |  3451 |  9289 | 20.9212103904905 |  457.13186991542
  35 |       17 |      9411 |  7585 | 16043 | 80.7564260350622 | 478.053080305911
  36 |       18 |      9411 |  4934 | 14353 | 10.5002288815307 | 558.809506340973
  37 |       19 |      9411 | 12112 | 14352 | 55.9670135119436 | 569.309735222503
  38 |       20 |      9411 | 11906 | 14351 | 38.7122610646535 | 625.276748734447
  39 |       21 |      9411 |  4752 |  9287 | 37.2567241043513 | 663.989009799101
  40 |       22 |      9411 |  6108 |  9286 | 68.6459619100458 | 701.245733903452
  41 |       23 |      9411 |  4650 | 15576 | 56.4497663287095 | 769.891695813498
  42 |       24 |      9411 |  6034 | 15572 | 51.2724619348868 | 826.341462142207
  43 |       25 |      9411 |   157 | 15958 | 5.47854504899092 | 877.613924077094
  44 |       26 |      9411 |  9016 |  4007 | 55.6720507198261 | 883.092469126085
  45 |       27 |      9411 |  7444 |  8374 | 90.4337668533131 | 938.764519845911
  46 |       28 |      9411 | 13009 |    -1 |                0 | 1029.19828669922
(46 rows)

13.1.3. Solution to Exercise 3

Exercise 3

 seq | path_seq | end_vid | node  | edge  |       cost       |     agg_cost     
-----+----------+---------+-------+-------+------------------+------------------
   1 |        1 |    3986 | 13009 |  8374 | 69.5644360410101 |                0
   2 |        2 |    3986 |  7444 |  4007 | 42.8246543998662 | 69.5644360410101
   3 |        3 |    3986 |  9016 | 15958 | 4.21426542230071 | 112.389090440876
   4 |        4 |    3986 |   157 | 15957 | 13.1967009987636 | 116.603355863177
   5 |        5 |    3986 | 12243 | 15956 | 4.97816633036676 | 129.800056861941
   6 |        6 |    3986 |  8630 | 15565 |  45.056710265486 | 134.778223192307
   7 |        7 |    3986 |  8158 |  1435 | 42.4312007519879 | 179.834933457793
   8 |        8 |    3986 |   628 |  1434 | 51.0901320420595 | 222.266134209781
   9 |        9 |    3986 |  2617 |  1433 | 54.3183213199142 | 273.356266251841
  10 |       10 |    3986 | 10006 |  1432 | 45.9750968882997 | 327.674587571755
  11 |       11 |    3986 |  6991 | 16019 | 83.0619573167892 | 373.649684460055
  12 |       12 |    3986 |  4209 | 16020 | 18.7928301581725 | 456.711641776844
  13 |       13 |    3986 |  8478 | 16021 | 41.8476090870029 | 475.504471935016
  14 |       14 |    3986 |  4884 | 13321 | 47.5279211492089 | 517.352081022019
  15 |       15 |    3986 |  3523 | 13320 | 10.4265541362723 | 564.880002171228
  16 |       16 |    3986 |   642 | 13323 | 10.8778690000794 | 575.306556307501
  17 |       17 |    3986 | 11738 |  8366 | 77.7355661417814 |  586.18442530758
  18 |       18 |    3986 |  3986 |    -1 |                0 | 663.919991449361
  19 |        1 |    9411 | 13009 |  8374 | 69.5644360410101 |                0
  20 |        2 |    9411 |  7444 |  4007 | 42.8246543998662 | 69.5644360410101
  21 |        3 |    9411 |  9016 | 15958 | 4.21426542230071 | 112.389090440876
  22 |        4 |    9411 |   157 | 15572 | 39.4403553345283 | 116.603355863177
  23 |        5 |    9411 |  6034 | 15576 | 43.4228971759304 | 156.043711197705
  24 |        6 |    9411 |  4650 |  9286 | 52.8045860846506 | 199.466608373636
  25 |        7 |    9411 |  6108 |  9287 | 28.6590185418087 | 252.271194458286
  26 |        8 |    9411 |  4752 | 14351 | 29.7786623574257 | 280.930213000095
  27 |        9 |    9411 | 11906 | 14352 | 43.0515488553412 | 310.708875357521
  28 |       10 |    9411 | 12112 | 14353 | 8.07709913963902 | 353.760424212862
  29 |       11 |    9411 |  4934 | 16043 | 62.1203277192786 | 361.837523352501
  30 |       12 |    9411 |  7585 |  9289 | 16.0932387619158 |  423.95785107178
  31 |       13 |    9411 |  3451 |  9290 | 11.5984149312496 | 440.051089833695
  32 |       14 |    9411 |  3723 |  9394 | 43.9631927159754 | 451.649504764945
  33 |       15 |    9411 |  3209 | 18758 | 14.8726049030594 |  495.61269748092
  34 |       16 |    9411 |  2968 | 16397 |   5.490292965345 |  510.48530238398
  35 |       17 |    9411 |   830 | 15632 | 20.0296527428534 | 515.975595349325
  36 |       18 |    9411 |  3809 | 18001 | 14.7054806194326 | 536.005248092178
  37 |       19 |    9411 | 14938 | 17447 | 37.1541863152347 | 550.710728711611
  38 |       20 |    9411 | 11769 | 15633 | 9.45556891585588 | 587.864915026846
  39 |       21 |    9411 |  8484 |  9276 | 47.1690887976143 | 597.320483942701
  40 |       22 |    9411 | 11151 | 17456 | 61.6547415954536 | 644.489572740316
  41 |       23 |    9411 | 15211 | 17997 | 11.9784983120862 | 706.144314335769
  42 |       24 |    9411 |  9686 |  6580 | 31.1168964390944 | 718.122812647856
  43 |       25 |    9411 | 10292 | 12988 | 14.8051912620702 |  749.23970908695
  44 |       26 |    9411 | 13059 | 13015 | 8.81075263928754 |  764.04490034902
  45 |       27 |    9411 |  5080 | 13014 | 18.8353367803263 | 772.855652988308
  46 |       28 |    9411 |  9411 |    -1 |                0 | 791.690989768634
(46 rows)

13.1.4. Solution to Exercise 4

Exercise 4

 seq | path_seq | start_vid | end_vid | node  | edge  |        cost        |     agg_cost      
-----+----------+-----------+---------+-------+-------+--------------------+-------------------
   1 |        1 |      3986 |    8401 |  3986 |  8366 |   1.29559276902969 |                 0
   2 |        2 |      3986 |    8401 | 11738 | 13323 |   0.18129781666799 |  1.29559276902969
   3 |        3 |      3986 |    8401 |   642 | 13320 |  0.173775902271205 |  1.47689058569768
   4 |        4 |      3986 |    8401 |  3523 | 13321 |  0.792132019153482 |  1.65066648796889
   5 |        5 |      3986 |    8401 |  4884 | 16022 |  0.809316245846986 |  2.44279850712237
   6 |        6 |      3986 |    8401 |  4823 | 16168 |  0.624317233103782 |  3.25211475296935
   7 |        7 |      3986 |    8401 |  5299 | 16169 |  0.144798053839561 |  3.87643198607313
   8 |        8 |      3986 |    8401 | 11729 | 18170 |  0.641407818431326 |   4.0212300399127
   9 |        9 |      3986 |    8401 | 14406 | 19754 |  0.135578590843651 |  4.66263785834402
  10 |       10 |      3986 |    8401 | 14765 | 19331 |   0.56784937768551 |  4.79821644918767
  11 |       11 |      3986 |    8401 |  7778 | 16757 |  0.144243302046582 |  5.36606582687318
  12 |       12 |      3986 |    8401 |  4981 | 16758 |    1.2071869749691 |  5.51030912891976
  13 |       13 |      3986 |    8401 |  4048 | 18882 |  0.648153227675285 |  6.71749610388886
  14 |       14 |      3986 |    8401 |  3247 | 18883 |   1.41059412915484 |  7.36564933156415
  15 |       15 |      3986 |    8401 |  8495 | 18051 |   1.54178336621869 |  8.77624346071899
  16 |       16 |      3986 |    8401 | 14274 | 19332 |  0.441964644137286 |  10.3180268269377
  17 |       17 |      3986 |    8401 |  1125 | 18884 |  0.254538268594667 |   10.759991471075
  18 |       18 |      3986 |    8401 |   394 | 10074 |  0.572987886740247 |  11.0145297396696
  19 |       19 |      3986 |    8401 |  8275 | 18694 |   2.46396527874693 |  11.5875176264099
  20 |       20 |      3986 |    8401 | 11155 | 10072 |  0.333401231549465 |  14.0514829051568
  21 |       21 |      3986 |    8401 |  9612 | 10071 |  0.331679507159939 |  14.3848841367063
  22 |       22 |      3986 |    8401 |  5019 | 19573 |  0.115078841996296 |  14.7165636438662
  23 |       23 |      3986 |    8401 | 15191 | 18064 |  0.148977491931751 |  14.8316424858625
  24 |       24 |      3986 |    8401 |   877 | 15548 |   0.17787303496707 |  14.9806199777942
  25 |       25 |      3986 |    8401 |  5404 | 15549 |  0.630203805028059 |  15.1584930127613
  26 |       26 |      3986 |    8401 |  6040 | 15551 |  0.486901325353354 |  15.7886968177894
  27 |       27 |      3986 |    8401 |  3719 | 15552 |  0.444001492226033 |  16.2755981431427
  28 |       28 |      3986 |    8401 | 12941 | 15553 |   0.90118976926879 |  16.7195996353688
  29 |       29 |      3986 |    8401 | 11137 | 15554 |  0.239460037000633 |  17.6207894046376
  30 |       30 |      3986 |    8401 |  8708 | 15555 |  0.135068015102306 |  17.8602494416382
  31 |       31 |      3986 |    8401 |  9354 | 15532 |  0.378847819468151 |  17.9953174567405
  32 |       32 |      3986 |    8401 | 10439 | 15556 |   1.36485735145228 |  18.3741652762086
  33 |       33 |      3986 |    8401 |  3253 | 15557 |   0.11808238428354 |  19.7390226276609
  34 |       34 |      3986 |    8401 |  9167 | 15558 |   1.15639055989557 |  19.8571050119445
  35 |       35 |      3986 |    8401 |  7437 |  4719 |  0.806056008064658 |    21.01349557184
  36 |       36 |      3986 |    8401 |  1110 | 12013 |  0.158472970705613 |  21.8195515799047
  37 |       37 |      3986 |    8401 |  4526 | 10821 |  0.144529379548726 |  21.9780245506103
  38 |       38 |      3986 |    8401 |  4989 | 10822 |  0.532889072098029 |   22.122553930159
  39 |       39 |      3986 |    8401 |  6213 | 10800 |  0.393439078447189 |  22.6554430022571
  40 |       40 |      3986 |    8401 |  5305 | 10869 | 0.0673108204803313 |  23.0488820807043
  41 |       41 |      3986 |    8401 |  6757 | 10870 |  0.302882607657706 |  23.1161929011846
  42 |       42 |      3986 |    8401 |  8401 |    -1 |                  0 |  23.4190755088423
  43 |        1 |      3986 |   12235 |  3986 |  8366 |   1.29559276902969 |                 0
  44 |        2 |      3986 |   12235 | 11738 | 13323 |   0.18129781666799 |  1.29559276902969
  45 |        3 |      3986 |   12235 |   642 | 13320 |  0.173775902271205 |  1.47689058569768
  46 |        4 |      3986 |   12235 |  3523 | 13321 |  0.792132019153482 |  1.65066648796889
  47 |        5 |      3986 |   12235 |  4884 | 16022 |  0.809316245846986 |  2.44279850712237
  48 |        6 |      3986 |   12235 |  4823 | 16168 |  0.624317233103782 |  3.25211475296935
  49 |        7 |      3986 |   12235 |  5299 | 16169 |  0.144798053839561 |  3.87643198607313
  50 |        8 |      3986 |   12235 | 11729 | 18170 |  0.641407818431326 |   4.0212300399127
  51 |        9 |      3986 |   12235 | 14406 | 19754 |  0.135578590843651 |  4.66263785834402
  52 |       10 |      3986 |   12235 | 14765 | 19331 |   0.56784937768551 |  4.79821644918767
  53 |       11 |      3986 |   12235 |  7778 | 16757 |  0.144243302046582 |  5.36606582687318
  54 |       12 |      3986 |   12235 |  4981 | 16758 |    1.2071869749691 |  5.51030912891976
  55 |       13 |      3986 |   12235 |  4048 | 18882 |  0.648153227675285 |  6.71749610388886
  56 |       14 |      3986 |   12235 |  3247 | 18883 |   1.41059412915484 |  7.36564933156415
  57 |       15 |      3986 |   12235 |  8495 | 18051 |   1.54178336621869 |  8.77624346071899
  58 |       16 |      3986 |   12235 | 14274 | 19332 |  0.441964644137286 |  10.3180268269377
  59 |       17 |      3986 |   12235 |  1125 | 18884 |  0.254538268594667 |   10.759991471075
  60 |       18 |      3986 |   12235 |   394 | 10074 |  0.572987886740247 |  11.0145297396696
  61 |       19 |      3986 |   12235 |  8275 | 18694 |   2.46396527874693 |  11.5875176264099
  62 |       20 |      3986 |   12235 | 11155 | 10072 |  0.333401231549465 |  14.0514829051568
  63 |       21 |      3986 |   12235 |  9612 | 10071 |  0.331679507159939 |  14.3848841367063
  64 |       22 |      3986 |   12235 |  5019 | 19573 |  0.115078841996296 |  14.7165636438662
  65 |       23 |      3986 |   12235 | 15191 | 18064 |  0.148977491931751 |  14.8316424858625
  66 |       24 |      3986 |   12235 |   877 |  9254 |  0.228318649221155 |  14.9806199777942
  67 |       25 |      3986 |   12235 |  1613 |  9229 |   0.41427069448954 |  15.2089386270154
  68 |       26 |      3986 |   12235 |   160 |  9253 | 0.0543347128364323 |  15.6232093215049
  69 |       27 |      3986 |   12235 |  5761 |  2387 |  0.264792752242311 |  15.6775440343414
  70 |       28 |      3986 |   12235 |  5445 |  6767 |  0.116656561943294 |  15.9423367865837
  71 |       29 |      3986 |   12235 |  5589 |  6768 |   0.35719202550434 |   16.058993348527
  72 |       30 |      3986 |   12235 |  8717 |  6769 |   1.18781493695624 |  16.4161853740313
  73 |       31 |      3986 |   12235 |  4264 |  6770 |   1.10172893726703 |  17.6040003109876
  74 |       32 |      3986 |   12235 | 11013 |  2481 |   1.46070606003444 |  18.7057292482546
  75 |       33 |      3986 |   12235 |  3634 |  5297 |  0.606253797484897 |   20.166435308289
  76 |       34 |      3986 |   12235 | 13473 | 11571 |    0.2282060727065 |  20.7726891057739
  77 |       35 |      3986 |   12235 |  3623 | 11572 |  0.281407097514513 |  21.0008951784804
  78 |       36 |      3986 |   12235 |  9203 | 11573 |  0.239131457043611 |  21.2823022759949
  79 |       37 |      3986 |   12235 |  4085 | 11574 |  0.150707714762662 |  21.5214337330385
  80 |       38 |      3986 |   12235 |  6109 | 11575 |   1.09150645295201 |  21.6721414478012
  81 |       39 |      3986 |   12235 | 11462 |  3180 |  0.507100372388549 |  22.7636479007532
  82 |       40 |      3986 |   12235 | 11287 |  7222 |  0.707143437383005 |  23.2707482731418
  83 |       41 |      3986 |   12235 | 12235 |    -1 |                  0 |  23.9778917105248
  84 |        1 |      9411 |    8401 |  9411 | 13014 |  0.313922279672105 |                 0
  85 |        2 |      9411 |    8401 |  5080 | 13015 |  0.146845877321459 | 0.313922279672105
  86 |        3 |      9411 |    8401 | 13059 | 12988 |   0.24675318770117 | 0.460768156993564
  87 |        4 |      9411 |    8401 | 10292 |  6580 |  0.518614940651573 | 0.707521344694734
  88 |        5 |      9411 |    8401 |  9686 | 18746 |   0.74571764400645 |  1.22613628534631
  89 |        6 |      9411 |    8401 |  4235 |  4883 |   1.33037053213686 |  1.97185392935276
  90 |        7 |      9411 |    8401 | 11347 |  4882 |   2.94814699347239 |  3.30222446148962
  91 |        8 |      9411 |    8401 |  2841 |  4162 |  0.384469075901186 |  6.25037145496201
  92 |        9 |      9411 |    8401 | 11337 |  5329 |   1.06696222897268 |  6.63484053086319
  93 |       10 |      9411 |    8401 |  1533 |  9293 |  0.242143286655001 |  7.70180275983587
  94 |       11 |      9411 |    8401 | 11833 |  9294 |   2.35244586340262 |  7.94394604649087
  95 |       12 |      9411 |    8401 |  8951 | 13386 |  0.122090867372235 |  10.2963919098935
  96 |       13 |      9411 |    8401 |  1458 | 13387 | 0.0435675777852065 |  10.4184827772657
  97 |       14 |      9411 |    8401 | 11046 | 13385 |   2.09208309548886 |  10.4620503550509
  98 |       15 |      9411 |    8401 |  9120 | 15542 |  0.105232858782891 |  12.5541334505398
  99 |       16 |      9411 |    8401 |  8976 |  4370 |    1.4118938750555 |  12.6593663093227
 100 |       17 |      9411 |    8401 | 11243 |  3303 |  0.114667819877985 |  14.0712601843782
 101 |       18 |      9411 |    8401 | 10211 | 10795 |  0.165264378268355 |  14.1859280042562
 102 |       19 |      9411 |    8401 |  5008 | 10796 |  0.821835287900264 |  14.3511923825245
 103 |       20 |      9411 |    8401 | 12591 | 10797 |    1.2439419179879 |  15.1730276704248
 104 |       21 |      9411 |    8401 |  3157 | 10798 |   1.55359852852537 |  16.4169695884127
 105 |       22 |      9411 |    8401 |  1935 | 10799 |  0.139646825741707 |  17.9705681169381
 106 |       23 |      9411 |    8401 |  6000 | 18693 |  0.159224824669347 |  18.1102149426798
 107 |       24 |      9411 |    8401 |   877 | 15548 |   0.17787303496707 |  18.2694397673491
 108 |       25 |      9411 |    8401 |  5404 | 15549 |  0.630203805028059 |  18.4473128023162
 109 |       26 |      9411 |    8401 |  6040 | 15551 |  0.486901325353354 |  19.0775166073442
 110 |       27 |      9411 |    8401 |  3719 | 15552 |  0.444001492226033 |  19.5644179326976
 111 |       28 |      9411 |    8401 | 12941 | 15553 |   0.90118976926879 |  20.0084194249236
 112 |       29 |      9411 |    8401 | 11137 | 15554 |  0.239460037000633 |  20.9096091941924
 113 |       30 |      9411 |    8401 |  8708 | 15555 |  0.135068015102306 |  21.1490692311931
 114 |       31 |      9411 |    8401 |  9354 | 15532 |  0.378847819468151 |  21.2841372462954
 115 |       32 |      9411 |    8401 | 10439 | 15556 |   1.36485735145228 |  21.6629850657635
 116 |       33 |      9411 |    8401 |  3253 | 15557 |   0.11808238428354 |  23.0278424172158
 117 |       34 |      9411 |    8401 |  9167 | 15558 |   1.15639055989557 |  23.1459248014993
 118 |       35 |      9411 |    8401 |  7437 |  4719 |  0.806056008064658 |  24.3023153613949
 119 |       36 |      9411 |    8401 |  1110 | 12013 |  0.158472970705613 |  25.1083713694596
 120 |       37 |      9411 |    8401 |  4526 | 10821 |  0.144529379548726 |  25.2668443401652
 121 |       38 |      9411 |    8401 |  4989 | 10822 |  0.532889072098029 |  25.4113737197139
 122 |       39 |      9411 |    8401 |  6213 | 10800 |  0.393439078447189 |  25.9442627918119
 123 |       40 |      9411 |    8401 |  5305 | 10869 | 0.0673108204803313 |  26.3377018702591
 124 |       41 |      9411 |    8401 |  6757 | 10870 |  0.302882607657706 |  26.4050126907394
 125 |       42 |      9411 |    8401 |  8401 |    -1 |                  0 |  26.7078952983972
 126 |        1 |      9411 |   12235 |  9411 | 13014 |  0.313922279672105 |                 0
 127 |        2 |      9411 |   12235 |  5080 | 13015 |  0.146845877321459 | 0.313922279672105
 128 |        3 |      9411 |   12235 | 13059 | 12988 |   0.24675318770117 | 0.460768156993564
 129 |        4 |      9411 |   12235 | 10292 |  6580 |  0.518614940651573 | 0.707521344694734
 130 |        5 |      9411 |   12235 |  9686 | 18746 |   0.74571764400645 |  1.22613628534631
 131 |        6 |      9411 |   12235 |  4235 |  4883 |   1.33037053213686 |  1.97185392935276
 132 |        7 |      9411 |   12235 | 11347 |  4882 |   2.94814699347239 |  3.30222446148962
 133 |        8 |      9411 |   12235 |  2841 |  4162 |  0.384469075901186 |  6.25037145496201
 134 |        9 |      9411 |   12235 | 11337 |  5329 |   1.06696222897268 |  6.63484053086319
 135 |       10 |      9411 |   12235 |  1533 |  9293 |  0.242143286655001 |  7.70180275983587
 136 |       11 |      9411 |   12235 | 11833 |  9294 |   2.35244586340262 |  7.94394604649087
 137 |       12 |      9411 |   12235 |  8951 | 13386 |  0.122090867372235 |  10.2963919098935
 138 |       13 |      9411 |   12235 |  1458 | 13387 | 0.0435675777852065 |  10.4184827772657
 139 |       14 |      9411 |   12235 | 11046 | 13385 |   2.09208309548886 |  10.4620503550509
 140 |       15 |      9411 |   12235 |  9120 | 15542 |  0.105232858782891 |  12.5541334505398
 141 |       16 |      9411 |   12235 |  8976 |  4370 |    1.4118938750555 |  12.6593663093227
 142 |       17 |      9411 |   12235 | 11243 |  3303 |  0.114667819877985 |  14.0712601843782
 143 |       18 |      9411 |   12235 | 10211 | 10795 |  0.165264378268355 |  14.1859280042562
 144 |       19 |      9411 |   12235 |  5008 | 10796 |  0.821835287900264 |  14.3511923825245
 145 |       20 |      9411 |   12235 | 12591 | 10860 |    1.7303617991596 |  15.1730276704248
 146 |       21 |      9411 |   12235 |  3088 | 10859 |  0.109981413606276 |  16.9033894695844
 147 |       22 |      9411 |   12235 |  1815 |  3927 |  0.128789576474208 |  17.0133708831907
 148 |       23 |      9411 |   12235 |  1881 |  3928 |  0.224610437604583 |  17.1421604596649
 149 |       24 |      9411 |   12235 |  7174 | 18697 |  0.340164362079662 |  17.3667708972695
 150 |       25 |      9411 |   12235 | 13301 | 18698 |  0.156199600761475 |  17.7069352593491
 151 |       26 |      9411 |   12235 |  7834 |  3971 |  0.129828852658453 |  17.8631348601106
 152 |       27 |      9411 |   12235 |  4299 |  3972 |    1.1064231048751 |  17.9929637127691
 153 |       28 |      9411 |   12235 |  4775 |  4340 |   1.49207532952385 |  19.0993868176442
 154 |       29 |      9411 |   12235 |  1437 | 19229 |  0.327236028337236 |   20.591462147168
 155 |       30 |      9411 |   12235 | 10704 | 19230 |   0.66683205268242 |  20.9186981755052
 156 |       31 |      9411 |   12235 |   998 | 18202 |  0.276598638165203 |  21.5855302281877
 157 |       32 |      9411 |   12235 | 14302 | 19698 |  0.227912188723948 |  21.8621288663529
 158 |       33 |      9411 |   12235 |  7310 | 11586 |  0.807821981600028 |  22.0900410550768
 159 |       34 |      9411 |   12235 |   283 |  5643 |  0.664905071466846 |  22.8978630366768
 160 |       35 |      9411 |   12235 | 13473 | 11571 |    0.2282060727065 |  23.5627681081437
 161 |       36 |      9411 |   12235 |  3623 | 11572 |  0.281407097514513 |  23.7909741808502
 162 |       37 |      9411 |   12235 |  9203 | 11573 |  0.239131457043611 |  24.0723812783647
 163 |       38 |      9411 |   12235 |  4085 | 11574 |  0.150707714762662 |  24.3115127354083
 164 |       39 |      9411 |   12235 |  6109 | 11575 |   1.09150645295201 |   24.462220450171
 165 |       40 |      9411 |   12235 | 11462 |  3180 |  0.507100372388549 |   25.553726903123
 166 |       41 |      9411 |   12235 | 11287 |  7222 |  0.707143437383005 |  26.0608272755115
 167 |       42 |      9411 |   12235 | 12235 |    -1 |                  0 |  26.7679707128945
(167 rows)

13.1.5. Solution to Exercise 5

Exercise 5

 start_vid | end_vid |     agg_cost     
-----------+---------+------------------
      3986 |    8401 | 23.4190755088423
      3986 |   12235 | 23.9778917105248
      9411 |    8401 | 26.7078952983972
      9411 |   12235 | 26.7679707128945
(4 rows)

13.1.6. Solution to Exercise 6

Exercise 6

 end_vid |       sum        
---------+------------------
    8401 | 50.1269708072394
   12235 | 50.7458624234193
(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 |  3986 |  8366 |  7.27604899087074 |                0
   2 |        2 | 11738 | 13323 |  1.01816853840743 | 7.27604899087074
   3 |        3 |   642 | 13320 | 0.975925467155088 | 8.29421752927817
   4 |        4 |  3523 | 13321 |  4.44861341956595 | 9.27014299643326
   5 |        5 |  4884 | 13322 | 0.671628596885399 | 13.7187564159992
   6 |        6 | 12929 | 16171 |  3.91486532383829 | 14.3903850128846
   7 |        7 |  8825 | 16172 |  1.76380581308775 | 18.3052503367229
   8 |        8 |  4368 | 16173 |  7.76546643488788 | 20.0690561498107
   9 |        9 |  6991 |  1432 |  4.30326906874485 | 27.8345225846985
  10 |       10 | 10006 |  1433 |  5.08419487554397 | 32.1377916534434
  11 |       11 |  2617 |  1434 |  4.78203635913677 | 37.2219865289874
  12 |       12 |   628 |  1435 |  3.97156039038607 | 42.0040228881241
  13 |       13 |  8158 | 15565 |  4.21730808084949 | 45.9755832785102
  14 |       14 |  8630 | 15956 | 0.465956368522328 | 50.1928913593597
  15 |       15 | 12243 | 15957 |  1.23521121348427 |  50.658847727882
  16 |       16 |   157 | 15958 | 0.394455243527346 | 51.8940589413663
  17 |       17 |  9016 |  4007 |  4.00838765182748 | 52.2885141848936
  18 |       18 |  7444 |  8374 |  6.51123121343855 | 56.2969018367211
  19 |       19 | 13009 |    -1 |                 0 | 62.8081330501596
(19 rows)

13.2.2. Solution to Exercise 8

Exercise 8

 seq | path_seq | node  | edge  |       cost        |     agg_cost     
-----+----------+-------+-------+-------------------+------------------
   1 |        1 | 13009 |  8374 |  6.51123121343855 |                0
   2 |        2 |  7444 |  1165 |  4.33193879056021 | 6.51123121343855
   3 |        3 | 12248 | 15960 | 0.141878295798221 | 10.8431700039988
   4 |        4 |  3539 | 15961 | 0.251307772011942 |  10.985048299797
   5 |        5 |  2194 | 15954 | 0.866603801260101 | 11.2363560718089
   6 |        6 | 12486 | 15512 |  4.94983218545002 |  12.102959873069
   7 |        7 |  8158 |  1435 |  3.97156039038607 |  17.052792058519
   8 |        8 |   628 |  1434 |  4.78203635913677 | 21.0243524489051
   9 |        9 |  2617 |  1433 |  5.08419487554397 | 25.8063888080419
  10 |       10 | 10006 |  1432 |  4.30326906874485 | 30.8905836835858
  11 |       11 |  6991 | 16019 |  7.77459920485147 | 35.1938527523307
  12 |       12 |  4209 | 16020 |  1.75900890280494 | 42.9684519571822
  13 |       13 |  8478 | 16021 |  3.91693621054347 | 44.7274608599871
  14 |       14 |  4884 | 13321 |  4.44861341956595 | 48.6443970705306
  15 |       15 |  3523 | 13320 | 0.975925467155088 | 53.0930104900965
  16 |       16 |   642 | 13323 |  1.01816853840743 | 54.0689359572516
  17 |       17 | 11738 |  8366 |  7.27604899087074 | 55.0871044956591
  18 |       18 |  3986 |    -1 |                 0 | 62.3631534865298
(18 rows)

13.2.3. Solution to Exercise 9

Exercise 9

 seq | path_seq | node  | edge  |        cost         |     agg_cost      
-----+----------+-------+-------+---------------------+-------------------
   1 |        1 | 13009 |  8374 |   0.180867533706626 |                 0
   2 |        2 |  7444 |  1165 |   0.120331633071117 | 0.180867533706626
   3 |        3 | 12248 | 15960 |  0.0039410637721728 | 0.301199166777743
   4 |        4 |  3539 | 15961 | 0.00698077144477616 | 0.305140230549916
   5 |        5 |  2194 | 15954 |  0.0240723278127806 | 0.312121001994692
   6 |        6 | 12486 | 15512 |   0.137495338484723 | 0.336193329807473
   7 |        7 |  8158 |  1435 |   0.110321121955169 | 0.473688668292196
   8 |        8 |   628 |  1434 |   0.132834343309355 | 0.584009790247364
   9 |        9 |  2617 |  1433 |   0.141227635431777 | 0.716844133556719
  10 |       10 | 10006 |  1432 |   0.119535251909579 | 0.858071768988496
  11 |       11 |  6991 | 16019 |   0.215961089023652 | 0.977607020898075
  12 |       12 |  4209 | 16020 |  0.0488613584112484 |  1.19356810992173
  13 |       13 |  8478 | 16021 |   0.108803783626208 |  1.24242946833298
  14 |       14 |  4884 | 13321 |   0.123572594987943 |  1.35123325195918
  15 |       15 |  3523 | 13320 |   0.027109040754308 |  1.47480584694713
  16 |       16 |   642 | 13323 |  0.0282824594002065 |  1.50191488770143
  17 |       17 | 11738 |  8366 |   0.202112471968632 |  1.53019734710164
  18 |       18 |  3986 |    -1 |                   0 |  1.73230981907027
(18 rows)

13.2.4. Solution to Exercise 10

Exercise 10

 seq | path_seq | node  | edge  |       cost        |     agg_cost     
-----+----------+-------+-------+-------------------+------------------
   1 |        1 | 13009 |  8374 |  6.51123121343855 |                0
   2 |        2 |  7444 | 15952 |  9.22333158615332 | 6.51123121343855
   3 |        3 |  9616 | 15953 |  3.60082042999407 | 15.7345627995919
   4 |        4 | 10458 | 15575 |   1.5192800134717 | 19.3353832295859
   5 |        5 |  4650 |  9286 |   4.9425092575233 | 20.8546632430576
   6 |        6 |  6108 |  9287 |  2.68248413551329 | 25.7971725005809
   7 |        7 |  4752 | 14351 |  2.78728279665505 | 28.4796566360942
   8 |        8 | 11906 | 14352 |  4.02962497285994 | 31.2669394327493
   9 |        9 | 12112 | 14353 | 0.756016479470212 | 35.2965644056092
  10 |       10 |  4934 | 16043 |  5.81446267452448 | 36.0525808850794
  11 |       11 |  7585 |  9289 |  1.50632714811532 | 41.8670435596039
  12 |       12 |  3451 |  9290 |  1.08561163756496 | 43.3733707077192
  13 |       13 |  3723 |  9394 |   4.1149548382153 | 44.4589823452842
  14 |       14 |  3209 | 18758 |  1.39207581892636 | 48.5739371834995
  15 |       15 |  2968 | 16397 | 0.513891421556292 | 49.9660130024258
  16 |       16 |   830 | 15632 |  1.87477549673108 | 50.4799044239821
  17 |       17 |  3809 | 18001 |  1.37643298597889 | 52.3546799207132
  18 |       18 | 14938 | 17447 |  3.47763183910597 | 53.7311129066921
  19 |       19 | 11769 |  7310 |   6.6992416411557 | 57.2087447457981
  20 |       20 |  8114 | 17998 |   3.4999787948903 | 63.9079863869538
  21 |       21 | 14606 | 17441 |  1.24271631757963 | 67.4079651818441
  22 |       22 | 14296 | 19710 |  14.0921195748295 | 68.6506814994237
  23 |       23 | 11992 | 19257 |  3.65226566822741 | 82.7428010742532
  24 |       24 |   220 |  9292 |  6.06923054833361 | 86.3950667424806
  25 |       25 | 11385 |  9271 |  3.06195433328302 | 92.4642972908142
  26 |       26 |  5108 |  8365 |  1.43468811868191 | 95.5262516240973
  27 |       27 | 11738 |  8366 |  7.27604899087074 | 96.9609397427792
  28 |       28 |  3986 |    -1 |                 0 |  104.23698873365
(28 rows)

13.2.5. Solution to Exercise 11

Exercise 11

 seq | path_seq | node  | edge  |       cost        |     agg_cost     
-----+----------+-------+-------+-------------------+------------------
   1 |        1 | 13009 |  8374 |  6.51123121343855 |                0
   2 |        2 |  7444 |  1165 |  4.33193879056021 | 6.51123121343855
   3 |        3 | 12248 | 15960 | 0.113502636638577 | 10.8431700039988
   4 |        4 |  3539 | 15961 | 0.201046217609553 | 10.9566726406373
   5 |        5 |  2194 | 15954 |  0.69328304100808 | 11.1577188582469
   6 |        6 | 12486 | 15512 |  3.95986574836002 |  11.851001899255
   7 |        7 |  8158 |  1435 |  3.97156039038607 |  15.810867647615
   8 |        8 |   628 |  6241 |  3.10490121156971 | 19.7824280380011
   9 |        9 |  8753 |  6240 |  1.65801407732367 | 22.8873292495708
  10 |       10 |  6046 |  7074 |  4.10916254976826 | 24.5453433268944
  11 |       11 |  8835 |  7073 |  2.19633414623596 | 28.6545058766627
  12 |       12 |  7546 |  7072 |  3.73878116484454 | 30.8508400228986
  13 |       13 | 11400 | 15597 |  1.31317463189831 | 34.5896211877432
  14 |       14 | 12365 |  9392 | 0.496900397699574 | 35.9027958196415
  15 |       15 |  4223 |  9393 |  2.58301501579337 | 36.3996962173411
  16 |       16 |  3723 |  9394 |  2.46897290292918 | 38.9827112331344
  17 |       17 |  3209 | 18758 | 0.835245491355817 | 41.4516841360636
  18 |       18 |  2968 | 16397 | 0.308334852933775 | 42.2869296274194
  19 |       19 |   830 | 15632 |  1.49982039738487 | 42.5952644803532
  20 |       20 |  3809 | 18001 |  1.10114638878311 | 44.0950848777381
  21 |       21 | 14938 | 17447 |  2.78210547128478 | 45.1962312665212
  22 |       22 | 11769 |  7310 |  5.35939331292456 |  47.978336737806
  23 |       23 |  8114 | 17998 |  2.79998303591224 | 53.3377300507305
  24 |       24 | 14606 | 17441 | 0.994173054063704 | 56.1377130866428
  25 |       25 | 14296 | 19710 |  14.0921195748295 | 57.1318861407065
  26 |       26 | 11992 | 19257 |  3.65226566822741 |  71.224005715536
  27 |       27 |   220 |  9292 |  6.06923054833361 | 74.8762713837634
  28 |       28 | 11385 |  9271 |  3.06195433328302 |  80.945501932097
  29 |       29 |  5108 |  8365 |  1.43468811868191 |   84.00745626538
  30 |       30 | 11738 |  8366 |  7.27604899087074 | 85.4421443840619
  31 |       31 |  3986 |    -1 |                 0 | 92.7181933749327
(31 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 
-------
 20883
(1 row)

 count 
-------
 15692
(1 row)

13.3.2. Solution to Chapter 7 Exercise 2

Exercise 2

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

13.3.3. Solution to Chapter 7 Exercise 3

Exercise 3

 seq | path_seq | node  | edge  |        cost         |     agg_cost      
-----+----------+-------+-------+---------------------+-------------------
   1 |        1 |  3986 |  8366 |   0.121267483181179 |                 0
   2 |        2 | 11738 |  8365 |  0.0239114686446986 | 0.121267483181179
   3 |        3 |  5108 |  9271 |  0.0510325722213837 | 0.145178951825878
   4 |        4 | 11385 |  9292 |   0.101153842472227 | 0.196211524047261
   5 |        5 |   220 | 19257 |  0.0608710944704568 | 0.297365366519488
   6 |        6 | 11992 | 19710 |   0.234868659580492 | 0.358236460989945
   7 |        7 | 14296 | 18214 |  0.0147122888254378 | 0.593105120570436
   8 |        8 |  9686 | 17997 |  0.0186864573668544 | 0.607817409395874
   9 |        9 | 15211 | 17456 |  0.0961813968889076 | 0.626503866762729
  10 |       10 | 11151 |  9276 |  0.0735837785242783 | 0.722685263651636
  11 |       11 |  8484 | 18765 |  0.0171717428653313 | 0.796269042175914
  12 |       12 |  4407 | 18763 |  0.0142367934392995 | 0.813440785041246
  13 |       13 |   277 | 18764 |     0.0422278366178 | 0.827677578480545
  14 |       14 | 10706 | 19820 | 0.00930280495806409 | 0.869905415098345
  15 |       15 | 14492 | 17445 | 0.00855593753684319 | 0.879208220056409
  16 |       16 | 10355 | 15637 |   0.053493905480869 | 0.887764157593253
  17 |       17 |   176 |  3269 | 0.00747206424752287 | 0.941258063074122
  18 |       18 |  2184 | 18759 |  0.0398537131748448 | 0.948730127321645
  19 |       19 |  9413 | 16396 |  0.0541036090365401 | 0.988583840496489
  20 |       20 |  3451 |  9289 |  0.0251054524685886 |  1.04268744953303
  21 |       21 |  7585 | 16043 |  0.0969077112420747 |  1.06779290200162
  22 |       22 |  4934 | 14353 |  0.0126002746578369 |  1.16470061324369
  23 |       23 | 12112 | 14352 |  0.0671604162143323 |  1.17730088790153
  24 |       24 | 11906 | 14351 |  0.0464547132775842 |  1.24446130411586
  25 |       25 |  4752 |  9287 |  0.0447080689252215 |  1.29091601739345
  26 |       26 |  6108 |  9286 |   0.082375154292055 |  1.33562408631867
  27 |       27 |  4650 | 15576 |  0.0677397195944514 |  1.41799924061072
  28 |       28 |  6034 | 15572 |  0.0615269543218642 |  1.48573896020517
  29 |       29 |   157 | 15958 | 0.00657425405878911 |  1.54726591452704
  30 |       30 |  9016 |  4007 |  0.0668064608637913 |  1.55384016858583
  31 |       31 |  7444 |  8374 |   0.108520520223976 |  1.62064662944962
  32 |       32 | 13009 |    -1 |                   0 |  1.72916714967359
(32 rows)

13.3.4. Solution to Chapter 7 Exercise 4

Exercise 4

 seq | path_seq | node  | edge  |        cost         |     agg_cost      |          name           
-----+----------+-------+-------+---------------------+-------------------+-------------------------
   1 |        1 |  3986 |  8366 |   0.121267483181179 |                 0 | 
   2 |        2 | 11738 |  8365 |  0.0239114686446986 | 0.121267483181179 | 
   3 |        3 |  5108 |  9271 |  0.0510325722213837 | 0.145178951825878 | World Trade Center Road
   4 |        4 | 11385 |  9292 |   0.101153842472227 | 0.196211524047261 | World Trade Center Road
   5 |        5 |   220 | 19257 |  0.0608710944704568 | 0.297365366519488 | World Trade Center Road
   6 |        6 | 11992 | 19710 |   0.234868659580492 | 0.358236460989945 | World Trade Center Road
   7 |        7 | 14296 | 18214 |  0.0147122888254378 | 0.593105120570436 | World Trade Center Road
   8 |        8 |  9686 | 17997 |  0.0186864573668544 | 0.607817409395874 | Summer Street
   9 |        9 | 15211 | 17456 |  0.0961813968889076 | 0.626503866762729 | Summer Street
  10 |       10 | 11151 |  9276 |  0.0735837785242783 | 0.722685263651636 | Summer Street
  11 |       11 |  8484 | 18765 |  0.0171717428653313 | 0.796269042175914 | Summer Street
  12 |       12 |  4407 | 18763 |  0.0142367934392995 | 0.813440785041246 | D Street
  13 |       13 |   277 | 18764 |     0.0422278366178 | 0.827677578480545 | D Street
  14 |       14 | 10706 | 19820 | 0.00930280495806409 | 0.869905415098345 | D Street
  15 |       15 | 14492 | 17445 | 0.00855593753684319 | 0.879208220056409 | D Street
  16 |       16 | 10355 | 15637 |   0.053493905480869 | 0.887764157593253 | D Street
  17 |       17 |   176 |  3269 | 0.00747206424752287 | 0.941258063074122 | D Street
  18 |       18 |  2184 | 18759 |  0.0398537131748448 | 0.948730127321645 | D Street
  19 |       19 |  9413 | 16396 |  0.0541036090365401 | 0.988583840496489 | D Street
  20 |       20 |  3451 |  9289 |  0.0251054524685886 |  1.04268744953303 | Silver Line Way
  21 |       21 |  7585 | 16043 |  0.0969077112420747 |  1.06779290200162 | Silver Line Way
  22 |       22 |  4934 | 14353 |  0.0126002746578369 |  1.16470061324369 | Silver Line Way
  23 |       23 | 12112 | 14352 |  0.0671604162143323 |  1.17730088790153 | Silver Line Way
  24 |       24 | 11906 | 14351 |  0.0464547132775842 |  1.24446130411586 | Silver Line Way
  25 |       25 |  4752 |  9287 |  0.0447080689252215 |  1.29091601739345 | Silver Line Way
  26 |       26 |  6108 |  9286 |   0.082375154292055 |  1.33562408631867 | Silver Line Way
  27 |       27 |  4650 | 15576 |  0.0677397195944514 |  1.41799924061072 | Haul Road
  28 |       28 |  6034 | 15572 |  0.0615269543218642 |  1.48573896020517 | Haul Road
  29 |       29 |   157 | 15958 | 0.00657425405878911 |  1.54726591452704 | 
  30 |       30 |  9016 |  4007 |  0.0668064608637913 |  1.55384016858583 | Northern Avenue
  31 |       31 |  7444 |  8374 |   0.108520520223976 |  1.62064662944962 | Northern Avenue
  32 |       32 | 13009 |    -1 |                   0 |  1.72916714967359 | 
(32 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 |  3986 |  8366 |   0.121267483181179 |                 0 |                         | LINESTRING(-71.0414012 42.3502602,-71.040802 42.351054)
   2 |        2 | 11738 |  8365 |  0.0239114686446986 | 0.121267483181179 |                         | LINESTRING(-71.0415194 42.3501037,-71.0414012 42.3502602)
   3 |        3 |  5108 |  9271 |  0.0510325722213837 | 0.145178951825878 | World Trade Center Road | LINESTRING(-71.0417712 42.3497695,-71.0415194 42.3501037)
   4 |        4 | 11385 |  9292 |   0.101153842472227 | 0.196211524047261 | World Trade Center Road | LINESTRING(-71.0422711 42.3491074,-71.0417712 42.3497695)
   5 |        5 |   220 | 19257 |  0.0608710944704568 | 0.297365366519488 | World Trade Center Road | LINESTRING(-71.0425686 42.3487076,-71.0422711 42.3491074)
   6 |        6 | 11992 | 19710 |   0.234868659580492 | 0.358236460989945 | World Trade Center Road | LINESTRING(-71.0437451 42.3471775,-71.0434581 42.3475149,-71.0433997 42.3475907,-71.0425686 42.3487076)
   7 |        7 | 14296 | 18214 |  0.0147122888254378 | 0.593105120570436 | World Trade Center Road | LINESTRING(-71.0438233 42.3470836,-71.0437451 42.3471775)
   8 |        8 |  9686 | 17997 |  0.0186864573668544 | 0.607817409395874 | Summer Street           | LINESTRING(-71.0438233 42.3470836,-71.043671 42.3470006)
   9 |        9 | 15211 | 17456 |  0.0961813968889076 | 0.626503866762729 | Summer Street           | LINESTRING(-71.043671 42.3470006,-71.0428787 42.346582)
  10 |       10 | 11151 |  9276 |  0.0735837785242783 | 0.722685263651636 | Summer Street           | LINESTRING(-71.0428787 42.346582,-71.0422726 42.3462617)
  11 |       11 |  8484 | 18765 |  0.0171717428653313 | 0.796269042175914 | Summer Street           | LINESTRING(-71.0422726 42.3462617,-71.0421315 42.3461866)
  12 |       12 |  4407 | 18763 |  0.0142367934392995 | 0.813440785041246 | D Street                | LINESTRING(-71.0421315 42.3461866,-71.0420352 42.346266)
  13 |       13 |   277 | 18764 |     0.0422278366178 | 0.827677578480545 | D Street                | LINESTRING(-71.0420352 42.346266,-71.0417497 42.3465016)
  14 |       14 | 10706 | 19820 | 0.00930280495806409 | 0.869905415098345 | D Street                | LINESTRING(-71.0417497 42.3465016,-71.0416868 42.3465535)
  15 |       15 | 14492 | 17445 | 0.00855593753684319 | 0.879208220056409 | D Street                | LINESTRING(-71.0416868 42.3465535,-71.0416289 42.3466012)
  16 |       16 | 10355 | 15637 |   0.053493905480869 | 0.887764157593253 | D Street                | LINESTRING(-71.0416289 42.3466012,-71.0412688 42.3469007)
  17 |       17 |   176 |  3269 | 0.00747206424752287 | 0.941258063074122 | D Street                | LINESTRING(-71.0412688 42.3469007,-71.041218 42.3469422)
  18 |       18 |  2184 | 18759 |  0.0398537131748448 | 0.948730127321645 | D Street                | LINESTRING(-71.041218 42.3469422,-71.0410361 42.3470908,-71.0409518 42.3471666)
  19 |       19 |  9413 | 16396 |  0.0541036090365401 | 0.988583840496489 | D Street                | LINESTRING(-71.0409518 42.3471666,-71.0407137 42.3474044,-71.0406169 42.3474873)
  20 |       20 |  3451 |  9289 |  0.0251054524685886 |  1.04268744953303 | Silver Line Way         | LINESTRING(-71.0403946 42.3473963,-71.0406169 42.3474873)
  21 |       21 |  7585 | 16043 |  0.0969077112420747 |  1.06779290200162 | Silver Line Way         | LINESTRING(-71.0403946 42.3473963,-71.0402893 42.3473511,-71.0401966 42.3473163,-71.0401046 42.3472839,-71.0400107 42.347252,-71.0399209 42.3472243,-71.0398319 42.3472009,-71.0397444 42.3471835,-71.0396585 42.3471687,-71.0395653 42.3471572,-71.0394815 42.3471494)
  22 |       22 |  4934 | 14353 |  0.0126002746578369 |  1.16470061324369 | Silver Line Way         | LINESTRING(-71.0393547 42.34714,-71.0394815 42.3471494)
  23 |       23 | 12112 | 14352 |  0.0671604162143323 |  1.17730088790153 | Silver Line Way         | LINESTRING(-71.038676 42.3471517,-71.0391207 42.3471377,-71.0392452 42.3471364,-71.0393547 42.34714)
  24 |       24 | 11906 | 14351 |  0.0464547132775842 |  1.24446130411586 | Silver Line Way         | LINESTRING(-71.0382062 42.3471545,-71.038676 42.3471517)
  25 |       25 |  4752 |  9287 |  0.0447080689252215 |  1.29091601739345 | Silver Line Way         | LINESTRING(-71.0377544 42.3471492,-71.0378511 42.3471553,-71.0382062 42.3471545)
  26 |       26 |  6108 |  9286 |   0.082375154292055 |  1.33562408631867 | Silver Line Way         | LINESTRING(-71.037061 42.346812,-71.0375693 42.3470852,-71.0376256 42.3471111,-71.0376861 42.3471336,-71.0377544 42.3471492)
  27 |       27 |  4650 | 15576 |  0.0677397195944514 |  1.41799924061072 | Haul Road               | LINESTRING(-71.037061 42.346812,-71.037059 42.346813,-71.0366705 42.3472294)
  28 |       28 |  6034 | 15572 |  0.0615269543218642 |  1.48573896020517 | Haul Road               | LINESTRING(-71.0366705 42.3472294,-71.0363266 42.3474955,-71.0362959 42.3475146,-71.0362642 42.3475305,-71.0362202 42.3475427)
  29 |       29 |   157 | 15958 | 0.00657425405878911 |  1.54726591452704 |                         | LINESTRING(-71.0362202 42.3475427,-71.0361854 42.347543,-71.0361543 42.3475475)
  30 |       30 |  9016 |  4007 |  0.0668064608637913 |  1.55384016858583 | Northern Avenue         | LINESTRING(-71.0361543 42.3475475,-71.0360943 42.3475372,-71.0360469 42.3475266,-71.0360014 42.3475067,-71.0359613 42.347478,-71.0358196 42.3473192,-71.0357825 42.347288,-71.0357302 42.3472563,-71.035666 42.3472266)
  31 |       31 |  7444 |  8374 |   0.108520520223976 |  1.62064662944962 | Northern Avenue         | LINESTRING(-71.035666 42.3472266,-71.0351521 42.3466748,-71.0350907 42.3466184,-71.0350277 42.346565)
  32 |       32 | 13009 |    -1 |                   0 |  1.72916714967359 |                         | 
(32 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 |  3986 |  8366 |   0.121267483181179 |                 0 |                         | 0102000020E610000002000000F8003851A6C251C0930B8453D52C454021E7FD7F9CC251C0A3906456EF2C4540
   2 |        2 | 11738 |  8365 |  0.0239114686446986 | 0.121267483181179 |                         | 0102000020E6100000020000009249FC40A8C251C0B3DAB232D02C4540F8003851A6C251C0930B8453D52C4540
   3 |        3 |  5108 |  9271 |  0.0510325722213837 | 0.145178951825878 | World Trade Center Road | 0102000020E6100000020000008A7A1C61ACC251C0B3D1393FC52C45409249FC40A8C251C0B3DAB232D02C4540
   4 |        4 | 11385 |  9292 |   0.101153842472227 | 0.196211524047261 | World Trade Center Road | 0102000020E6100000020000003804D891B4C251C053E5208DAF2C45408A7A1C61ACC251C0B3D1393FC52C4540
   5 |        5 |   220 | 19257 |  0.0608710944704568 | 0.297365366519488 | World Trade Center Road | 0102000020E6100000020000008935A671B9C251C0EEEE5C73A22C45403804D891B4C251C053E5208DAF2C4540
   6 |        6 | 11992 | 19710 |   0.234868659580492 | 0.358236460989945 | World Trade Center Road | 0102000020E6100000040000000E773FB8CCC251C01A34F44F702C4540C38F7B04C8C251C0B52F455E7B2C4540FF09890FC7C251C0667220DA7D2C45408935A671B9C251C0EEEE5C73A22C4540
   7 |        7 | 14296 | 18214 |  0.0147122888254378 | 0.593105120570436 | World Trade Center Road | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C45400E773FB8CCC251C01A34F44F702C4540
   8 |        8 |  9686 | 17997 |  0.0186864573668544 | 0.607817409395874 | Summer Street           | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C454027327381CBC251C0A05802846A2C4540
   9 |        9 | 15211 | 17456 |  0.0961813968889076 | 0.626503866762729 | Summer Street           | 0102000020E61000000200000027327381CBC251C0A05802846A2C45407B8C4D86BEC251C0EEB089CC5C2C4540
  10 |       10 | 11151 |  9276 |  0.0735837785242783 | 0.722685263651636 | Summer Street           | 0102000020E6100000020000007B8C4D86BEC251C0EEB089CC5C2C454015A12298B4C251C0BEADAA4D522C4540
  11 |       11 |  8484 | 18765 |  0.0171717428653313 | 0.796269042175914 | Summer Street           | 0102000020E61000000200000015A12298B4C251C0BEADAA4D522C454069A85148B2C251C01FA8AED74F2C4540
  12 |       12 |  4407 | 18763 |  0.0142367934392995 | 0.813440785041246 | D Street                | 0102000020E61000000200000069A85148B2C251C01FA8AED74F2C4540F95168B4B0C251C0BEDBBC71522C4540
  13 |       13 |   277 | 18764 |     0.0422278366178 | 0.827677578480545 | D Street                | 0102000020E610000002000000F95168B4B0C251C0BEDBBC71522C45408A07EF06ACC251C07F01182A5A2C4540
  14 |       14 | 10706 | 19820 | 0.00930280495806409 | 0.869905415098345 | D Street                | 0102000020E6100000020000008A07EF06ACC251C07F01182A5A2C454031AB1CFFAAC251C03C6876DD5B2C4540
  15 |       15 | 14492 | 17445 | 0.00855593753684319 | 0.879208220056409 | D Street                | 0102000020E61000000200000031AB1CFFAAC251C03C6876DD5B2C45406204430CAAC251C08F60996D5D2C4540
  16 |       16 | 10355 | 15637 |   0.053493905480869 | 0.887764157593253 | D Street                | 0102000020E6100000020000006204430CAAC251C08F60996D5D2C45401796E425A4C251C0D1BAFC3D672C4540
  17 |       17 |   176 |  3269 | 0.00747206424752287 | 0.941258063074122 | D Street                | 0102000020E6100000020000001796E425A4C251C0D1BAFC3D672C45406B80D250A3C251C0184D1D9A682C4540
  18 |       18 |  2184 | 18759 |  0.0398537131748448 | 0.948730127321645 | D Street                | 0102000020E6100000030000006B80D250A3C251C0184D1D9A682C454025DDE055A0C251C0095FA9786D2C4540976D4CF49EC251C0BBA184F46F2C4540
  19 |       19 |  9413 | 16396 |  0.0541036090365401 | 0.988583840496489 | D Street                | 0102000020E610000003000000976D4CF49EC251C0BBA184F46F2C4540F27FA20D9BC251C0463E54BF772C45408E4AA07799C251C03EA3BE767A2C4540
  20 |       20 |  3451 |  9289 |  0.0251054524685886 |  1.04268744953303 | Silver Line Way         | 0102000020E610000002000000D77B3BD395C251C02EA0617B772C45408E4AA07799C251C03EA3BE767A2C4540
  21 |       21 |  7585 | 16043 |  0.0969077112420747 |  1.06779290200162 | Silver Line Way         | 0102000020E61000000B000000D77B3BD395C251C02EA0617B772C45403D78921994C251C0645D3700762C4540449AC29492C251C012EF4ADC742C4540D45AE21291C251C0B37680CC732C45405DFF09898FC251C03CBCE7C0722C454052FB63108EC251C031708AD8712C45409AF5189B8CC251C025523F14712C4540BF8C182C8BC251C0FC1A4982702C45408A20CEC389C251C0F0582206702C45409D63E53C88C251C01449AAA56F2C454002D369DD86C251C0BBE93B646F2C4540
  22 |       22 |  4934 | 14353 |  0.0126002746578369 |  1.16470061324369 | Silver Line Way         | 0102000020E610000002000000695C93C984C251C0159161156F2C454002D369DD86C251C0BBE93B646F2C4540
  23 |       23 | 12112 | 14352 |  0.0671604162143323 |  1.17730088790153 | Silver Line Way         | 0102000020E610000004000000F7C8E6AA79C251C01A2087776F2C45402FC61BF480C251C0B55A16026F2C454099A14CFE82C251C026A02EF76E2C4540695C93C984C251C0159161156F2C4540
  24 |       24 | 11906 | 14351 |  0.0464547132775842 |  1.24446130411586 | Silver Line Way         | 0102000020E61000000200000049E06AF871C251C06214048F6F2C4540F7C8E6AA79C251C01A2087776F2C4540
  25 |       25 |  4752 |  9287 |  0.0447080689252215 |  1.29091601739345 | Silver Line Way         | 0102000020E610000003000000ED516E916AC251C0916A8E626F2C4540872705276CC251C00811BA956F2C454049E06AF871C251C06214048F6F2C4540
  26 |       26 |  6108 |  9286 |   0.082375154292055 |  1.33562408631867 | Silver Line Way         | 0102000020E61000000500000040BD19355FC251C020EEEA55642C45405AB5108967C251C07B76AF496D2C4540835F347568C251C00F4AF3226E2C4540E2C0F57269C251C0DFABB1DF6E2C4540ED516E916AC251C0916A8E626F2C4540
  27 |       27 |  4650 | 15576 |  0.0677397195944514 |  1.41799924061072 | Haul Road               | 0102000020E61000000300000040BD19355FC251C020EEEA55642C45407041B62C5FC251C0F0694E5E642C4540978E39CF58C251C0D89A5203722C4540
  28 |       28 |  6034 | 15572 |  0.0615269543218642 |  1.48573896020517 | Haul Road               | 0102000020E610000005000000978E39CF58C251C0D89A5203722C454064BECD2C53C251C0EB0088BB7A2C4540A6DE09AC52C251C0F6F0C05B7B2C45400041142752C251C067EE21E17B2C4540189D876E51C251C0553B79477C2C4540
  29 |       29 |   157 | 15958 | 0.00657425405878911 |  1.54726591452704 |                         | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  30 |       30 |  9016 |  4007 |  0.0668064608637913 |  1.55384016858583 | Northern Avenue         | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  31 |       31 |  7444 |  8374 |   0.108520520223976 |  1.62064662944962 | Northern Avenue         | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
  32 |       32 | 13009 |    -1 |                   0 |  1.72916714967359 |                         | 
(32 rows)

13.3.7. Solution to Chapter 7 Exercise 7

Exercise 7

 seq |          name           |        cost         |     azimuth      |                                                                                                                                st_astext                                                                                                                                |                                                                                                                                                                                         route_geom                                                                                                                                                                                         
-----+-------------------------+---------------------+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 |                         |   0.121267483181179 | 37.0473333326841 | LINESTRING(-71.0414012 42.3502602,-71.040802 42.351054)                                                                                                                                                                                                                 | 0102000020E610000002000000F8003851A6C251C0930B8453D52C454021E7FD7F9CC251C0A3906456EF2C4540
   2 |                         |  0.0239114686446986 | 37.0627136348267 | LINESTRING(-71.0415194 42.3501037,-71.0414012 42.3502602)                                                                                                                                                                                                               | 0102000020E6100000020000009249FC40A8C251C0B3DAB232D02C4540F8003851A6C251C0930B8453D52C4540
   3 | World Trade Center Road |  0.0510325722213837 | 36.9958703834949 | LINESTRING(-71.0417712 42.3497695,-71.0415194 42.3501037)                                                                                                                                                                                                               | 0102000020E6100000020000008A7A1C61ACC251C0B3D1393FC52C45409249FC40A8C251C0B3DAB232D02C4540
   4 | World Trade Center Road |   0.101153842472227 | 37.0536037413973 | LINESTRING(-71.0422711 42.3491074,-71.0417712 42.3497695)                                                                                                                                                                                                               | 0102000020E6100000020000003804D891B4C251C053E5208DAF2C45408A7A1C61ACC251C0B3D1393FC52C4540
   5 | World Trade Center Road |  0.0608710944704568 | 36.6537489230393 | LINESTRING(-71.0425686 42.3487076,-71.0422711 42.3491074)                                                                                                                                                                                                               | 0102000020E6100000020000008935A671B9C251C0EEEE5C73A22C45403804D891B4C251C053E5208DAF2C4540
   6 | World Trade Center Road |   0.234868659580492 | 37.5568274650646 | LINESTRING(-71.0437451 42.3471775,-71.0434581 42.3475149,-71.0433997 42.3475907,-71.0425686 42.3487076)                                                                                                                                                                 | 0102000020E6100000040000000E773FB8CCC251C01A34F44F702C4540C38F7B04C8C251C0B52F455E7B2C4540FF09890FC7C251C0667220DA7D2C45408935A671B9C251C0EEEE5C73A22C4540
   7 | World Trade Center Road |  0.0147122888254378 | 39.7875611041326 | LINESTRING(-71.0438233 42.3470836,-71.0437451 42.3471775)                                                                                                                                                                                                               | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C45400E773FB8CCC251C01A34F44F702C4540
   8 | Summer Street           |  0.0186864573668544 | 118.589368872019 | LINESTRING(-71.0438233 42.3470836,-71.043671 42.3470006)                                                                                                                                                                                                                | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C454027327381CBC251C0A05802846A2C4540
   9 | Summer Street           |  0.0961813968889076 | 117.849071651488 | LINESTRING(-71.043671 42.3470006,-71.0428787 42.346582)                                                                                                                                                                                                                 | 0102000020E61000000200000027327381CBC251C0A05802846A2C45407B8C4D86BEC251C0EEB089CC5C2C4540
  10 | Summer Street           |  0.0735837785242783 | 117.854689391022 | LINESTRING(-71.0428787 42.346582,-71.0422726 42.3462617)                                                                                                                                                                                                                | 0102000020E6100000020000007B8C4D86BEC251C0EEB089CC5C2C454015A12298B4C251C0BEADAA4D522C4540
  11 | Summer Street           |  0.0171717428653313 |   118.0239901678 | LINESTRING(-71.0422726 42.3462617,-71.0421315 42.3461866)                                                                                                                                                                                                               | 0102000020E61000000200000015A12298B4C251C0BEADAA4D522C454069A85148B2C251C01FA8AED74F2C4540
  12 | D Street                |  0.0142367934392995 | 50.4941886627578 | LINESTRING(-71.0421315 42.3461866,-71.0420352 42.346266)                                                                                                                                                                                                                | 0102000020E61000000200000069A85148B2C251C01FA8AED74F2C4540F95168B4B0C251C0BEDBBC71522C4540
  13 | D Street                |     0.0422278366178 | 50.4699063198211 | LINESTRING(-71.0420352 42.346266,-71.0417497 42.3465016)                                                                                                                                                                                                                | 0102000020E610000002000000F95168B4B0C251C0BEDBBC71522C45408A07EF06ACC251C07F01182A5A2C4540
  14 | D Street                | 0.00930280495806409 | 50.4733039530504 | LINESTRING(-71.0417497 42.3465016,-71.0416868 42.3465535)                                                                                                                                                                                                               | 0102000020E6100000020000008A07EF06ACC251C07F01182A5A2C454031AB1CFFAAC251C03C6876DD5B2C4540
  15 | D Street                | 0.00855593753684319 |   50.51713597098 | LINESTRING(-71.0416868 42.3465535,-71.0416289 42.3466012)                                                                                                                                                                                                               | 0102000020E61000000200000031AB1CFFAAC251C03C6876DD5B2C45406204430CAAC251C08F60996D5D2C4540
  16 | D Street                |   0.053493905480869 |  50.249248396176 | LINESTRING(-71.0416289 42.3466012,-71.0412688 42.3469007)                                                                                                                                                                                                               | 0102000020E6100000020000006204430CAAC251C08F60996D5D2C45401796E425A4C251C0D1BAFC3D672C4540
  17 | D Street                | 0.00747206424752287 | 50.7536125897522 | LINESTRING(-71.0412688 42.3469007,-71.041218 42.3469422)                                                                                                                                                                                                                | 0102000020E6100000020000001796E425A4C251C0D1BAFC3D672C45406B80D250A3C251C0184D1D9A682C4540
  18 | D Street                |  0.0398537131748448 | 49.8699417160816 | LINESTRING(-71.041218 42.3469422,-71.0410361 42.3470908,-71.0409518 42.3471666)                                                                                                                                                                                         | 0102000020E6100000030000006B80D250A3C251C0184D1D9A682C454025DDE055A0C251C0095FA9786D2C4540976D4CF49EC251C0BBA184F46F2C4540
  19 | D Street                |  0.0541036090365401 | 46.2408067042895 | LINESTRING(-71.0409518 42.3471666,-71.0407137 42.3474044,-71.0406169 42.3474873)                                                                                                                                                                                        | 0102000020E610000003000000976D4CF49EC251C0BBA184F46F2C4540F27FA20D9BC251C0463E54BF772C45408E4AA07799C251C03EA3BE767A2C4540
  20 | Silver Line Way         |  0.0251054524685886 | 292.262069143208 | LINESTRING(-71.0403946 42.3473963,-71.0406169 42.3474873)                                                                                                                                                                                                               | 0102000020E610000002000000D77B3BD395C251C02EA0617B772C45408E4AA07799C251C03EA3BE767A2C4540
  21 | Silver Line Way         |  0.0969077112420747 | 105.130803079466 | LINESTRING(-71.0403946 42.3473963,-71.0402893 42.3473511,-71.0401966 42.3473163,-71.0401046 42.3472839,-71.0400107 42.347252,-71.0399209 42.3472243,-71.0398319 42.3472009,-71.0397444 42.3471835,-71.0396585 42.3471687,-71.0395653 42.3471572,-71.0394815 42.3471494) | 0102000020E61000000B000000D77B3BD395C251C02EA0617B772C45403D78921994C251C0645D3700762C4540449AC29492C251C012EF4ADC742C4540D45AE21291C251C0B37680CC732C45405DFF09898FC251C03CBCE7C0722C454052FB63108EC251C031708AD8712C45409AF5189B8CC251C025523F14712C4540BF8C182C8BC251C0FC1A4982702C45408A20CEC389C251C0F0582206702C45409D63E53C88C251C01449AAA56F2C454002D369DD86C251C0BBE93B646F2C4540
  22 | Silver Line Way         |  0.0126002746578369 | 274.239723625209 | LINESTRING(-71.0393547 42.34714,-71.0394815 42.3471494)                                                                                                                                                                                                                 | 0102000020E610000002000000695C93C984C251C0159161156F2C454002D369DD86C251C0BBE93B646F2C4540
  23 | Silver Line Way         |  0.0671604162143323 | 269.012385109114 | LINESTRING(-71.038676 42.3471517,-71.0391207 42.3471377,-71.0392452 42.3471364,-71.0393547 42.34714)                                                                                                                                                                    | 0102000020E610000004000000F7C8E6AA79C251C01A2087776F2C45402FC61BF480C251C0B55A16026F2C454099A14CFE82C251C026A02EF76E2C4540695C93C984C251C0159161156F2C4540
  24 | Silver Line Way         |  0.0464547132775842 | 269.658522172452 | LINESTRING(-71.0382062 42.3471545,-71.038676 42.3471517)                                                                                                                                                                                                                | 0102000020E61000000200000049E06AF871C251C06214048F6F2C4540F7C8E6AA79C251C01A2087776F2C4540
  25 | Silver Line Way         |  0.0447080689252215 | 270.672097616919 | LINESTRING(-71.0377544 42.3471492,-71.0378511 42.3471553,-71.0382062 42.3471545)                                                                                                                                                                                        | 0102000020E610000003000000ED516E916AC251C0916A8E626F2C4540872705276CC251C00811BA956F2C454049E06AF871C251C06214048F6F2C4540
  26 | Silver Line Way         |   0.082375154292055 | 295.933626733957 | LINESTRING(-71.037061 42.346812,-71.0375693 42.3470852,-71.0376256 42.3471111,-71.0376861 42.3471336,-71.0377544 42.3471492)                                                                                                                                            | 0102000020E61000000500000040BD19355FC251C020EEEA55642C45405AB5108967C251C07B76AF496D2C4540835F347568C251C00F4AF3226E2C4540E2C0F57269C251C0DFABB1DF6E2C4540ED516E916AC251C0916A8E626F2C4540
  27 | Haul Road               |  0.0677397195944514 | 43.0929727895055 | LINESTRING(-71.037061 42.346812,-71.037059 42.346813,-71.0366705 42.3472294)                                                                                                                                                                                            | 0102000020E61000000300000040BD19355FC251C020EEEA55642C45407041B62C5FC251C0F0694E5E642C4540978E39CF58C251C0D89A5203722C4540
  28 | Haul Road               |  0.0615269543218642 | 55.1714102195302 | LINESTRING(-71.0366705 42.3472294,-71.0363266 42.3474955,-71.0362959 42.3475146,-71.0362642 42.3475305,-71.0362202 42.3475427)                                                                                                                                          | 0102000020E610000005000000978E39CF58C251C0D89A5203722C454064BECD2C53C251C0EB0088BB7A2C4540A6DE09AC52C251C0F6F0C05B7B2C45400041142752C251C067EE21E17B2C4540189D876E51C251C0553B79477C2C4540
  29 |                         | 0.00657425405878911 | 85.8340678607035 | LINESTRING(-71.0362202 42.3475427,-71.0361854 42.347543,-71.0361543 42.3475475)                                                                                                                                                                                         | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  30 | Northern Avenue         |  0.0668064608637913 | 123.312035637714 | LINESTRING(-71.0361543 42.3475475,-71.0360943 42.3475372,-71.0360469 42.3475266,-71.0360014 42.3475067,-71.0359613 42.347478,-71.0358196 42.3473192,-71.0357825 42.347288,-71.0357302 42.3472563,-71.035666 42.3472266)                                                 | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  31 | Northern Avenue         |   0.108520520223976 | 136.026885697745 | LINESTRING(-71.035666 42.3472266,-71.0351521 42.3466748,-71.0350907 42.3466184,-71.0350277 42.346565)                                                                                                                                                                   | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
(31 rows)

13.3.8. Solution to Chapter 7 Exercise 8

Exercise 8

 seq |          name           |        cost         |     azimuth      |                                                                                                                                st_astext                                                                                                                                |                                                                                                                                                                                         route_geom                                                                                                                                                                                         
-----+-------------------------+---------------------+------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 |                         |   0.121267483181179 | 217.047333332684 | LINESTRING(-71.040802 42.351054,-71.0414012 42.3502602)                                                                                                                                                                                                                 | 0102000020E61000000200000021E7FD7F9CC251C0A3906456EF2C4540F8003851A6C251C0930B8453D52C4540
   2 |                         |  0.0239114686446986 | 217.062713634827 | LINESTRING(-71.0414012 42.3502602,-71.0415194 42.3501037)                                                                                                                                                                                                               | 0102000020E610000002000000F8003851A6C251C0930B8453D52C45409249FC40A8C251C0B3DAB232D02C4540
   3 | World Trade Center Road |  0.0510325722213837 | 216.995870383495 | LINESTRING(-71.0415194 42.3501037,-71.0417712 42.3497695)                                                                                                                                                                                                               | 0102000020E6100000020000009249FC40A8C251C0B3DAB232D02C45408A7A1C61ACC251C0B3D1393FC52C4540
   4 | World Trade Center Road |   0.101153842472227 | 217.053603741397 | LINESTRING(-71.0417712 42.3497695,-71.0422711 42.3491074)                                                                                                                                                                                                               | 0102000020E6100000020000008A7A1C61ACC251C0B3D1393FC52C45403804D891B4C251C053E5208DAF2C4540
   5 | World Trade Center Road |  0.0608710944704568 | 216.653748923039 | LINESTRING(-71.0422711 42.3491074,-71.0425686 42.3487076)                                                                                                                                                                                                               | 0102000020E6100000020000003804D891B4C251C053E5208DAF2C45408935A671B9C251C0EEEE5C73A22C4540
   6 | World Trade Center Road |   0.234868659580492 | 217.556827465065 | LINESTRING(-71.0425686 42.3487076,-71.0433997 42.3475907,-71.0434581 42.3475149,-71.0437451 42.3471775)                                                                                                                                                                 | 0102000020E6100000040000008935A671B9C251C0EEEE5C73A22C4540FF09890FC7C251C0667220DA7D2C4540C38F7B04C8C251C0B52F455E7B2C45400E773FB8CCC251C01A34F44F702C4540
   7 | World Trade Center Road |  0.0147122888254378 | 219.787561104133 | LINESTRING(-71.0437451 42.3471775,-71.0438233 42.3470836)                                                                                                                                                                                                               | 0102000020E6100000020000000E773FB8CCC251C01A34F44F702C454061133E00CEC251C02D7D433C6D2C4540
   8 | Summer Street           |  0.0186864573668544 | 118.589368872019 | LINESTRING(-71.0438233 42.3470836,-71.043671 42.3470006)                                                                                                                                                                                                                | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C454027327381CBC251C0A05802846A2C4540
   9 | Summer Street           |  0.0961813968889076 | 117.849071651488 | LINESTRING(-71.043671 42.3470006,-71.0428787 42.346582)                                                                                                                                                                                                                 | 0102000020E61000000200000027327381CBC251C0A05802846A2C45407B8C4D86BEC251C0EEB089CC5C2C4540
  10 | Summer Street           |  0.0735837785242783 | 117.854689391022 | LINESTRING(-71.0428787 42.346582,-71.0422726 42.3462617)                                                                                                                                                                                                                | 0102000020E6100000020000007B8C4D86BEC251C0EEB089CC5C2C454015A12298B4C251C0BEADAA4D522C4540
  11 | Summer Street           |  0.0171717428653313 |   118.0239901678 | LINESTRING(-71.0422726 42.3462617,-71.0421315 42.3461866)                                                                                                                                                                                                               | 0102000020E61000000200000015A12298B4C251C0BEADAA4D522C454069A85148B2C251C01FA8AED74F2C4540
  12 | D Street                |  0.0142367934392995 | 50.4941886627578 | LINESTRING(-71.0421315 42.3461866,-71.0420352 42.346266)                                                                                                                                                                                                                | 0102000020E61000000200000069A85148B2C251C01FA8AED74F2C4540F95168B4B0C251C0BEDBBC71522C4540
  13 | D Street                |     0.0422278366178 | 50.4699063198211 | LINESTRING(-71.0420352 42.346266,-71.0417497 42.3465016)                                                                                                                                                                                                                | 0102000020E610000002000000F95168B4B0C251C0BEDBBC71522C45408A07EF06ACC251C07F01182A5A2C4540
  14 | D Street                | 0.00930280495806409 | 50.4733039530504 | LINESTRING(-71.0417497 42.3465016,-71.0416868 42.3465535)                                                                                                                                                                                                               | 0102000020E6100000020000008A07EF06ACC251C07F01182A5A2C454031AB1CFFAAC251C03C6876DD5B2C4540
  15 | D Street                | 0.00855593753684319 |   50.51713597098 | LINESTRING(-71.0416868 42.3465535,-71.0416289 42.3466012)                                                                                                                                                                                                               | 0102000020E61000000200000031AB1CFFAAC251C03C6876DD5B2C45406204430CAAC251C08F60996D5D2C4540
  16 | D Street                |   0.053493905480869 |  50.249248396176 | LINESTRING(-71.0416289 42.3466012,-71.0412688 42.3469007)                                                                                                                                                                                                               | 0102000020E6100000020000006204430CAAC251C08F60996D5D2C45401796E425A4C251C0D1BAFC3D672C4540
  17 | D Street                | 0.00747206424752287 | 50.7536125897522 | LINESTRING(-71.0412688 42.3469007,-71.041218 42.3469422)                                                                                                                                                                                                                | 0102000020E6100000020000001796E425A4C251C0D1BAFC3D672C45406B80D250A3C251C0184D1D9A682C4540
  18 | D Street                |  0.0398537131748448 | 49.8699417160816 | LINESTRING(-71.041218 42.3469422,-71.0410361 42.3470908,-71.0409518 42.3471666)                                                                                                                                                                                         | 0102000020E6100000030000006B80D250A3C251C0184D1D9A682C454025DDE055A0C251C0095FA9786D2C4540976D4CF49EC251C0BBA184F46F2C4540
  19 | D Street                |  0.0541036090365401 | 46.2408067042895 | LINESTRING(-71.0409518 42.3471666,-71.0407137 42.3474044,-71.0406169 42.3474873)                                                                                                                                                                                        | 0102000020E610000003000000976D4CF49EC251C0BBA184F46F2C4540F27FA20D9BC251C0463E54BF772C45408E4AA07799C251C03EA3BE767A2C4540
  20 | Silver Line Way         |  0.0251054524685886 | 112.262069143208 | LINESTRING(-71.0406169 42.3474873,-71.0403946 42.3473963)                                                                                                                                                                                                               | 0102000020E6100000020000008E4AA07799C251C03EA3BE767A2C4540D77B3BD395C251C02EA0617B772C4540
  21 | Silver Line Way         |  0.0969077112420747 | 105.130803079466 | LINESTRING(-71.0403946 42.3473963,-71.0402893 42.3473511,-71.0401966 42.3473163,-71.0401046 42.3472839,-71.0400107 42.347252,-71.0399209 42.3472243,-71.0398319 42.3472009,-71.0397444 42.3471835,-71.0396585 42.3471687,-71.0395653 42.3471572,-71.0394815 42.3471494) | 0102000020E61000000B000000D77B3BD395C251C02EA0617B772C45403D78921994C251C0645D3700762C4540449AC29492C251C012EF4ADC742C4540D45AE21291C251C0B37680CC732C45405DFF09898FC251C03CBCE7C0722C454052FB63108EC251C031708AD8712C45409AF5189B8CC251C025523F14712C4540BF8C182C8BC251C0FC1A4982702C45408A20CEC389C251C0F0582206702C45409D63E53C88C251C01449AAA56F2C454002D369DD86C251C0BBE93B646F2C4540
  22 | Silver Line Way         |  0.0126002746578369 |  94.239723625209 | LINESTRING(-71.0394815 42.3471494,-71.0393547 42.34714)                                                                                                                                                                                                                 | 0102000020E61000000200000002D369DD86C251C0BBE93B646F2C4540695C93C984C251C0159161156F2C4540
  23 | Silver Line Way         |  0.0671604162143323 | 89.0123851091139 | LINESTRING(-71.0393547 42.34714,-71.0392452 42.3471364,-71.0391207 42.3471377,-71.038676 42.3471517)                                                                                                                                                                    | 0102000020E610000004000000695C93C984C251C0159161156F2C454099A14CFE82C251C026A02EF76E2C45402FC61BF480C251C0B55A16026F2C4540F7C8E6AA79C251C01A2087776F2C4540
  24 | Silver Line Way         |  0.0464547132775842 | 89.6585221724515 | LINESTRING(-71.038676 42.3471517,-71.0382062 42.3471545)                                                                                                                                                                                                                | 0102000020E610000002000000F7C8E6AA79C251C01A2087776F2C454049E06AF871C251C06214048F6F2C4540
  25 | Silver Line Way         |  0.0447080689252215 | 90.6720976169185 | LINESTRING(-71.0382062 42.3471545,-71.0378511 42.3471553,-71.0377544 42.3471492)                                                                                                                                                                                        | 0102000020E61000000300000049E06AF871C251C06214048F6F2C4540872705276CC251C00811BA956F2C4540ED516E916AC251C0916A8E626F2C4540
  26 | Silver Line Way         |   0.082375154292055 | 115.933626733957 | LINESTRING(-71.0377544 42.3471492,-71.0376861 42.3471336,-71.0376256 42.3471111,-71.0375693 42.3470852,-71.037061 42.346812)                                                                                                                                            | 0102000020E610000005000000ED516E916AC251C0916A8E626F2C4540E2C0F57269C251C0DFABB1DF6E2C4540835F347568C251C00F4AF3226E2C45405AB5108967C251C07B76AF496D2C454040BD19355FC251C020EEEA55642C4540
  27 | Haul Road               |  0.0677397195944514 | 43.0929727895055 | LINESTRING(-71.037061 42.346812,-71.037059 42.346813,-71.0366705 42.3472294)                                                                                                                                                                                            | 0102000020E61000000300000040BD19355FC251C020EEEA55642C45407041B62C5FC251C0F0694E5E642C4540978E39CF58C251C0D89A5203722C4540
  28 | Haul Road               |  0.0615269543218642 | 55.1714102195302 | LINESTRING(-71.0366705 42.3472294,-71.0363266 42.3474955,-71.0362959 42.3475146,-71.0362642 42.3475305,-71.0362202 42.3475427)                                                                                                                                          | 0102000020E610000005000000978E39CF58C251C0D89A5203722C454064BECD2C53C251C0EB0088BB7A2C4540A6DE09AC52C251C0F6F0C05B7B2C45400041142752C251C067EE21E17B2C4540189D876E51C251C0553B79477C2C4540
  29 |                         | 0.00657425405878911 | 85.8340678607035 | LINESTRING(-71.0362202 42.3475427,-71.0361854 42.347543,-71.0361543 42.3475475)                                                                                                                                                                                         | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  30 | Northern Avenue         |  0.0668064608637913 | 123.312035637714 | LINESTRING(-71.0361543 42.3475475,-71.0360943 42.3475372,-71.0360469 42.3475266,-71.0360014 42.3475067,-71.0359613 42.347478,-71.0358196 42.3473192,-71.0357825 42.347288,-71.0357302 42.3472563,-71.035666 42.3472266)                                                 | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  31 | Northern Avenue         |   0.108520520223976 | 136.026885697745 | LINESTRING(-71.035666 42.3472266,-71.0351521 42.3466748,-71.0350907 42.3466184,-71.0350277 42.346565)                                                                                                                                                                   | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
(31 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 |  8366 |                         |   0.121267483181179 | 217.047333332684 | LINESTRING(-71.040802 42.351054,-71.0414012 42.3502602)                                                                                                                                                                                                                 | 0102000020E61000000200000021E7FD7F9CC251C0A3906456EF2C4540F8003851A6C251C0930B8453D52C4540
   2 |  8365 |                         |  0.0239114686446986 | 217.062713634827 | LINESTRING(-71.0414012 42.3502602,-71.0415194 42.3501037)                                                                                                                                                                                                               | 0102000020E610000002000000F8003851A6C251C0930B8453D52C45409249FC40A8C251C0B3DAB232D02C4540
   3 |  9271 | World Trade Center Road |  0.0510325722213837 | 216.995870383495 | LINESTRING(-71.0415194 42.3501037,-71.0417712 42.3497695)                                                                                                                                                                                                               | 0102000020E6100000020000009249FC40A8C251C0B3DAB232D02C45408A7A1C61ACC251C0B3D1393FC52C4540
   4 |  9292 | World Trade Center Road |   0.101153842472227 | 217.053603741397 | LINESTRING(-71.0417712 42.3497695,-71.0422711 42.3491074)                                                                                                                                                                                                               | 0102000020E6100000020000008A7A1C61ACC251C0B3D1393FC52C45403804D891B4C251C053E5208DAF2C4540
   5 | 19257 | World Trade Center Road |  0.0608710944704568 | 216.653748923039 | LINESTRING(-71.0422711 42.3491074,-71.0425686 42.3487076)                                                                                                                                                                                                               | 0102000020E6100000020000003804D891B4C251C053E5208DAF2C45408935A671B9C251C0EEEE5C73A22C4540
   6 | 19710 | World Trade Center Road |   0.234868659580492 | 217.556827465065 | LINESTRING(-71.0425686 42.3487076,-71.0433997 42.3475907,-71.0434581 42.3475149,-71.0437451 42.3471775)                                                                                                                                                                 | 0102000020E6100000040000008935A671B9C251C0EEEE5C73A22C4540FF09890FC7C251C0667220DA7D2C4540C38F7B04C8C251C0B52F455E7B2C45400E773FB8CCC251C01A34F44F702C4540
   7 | 18214 | World Trade Center Road |  0.0147122888254378 | 219.787561104133 | LINESTRING(-71.0437451 42.3471775,-71.0438233 42.3470836)                                                                                                                                                                                                               | 0102000020E6100000020000000E773FB8CCC251C01A34F44F702C454061133E00CEC251C02D7D433C6D2C4540
   8 | 17997 | Summer Street           |  0.0186864573668544 | 118.589368872019 | LINESTRING(-71.0438233 42.3470836,-71.043671 42.3470006)                                                                                                                                                                                                                | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C454027327381CBC251C0A05802846A2C4540
   9 | 17456 | Summer Street           |  0.0961813968889076 | 117.849071651488 | LINESTRING(-71.043671 42.3470006,-71.0428787 42.346582)                                                                                                                                                                                                                 | 0102000020E61000000200000027327381CBC251C0A05802846A2C45407B8C4D86BEC251C0EEB089CC5C2C4540
  10 |  9276 | Summer Street           |  0.0735837785242783 | 117.854689391022 | LINESTRING(-71.0428787 42.346582,-71.0422726 42.3462617)                                                                                                                                                                                                                | 0102000020E6100000020000007B8C4D86BEC251C0EEB089CC5C2C454015A12298B4C251C0BEADAA4D522C4540
  11 | 18765 | Summer Street           |  0.0171717428653313 |   118.0239901678 | LINESTRING(-71.0422726 42.3462617,-71.0421315 42.3461866)                                                                                                                                                                                                               | 0102000020E61000000200000015A12298B4C251C0BEADAA4D522C454069A85148B2C251C01FA8AED74F2C4540
  12 | 18763 | D Street                |  0.0142367934392995 | 50.4941886627578 | LINESTRING(-71.0421315 42.3461866,-71.0420352 42.346266)                                                                                                                                                                                                                | 0102000020E61000000200000069A85148B2C251C01FA8AED74F2C4540F95168B4B0C251C0BEDBBC71522C4540
  13 | 18764 | D Street                |     0.0422278366178 | 50.4699063198211 | LINESTRING(-71.0420352 42.346266,-71.0417497 42.3465016)                                                                                                                                                                                                                | 0102000020E610000002000000F95168B4B0C251C0BEDBBC71522C45408A07EF06ACC251C07F01182A5A2C4540
  14 | 19820 | D Street                | 0.00930280495806409 | 50.4733039530504 | LINESTRING(-71.0417497 42.3465016,-71.0416868 42.3465535)                                                                                                                                                                                                               | 0102000020E6100000020000008A07EF06ACC251C07F01182A5A2C454031AB1CFFAAC251C03C6876DD5B2C4540
  15 | 17445 | D Street                | 0.00855593753684319 |   50.51713597098 | LINESTRING(-71.0416868 42.3465535,-71.0416289 42.3466012)                                                                                                                                                                                                               | 0102000020E61000000200000031AB1CFFAAC251C03C6876DD5B2C45406204430CAAC251C08F60996D5D2C4540
  16 | 15637 | D Street                |   0.053493905480869 |  50.249248396176 | LINESTRING(-71.0416289 42.3466012,-71.0412688 42.3469007)                                                                                                                                                                                                               | 0102000020E6100000020000006204430CAAC251C08F60996D5D2C45401796E425A4C251C0D1BAFC3D672C4540
  17 |  3269 | D Street                | 0.00747206424752287 | 50.7536125897522 | LINESTRING(-71.0412688 42.3469007,-71.041218 42.3469422)                                                                                                                                                                                                                | 0102000020E6100000020000001796E425A4C251C0D1BAFC3D672C45406B80D250A3C251C0184D1D9A682C4540
  18 | 18759 | D Street                |  0.0398537131748448 | 49.8699417160816 | LINESTRING(-71.041218 42.3469422,-71.0410361 42.3470908,-71.0409518 42.3471666)                                                                                                                                                                                         | 0102000020E6100000030000006B80D250A3C251C0184D1D9A682C454025DDE055A0C251C0095FA9786D2C4540976D4CF49EC251C0BBA184F46F2C4540
  19 | 16396 | D Street                |  0.0541036090365401 | 46.2408067042895 | LINESTRING(-71.0409518 42.3471666,-71.0407137 42.3474044,-71.0406169 42.3474873)                                                                                                                                                                                        | 0102000020E610000003000000976D4CF49EC251C0BBA184F46F2C4540F27FA20D9BC251C0463E54BF772C45408E4AA07799C251C03EA3BE767A2C4540
  20 |  9289 | Silver Line Way         |  0.0251054524685886 | 112.262069143208 | LINESTRING(-71.0406169 42.3474873,-71.0403946 42.3473963)                                                                                                                                                                                                               | 0102000020E6100000020000008E4AA07799C251C03EA3BE767A2C4540D77B3BD395C251C02EA0617B772C4540
  21 | 16043 | Silver Line Way         |  0.0969077112420747 | 105.130803079466 | LINESTRING(-71.0403946 42.3473963,-71.0402893 42.3473511,-71.0401966 42.3473163,-71.0401046 42.3472839,-71.0400107 42.347252,-71.0399209 42.3472243,-71.0398319 42.3472009,-71.0397444 42.3471835,-71.0396585 42.3471687,-71.0395653 42.3471572,-71.0394815 42.3471494) | 0102000020E61000000B000000D77B3BD395C251C02EA0617B772C45403D78921994C251C0645D3700762C4540449AC29492C251C012EF4ADC742C4540D45AE21291C251C0B37680CC732C45405DFF09898FC251C03CBCE7C0722C454052FB63108EC251C031708AD8712C45409AF5189B8CC251C025523F14712C4540BF8C182C8BC251C0FC1A4982702C45408A20CEC389C251C0F0582206702C45409D63E53C88C251C01449AAA56F2C454002D369DD86C251C0BBE93B646F2C4540
  22 | 14353 | Silver Line Way         |  0.0126002746578369 |  94.239723625209 | LINESTRING(-71.0394815 42.3471494,-71.0393547 42.34714)                                                                                                                                                                                                                 | 0102000020E61000000200000002D369DD86C251C0BBE93B646F2C4540695C93C984C251C0159161156F2C4540
  23 | 14352 | Silver Line Way         |  0.0671604162143323 | 89.0123851091139 | LINESTRING(-71.0393547 42.34714,-71.0392452 42.3471364,-71.0391207 42.3471377,-71.038676 42.3471517)                                                                                                                                                                    | 0102000020E610000004000000695C93C984C251C0159161156F2C454099A14CFE82C251C026A02EF76E2C45402FC61BF480C251C0B55A16026F2C4540F7C8E6AA79C251C01A2087776F2C4540
  24 | 14351 | Silver Line Way         |  0.0464547132775842 | 89.6585221724515 | LINESTRING(-71.038676 42.3471517,-71.0382062 42.3471545)                                                                                                                                                                                                                | 0102000020E610000002000000F7C8E6AA79C251C01A2087776F2C454049E06AF871C251C06214048F6F2C4540
  25 |  9287 | Silver Line Way         |  0.0447080689252215 | 90.6720976169185 | LINESTRING(-71.0382062 42.3471545,-71.0378511 42.3471553,-71.0377544 42.3471492)                                                                                                                                                                                        | 0102000020E61000000300000049E06AF871C251C06214048F6F2C4540872705276CC251C00811BA956F2C4540ED516E916AC251C0916A8E626F2C4540
  26 |  9286 | Silver Line Way         |   0.082375154292055 | 115.933626733957 | LINESTRING(-71.0377544 42.3471492,-71.0376861 42.3471336,-71.0376256 42.3471111,-71.0375693 42.3470852,-71.037061 42.346812)                                                                                                                                            | 0102000020E610000005000000ED516E916AC251C0916A8E626F2C4540E2C0F57269C251C0DFABB1DF6E2C4540835F347568C251C00F4AF3226E2C45405AB5108967C251C07B76AF496D2C454040BD19355FC251C020EEEA55642C4540
  27 | 15576 | Haul Road               |  0.0677397195944514 | 43.0929727895055 | LINESTRING(-71.037061 42.346812,-71.037059 42.346813,-71.0366705 42.3472294)                                                                                                                                                                                            | 0102000020E61000000300000040BD19355FC251C020EEEA55642C45407041B62C5FC251C0F0694E5E642C4540978E39CF58C251C0D89A5203722C4540
  28 | 15572 | Haul Road               |  0.0615269543218642 | 55.1714102195302 | LINESTRING(-71.0366705 42.3472294,-71.0363266 42.3474955,-71.0362959 42.3475146,-71.0362642 42.3475305,-71.0362202 42.3475427)                                                                                                                                          | 0102000020E610000005000000978E39CF58C251C0D89A5203722C454064BECD2C53C251C0EB0088BB7A2C4540A6DE09AC52C251C0F6F0C05B7B2C45400041142752C251C067EE21E17B2C4540189D876E51C251C0553B79477C2C4540
  29 | 15958 |                         | 0.00657425405878911 | 85.8340678607035 | LINESTRING(-71.0362202 42.3475427,-71.0361854 42.347543,-71.0361543 42.3475475)                                                                                                                                                                                         | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  30 |  4007 | Northern Avenue         |  0.0668064608637913 | 123.312035637714 | LINESTRING(-71.0361543 42.3475475,-71.0360943 42.3475372,-71.0360469 42.3475266,-71.0360014 42.3475067,-71.0359613 42.347478,-71.0358196 42.3473192,-71.0357825 42.347288,-71.0357302 42.3472563,-71.035666 42.3472266)                                                 | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  31 |  8374 | Northern Avenue         |   0.108520520223976 | 136.026885697745 | LINESTRING(-71.035666 42.3472266,-71.0351521 42.3466748,-71.0350907 42.3466184,-71.0350277 42.346565)                                                                                                                                                                   | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
(31 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 
-------
 15394
(1 row)

 count 
-------
 11882
(1 row)

 count 
-------
   502
(1 row)

13.4.2. Solution to Chapter 8 Exercise 2

Exercise 2: Nearest Vertex

   osm_id   
------------
 1143179109
(1 row)

  osm_id  
----------
 61350413
(1 row)

   osm_id   
------------
   61348258
 2003929490
 1097411990
   61361864
 3403848827
   61364750
 1097411887
  621528964
 2175188890
  996932899
   61364748
   61541100
 3008066131
 2565713540
   61377234
   61590026
 1326968696
 2959015263
   61379394
   61439475
   61349615
 2963507838
 2963593175
 2938306524
   61415559
 2938353103
   61445938
 2968168635
 2958958918
 4007669296
 1293735420
 1892697363
  996932520
 3856618058
 2565690812
 2965310038
   61444012
 2565690732
   61395601
 1326968715
 3856675372
   61359286
 2969471569
 3856675387
  621528967
 3010733538
 2565713544
 3856599569
 1892697357
   61426429
 4257931018
   61601468
   61377568
   61442963
   61425098
 2969465114
   61356433
   61415332
 3008068354
 3856599064
   61395595
   61598255
 3010733537
 3856675365
 2959100807
 2565713604
   61472757
 4257931020
   61601865
   61598258
   61511248
  990472447
 2963507834
 4452288520
   61415619
 3856599861
 2266605635
 2003929469
 1293735441
   61443151
 3856599572
   61476475
 2565713505
   61342939
   61423006
   61443796
  621528974
 1325873756
 2266605633
 3010733539
   61343205
   61601504
 4257913988
 3414107930
   61578434
 4257916970
 4257879732
 2266605642
   61476421
   61442935
 2938276549
 4007709009
 2003938792
   61377584
 2003929475
   61343200
  621527738
 2959100806
 2965290052
 2936200700
   61443172
 2565713777
   61440207
   61602000
  621529539
  621527739
 2968168637
   61489632
 4257916969
   61341290
 2938328594
   61425301
   61350413
 2963593176
 4073730143
 4259341522
   61342940
  990472131
   61405357
   61349607
 2565713769
   61344338
 2938271375
   61578494
 2938353139
 4257908041
  621530728
  621530729
 4007669295
  621527742
   61356465
   61476571
   61476439
   61442686
   61560779
   61344236
 2938353135
   61378288
 2003929486
 2938276555
   61476848
   61439472
 4257936755
 1293735446
 2963507836
   61348259
   61426955
 2968168638
   61597892
   61443806
 2936205204
 1330267011
 2565713661
   61415364
 2936205201
 2173860769
 2965310046
 2966819808
 2959015262
   61598646
 2965290062
   61443042
 2965205152
   61590037
   61378294
 1718017679
 2003929491
  319125333
 2565713614
   61356435
   61423079
   61380648
   61550524
 2965205157
   61590042
   61519305
 1964402621
 3856599067
   61443420
   61377578
 3856722961
   61415638
   61426436
 1146564472
 2938353145
   61601473
 2175188872
 4257910303
 2565713815
   61395580
 2959141174
   61379728
 3856723058
   61602027
 2938275301
   61439467
 1326968703
   61597879
   61443077
 2167709162
 2830415434
   61343379
   61383687
 2959015254
   61442759
   61425104
   61395511
 2565713548
   61443108
 1718017685
   61415296
 3856599668
 1948679757
   61598342
 4257908047
   61556327
   61598017
   61395557
   61440534
 2938355712
 4257931017
   61428136
   61343247
 2965205155
 1098574272
 2959015256
 2965290072
   61426469
 2565690773
 2965290041
   61426857
 4257910302
   61439452
   61440490
   61377574
 2175188883
   61556335
   61511236
   61344394
 4257770848
   61440537
 2936205205
   61415519
   61578440
 2963487493
   61405338
   61415506
 2969471573
 4873177636
   61426499
   61443374
 2938270809
   61415515
 4257908040
 2936201617
   61550364
   61428111
   61440051
   61351836
  996932473
   61423090
  621021572
   61343385
 1097411892
   61601565
   61340725
 2936205202
 2938355103
 4780407100
 2936105879
 2003929498
   61438427
 3403848825
   61356862
 2938328593
 4257907977
 1411456855
 1293735434
 4546573132
 2266605572
   61379109
   61379546
   61428068
   61415522
   61349979
  990472307
 3403848828
 2565713511
   61426456
 3856675560
   61428091
   61598002
   61395484
 1718017636
 2938355706
   61440581
 1330267012
 4073730146
   61440520
   61493601
   61590045
 2959023209
 2959015260
   61442679
   61443136
 4780407096
 1411456857
   61344264
   61476547
   61476487
   61423134
   61380711
 4257908044
 2969535089
 4257913986
 3008072299
   61340719
   61598217
 2266605601
   61356858
   61598273
 1326968692
 2938353737
   61379632
   61443802
   61356438
 2959023210
 4257924329
   61341289
 2565690790
 1330264334
 4546573131
 1098574509
   61380688
  621530750
   61367644
 2938355708
 1330267009
 4257911824
 2266605583
 4073730140
   61426482
 2565713658
 2959015264
 4257936757
   61377241
 2938328592
   61343203
  621528973
   61442698
   61380673
 4257756853
   61378311
  621528963
   61442634
   61439444
   61370573
   61591229
   61415576
   61426923
   61415430
 1097411832
 2963593180
 2565713608
 2936200697
 1964424568
   61598270
   61442742
 3856599073
 2173840664
  621528968
   61380653
   61443067
   61485119
 2963507835
   61440484
  996932871
  621528972
 2938306536
 2003929472
 2003927285
   61489649
   61342669
  621529536
   61440479
  621530732
 3403848826
 4063942810
 2938355101
   61426448
 4259341521
   61415609
 2266605613
   61379098
 2959015257
 2565690646
   61364752
   61377606
 4873179678
   61598030
 2959100795
 2938306540
 1097411824
   61443829
 4257913987
 1098574199
 2959141171
 2959015259
   61555355
 2963507842
   61598182
 1097411763
   61591194
   61415614
   61380634
   61342667
 2935677397
   61598290
   61355562
 4007664436
 1964424573
   61479912
 1718017707
 1330267010
 2963593179
 2965310040
 2965310055
   61343232
 1097411159
   61367437
 1330267013
 1330267014
 4421257473
 4780407098
 3856599576
 4780407095
 3856675669
 3856723057
 4257908046
 3856675363
 4421257477
 3856675373
   61356461
 4257908039
 3856675369
 3856599577
 3856626557
 3856599574
 3856723062
 4257908042
 3856599071
 3856599571
 3856675664
   61476526
 3856722761
 3856722959
 3856675659
 3856723158
 4259341523
 3856599667
   61350439
 4257908043
 2965205160
 4257916971
 3856599070
 3856722957
 4257916968
 3856675376
 3856722958
 2565667221
  621530730
 4257936756
 3856599573
 3856675379
 4259341520
 4257924328
   61516489
 2938355105
 4257911825
 4780407099
 3856723060
 3856722759
 3856722758
 4257931019
 3856675662
 4780407083
  621530731
 4259341519
 2003929478
 2266605585
 3856723061
 4257908045
(502 rows)

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 |  8366 |                         |   0.101056235984316 |   0.121267483181179 | 217.047333332684 | 0102000020E61000000200000021E7FD7F9CC251C0A3906456EF2C4540F8003851A6C251C0930B8453D52C4540
   2 |  8365 |                         |  0.0199262238705821 |  0.0239114686446986 | 217.062713634827 | 0102000020E610000002000000F8003851A6C251C0930B8453D52C45409249FC40A8C251C0B3DAB232D02C4540
   3 |  9271 | World Trade Center Road |  0.0425271435178198 |  0.0510325722213837 | 216.995870383495 | 0102000020E6100000020000009249FC40A8C251C0B3DAB232D02C45408A7A1C61ACC251C0B3D1393FC52C4540
   4 |  9292 | World Trade Center Road |  0.0842948687268557 |   0.101153842472227 | 217.053603741397 | 0102000020E6100000020000008A7A1C61ACC251C0B3D1393FC52C45403804D891B4C251C053E5208DAF2C4540
   5 | 19257 | World Trade Center Road |   0.050725912058714 |  0.0608710944704568 | 216.653748923039 | 0102000020E6100000020000003804D891B4C251C053E5208DAF2C45408935A671B9C251C0EEEE5C73A22C4540
   6 | 19710 | World Trade Center Road |   0.195723882983743 |   0.234868659580492 | 217.556827465065 | 0102000020E6100000040000008935A671B9C251C0EEEE5C73A22C4540FF09890FC7C251C0667220DA7D2C4540C38F7B04C8C251C0B52F455E7B2C45400E773FB8CCC251C01A34F44F702C4540
   7 | 18214 | World Trade Center Road |  0.0122602406878648 |  0.0147122888254378 | 219.787561104133 | 0102000020E6100000020000000E773FB8CCC251C01A34F44F702C454061133E00CEC251C02D7D433C6D2C4540
   8 | 17997 | Summer Street           |   0.015572047805712 |  0.0186864573668544 | 118.589368872019 | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C454027327381CBC251C0A05802846A2C4540
   9 | 17456 | Summer Street           |  0.0801511640740896 |  0.0961813968889076 | 117.849071651488 | 0102000020E61000000200000027327381CBC251C0A05802846A2C45407B8C4D86BEC251C0EEB089CC5C2C4540
  10 |  9276 | Summer Street           |  0.0613198154368986 |  0.0735837785242783 | 117.854689391022 | 0102000020E6100000020000007B8C4D86BEC251C0EEB089CC5C2C454015A12298B4C251C0BEADAA4D522C4540
  11 | 18765 | Summer Street           |  0.0143097857211094 |  0.0171717428653313 |   118.0239901678 | 0102000020E61000000200000015A12298B4C251C0BEADAA4D522C454069A85148B2C251C01FA8AED74F2C4540
  12 | 18763 | D Street                |  0.0118639945327496 |  0.0142367934392995 | 50.4941886627578 | 0102000020E61000000200000069A85148B2C251C01FA8AED74F2C4540F95168B4B0C251C0BEDBBC71522C4540
  13 | 18764 | D Street                |  0.0351898638481667 |     0.0422278366178 | 50.4699063198211 | 0102000020E610000002000000F95168B4B0C251C0BEDBBC71522C45408A07EF06ACC251C07F01182A5A2C4540
  14 | 19820 | D Street                | 0.00775233746505341 | 0.00930280495806409 | 50.4733039530504 | 0102000020E6100000020000008A07EF06ACC251C07F01182A5A2C454031AB1CFFAAC251C03C6876DD5B2C4540
  15 | 17445 | D Street                | 0.00712994794736932 | 0.00855593753684319 |   50.51713597098 | 0102000020E61000000200000031AB1CFFAAC251C03C6876DD5B2C45406204430CAAC251C08F60996D5D2C4540
  16 | 15637 | D Street                |  0.0445782545673909 |   0.053493905480869 |  50.249248396176 | 0102000020E6100000020000006204430CAAC251C08F60996D5D2C45401796E425A4C251C0D1BAFC3D672C4540
  17 |  3269 | D Street                | 0.00622672020626906 | 0.00747206424752287 | 50.7536125897522 | 0102000020E6100000020000001796E425A4C251C0D1BAFC3D672C45406B80D250A3C251C0184D1D9A682C4540
  18 | 18759 | D Street                |   0.033211427645704 |  0.0398537131748448 | 49.8699417160816 | 0102000020E6100000030000006B80D250A3C251C0184D1D9A682C454025DDE055A0C251C0095FA9786D2C4540976D4CF49EC251C0BBA184F46F2C4540
  19 | 16396 | D Street                |  0.0450863408637835 |  0.0541036090365401 | 46.2408067042895 | 0102000020E610000003000000976D4CF49EC251C0BBA184F46F2C4540F27FA20D9BC251C0463E54BF772C45408E4AA07799C251C03EA3BE767A2C4540
  20 |  9289 | Silver Line Way         |  0.0209212103904905 |  0.0251054524685886 | 112.262069143208 | 0102000020E6100000020000008E4AA07799C251C03EA3BE767A2C4540D77B3BD395C251C02EA0617B772C4540
  21 | 16043 | Silver Line Way         |  0.0807564260350622 |  0.0969077112420747 | 105.130803079466 | 0102000020E61000000B000000D77B3BD395C251C02EA0617B772C45403D78921994C251C0645D3700762C4540449AC29492C251C012EF4ADC742C4540D45AE21291C251C0B37680CC732C45405DFF09898FC251C03CBCE7C0722C454052FB63108EC251C031708AD8712C45409AF5189B8CC251C025523F14712C4540BF8C182C8BC251C0FC1A4982702C45408A20CEC389C251C0F0582206702C45409D63E53C88C251C01449AAA56F2C454002D369DD86C251C0BBE93B646F2C4540
  22 | 14353 | Silver Line Way         |  0.0105002288815307 |  0.0126002746578369 |  94.239723625209 | 0102000020E61000000200000002D369DD86C251C0BBE93B646F2C4540695C93C984C251C0159161156F2C4540
  23 | 14352 | Silver Line Way         |  0.0559670135119436 |  0.0671604162143323 | 89.0123851091139 | 0102000020E610000004000000695C93C984C251C0159161156F2C454099A14CFE82C251C026A02EF76E2C45402FC61BF480C251C0B55A16026F2C4540F7C8E6AA79C251C01A2087776F2C4540
  24 | 14351 | Silver Line Way         |  0.0387122610646535 |  0.0464547132775842 | 89.6585221724515 | 0102000020E610000002000000F7C8E6AA79C251C01A2087776F2C454049E06AF871C251C06214048F6F2C4540
  25 |  9287 | Silver Line Way         |  0.0372567241043513 |  0.0447080689252215 | 90.6720976169185 | 0102000020E61000000300000049E06AF871C251C06214048F6F2C4540872705276CC251C00811BA956F2C4540ED516E916AC251C0916A8E626F2C4540
  26 |  9286 | Silver Line Way         |  0.0686459619100458 |   0.082375154292055 | 115.933626733957 | 0102000020E610000005000000ED516E916AC251C0916A8E626F2C4540E2C0F57269C251C0DFABB1DF6E2C4540835F347568C251C00F4AF3226E2C45405AB5108967C251C07B76AF496D2C454040BD19355FC251C020EEEA55642C4540
  27 | 15576 | Haul Road               |  0.0564497663287095 |  0.0677397195944514 | 43.0929727895055 | 0102000020E61000000300000040BD19355FC251C020EEEA55642C45407041B62C5FC251C0F0694E5E642C4540978E39CF58C251C0D89A5203722C4540
  28 | 15572 | Haul Road               |  0.0512724619348868 |  0.0615269543218642 | 55.1714102195302 | 0102000020E610000005000000978E39CF58C251C0D89A5203722C454064BECD2C53C251C0EB0088BB7A2C4540A6DE09AC52C251C0F6F0C05B7B2C45400041142752C251C067EE21E17B2C4540189D876E51C251C0553B79477C2C4540
  29 | 15958 |                         | 0.00547854504899092 | 0.00657425405878911 | 85.8340678607035 | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  30 |  4007 | Northern Avenue         |  0.0556720507198261 |  0.0668064608637913 | 123.312035637714 | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  31 |  8374 | Northern Avenue         |  0.0904337668533131 |   0.108520520223976 | 136.026885697745 | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
(31 rows)

 seq |  gid  |          name           |       length        |      the_time       |     azimuth      |                                                                                                                                                                                            geom                                                                                                                                                                                            
-----+-------+-------------------------+---------------------+---------------------+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 |  8366 |                         |   0.101056235984316 |   0.121267483181179 | 217.047333332684 | 0102000020E61000000200000021E7FD7F9CC251C0A3906456EF2C4540F8003851A6C251C0930B8453D52C4540
   2 |  8365 |                         |  0.0199262238705821 |  0.0239114686446986 | 217.062713634827 | 0102000020E610000002000000F8003851A6C251C0930B8453D52C45409249FC40A8C251C0B3DAB232D02C4540
   3 |  9271 | World Trade Center Road |  0.0425271435178198 |  0.0510325722213837 | 216.995870383495 | 0102000020E6100000020000009249FC40A8C251C0B3DAB232D02C45408A7A1C61ACC251C0B3D1393FC52C4540
   4 |  9292 | World Trade Center Road |  0.0842948687268557 |   0.101153842472227 | 217.053603741397 | 0102000020E6100000020000008A7A1C61ACC251C0B3D1393FC52C45403804D891B4C251C053E5208DAF2C4540
   5 | 19257 | World Trade Center Road |   0.050725912058714 |  0.0608710944704568 | 216.653748923039 | 0102000020E6100000020000003804D891B4C251C053E5208DAF2C45408935A671B9C251C0EEEE5C73A22C4540
   6 | 19710 | World Trade Center Road |   0.195723882983743 |   0.234868659580492 | 217.556827465065 | 0102000020E6100000040000008935A671B9C251C0EEEE5C73A22C4540FF09890FC7C251C0667220DA7D2C4540C38F7B04C8C251C0B52F455E7B2C45400E773FB8CCC251C01A34F44F702C4540
   7 | 18214 | World Trade Center Road |  0.0122602406878648 |  0.0147122888254378 | 219.787561104133 | 0102000020E6100000020000000E773FB8CCC251C01A34F44F702C454061133E00CEC251C02D7D433C6D2C4540
   8 | 17997 | Summer Street           |   0.015572047805712 |  0.0186864573668544 | 118.589368872019 | 0102000020E61000000200000061133E00CEC251C02D7D433C6D2C454027327381CBC251C0A05802846A2C4540
   9 | 17456 | Summer Street           |  0.0801511640740896 |  0.0961813968889076 | 117.849071651488 | 0102000020E61000000200000027327381CBC251C0A05802846A2C45407B8C4D86BEC251C0EEB089CC5C2C4540
  10 |  9276 | Summer Street           |  0.0613198154368986 |  0.0735837785242783 | 117.854689391022 | 0102000020E6100000020000007B8C4D86BEC251C0EEB089CC5C2C454015A12298B4C251C0BEADAA4D522C4540
  11 | 18765 | Summer Street           |  0.0143097857211094 |  0.0171717428653313 |   118.0239901678 | 0102000020E61000000200000015A12298B4C251C0BEADAA4D522C454069A85148B2C251C01FA8AED74F2C4540
  12 | 18763 | D Street                |  0.0118639945327496 |  0.0142367934392995 | 50.4941886627578 | 0102000020E61000000200000069A85148B2C251C01FA8AED74F2C4540F95168B4B0C251C0BEDBBC71522C4540
  13 | 18764 | D Street                |  0.0351898638481667 |     0.0422278366178 | 50.4699063198211 | 0102000020E610000002000000F95168B4B0C251C0BEDBBC71522C45408A07EF06ACC251C07F01182A5A2C4540
  14 | 19820 | D Street                | 0.00775233746505341 | 0.00930280495806409 | 50.4733039530504 | 0102000020E6100000020000008A07EF06ACC251C07F01182A5A2C454031AB1CFFAAC251C03C6876DD5B2C4540
  15 | 17445 | D Street                | 0.00712994794736932 | 0.00855593753684319 |   50.51713597098 | 0102000020E61000000200000031AB1CFFAAC251C03C6876DD5B2C45406204430CAAC251C08F60996D5D2C4540
  16 | 15637 | D Street                |  0.0445782545673909 |   0.053493905480869 |  50.249248396176 | 0102000020E6100000020000006204430CAAC251C08F60996D5D2C45401796E425A4C251C0D1BAFC3D672C4540
  17 |  3269 | D Street                | 0.00622672020626906 | 0.00747206424752287 | 50.7536125897522 | 0102000020E6100000020000001796E425A4C251C0D1BAFC3D672C45406B80D250A3C251C0184D1D9A682C4540
  18 | 18759 | D Street                |   0.033211427645704 |  0.0398537131748448 | 49.8699417160816 | 0102000020E6100000030000006B80D250A3C251C0184D1D9A682C454025DDE055A0C251C0095FA9786D2C4540976D4CF49EC251C0BBA184F46F2C4540
  19 | 16396 | D Street                |  0.0450863408637835 |  0.0541036090365401 | 46.2408067042895 | 0102000020E610000003000000976D4CF49EC251C0BBA184F46F2C4540F27FA20D9BC251C0463E54BF772C45408E4AA07799C251C03EA3BE767A2C4540
  20 |  9289 | Silver Line Way         |  0.0209212103904905 |  0.0251054524685886 | 112.262069143208 | 0102000020E6100000020000008E4AA07799C251C03EA3BE767A2C4540D77B3BD395C251C02EA0617B772C4540
  21 | 16043 | Silver Line Way         |  0.0807564260350622 |  0.0969077112420747 | 105.130803079466 | 0102000020E61000000B000000D77B3BD395C251C02EA0617B772C45403D78921994C251C0645D3700762C4540449AC29492C251C012EF4ADC742C4540D45AE21291C251C0B37680CC732C45405DFF09898FC251C03CBCE7C0722C454052FB63108EC251C031708AD8712C45409AF5189B8CC251C025523F14712C4540BF8C182C8BC251C0FC1A4982702C45408A20CEC389C251C0F0582206702C45409D63E53C88C251C01449AAA56F2C454002D369DD86C251C0BBE93B646F2C4540
  22 | 14353 | Silver Line Way         |  0.0105002288815307 |  0.0126002746578369 |  94.239723625209 | 0102000020E61000000200000002D369DD86C251C0BBE93B646F2C4540695C93C984C251C0159161156F2C4540
  23 | 14352 | Silver Line Way         |  0.0559670135119436 |  0.0671604162143323 | 89.0123851091139 | 0102000020E610000004000000695C93C984C251C0159161156F2C454099A14CFE82C251C026A02EF76E2C45402FC61BF480C251C0B55A16026F2C4540F7C8E6AA79C251C01A2087776F2C4540
  24 | 14351 | Silver Line Way         |  0.0387122610646535 |  0.0464547132775842 | 89.6585221724515 | 0102000020E610000002000000F7C8E6AA79C251C01A2087776F2C454049E06AF871C251C06214048F6F2C4540
  25 |  9287 | Silver Line Way         |  0.0372567241043513 |  0.0447080689252215 | 90.6720976169185 | 0102000020E61000000300000049E06AF871C251C06214048F6F2C4540872705276CC251C00811BA956F2C4540ED516E916AC251C0916A8E626F2C4540
  26 |  9286 | Silver Line Way         |  0.0686459619100458 |   0.082375154292055 | 115.933626733957 | 0102000020E610000005000000ED516E916AC251C0916A8E626F2C4540E2C0F57269C251C0DFABB1DF6E2C4540835F347568C251C00F4AF3226E2C45405AB5108967C251C07B76AF496D2C454040BD19355FC251C020EEEA55642C4540
  27 | 15576 | Haul Road               |  0.0564497663287095 |  0.0677397195944514 | 43.0929727895055 | 0102000020E61000000300000040BD19355FC251C020EEEA55642C45407041B62C5FC251C0F0694E5E642C4540978E39CF58C251C0D89A5203722C4540
  28 | 15572 | Haul Road               |  0.0512724619348868 |  0.0615269543218642 | 55.1714102195302 | 0102000020E610000005000000978E39CF58C251C0D89A5203722C454064BECD2C53C251C0EB0088BB7A2C4540A6DE09AC52C251C0F6F0C05B7B2C45400041142752C251C067EE21E17B2C4540189D876E51C251C0553B79477C2C4540
  29 | 15958 |                         | 0.00547854504899092 | 0.00657425405878911 | 85.8340678607035 | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  30 |  4007 | Northern Avenue         |  0.0556720507198261 |  0.0668064608637913 | 123.312035637714 | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  31 |  8374 | Northern Avenue         |  0.0904337668533131 |   0.108520520223976 | 136.026885697745 | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
(31 rows)

 seq |  gid  |       name        |       length        |       the_time       |     azimuth      |                                                                                                                                                            geom                                                                                                                                                            
-----+-------+-------------------+---------------------+----------------------+------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | 16164 | Boston HarborWalk |   0.122025068335005 |  0.00119884800121704 | 216.660566628008 | 0102000020E6100000020000007A7DF7D8A7C251C012AA2FA6F42C454045E33F93B3C251C0DAA3DC22D52C4540
   2 | 16163 | Boston HarborWalk | 0.00930484960137577 | 9.18286447627767e-05 | 217.656089663993 | 0102000020E61000000200000045E33F93B3C251C0DAA3DC22D52C4540D9CD8C7EB4C251C02F9402C1D22C4540
   3 | 16170 | Seaport Boulevard |  0.0630637068497959 | 0.000723620508278441 | 112.404253060825 | 0102000020E610000002000000D9CD8C7EB4C251C02F9402C1D22C45401A868F88A9C251C0B7966EB7C92C4540
   4 | 16171 | Seaport Boulevard |   0.054373129497754 | 0.000623896690157318 | 112.405110979493 | 0102000020E6100000020000001A868F88A9C251C0B7966EB7C92C4540613D4915A0C251C02CFA9EECC12C4540
   5 | 16172 | Seaport Boulevard |  0.0244973029595521 | 0.000281102152254092 | 112.395656354024 | 0102000020E610000002000000613D4915A0C251C02CFA9EECC12C45405DBD2FD39BC251C0817A336ABE2C4540
   6 | 16173 | Seaport Boulevard |   0.107853700484554 |  0.00124529200773726 | 110.572251526834 | 0102000020E6100000050000005DBD2FD39BC251C0817A336ABE2C4540D69A9C908CC251C0CF424CD3B12C4540D613025E8BC251C00BEB6B02B12C4540B92EA1278AC251C0D57B8560B02C4540EAFD90C888C251C07C1C171FB02C4540
   7 |  1432 | Northern Avenue   |  0.0597676259547896 | 0.000686529416715039 | 112.164055776745 | 0102000020E610000002000000EAFD90C888C251C07C1C171FB02C4540ADF0D35D7EC251C0B0D870A2A72C4540
   8 |  1433 | Northern Avenue   |  0.0706138177158884 | 0.000811205553480104 |  112.13848588618 | 0102000020E610000002000000ADF0D35D7EC251C0B0D870A2A72C454066553A0E72C251C062180B9E9D2C4540
   9 |  1434 | Northern Avenue   |  0.0664171716546774 | 0.000762600209800641 | 112.253448823009 | 0102000020E61000000200000066553A0E72C251C062180B9E9D2C4540AE5AE37D66C251C055D16927942C4540
  10 |  1435 | Northern Avenue   |  0.0551605609775843 | 0.000633859605906435 | 112.073333274548 | 0102000020E610000002000000AE5AE37D66C251C055D16927942C4540246827DE5CC251C077363F598C2C4540
  11 | 15565 | Northern Avenue   |  0.0585737233451319 | 0.000638049456555293 | 122.784667415104 | 0102000020E610000005000000246827DE5CC251C077363F598C2C45404529215855C251C01C0A9FAD832C454010D143C854C251C05251AB9E822C4540D5B8927854C251C0BDD98B0D822C45401C23D92354C251C0B8921D1B812C4540
  12 | 15956 |                   | 0.00647161622947678 | 5.88688536088866e-05 | 170.715514011562 | 0102000020E6100000030000001C23D92354C251C0B8921D1B812C4540BD03972254C251C083C71231802C4540C9F66BFC53C251C06C43C5387F2C4540
  13 | 15957 |                   |  0.0171557112983927 | 0.000187955794696734 | 119.942384065525 | 0102000020E610000006000000C9F66BFC53C251C06C43C5387F2C4540E70F17CA53C251C0B956D6917E2C45402F7A5D7553C251C0A8339CD77D2C454088C55EDE52C251C0CC99ED0A7D2C4540DCDD5E2D52C251C0C6DCB5847C2C4540189D876E51C251C0553B79477C2C4540
  14 | 15958 |                   | 0.00547854504899092 | 6.62251693472716e-05 | 85.8340678607035 | 0102000020E610000003000000189D876E51C251C0553B79477C2C4540EE6591DC50C251C0147AFD497C2C45400707205A50C251C03D27BD6F7C2C4540
  15 |  4007 | Northern Avenue   |  0.0556720507198261 | 0.000601620816990444 | 123.312035637714 | 0102000020E6100000090000000707205A50C251C03D27BD6F7C2C45409C84775E4FC251C05B1256197C2C4540D227A8974EC251C0BBBE6AC07B2C45400EE7D0D84DC251C008D27B197B2C4540FCDA9F304DC251C02D0ABB287A2C454092A34ADE4AC251C0EEA29EF4742C454039D1AE424AC251C08925E5EE732C4540B11E526749C251C03CEAF9E4722C454011E50B5A48C251C090A6D5EB712C4540
  16 |  8374 | Northern Avenue   |  0.0904337668533131 | 0.000919998944494188 | 136.026885697745 | 0102000020E61000000400000011E50B5A48C251C090A6D5EB712C4540B0F897EE3FC251C0762C00D75F2C4540333910ED3EC251C08E18E2FD5D2C4540107DD2E43DC251C01878EE3D5C2C4540
(16 rows)