<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-02-20 22:47 GMT+01:00 Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">On 2/20/2014 4:39 PM, Carsten Hogertz wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">
<br>
<br>
<br>
2014-02-20 22:20 GMT+01:00 Stephen Woodbridge <<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a><br></div>
<mailto:<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.<u></u>com</a>>>:<div class=""><br>
<br>
On 2/20/2014 3:54 PM, Carsten Hogertz wrote:<br>
<br>
Thanks Steve,<br>
<br>
coming home and adding your lines it returns with an error:<br>
<br>
NOTICE: r2:<br></div>
(34304,"{0,5.<a href="tel:3602868897" value="+13602868897" target="_blank">3602868897</a> <tel:<a href="tel:3602868897" value="+13602868897" target="_blank">3602868897</a>>,4.<a href="tel:6782573327" value="+16782573327" target="_blank">6782573327</a><br>
<tel:<a href="tel:6782573327" value="+16782573327" target="_blank">6782573327</a>>,5.<a href="tel:6026971537" value="+16026971537" target="_blank">6026971537</a> <tel:<a href="tel:6026971537" value="+16026971537" target="_blank">6026971537</a>>,5.<a href="tel:2062747797" value="+12062747797" target="_blank">2062747797</a><br>
<tel:<a href="tel:2062747797" value="+12062747797" target="_blank">2062747797</a>>,5.__0497181017,5.<a href="tel:3147719797" value="+13147719797" target="_blank">3147719797</a><br>
<tel:<a href="tel:3147719797" value="+13147719797" target="_blank">3147719797</a>>,5.__0700916462,4.<u></u>3220066797,4.__<a href="tel:8593618137" value="+18593618137" target="_blank">8593618137</a><br>
<tel:<a href="tel:8593618137" value="+18593618137" target="_blank">8593618137</a>>,4.0002255227,6.__<u></u>055760592,12.<a href="tel:5155379824" value="+15155379824" target="_blank">5155379824</a><br>
<tel:<a href="tel:5155379824" value="+15155379824" target="_blank">5155379824</a>>,9.__3170226155,8.<u></u>72783427270001,5.__9460446587,<u></u>3.0868131677,5.__1839796057,5.<u></u>2301666167,2.__1211198847,5.<u></u><a href="tel:7037465591" value="+17037465591" target="_blank">7037465591</a><br>
<tel:<a href="tel:7037465591" value="+17037465591" target="_blank">7037465591</a>>,2.__7282842677,8.<a href="tel:4758437557" value="+14758437557" target="_blank">4758437557</a><br>
<tel:<a href="tel:4758437557" value="+14758437557" target="_blank">4758437557</a>>,11.__1027935904,7.<u></u>9434273599,7.__8361619299,7.<u></u>7610621969,7.__4929139614,5.<u></u><a href="tel:8106133327" value="+18106133327" target="_blank">8106133327</a><br>
<tel:<a href="tel:8106133327" value="+18106133327" target="_blank">8106133327</a>>,5.__9579132527,5.<u></u>9888473034,6.__<a href="tel:5618433959" value="+15618433959" target="_blank">5618433959</a><br>
<tel:<a href="tel:5618433959" value="+15618433959" target="_blank">5618433959</a>>,4.<a href="tel:5013708887" value="+15013708887" target="_blank">5013708887</a><br>
<tel:<a href="tel:5013708887" value="+15013708887" target="_blank">5013708887</a>>,1.__9218516244,5.<u></u>7559805232,5.__<a href="tel:2267081177" value="+12267081177" target="_blank">2267081177</a><br>
<tel:<a href="tel:2267081177" value="+12267081177" target="_blank">2267081177</a>>,5.0968196707,4.__<u></u>8949133597,5.<a href="tel:9137964962" value="+19137964962" target="_blank">9137964962</a><br>
<tel:<a href="tel:9137964962" value="+19137964962" target="_blank">9137964962</a>>,4.__2936059427,4.<u></u>6948533593,3.__<a href="tel:4377318427" value="+14377318427" target="_blank">4377318427</a><br>
<tel:<a href="tel:4377318427" value="+14377318427" target="_blank">4377318427</a>>,3.7991617067,4.__<u></u>1242444467,3.8858731777,3.__<u></u>9596393887,4.<a href="tel:9192685996" value="+19192685996" target="_blank">9192685996</a><br>
<tel:<a href="tel:9192685996" value="+19192685996" target="_blank">9192685996</a>>,4.__6734033563,4.<u></u>7511846457,4.__4544981945,4.<u></u>2748693367,3.__411559417,6.<u></u>6851381985,6.__6744741285,6.<u></u><a href="tel:9296475385" value="+19296475385" target="_blank">9296475385</a>,7.__0136847108,7.<u></u>1371500908,7.__2719520708,6.<u></u><a href="tel:6787720528" value="+16787720528" target="_blank">6787720528</a>,7.__3530295908,6.<u></u><a href="tel:8599596928" value="+18599596928" target="_blank">8599596928</a>,7.__2216891568,7.<u></u>4951304208,7.__<a href="tel:4404728868" value="+14404728868" target="_blank">4404728868</a>,8.<u></u>1332243958,6.__2736028029,6.<u></u>963685048,6.__0483763169,5.<u></u><a href="tel:8653351624" value="+18653351624" target="_blank">8653351624</a>,5.__<a href="tel:6164044005" value="+16164044005" target="_blank">6164044005</a>,6.<u></u>54979166,5.__<a href="tel:8783224469" value="+18783224469" target="_blank">8783224469</a>,6.<u></u>533468297,5.__<a href="tel:8553434082" value="+18553434082" target="_blank">8553434082</a>,5.<u></u>7676662122,6.__267915357,5.<u></u>22607939<br>
<br>
03,3.745459072,6.352470342,5._<u></u>_4392033722,5.5562602522,5.__<u></u>3996670482,6.171297855,5.__<u></u>648779598,5.5653279855,5.__<u></u>671668653,5.3243595462,5.__<u></u>879320328,<a href="tel:5.859442385" value="+15859442385" target="_blank">5.859442385</a>,6.__<u></u>080574272,5.3767159992,6.__<u></u>170852717,5.3001119472,5.__<u></u>687201287,5.3573110752,3.__<u></u>586385579,5.566591422,5.__<u></u>5104826925,5.916268775,5.__<u></u>4418422465,5.4037394705,5.__<u></u>640889612,5.1407657702,4.__<u></u>5523677017,5.3873769863,3.__<u></u>601570449,2.978252449,4.__<u></u>8725960282,4.9817842222,5.__<u></u>2355359365,5.1227105795,5.__<u></u>177856607,5.098596533,5.__<u></u>1891181988,4.9327118245,4.__<u></u>4632330777,7.4879538737,4.__<u></u>8591269625,3.1339054377,5.__<u></u>8472818275,4.6043306952,3.__<u></u>3542942377,4.7660145915,6.__<u></u>6679095357,5.51150886,2.__<u></u>7404344677,5.9332075344,6.__<u></u>2019594857,5.266709364,5.__<u></u>4924174224,5.180577724,3.__<u></u>0277711677,6.2913260157,4.__<u></u>2862670877,5.5461328154,5.__<u></u>5809644644,5.1132029296,5.__<u></u>1904326724,4.8352505633,4.__<u></u>9641930171,5.1366240426,7.__<u></u>0699378037,3.1274712477,5.__<u></u>1487646306,5.2717034197,5.__<u></u>0200090866,3.0911490977,5.__<u></u>8984613527,5.1973381747,4.__<br>
</blockquote>
2427530627,6.7293864957,4.__<u></u>7943011637,5.1130266607,5.__<u></u>3948779287,4.7124246547,5.2<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
186371577,2.<a href="tel:9723417287" value="+19723417287" target="_blank">9723417287</a> <tel:<a href="tel:9723417287" value="+19723417287" target="_blank">9723417287</a>>,2.3171875277,2.<a href="tel:8159853427" value="+18159853427" target="_blank">8159853427</a><br>
<tel:<a href="tel:8159853427" value="+18159853427" target="_blank">8159853427</a>>,__4.7913513947,4.<a href="tel:7863347867" value="+17863347867" target="_blank">7863347867</a><br>
<tel:<a href="tel:7863347867" value="+17863347867" target="_blank">7863347867</a>>,3.4531342837,__3.<u></u>8161332287,5.8431115757,4.__<u></u>4873126817,5.6577494097,5.__<u></u>5867970832,9.4583860946,2.__<u></u>7784615917,5.4279953797,1.__<u></u>9376872717,5.0813930177,5.__<u></u>8860618114,6.2411339874,6.__<u></u>4536904614,6.0972641874,5.__<u></u>7247963284,5.9823452114,5.__<u></u>8316140784,5.2398164977,6.__<u></u>2963392357,5.5864457124,6.__<u></u>1599995178,5.2609646384,6.__<u></u>1012355027,6.4129483756,6.__<u></u>0056487896,5.0106569884,5.__<u></u>4239402364,6.1148656496,2.__<u></u>673828844,4.3332873457,3.__<u></u>2943586634,4.5834393467,7.__<u></u>278601561,3.5870893269,3.__<u></u>3299191554,4.1049776549,5.__<u></u>9256568037,6.2719334873,6.__<u></u>2594329923,5.5752581689,5.__<u></u>6058592867,6.1311384893,6.__<u></u>4726413519,5.8973941434,6.__<u></u>2572672069,5.9667442136,5.__<u></u>3965422637,7.2837623985,6.__<u></u>9586195092,7.1137641952,6.__<u></u>3682104908,7.8495628418,7.__<u></u>2245886958,6.2983788278,7.__<u></u>3509762248,6.9925366658,6.__<u></u>5600944468,6.936328733,6.__<u></u>616665943,6.738732443}")<div>
<div class="h5"><br>
<br>
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
NOTICE: r2.id1: 34304<br>
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
NOTICE: ids: <NULL><br>
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
ERROR: cannot concatenate incompatible arrays<br>
DETAIL: Arrays with differing element dimensions are not<br>
compatible for<br>
concatenation.<br>
CONTEXT: PL/pgSQL function "pgr_makedijkstramatrix" line 25 at<br>
assignment<br>
PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
<br>
I tried to write to Dose but he didn't reply yet.<br>
Does anyone have a clue?<br>
<br>
<br>
Try adding the follow line after the "begin" line:<br>
<br>
ids := '{}'::integer[];<br>
<br>
This should make sure the ids is initialized as an empty array of<br>
integers.<br>
<br>
-Steve<br>
<br>
<br>
<br>
Again:<br>
NOTICE: r2:<br>
(34304,"{0,5.<a href="tel:3602868897" value="+13602868897" target="_blank">3602868897</a>,4.<a href="tel:6782573327" value="+16782573327" target="_blank">6782573327</a>,5.<a href="tel:6026971537" value="+16026971537" target="_blank">6026971537</a>,5.<a href="tel:2062747797" value="+12062747797" target="_blank">2062747797</a>,5.<u></u>0497181017,5.3147719797,5.<u></u>0700916462,4.3220066797,4.<u></u>8593618137,4.0002255227,6.<u></u>055760592,12.5155379824,9.<u></u>3170226155,8.72783427270001,5.<u></u>9460446587,3.0868131677,5.<u></u>1839796057,5.2301666167,2.<u></u>1211198847,5.7037465591,2.<u></u>7282842677,8.4758437557,11.<u></u>1027935904,7.9434273599,7.<u></u>8361619299,7.7610621969,7.<u></u>4929139614,5.8106133327,5.<u></u>9579132527,5.9888473034,6.<u></u>5618433959,4.5013708887,1.<u></u>9218516244,5.7559805232,5.<u></u>2267081177,5.0968196707,4.<u></u>8949133597,5.9137964962,4.<u></u>2936059427,4.6948533593,3.<u></u>4377318427,3.7991617067,4.<u></u>1242444467,3.8858731777,3.<u></u>9596393887,4.9192685996,4.<u></u>6734033563,4.7511846457,4.<u></u>4544981945,4.2748693367,3.<u></u>411559417,6.6851381985,6.<u></u>6744741285,6.9296475385,7.<u></u>0136847108,7.1371500908,7.<u></u>2719520708,6.6787720528,7.<u></u>3530295908,6.8599596928,7.<u></u>2216891568,7.4951304208,7.<u></u>4404728868,8.1332243958,6.<u></u>2736028029,6.963685048,6.<u></u>0483763169,5.8653351624,5.<u></u>6164044005,6.54979166,5.<u></u>8783224469,6.533468297,5.<u></u>8553434082,5.7676662122,6.<u></u>267915357,5.22607939<br>
</div></div></blockquote>
03,3.745459072,6.352470342,5.<u></u>4392033722,5.5562602522,5.<u></u>3996670482,6.171297855,5.<u></u>648779598,5.5653279855,5.<u></u>671668653,5.3243595462,5.<u></u>879320328,5.859442385,6.<u></u>080574272,5.3767159992,6.<u></u>170852717,5.3001119472,5.<u></u>687201287,5.3573110752,3.<u></u>586385579,5.566591422,5.<u></u>5104826925,5.916268775,5.<u></u>4418422465,5.4037394705,5.<u></u>640889612,5.1407657702,4.<u></u>5523677017,5.3873769863,3.<u></u>601570449,2.978252449,4.<u></u>8725960282,4.9817842222,5.<u></u>2355359365,5.1227105795,5.<u></u>177856607,5.098596533,5.<u></u>1891181988,4.9327118245,4.<u></u>4632330777,7.4879538737,4.<u></u>8591269625,3.1339054377,5.<u></u>8472818275,4.6043306952,3.<u></u>3542942377,4.7660145915,6.<u></u>6679095357,5.51150886,2.<u></u>7404344677,5.9332075344,6.<u></u>2019594857,5.266709364,5.<u></u>4924174224,5.180577724,3.<u></u>0277711677,6.2913260157,4.<u></u>2862670877,5.5461328154,5.<u></u>5809644644,5.1132029296,5.<u></u>1904326724,4.8352505633,4.<u></u>9641930171,5.1366240426,7.<u></u>0699378037,3.1274712477,5.<u></u>1487646306,5.2717034197,5.<u></u>0200090866,3.0911490977,5.<u></u>8984613527,5.1973381747,4.<u></u>2427530627,6.7293864957,4.<u></u>7943011637,5.1130266607,5.<u></u>3948779287,4.7124246547,5.2<br>
186371577,2.<a href="tel:9723417287" value="+19723417287" target="_blank">9723417287</a>,2.3171875277,2.<a href="tel:8159853427" value="+18159853427" target="_blank">8159853427</a>,<u></u>4.7913513947,4.<a href="tel:7863347867" value="+17863347867" target="_blank">7863347867</a>,3.4531342837,<u></u>3.8161332287,5.8431115757,4.<u></u>4873126817,5.6577494097,5.<u></u>5867970832,9.4583860946,2.<u></u>7784615917,5.4279953797,1.<u></u>9376872717,5.0813930177,5.<u></u>8860618114,6.2411339874,6.<u></u>4536904614,6.0972641874,5.<u></u>7247963284,5.9823452114,5.<u></u>8316140784,5.2398164977,6.<u></u>2963392357,5.5864457124,6.<u></u>1599995178,5.2609646384,6.<u></u>1012355027,6.4129483756,6.<u></u>0056487896,5.0106569884,5.<u></u>4239402364,6.1148656496,2.<u></u>673828844,4.3332873457,3.<u></u>2943586634,4.5834393467,7.<u></u>278601561,3.5870893269,3.<u></u>3299191554,4.1049776549,5.<u></u>9256568037,6.2719334873,6.<u></u>2594329923,5.5752581689,5.<u></u>6058592867,6.1311384893,6.<u></u>4726413519,5.8973941434,6.<u></u>2572672069,5.9667442136,5.<u></u>3965422637,7.2837623985,6.<u></u>9586195092,7.1137641952,6.<u></u>3682104908,7.8495628418,7.<u></u>2245886958,6.2983788278,7.<u></u>3509762248,6.9925366658,6.<u></u>5600944468,6.936328733,6.<u></u>616665943,6.738732443}")<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
NOTICE: r2.id1: 34304<br>
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br></div></div>
NOTICE: ids: {}<div><div class="h5"><br>
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
ERROR: cannot concatenate incompatible arrays<br>
DETAIL: Arrays with differing element dimensions are not compatible for<br>
concatenation.<br>
CONTEXT: PL/pgSQL function "pgr_makedijkstramatrix" line 26 at assignment<br>
PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
<br>
Thanks for your help. Maybe you need some other facts about my table?<br>
The whole script I am excecuting is the following. I changed some<br>
things, like adding your code and changing the table name 'ways' to<br>
'cgn_2po_4pgr':<br>
<br>
create or replace function pgr_makeDijkstraMatrix(thetbl text, sqlP<br>
text, OUT dmatrix double precision[], OUT ids integer[])<br>
as<br>
$body$<br>
declare<br>
sql text;<br>
sql2 text;<br>
r record;<br>
r2 record;<br>
i integer;<br>
j integer;<br>
matrixl double precision[];<br>
begin<br>
<br>
ids := '{}'::integer[];<br>
sql:='select node, id-1 as id from '||thetbl;<br>
for r in execute sql loop<br>
sql2:='select id1, array_agg(cost) as arow from (<br>
SELECT id1, id2, cost<br>
FROM pgr_kdijkstraCost('''||sqlP||'<u></u>'', '||r.node||<br>
', (select array_agg(node) from '||thetbl||' where<br></div></div>
id>'||<a href="http://r.id" target="_blank">r.id</a> <<a href="http://r.id" target="_blank">http://r.id</a>>||'), false, false)<div class=""><br>
) as foo group by id1 order by id1';<br>
for r2 in execute sql2 loop<br>
matrixl := '{}';<br></div>
for i in 1..<a href="http://r.id" target="_blank">r.id</a> <<a href="http://r.id" target="_blank">http://r.id</a>> loop<div class=""><br>
matrixl := array_append(matrixl, dmatrix[i][<a href="http://r.id" target="_blank">r.id</a><br></div>
<<a href="http://r.id" target="_blank">http://r.id</a>>+1]);<div class=""><br>
end loop;<br>
matrixl := array_cat(matrixl, r2.arow);<br>
dmatrix := array_cat(dmatrix, array[matrixl]);<br>
raise notice 'r2: %', r2;<br>
raise notice 'r2.id1: %', r2.id1;<br>
raise notice 'ids: %', ids;<br>
</div></blockquote>
<br>
Sorry, I don't have a running version of this so this is somewhat guess work.<br>
<br>
-- ids := ids || r2.id1;<br>
ids := array_cat(ids, r2.id1);<br>
<br>
So comment out the old like and rewrite like this.<br>
<br>
-Steve<br></blockquote><div><br></div><div>Thanks for all your help Steve,<br></div><div>hope, we're getting closer! Look, not it returns this:<br>NOTICE: r2: (34304,"{0,5.3602868897,4.6782573327,5.6026971537,5.2062747797,5.0497181017,5.3147719797,5.0700916462,4.3220066797,4.8593618137,4.0002255227,6.055760592,12.5155379824,9.3170226155,8.72783427270001,5.9460446587,3.0868131677,5.1839796057,5.2301666167,2.1211198847,5.7037465591,2.7282842677,8.4758437557,11.1027935904,7.9434273599,7.8361619299,7.7610621969,7.4929139614,5.8106133327,5.9579132527,5.9888473034,6.5618433959,4.5013708887,1.9218516244,5.7559805232,5.2267081177,5.0968196707,4.8949133597,5.9137964962,4.2936059427,4.6948533593,3.4377318427,3.7991617067,4.1242444467,3.8858731777,3.9596393887,4.9192685996,4.6734033563,4.7511846457,4.4544981945,4.2748693367,3.411559417,6.6851381985,6.6744741285,6.9296475385,7.0136847108,7.1371500908,7.2719520708,6.6787720528,7.3530295908,6.8599596928,7.2216891568,7.4951304208,7.4404728868,8.1332243958,6.2736028029,6.963685048,6.0483763169,5.8653351624,5.6164044005,6.54979166,5.8783224469,6.533468297,5.8553434082,5.7676662122,6.267915357,5.2260793903,3.745459072,6.352470342,5.4392033722,5.5562602522,5.3996670482,6.171297855,5.648779598,5.5653279855,5.671668653,5.3243595462,5.879320328,5.859442385,6.080574272,5.3767159992,6.170852717,5.3001119472,5.687201287,5.3573110752,3.586385579,5.566591422,5.5104826925,5.916268775,5.4418422465,5.4037394705,5.640889612,5.1407657702,4.5523677017,5.3873769863,3.601570449,2.978252449,4.8725960282,4.9817842222,5.2355359365,5.1227105795,5.177856607,5.098596533,5.1891181988,4.9327118245,4.4632330777,7.4879538737,4.8591269625,3.1339054377,5.8472818275,4.6043306952,3.3542942377,4.7660145915,6.6679095357,5.51150886,2.7404344677,5.9332075344,6.2019594857,5.266709364,5.4924174224,5.180577724,3.0277711677,6.2913260157,4.2862670877,5.5461328154,5.5809644644,5.1132029296,5.1904326724,4.8352505633,4.9641930171,5.1366240426,7.0699378037,3.1274712477,5.1487646306,5.2717034197,5.0200090866,3.0911490977,5.8984613527,5.1973381747,4.2427530627,6.7293864957,4.7943011637,5.1130266607,5.3948779287,4.7124246547,5.2186371577,2.9723417287,2.3171875277,2.8159853427,4.7913513947,4.7863347867,3.4531342837,3.8161332287,5.8431115757,4.4873126817,5.6577494097,5.5867970832,9.4583860946,2.7784615917,5.4279953797,1.9376872717,5.0813930177,5.8860618114,6.2411339874,6.4536904614,6.0972641874,5.7247963284,5.9823452114,5.8316140784,5.2398164977,6.2963392357,5.5864457124,6.1599995178,5.2609646384,6.1012355027,6.4129483756,6.0056487896,5.0106569884,5.4239402364,6.1148656496,2.673828844,4.3332873457,3.2943586634,4.5834393467,7.278601561,3.5870893269,3.3299191554,4.1049776549,5.9256568037,6.2719334873,6.2594329923,5.5752581689,5.6058592867,6.1311384893,6.4726413519,5.8973941434,6.2572672069,5.9667442136,5.3965422637,7.2837623985,6.9586195092,7.1137641952,6.3682104908,7.8495628418,7.2245886958,6.2983788278,7.3509762248,6.9925366658,6.5600944468,6.936328733,6.616665943,6.738732443}")<br>
CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>NOTICE: r2.id1: 34304<br>CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>
PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>NOTICE: ids: {}<br>CONTEXT: PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
<br><br>ERROR: function array_cat(integer[], integer) does not exist<br>LINE 1: SELECT array_cat(ids, r2.id1)<br> ^<br>HINT: No function matches the given name and argument types. You might need to add explicit type casts.<br>
QUERY: SELECT array_cat(ids, r2.id1)<br>CONTEXT: PL/pgSQL function "pgr_makedijkstramatrix" line 31 at assignment<br>PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
<br>********** Fehler **********<br><br>ERROR: function array_cat(integer[], integer) does not exist<br>SQL Status:42883<br>Hinweis:No function matches the given name and argument types. You might need to add explicit type casts.<br>
Kontext:PL/pgSQL function "pgr_makedijkstramatrix" line 31 at assignment<br>PL/pgSQL function "pgr_tspdijkstra" line 8 at RETURN QUERY<br>PL/pgSQL function "pgr_tspdijkstralen" line 3 at RETURN QUERY<br>
<br><br></div><div>Function does not exist? Still have an idea?<br></div><div>Thanks<br>Carsten <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">
end loop;<br>
end loop;<br>
end;<br>
$body$<br>
language plpgsql stable cost 10;<br>
<br>
<br>
create or replace function pgr_tspDijkstra(thetbl text, sql text,<br>
start_id integer, end_id integer default (-1))<br>
returns setof pgr_costResult as<br>
$body$<br>
declare<br>
sid integer;<br>
eid integer;<br>
<br>
begin<br>
<br>
return query with dm as (<br>
select * from pgr_makeDijkstraMatrix( thetbl, sql )<br>
),<br>
ids as (<br>
select (row_number() over (order by id asc))-1 as rnum, id<br>
from (<br>
select unnest(ids) as id<br>
from dm<br>
) foo<br>
),<br>
t as (<br></div>
select a.seq, b.rnum, <a href="http://b.id" target="_blank">b.id</a> <<a href="http://b.id" target="_blank">http://b.id</a>><div class=""><br>
from pgr_tsp(<br>
(select dmatrix from dm),<br>
(select rnum from ids where id=start_id limit<br>
1)::integer,<br>
(case when end_id = -1 then -1 else (select rnum<br>
from ids where id=end_id limit 1) end)::integer<br>
) a,<br>
ids b<br></div>
where <a href="http://a.id" target="_blank">a.id</a> <<a href="http://a.id" target="_blank">http://a.id</a>>=b.rnum<div><div class="h5"><br>
),<br>
r as (<br>
select array_agg(t.rnum) as rnum from t<br>
)<br>
select t.seq::integer,<br>
t.rnum::integer as id1,<br>
t.id::integer as id2,<br>
<br>
dm.dmatrix[r.rnum[t.seq+1]+1][<u></u>r.rnum[(t.seq+1)%array_length(<u></u>r.rnum,<br>
1)+1]+1]::float8 as cost<br>
from t, dm, r;<br>
end;<br>
$body$<br>
language plpgsql volatile cost 50 rows 50;<br>
<br>
<br>
create or replace function pgr_tspDijkstraLen(thetbl text, start_id<br>
integer, end_id integer default (-1))<br>
returns setof pgr_costResult as<br>
$body$<br>
begin<br>
return query SELECT * FROM pgr_tspDijkstra(thetbl,<br>
'SELECT id, source::integer, target::integer, length::double<br>
precision AS cost FROM cgn_2po_4pgr',<br>
start_id, end_id);<br>
end;<br>
$body$<br>
language plpgsql stable;<br>
<br>
<br>
Maybe you've got another idea?<br>
Thank you<br>
Carsten<br>
<br>
<br>
Thanks for you help<br>
Carsten<br>
<br>
<br>
2014-02-20 16:24 GMT+01:00 Stephen Woodbridge<br>
<<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a> <mailto:<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.<u></u>com</a>><br></div></div>
<mailto:<a href="mailto:woodbri@swoodbridge." target="_blank">woodbri@swoodbridge.</a>__<u></u>com<div class=""><br>
<mailto:<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.<u></u>com</a>>>>:<br>
<br>
<br>
On 2/20/2014 9:41 AM, Stephen Woodbridge wrote:<br>
<br>
Hi Carsten,<br>
<br>
The functions at<br></div>
<a href="http://dose.0wnz.at/scripts/____sql/pgroute_tspDijkstra.sql" target="_blank">http://dose.0wnz.at/scripts/__<u></u>__sql/pgroute_tspDijkstra.sql</a><br>
<<a href="http://dose.0wnz.at/scripts/__sql/pgroute_tspDijkstra.sql" target="_blank">http://dose.0wnz.at/scripts/_<u></u>_sql/pgroute_tspDijkstra.sql</a>><div><div class="h5"><br>
<br>
<br>
<<a href="http://dose.0wnz.at/scripts/__sql/pgroute_tspDijkstra.sql" target="_blank">http://dose.0wnz.at/scripts/_<u></u>_sql/pgroute_tspDijkstra.sql</a><br>
<<a href="http://dose.0wnz.at/scripts/sql/pgroute_tspDijkstra.sql" target="_blank">http://dose.0wnz.at/scripts/<u></u>sql/pgroute_tspDijkstra.sql</a>>><br>
are not part of pgRouting.<br>
<br>
You need to ask this question to Ivan the author of the<br>
original<br>
article.<br>
<br>
<br>
Sorry, Dose was the original author.<br>
<br>
<br>
<br>
You probably need to add some debug statements to get a<br>
better<br>
understanding of what the code is doing. For example in<br>
pgr_makeDijkstraMatrix before the statement:<br>
<br>
ids := ids || array[r2.id1];<br>
<br>
<br>
You could try changing this line to:<br>
<br>
ids := ids || r2.id1;<br>
<br>
and see if that fixes the problem.<br>
<br>
-Steve<br>
<br>
<br>
Add:<br>
<br>
raise notice 'r2: %', r2;<br>
raise notice 'r2.id1: %', r2.id1;<br>
raise notice 'ids: %', ids;<br>
<br>
This should show you the progression of how the array<br>
ids is getting<br>
built as it appears to be compaining about that in the<br>
error<br>
message.<br>
<br>
Hope this helps,<br>
-Steve<br>
<br>
On 2/20/2014 9:21 AM, Carsten Hogertz wrote:<br>
<br>
Hi everybody, I am new to this list and new to<br>
pgrouting.<br>
<br>
I found the following TSP example<br></div></div>
<a href="http://hardwarefetish.com/513-____pgrouting-dijksta-__travelling-__salesman-problem-__tsp-with-__openstreetmap" target="_blank">http://hardwarefetish.com/513-<u></u>____pgrouting-dijksta-__<u></u>travelling-__salesman-problem-<u></u>__tsp-with-__openstreetmap</a><br>
<<a href="http://hardwarefetish.com/513-__pgrouting-dijksta-travelling-__salesman-problem-tsp-with-__openstreetmap" target="_blank">http://hardwarefetish.com/<u></u>513-__pgrouting-dijksta-<u></u>travelling-__salesman-problem-<u></u>tsp-with-__openstreetmap</a>><br>
<br>
<br>
<<a href="http://hardwarefetish.com/__513-pgrouting-dijksta-__travelling-salesman-problem-__tsp-with-openstreetmap" target="_blank">http://hardwarefetish.com/__<u></u>513-pgrouting-dijksta-__<u></u>travelling-salesman-problem-__<u></u>tsp-with-openstreetmap</a><div>
<div class="h5"><br>
<<a href="http://hardwarefetish.com/513-pgrouting-dijksta-travelling-salesman-problem-tsp-with-openstreetmap" target="_blank">http://hardwarefetish.com/<u></u>513-pgrouting-dijksta-<u></u>travelling-salesman-problem-<u></u>tsp-with-openstreetmap</a>>><br>
<br>
and tried to reproduce the solution.<br>
<br>
Unfortunately I always get an error message.<br>
My DB is complaining about one of your functions.<br>
<br>
I got my routing table from osm2po. The table has<br>
the following<br>
structure:<br>
<br>
1;”id”;”integer”<br>
2;”osm_id”;”bigint”<br>
3;”osm_name”;”character varying”<br>
4;”osm_meta”;”character varying”<br>
5;”osm_source_id”;”bigint”<br>
6;”osm_target_id”;”bigint”;<br>
7;”clazz”;”integer”<br>
8;”flags”;”integer”<br>
9;”source”;”integer”<br>
10;”target”;”integer”<br>
11;”length”;”double precision”<br>
12;”kmh”;”integer”<br>
13;”cost”;”double precision”<br>
14;”reverse_cost”;”double precision”<br>
15;”x1″;”double precision”<br>
16;”y1″;”double precision”<br>
17;”x2″;”double precision”<br>
18;”y2″;”double precision”<br></div></div>
19;”geom_way”;”geometry(____<u></u>LineString,4326)”<div><div class="h5"><br>
<br>
<br>
- I installed the functions as mentioned via SQL<br>
window in<br>
pgAdmin3<br>
(copy&paste then excecute)<br>
- I create and populate the my_route table<br>
- When it comes to step 5 and I try<br>
<br>
select id,lon,lat from<br>
pgr_tspDijkstraLen(’my_route’, 1260<br>
) dj, my_route rt where dj.id2=rt.node;<br>
<br>
my DB warns<br>
<br>
ERROR: cannot concatenate incompatible arrays<br>
DETAIL: Arrays with differing element dimensions<br>
are not<br>
compatible for<br>
concatenation.<br>
CONTEXT: PL/pgSQL function “pgr_makedijkstramatrix”<br>
line 25 at<br>
assignment PL/pgSQL function “pgr_tspdijkstra” line<br>
8 at<br>
RETURN QUERY<br>
PL/pgSQL function “pgr_tspdijkstralen” line 3 at<br>
RETURN QUERY<br>
<br>
********** Fehler **********<br>
<br>
ERROR: cannot concatenate incompatible arrays SQL<br>
Status:2202E<br>
Detail:Arrays with differing element dimensions are not<br>
compatible for<br>
concatenation.<br>
Kontext:PL/pgSQL function “pgr_makedijkstramatrix”<br>
line 25<br>
at assignment<br>
PL/pgSQL function “pgr_tspdijkstra” line 8 at<br>
RETURN QUERY<br>
PL/pgSQL function “pgr_tspdijkstralen” line 3 at<br>
RETURN QUERY<br>
<br>
Do you have any idea what went wrong? I really<br>
really need your<br>
solutionget working. I would appreciate a lot.<br>
<br>
Thanks for your help.<br>
<br>
PS: this text is a copy of what I wrote on on the<br>
comment<br>
site of the<br>
blog where I found the solution.<br>
<br>
BR<br>
Carsten<br>
<br>
<br></div></div>
______________________________<u></u>_____________________<br>
Pgrouting-users mailing list<br>
Pgrouting-users@lists.osgeo.__<u></u>__org<br>
<mailto:<a href="mailto:Pgrouting-users@lists." target="_blank">Pgrouting-users@lists.</a><u></u>__<a href="http://osgeo.org" target="_blank">osgeo.org</a><br>
<mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>>><br>
<a href="http://lists.osgeo.org/____mailman/listinfo/pgrouting-____users" target="_blank">http://lists.osgeo.org/____<u></u>mailman/listinfo/pgrouting-___<u></u>_users</a><br>
<<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a>><br>
<br>
<<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a><br>
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a>>><br>
<br>
<br>
______________________________<u></u>_____________________<br>
Pgrouting-users mailing list<br>
Pgrouting-users@lists.osgeo.__<u></u>__org<br>
<mailto:<a href="mailto:Pgrouting-users@lists." target="_blank">Pgrouting-users@lists.</a><u></u>__<a href="http://osgeo.org" target="_blank">osgeo.org</a><br>
<mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>>><br>
<a href="http://lists.osgeo.org/____mailman/listinfo/pgrouting-____users" target="_blank">http://lists.osgeo.org/____<u></u>mailman/listinfo/pgrouting-___<u></u>_users</a><br>
<<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a>><br>
<br>
<<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a><br>
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a>>><br>
<br>
<br>
______________________________<u></u>_____________________<br>
Pgrouting-users mailing list<br>
Pgrouting-users@lists.osgeo.__<u></u>__org<br>
<mailto:<a href="mailto:Pgrouting-users@lists." target="_blank">Pgrouting-users@lists.</a><u></u>__<a href="http://osgeo.org" target="_blank">osgeo.org</a><br>
<mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>>><br>
<a href="http://lists.osgeo.org/____mailman/listinfo/pgrouting-____users" target="_blank">http://lists.osgeo.org/____<u></u>mailman/listinfo/pgrouting-___<u></u>_users</a><br>
<<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a>><div class=""><br>
<br>
<br>
<<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a><br>
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a>>><br>
<br>
<br>
<br>
<br>
______________________________<u></u>___________________<br>
Pgrouting-users mailing list<br>
Pgrouting-users@lists.osgeo.__<u></u>org<br>
<mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>><br>
<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a><br>
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a>><br>
<br>
<br>
______________________________<u></u>___________________<br>
Pgrouting-users mailing list<br>
Pgrouting-users@lists.osgeo.__<u></u>org<br>
<mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>><br>
<a href="http://lists.osgeo.org/__mailman/listinfo/pgrouting-__users" target="_blank">http://lists.osgeo.org/__<u></u>mailman/listinfo/pgrouting-__<u></u>users</a><br>
<<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a>><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
Pgrouting-users mailing list<br>
<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a><br>
<br>
</div></blockquote><div class=""><div class="h5">
<br>
______________________________<u></u>_________________<br>
Pgrouting-users mailing list<br>
<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a></div></div></blockquote></div><br></div></div>