User Discussions > How To?

Using grep and shell scripts to search highway data, waypoint labels, etc.

<< < (5/5)

yakra:
Open all of a route's intersecting/concurrent routes in the HB
...in however many separate browser tabs centered at each intersecting/concurrent waypoint.
Run this in the appropriate regional subdirectory of hwy_data/:
file=usama/ma.ma003.wpt #or whatever
for url in `cat $file | sed 's~.* ~~'`; do grep $url */*.wpt | grep -v "^$file"; done | sed -r 's~.*/(.*)\.wpt:.*(lat=.*)~https://travelmapping.net/hb/showroute.php?r=\1\&\2\&zoom=16~' | xargs firefox


Named designation with a slash
for rg in `ls | grep -v _`; do
  grep -sv '^+' $rg/*/*.wpt | cut -f1 -d' ' \
  | egrep -v '_|Alt_?[NEWS]?$|Bus_?[NEWS]?$|Byp_?[NEWS]?$|Spr_?[NEWS]?$|Trk_?[NEWS]?$' \
  | grep ':.*[0-9].*/.*[A-Z][a-z]'
done

for rg in `ls | grep -v _`; do
  grep -sv '^+' $rg/*/*.wpt | cut -f1 -d' ' \
  | egrep -v 'Alt_?[NEWS]?$|Bus_?[NEWS]?$|Byp_?[NEWS]?$|Spr_?[NEWS]?$|Trk_?[NEWS]?$|:[A-Za-z]{3,4}/[A-Za-z]{3,4}$' \
  | grep ':.*[0-9a-z].*[A-Z].*/.*[A-Z][a-z]'
done
Putting two highways in a waypoint label

--- Quote ---If you encounter the need for using both a named and numbered designation in the waypoint label, or the need for two named designations, pick only one of the two for brevity. I-95/New Jersey Turnpike becomes I-95.
--- End quote ---


Potential continuing highways that should be "End"
for rg in `ls | grep -v _`; do
  head -n 1 -v $rg/*/*.wpt 2>/dev/null | tr '\n>' ' \n' | sed -e 's~ ~~' -e 's~ <== ~:~' | cut -f1 -d' ' | grep -v ':.*[0-9]' | grep '_[NEWS]$'
  tail -n 1 -v $rg/*/*.wpt 2>/dev/null | tr '\n>' ' \n' | sed -e 's~ ~~' -e 's~ <== ~:~' | cut -f1 -d' ' | grep -v ':.*[0-9]' | grep '_[NEWS]$'
done
Highway ends at non-intersections or non-borders

--- Quote ---For sudden ends at no particular intersection or landmark, the name of the continuing highway can be used if it begins where the highway in question ends, i.e., is not concurrent.
--- End quote ---
Plenty false positives & some false negatives.

yakra:
List routes in a region sorted by number of shaping points
Run this in the appropriate regional subdirectory of hwy_data/:

for f in */*.wpt; do printf '%03i\t' $(grep -c '^+' $f); echo $f; done | grep -v '^000' | sort

yakra:
When you've edited some files and want to find intersecting/concurrent points in other files not edited yet
Helpful for avoiding breaking concurrencies. Changes must be unstaged for this to work.
Run this from HighwayData/ or hwy_data/, or in the regional subdirectory if you didn't go near any borders:

fgrep -rf <(git diff | grep ^- | grep -v '\.wpt$' | sed 's~.* ~~') . | fgrep -vf <(git diff --name-only | cut -f4 -d/)

Downsides:
• Doesn't help with brand new points added to one route in a concurrency.
• Won't find http://www.openstreetmap.org/?lat=42.094226&lon=-75.75703 when you're looking for http://www.openstreetmap.org/?lat=42.094226&lon=-75.757030.

Navigation

[0] Message Index

[*] Previous page

Go to full version