# wget https://s3.amazonaws.com/metro-extracts.mapzen.com/london_england.osm.pbf

osmosis=../osmosis/bin/osmosis

$osmosis \
   --read-pbf london_england.osm.pbf \
   --tf accept-nodes amenity=pub \
   --tf reject-ways \
   --tf reject-relations \
   --write-xml pub-nodes.osm

$osmosis \
   --read-pbf london_england.osm.pbf \
   --tf accept-ways amenity=pub \
   --tf reject-relations \
   --used-node \
   --write-xml pub-ways.osm

$osmosis \
   --read-xml pub-nodes.osm \
   --read-xml pub-ways.osm \
   --merge \
   --write-xml pubs.osm

../osmconvert pubs.osm --all-to-nodes > pubs-all-nodes.osm

../osmconvert pubs-all-nodes.osm --csv="@lon @lat name" > pubs.csv

#grep tree pubs.csv | grep -v Street > treepubs.csv
#grep Tree pubs.csv >> treepubs.csv
#grep bush pubs.csv >> treepubs.csv
#grep Bush pubs.csv >> treepubs.csv

#Update: let's match on tree types too
grep -Ei "\btree|\bbush|\bAlder\b|\bApple\b|\bAsh\b|\bAspen\b|\bBeech\b|\bBirch\b|\bBlackthorn\b|\bBuckthorn\b|\bCedar\b|\bCherry\b|\bChestnut\b|\bCrab apple\b|\bCypress\b|\bDogwood\b|\bElder\b|\bElm\b|\bEucalyptus\b|\bFir\b|\bHawthorn\b|\bHazel\b|\bHemlock\b|\bHolly\b|\bHornbeam\b|\bJuniper\b|\bLarch\b|\bLime\b|\bMaple\b|\bMonkey puzzle\b|\bOak\b|\bPear\b|\bPine\b|\bPlane\b|\bPlum\b|\bPoplar\b|\bRowan\b|\bSilver Birch\b|\bSpindle\b|\bSpruce\b|\bSycamore\b|\bWalnut\b|\bWhitebeam\b|\bWillow\b|\bYew\b" pubs.csv > treepubs.csv
