https://github.com/alifeee/service-stations
map of service stations in the uk and Ireland from https://motorwayservices.uk/
https://github.com/alifeee/service-stations
geojson postcodes service-station
Last synced: about 1 month ago
JSON representation
map of service stations in the uk and Ireland from https://motorwayservices.uk/
- Host: GitHub
- URL: https://github.com/alifeee/service-stations
- Owner: alifeee
- Created: 2024-10-18T15:44:52.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-14T17:12:59.000Z (6 months ago)
- Last Synced: 2025-03-28T16:49:57.161Z (about 1 month ago)
- Topics: geojson, postcodes, service-station
- Homepage: https://geojson.io/#data=data:text/x-url,https%3A%2F%2Fraw.githubusercontent.com%2Falifeee%2Fservice-stations%2Frefs%2Fheads%2Fmain%2Fservice-stations-all.geojson
- Size: 777 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# service-stations
map of service stations in the uk from and Ireland from
view map on geojson.io:
view map on Google Maps:
see more maps on

also view on Google Maps / OSMAnd / Bing Maps / etc with...
## Import to different apps
### Google Maps
create a custom map ([how?](https://www.google.com/maps/about/mymaps/)) and import the `.kml` file above.
### OSMAnd
Import as places to , by downloading the `.gpx` file and uploading it to places.
### Apple Maps
not sure yet...
## Generation
### UK Services
```bash
# get all possible pages from motorway services site
wget "https://motorwayservices.uk/elements/sitemap.xml" -O sitemap.xml
# format sitemap so there is one link per line
sudo apt install libxml2-utils
xmllint --format sitemap.xml > sitemap_reformatted.xml
# search for links that do not look like "File:" or "History:" etc
cat sitemap_reformatted.xml | pcregrep -o1 "(https://motorwayservices.uk/[^:]*)" | sort -h | uniq > pages.txt
# save all sites from sitemap
mkdir pages
while read site; do name=$(echo "${site}" | sed 's/\///g' | sed 's/https:motorwayservices.uk//g'); wget "${site}" -O "pages/${name}.html" --timeout=2 --tries=1; sleep 1; done <<< $(cat pages.txt)
# find postcodes from each HTML page, they look like:
#
Postcode:
#LL57 4BG
pcregrep -ri "[A-Z]{1,2}[0-9]{1,2} ?[0-9]{1,2}[A-Z]{1,2}" pages | pcregrep -o1 -o2 --om-separator="," "pages/(.*)\.html.*
([A-Z]{1,2}[0-9]{1,2} ?[0-9]{1,2}[A-Z]{1,2})" | sort -h > postcodes.csv
# get lat/long coords from postcode using API from https://www.doogal.co.uk/BatchGeocoding
# curl -s 'https://www.doogal.co.uk/GetPostcode/CV10%207DA' | jq '.latitude, .longitude' | paste -sd, -
while read line; do postcode=$(echo "${line}" | csvtool col 2 -); pcurlencoded=$(echo "${postcode}" | sed 's/ /%20/g'); curl -s "https://www.doogal.co.uk/GetPostcode/${pcurlencoded}" | jq '.latitude, .longitude' | paste -sd, - | echo "${line},"$(cat /dev/stdin) | tee -a service-stations-uk.csv; done < postcodes.csv
# add URL to motorwayservices.uk
csvtool col 1 service-stations-uk.csv | sed 's/^/http:\/\/motorwayservices.uk\//' | paste -d, service-stations-uk.csv - > /tmp/coords
mv /tmp/coords service-stations-uk.csv
# add header to CSV
sed -i '1s/^/name,postcode,latitude,longitude,URL\n/' service-stations-uk.csv
# create geojson (see https://gist.github.com/alifeee/60e121a4b55ce1069b003e1d94f0e046)
git clone [email protected]:pvernier/csv2geojson.git
(cd csv2geojson/; go build main.go)
./csv2geojson/main service-stations-uk.csv
# file now is -> service-stations-uk.geojson !
```### Ireland services
```bash
pages.txt
# Irish site has no sitemap, but lists all services when you search for them, as there are not many
wget "https://motorwayservices.ie/Services_Search?reply=yes&country=IE&road=Any&brands=Any&operator=Any&access=Any&rating=None&ratingt=All" -O services_search.html
# tidy HTML so that we can easily grep for links instead of parsing HTML
tidy services_search.html > temp.html; mv temp.html services_search.html
# find all links in table
cat services_search.html | pcregrep -o1 '
# save all sites locally
mkdir pages
while read site; do name=$(echo "${site}" | sed 's/\///g' | sed 's/https:motorwayservices.ie//g'); wget "${site}" -O "pages/${name}.html" --timeout=2 --tries=1; sleep 1; done <<< $(cat pages.txt)
# get eirecodes from each page
pcregrep -ri "[A-Z0-9]{3} ?[A-Z0-9]{4}" pages | pcregrep -o1 -o2 --om-separator="," "pages/(.*)\.html.*
([A-Z0-9]{3} ?[A-Z0-9]{4})" | sort -h > service-stations-ie.csv
# now, we cannot convert Eircodes to latlong coordinates easily, as Eircodes are proprietary(?)
# so, what I did was manually paste each Eircode into Google Maps, refresh the page (to centre the page on the pin), and copy the coordinates from the URL
echo "do it manually :)"
# add URLs
csvtool col 1 service-stations-ie.csv | sed 's/^/http:\/\/motorwayservices.ie\//' | paste -d, service-stations-ie.csv - > /tmp/coords
mv /tmp/coords service-stations-ie.csv
# add header to CSV
sed -i '1s/^/name,eircode,latitude,longitude,URL\n/' service-stations-ie.csv
# create geojson (see https://gist.github.com/alifeee/60e121a4b55ce1069b003e1d94f0e046)
git clone [email protected]:pvernier/csv2geojson.git
(cd csv2geojson/; go build main.go)
./csv2geojson/main service-stations-ie.csv
# file now is -> service-stations-ie.geojson !
```### Combined file
Combine the CSV files
```bash
cat service-stations-uk.csv | awk 'NR>1{print}' > service-stations-all.csv; cat service-stations-ie.csv | awk 'NR>1{print}' >> service-stations-all.csv; sed -i '1s/^/name,postcode\/eircode\/etc,latitude,longitude,URL\n/' service-stations-all.csv
```We can combine geojson files with
```bash
npm install -g @mapbox/geojson-merge
geojson-merge service-stations-uk.geojson service-stations-ie.geojson > service-stations-all.geojson
```Create a gpx file using or similar (search "geojson to gpx")
Create a kml file using