lifomapserver/scripts/geojson/fetch_all_points.sh

36 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/bash
json=`curl -s 'https://wiki.linux-forks.de/mediawiki/api.php?action=query&format=json&list=search&redirects=1&converttitles=1&srsearch=%7B%7BCo%7C&srlimit=max&srwhat=text&srprop=snippet'`
data=`echo "$json" | json_reformat`;
echo "[";
IFS=$'\n';
for line in $data; do
temp=`echo "$line" | sed -n 's/^\s*{\s*$/END/p'`
if [[ "$temp" == "END" ]]; then
title="";
coords="";
fi
temp=`echo "$line" | sed -n 's/\s*"title": "*\([^"]\+\).*/\1/p'`
if [[ "$temp" != "" ]]; then
title="$temp";
fi
temp=`echo "$line" | sed -n 's#.*<span class=.searchmatch.>Co<\/span>|\([0-9\-]\+\)|\([0-9\-]\+\)|\([0-9\-]\+\).*#\1,\3#p'`
if [[ "$temp" != "" ]]; then
coords="$temp";
fi
if [[ "$title" != "" && "$coords" != "" ]]; then
echo "{\"type\": \"Feature\", \"properties\": {\"name\": \"$title\","
urltitle=`echo "$title" | sed 's/ /_/g'`
./get_rendered_meta.sh "https://wiki.linux-forks.de/mediawiki/index.php/$urltitle"
echo "},";
echo "\"geometry\": {\"type\": \"Point\", \"coordinates\": [$coords]}},";
title="";
coords="";
fi
done
IFS=" ";
echo "{}]";