#!/usr/bin/perl # grat --- set up graticule lines, WKT version # Author: Dan Jacobson https://www.jidanni.org/ # Copyright: https://www.gnu.org/licenses/gpl.html # Created: 2023-09-03T11:01:01+0000 # Last-Updated: 2023-09-27T19:58:48+0000 # Update #: 10 # #set up graticule lines use warnings q(all); use strict; #do only one dimension (only N/S, only E/W), #because the axes might not be perpendicular anyway, #e.g., Highland Park, IL. die "ARGS: House number's Xmin Xmax Ymin Ymax Increment AXIS(0/1)" unless @ARGV == 6; my ( $increment, $axis ) = @ARGV[ 4 .. 5 ]; die "0 will cause loop, dude" unless $increment; my @range; for ( 0, 1 ) { $range[$_] = [ shift, shift ]; my $v = $range[$_][0]; warn "Are you sure you want $v min, that are not a clean \$increment?" if $v % $increment; } my @letter = ( [qw/W E/], [qw/S N/] ); print "WKT,Name\n" unless $ENV{nohead}; # https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry for ( my $i = $range[$axis][0] ; $i <= $range[$axis][1] ; $i += $increment ) { print "\"LINESTRING ("; my @k; for my $m ( 0, 1 ) { my @t = ( $i, $range[ !$axis ][$m] ); push @k, sprintf "%d %d", $axis ? reverse @t : @t; } print join ",", @k; print ")\","; printf "%d%s\n", abs $i, $i ? $letter[$axis][ $i >= 0 ] : join "", reverse @{ $letter[$axis] }; #reverse, so sounds more English }