#!/usr/bin/perl
# PLSS Township wanted list.
# Yes, we could add a check to see if we got all that we requested...
# Author: Dan Jacobson https://www.jidanni.org/
# Copyright: https://www.gnu.org/licenses/gpl.htm
# Created: 2023-12-06T04:10:04+0000
# Last-Updated: 2023-12-06T04:40:54+0000
#     Update #: 7
#
use strict;
use warnings q(all);
use PointId2Address;

=pod
=head1 Burkle

"The west-east Centerline of North Dakota is between Townships 145 and
146. This center line is called Main Street. The South-North Center
line of North Dakota is between Ranges 77 and 78. This is called
Center Avenue."

Well, we could download township outlines from the BLM, but in fact
all we need are one section from each to get its corner and thus the
corner of the entire township.

We recall that the north and west edges of a township absorb surveying
errors sometimes, not let's get the southeast corners, i.e., we are
looking for the SE corners of sections 36.

As these will be _700100, expect to find them as _100100 of the next
township east when our program returns them to us.

Let's get strips of townships along both axes.

=cut

# T&R nos. from http://www.earthsurvey.us/maps/mobile.html

my %h = (    #Maybe we should instead make our points on the southern
             #border, as that will get the most BLM replies. But then we
             #face the Sisseton Reservation disturbance.
    t => [ [146], [ 129 .. 164 ] ],
    r => [ [-78],
        [ -107 .. -48 ] ]  #But only -103 at north end. SE corner to 47 partial.
);
my %wants
  ; #A hash, so we can remove the doubled node at the origin where the two axes meet.
for ( 0, 1 ) {
    $wants{$_}++
      for PointId2Address::twsp_blanket(
        {
            state    => "ND",
            meridian => "05",
            T        => $h{t}[$_],
            R        => $h{r}[ !$_ ],
            S        => [36]
        }
      );
}
print STDERR "Total wanted: ", scalar keys %wants, ".\n";
print join "%7C", sort keys %wants;