Try this:
[{"id":"c2ff6bfb.9b2a08","type":"debug","z":"d046350b.4cbc2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":850,"y":220,"wires":[]},{"id":"b17ddf76.3da398","type":"template","z":"d046350b.4cbc2","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"https://foobar.com/api/?poly={{payload}}","output":"str","x":700,"y":220,"wires":[["c2ff6bfb.9b2a08"]]},{"id":"d28a2729.4c81d","type":"split","z":"d046350b.4cbc2","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":310,"y":220,"wires":[["26f845ea.346452"]]},{"id":"26f845ea.346452","type":"template","z":"d046350b.4cbc2","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.latitude}},{{payload.longitude}}","output":"str","x":440,"y":220,"wires":[["d18a3f96.1a2588"]]},{"id":"d18a3f96.1a2588","type":"join","z":"d046350b.4cbc2","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":":","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":570,"y":220,"wires":[["78c37af0.b9e8a4","b17ddf76.3da398"]]}]
It should work for arbitrary array lengths.