source: josm/trunk/test/generate-proj-data.pl@ 8991

Last change on this file since 8991 was 4277, checked in by bastiK, 13 years ago

new test comparing josm projections with Proj.4 data

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.3 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6print "# Reference data created by proj.4\n";
7print "#\n";
8print "# code,lat,lon,east,north\n";
9for my $in (<>) {
10 # input data looks like this: "EPSG:4326 Bounds[-90.0,-180.0,90.0,180.0]"
11 # (created by ProjectionRefTest.java)
12 next unless $in =~ /EPSG:([0-9]+) Bounds\[(.*),(.*),(.*),(.*)\]/;
13 my ($epsg, $minlat, $minlon, $maxlat, $maxlon) = ($1, $2, $3, $4, $5);
14 next if $epsg =~ /325.../; # strange codes, don't seem to exist
15 next if $epsg eq '4326'; # trivial, but annoying, because output isn't in meters
16 next if $epsg =~ /^2756[1-4]$/; # proj.4 seems to give wrong results for Lambert 4 zones (missing grid shift file?)
17 if ($epsg eq '3059') { # proj.4 cannot handle the wider bounds that are built into josm
18 ($minlat, $minlon, $maxlat, $maxlon) = (55.64,20.98,58.12,28.23);
19 }
20 #print "$epsg: ($minlat, $minlon, $maxlat, $maxlon)\n";
21
22 for (1 .. 3) {
23 my $lat = rand() * ($maxlat - $minlat) + $minlat;
24 my $lon = rand() * ($maxlon - $minlon) + $minlon;
25
26 open PROJ4, "echo \"$lon $lat\" | cs2cs +init=epsg:4326 +to +init=epsg:$epsg -f %.9f |" or die;
27 my $res = <PROJ4>;
28 die unless $res =~ /(\S+)\s+(\S+)\s/;
29 print "EPSG:$epsg,$lat,$lon,$1,$2\n";
30 close PROJ4 or die "error: $! $?";
31 }
32
33}
Note: See TracBrowser for help on using the repository browser.