#!/usr/bin/perl # PLSS point ids to addresses, for Orem UT # Author: Dan Jacobson https://www.jidanni.org/ # Copyright: https://www.gnu.org/licenses/gpl.htm # Created: 2024-03-25T03:56:33+0000 # Last-Updated: 2024-03-25T07:19:40+0000 # Update #: 16 # # https://gis.utah.gov/data/address/address-grids/ use strict; use warnings q(all); use PointId2Address; use JSON; my %grid = ( state => "UT", #Just for our example today county => "Utah", municipality => "Orem", origin => { id => 'UT260060S0020E0_500440', #PLSS corner ID of the #(virtual) corner of #Center & Main Sts. address => [ (0) x 2 ] }, num_per_mile => [ (800) x 2 ] ); if (@ARGV) { if ( $ARGV[0] eq "--json" ) { print encode_json \%grid; exit; } if ( $ARGV[0] eq "--points" ) { ## Diagonal for ( -5 .. 5 ) { for ( $_ * 200 ) { printf "%4d E %4d S %s$/", ($_) x 2, PointId2Address::addr2id( \%grid, $_, -$_ ); } } exit; } } while (<>) { print $. , $/; next unless /\d/ && $. == 1; #Skip headers chomp; my @F = split /,/; $grid{target} = { id => $F[2] }; #we wipe out any previous {target}{miles} my @p = PointId2Address::id2addr( \%grid ); die "No address for $_" unless @p; print join ",", @F[ 0, 1 ], "@p"; print $/; }