source: rdnap/rdnap.pl@ 264

Last change on this file since 264 was 203, checked in by Rick van der Zwet, 14 years ago

Little wrapper, as, the orginal one is gone.

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2#
3# Little wrapper around the usefull Geo::Coordinates::RDNAP cause the Dutch
4# Cadaster Organisation decided to take down their usefull one.
5#
6# License: BSDLike - http://rickvanderzwet.nl/LICENSE
7#
8# Rick van der Zwet <info@rickvanderzwet.nl>
9use lib 'lib';
10use strict;
11use Geo::Coordinates::RDNAP qw/from_rd to_rd dms/;
12
13print "Content-type: text/plain\n\n";
14my @uri = split /\//, $ENV{'REQUEST_URI'};
15if ($#uri lt 5) {
16 print "ERROR in parameters size (example /rdnap/rd2etrs/150.000/480.000/0)\n";
17 exit 1;
18}
19shift(@uri);
20my ($script, $command, $raw1, $raw2, $raw3) = @uri;
21$raw1 =~ tr/_//d;
22$raw2 =~ tr/_//d;
23
24my ($res1, $res2, $res3) = 0;
25
26if ($command eq "rd2etrs") {
27 ($res1, $res2, $res3) = from_rd($raw1, $raw2, $raw3);
28 $res1 = sprintf("%.2f", $res1);
29 $res2 = sprintf("%.2f", $res2);
30 $res3 = sprintf("%.2f", $res3);
31} elsif( $command eq "etrs2rd") {
32 ($res1, $res2, $res3) = to_rd($raw1, $raw2, $raw3);
33 $res1 = sprintf("%.0f", $res1);
34 $res2 = sprintf("%.0f", $res2);
35 $res3 = sprintf("%.2f", $res3);
36} else {
37 print "ERROR in parameters size (example /rdnap/rd2etrs/150.000/480.000/0)\n";
38 exit 1;
39}
40
41print join("/",($res1, $res2, $res3));
42print "\n";
Note: See TracBrowser for help on using the repository browser.