chartbundle / charts

Code formerly used for chartbundle.com to crop, tile and present FAA charts.
5 stars 4 forks source link

Range iterator outside integer range at /home/mapserv/bin/thecropper.pl line 423 #3

Closed bkielczewski closed 8 months ago

bkielczewski commented 8 months ago

Thanks for making the code available.

So I have it running with modified Dockerfile and no changes to the code:

FROM debian:bullseye-slim

RUN apt update && apt install -y --no-install-recommends proj-bin proj-data libgdal-perl python3-gdal gdal-bin && rm -rf /var/lib/apt/lists && rm -rf /var/cache/apt

COPY basemap/ /home/mapserv/basemap/
COPY grid/ /home/mapserv/grid/
COPY mapfiles/ /home/mapserv/mapfiles/
COPY perl/ /home/mapserv/perl/

VOLUME /home/mapserv/charts
VOLUME /home/mapserv/bin

Running I'm stuck on this one:

root@939f700189a8:/home/mapserv# ./bin/makemap3.pl 
/home/mapserv/charts/sec/20240125/Honolulu Inset SEC.tif
/home/mapserv/charts/sec/20240125/Western Aleutian Islands West SEC.tif
/home/mapserv/charts/sec/20240125/Chicago SEC.tif
/home/mapserv/charts/sec/20240125/Cincinnati SEC.tif
/home/mapserv/charts/sec/20240125/Cheyenne SEC.tif
/home/mapserv/charts/sec/20240125/Green Bay SEC.tif
/home/mapserv/charts/sec/20240125/Los Angeles SEC.tif
/home/mapserv/charts/sec/20240125/New Orleans SEC.tif
/home/mapserv/charts/sec/20240125/Albuquerque SEC.tif
/home/mapserv/charts/sec/20240125/Twin Cities SEC.tif
/home/mapserv/charts/sec/20240125/Seward SEC.tif
/home/mapserv/charts/sec/20240125/Fairbanks SEC.tif
/home/mapserv/charts/sec/20240125/Memphis SEC.tif
/home/mapserv/charts/sec/20240125/Phoenix SEC.tif
/home/mapserv/charts/sec/20240125/Great Falls SEC.tif
/home/mapserv/charts/sec/20240125/Halifax SEC.tif
/home/mapserv/charts/sec/20240125/Omaha SEC.tif
/home/mapserv/charts/sec/20240125/Detroit SEC.tif
/home/mapserv/charts/sec/20240125/Jacksonville SEC.tif
/home/mapserv/charts/sec/20240125/Samoan Islands Inset SEC.tif
/home/mapserv/charts/sec/20240125/Klamath Falls SEC.tif
/home/mapserv/charts/sec/20240125/El Paso SEC.tif
/home/mapserv/charts/sec/20240125/Hawaiian Islands SEC.tif
/home/mapserv/charts/sec/20240125/Kodiak SEC.tif
/home/mapserv/charts/sec/20240125/Miami SEC.tif
/home/mapserv/charts/sec/20240125/Dallas-Ft Worth SEC.tif
/home/mapserv/charts/sec/20240125/Denver SEC.tif
/home/mapserv/charts/sec/20240125/Atlanta SEC.tif
/home/mapserv/charts/sec/20240125/San Francisco SEC.tif
/home/mapserv/charts/sec/20240125/Brownsville SEC.tif
/home/mapserv/charts/sec/20240125/Las Vegas SEC.tif
/home/mapserv/charts/sec/20240125/Mariana Islands Inset SEC.tif
/home/mapserv/charts/sec/20240125/Salt Lake City SEC.tif
/home/mapserv/charts/sec/20240125/Dawson SEC.tif
/home/mapserv/charts/sec/20240125/Dutch Harbor SEC.tif
/home/mapserv/charts/sec/20240125/Ketchikan SEC.tif
/home/mapserv/charts/sec/20240125/Billings SEC.tif
/home/mapserv/charts/sec/20240125/Nome SEC.tif
/home/mapserv/charts/sec/20240125/Anchorage SEC.tif
/home/mapserv/charts/sec/20240125/Cold Bay SEC.tif
/home/mapserv/charts/sec/20240125/New York SEC.tif
/home/mapserv/charts/sec/20240125/Montreal SEC.tif
/home/mapserv/charts/sec/20240125/Wichita SEC.tif
/home/mapserv/charts/sec/20240125/Washington SEC.tif
/home/mapserv/charts/sec/20240125/Cape Lisburne SEC.tif
/home/mapserv/charts/sec/20240125/Juneau SEC.tif
/home/mapserv/charts/sec/20240125/Kansas City SEC.tif
/home/mapserv/charts/sec/20240125/Charlotte SEC.tif
/home/mapserv/charts/sec/20240125/Western Aleutian Islands East SEC.tif
/home/mapserv/charts/sec/20240125/San Antonio SEC.tif
/home/mapserv/charts/sec/20240125/Houston SEC.tif
/home/mapserv/charts/sec/20240125/St Louis SEC.tif
/home/mapserv/charts/sec/20240125/Lake Huron SEC.tif
/home/mapserv/charts/sec/20240125/Point Barrow SEC.tif
/home/mapserv/charts/sec/20240125/Bethel SEC.tif
/home/mapserv/charts/sec/20240125/McGrath SEC.tif
/home/mapserv/charts/sec/20240125/Seattle SEC.tif

Processing: /home/mapserv/charts/sec/20240125/Albuquerque SEC.tif
-418330.87674177,42.3343286240037,0,253556.582296931,0,-42.3345738639264
17947 12315 -418330.87674177 -267793.694837323 341443.319073225 253556.582296931
20240125/Albuquerque SEC-o\.tif
Convert: /home/mapserv/charts/sec/20240125/Albuquerque SEC.tif
/home/mapserv/bin/thecropper.pl /home/mapserv/charts/sec/20240125/Albuquerque SEC.tif
Bref_Path: /home/mapserv/charts/bref/Albuquerque SEC.bref
GT: -418330.87674177,42.3343286240037,0,253556.582296931,0,-42.3345738639264
Raster Count: 1
pct2rgb.py /home/mapserv/charts/sec/20240125/Albuquerque SEC.tif /tmp/temp1.26.tif.1.tif
0...10...20...30...40...50...60...70...80...90...100 - done.
gdalwarp -dstalpha /tmp/temp1.26.tif.1.tif /tmp/temp1.26.tif
Creating output file that is 17947P x 12315L.
Processing /tmp/temp1.26.tif.1.tif [1/1] : 0...10...20...30...40...50...60...70...80...90...100 - done.
17947 12315 -418330.87674177 -267793.694837323 341443.319073225 253556.582296931
Using Bref: /home/mapserv/charts/bref/Albuquerque SEC.bref
REF: /home/mapserv/charts/bref/Albuquerque SEC.bref
Range iterator outside integer range at /home/mapserv/bin/thecropper.pl line 423.
        ...propagated at /home/mapserv/bin/thecropper.pl line 578.
/home/mapserv/bin/thecropperblah.pl /home/mapserv/charts/sec/20240125/Albuquerque SEC.tif
Bref_Path: /home/mapserv/charts/bref/Albuquerque SEC.bref
GT: -418330.87674177,42.3343286240037,0,253556.582296931,0,-42.3345738639264
Raster Count: 1
pct2rgb.py /home/mapserv/charts/sec/20240125/Albuquerque SEC.tif /tmp/temp1.29.tif.1.tif
0...10...20...30...40...50...60...70...80...90...100 - done.
gdalwarp -dstalpha /tmp/temp1.29.tif.1.tif /tmp/temp1.29.tif
Creating output file that is 17947P x 12315L.
Processing /tmp/temp1.29.tif.1.tif [1/1] : 0...10...20...30...40...50...60...70...80...90...100 - done.
17947 12315 -418330.87674177 -267793.694837323 341443.319073225 253556.582296931
Using Bref: /home/mapserv/charts/bref/Albuquerque SEC.bref
REF: /home/mapserv/charts/bref/Albuquerque SEC.bref
Range iterator outside integer range at /home/mapserv/bin/thecropperblah.pl line 421.
        ...propagated at /home/mapserv/bin/thecropperblah.pl line 576.
Child: 25 returned 61952 at /home/mapserv/perl/Spork.pm line 47.

Backtracking:

my $pixlength = int( sqrt(($refbox[$cki]->{'x_p'} - $refbox[$ckj]->{'x_p'} )**2  + 
              ($refbox[$cki]->{'y_p'} - $refbox[$ckj]->{'y_p'} )**2  ) /6.3 ) ;

= Inf

( $refbox[$refcount]->{'x_p'}, $refbox[$refcount]->{'y_p'} ) = xy_gt( $refbox[$refcount]->{'x_m'}, $refbox[$refcount]->{'y_m'}, @igt );

= NaN, NaN

    ( $refbox[$refcount]->{'x_m'},
      $refbox[$refcount]->{'y_m'} )  =
    @{$invreproj->TransformPoint($x,$y)};

= Inf, Inf

Help? If I reverse $x, $y for TransformPoint (it seems in bref is lon lat and transformpoint expects lat lon) it proceeds further. But then:

gdalwarp -wm 128 -r cubic -co COMPRESS=DEFLATE -co PREDICTOR=2 -co TILED=YES -cutline /home/mapserv/charts/sec/20240125/Cape Lisburne SEC-ca.vrt -crop_to_cutline -t_srs EPSG:3857 /tmp/temp1.164.tif /home/mapserv/charts/sec/20240125/Cape Lisburne SEC-ca.tif
Using band 4 of source image as alpha.
Creating output file that is 0P x 0L.
ERROR 1: Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.
gdalwarp: 256 at /home/mapserv/bin/thecropper.pl line 562.
        ...propagated at /home/mapserv/bin/thecropper.pl line 578.
/home/mapserv/bin/thecropperblah.pl /home/mapserv/charts/sec/20240125/Cape Lisburne SEC.tif
Bref_Path: /home/mapserv/charts/bref/Cape Lisburne SEC.bref
IN: /home/mapserv/charts/sec/20240125/Cape Lisburne SEC.tif
Geo::GDAL::Dataset=HASH(0x563e84bd25d0)Child: 163 returned 512 at /home/mapserv/perl/Spork.pm line 47.

What's /home/mapserv/bin/local-gdalwarp, some wrapper over gdalwarp? What does it do?

I'd really appreciate suggestions.

Best, b.

chartbundle commented 8 months ago

local-gdalwarp was just a locally compiled new version to improve memory use. Modern gdalwarp should be fine. Additionally the X/Y change can be resolved with $srout->SetAxisMappingStrategy($Geo::OSR::OAMS_TRADITIONAL_GIS_ORDER); after my $srout = Geo::OSR::SpatialReference->new('EPSG' => 4326) ;

This may also fix your Cape Lisburne issue.

I've made both changes to the repository.

bkielczewski commented 8 months ago

That did it, thank you. My minimal goal is to produce some docker container(s) to build the maps and run the server. I'll share a fork once I get something working.

bkielczewski commented 8 months ago

The fork is https://github.com/bkielczewski/faa-charts