Skip to content

Instantly share code, notes, and snippets.

@yurukov
Last active March 7, 2018 13:04
Show Gist options
  • Save yurukov/983db8fe40a80952365e3ae0f0803a76 to your computer and use it in GitHub Desktop.
Save yurukov/983db8fe40a80952365e3ae0f0803a76 to your computer and use it in GitHub Desktop.
Данни за спирките и линиите на градския транспорт в София
wget https://www.sofiatraffic.bg/interactivecard/lines/1 -O a1
wget https://www.sofiatraffic.bg/interactivecard/lines/2 -O a2
wget https://www.sofiatraffic.bg/interactivecard/lines/3 -O a3
grep -h -o 'for="line[0-9]\+">[^<]\+' a* | sed 's_.*line__;s_">_\t_' > lines
mkdir l
for i in `sed 's_\t.*__' lines|sort -n`; do wget -q -O "l/$i.json" "https://www.sofiatraffic.bg/interactivecard/lines/stops/geo?line_id=$i"; echo -n "."; done
for i in l/*; do echo -e `cat $i` | sed 's_{"geometry":_\n{"geometry":_g' > temp; mv temp $i; done
echo '{"type": "FeatureCollection", "features": [' > stops.geojson
grep -h geometry l/* | sed 's_}}]}_}},_' >> stops.geojson
sed -i '$ s_}},_}}]}_' stops.geojson
grep -o '\[[0-9.]\+, [0-9.]\+]' stops.geojson | sed 's_\[\|\]__g' | sort -nu > coords
for i in {0..130}; do j=`expr 2614 - $i \* 20`; wget -q "https://mygeodata.cloud/data/cs2cs/?incrs=%2Bproj%3Dmerc+%2Ba%3D6378137+%2Bb%3D6378137+%2Blat_ts%3D0.0+%2Blon_0%3D0.0+%2Bx_0%3D0.0+%2By_0%3D0+%2Bk%3D1.0+%2Bunits%3Dm+%2Bnadgrids%3D%40null+%2Bwktext++%2Bno_defs&outcrs=%2Bproj%3Dlonglat+%2Bdatum%3DWGS84+%2Bno_defs+&coords="`tail -$j coords | head -20 | tr '\n' '|' |sed 's_, _%2C_g;s_|_%0A_g'`"&addinput=false&switch=false" -O - | sed 's_{"status": "OK", "data": "\|"}__g;s_;_,_g;s_\\n_\n_g' >> coords_4326; echo -n "."; sleep 1; done
for i in {1..2614}; do c1=`head -$i coords |tail -1 | tr '\n' ' ' | sed 's_ $__'`; c2=`head -$i coords_4326 |tail -1 | tr '\n' ' ' | sed 's_ $__'`; sed -i "s_${c1}_${c2}_g" stops.geojson; echo -n '.'; done
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yurukov
Copy link
Author

yurukov commented Mar 17, 2017

Данните се предоставят във вида, в който са. Използвайте ги както намерите за добре.

@ignisf
Copy link

ignisf commented Mar 7, 2018

Маршрутите могат да се достъпят така: https://www.sofiatraffic.bg/interactivecard/lines/geo?line_id=4155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment