Thread View: att.lang.c++
2 messages
2 total messages
Started by TeKiT
Wed, 20 Feb 2002 09:13
Programming mercator projection
Author: TeKiT
Date: Wed, 20 Feb 2002 09:13
Date: Wed, 20 Feb 2002 09:13
5 lines
1316 bytes
1316 bytes
Hello... I must add to one of my project the projection of mercator .... Anyone have done this before ??? Is there a library for that ?? Thxs
Re: Programming mercator projection
Author: Maurizio Loreti
Date: Wed, 20 Feb 2002 12:42
Date: Wed, 20 Feb 2002 12:42
153 lines
7370 bytes
7370 bytes
"TeKiT" <tekit@noos.fr> writes:
> I must add to one of my project the projection of mercator ....
> Anyone have done this before ???
"Mercator" is a geographical representation essentially linear in
longitude and logarithmic in the tangent of the latitude. It is
conformant, i.e. at any intersection of longitude and latitude it
maintains all angular relationships. The included Encapsulated
PostScript file has been hand written by me four years ago for a
friend (is this in-topic WRT cern.c++? :-)
-------------Begin included file: merc.eps
%!PS-Adobe-1.0 EPSF-1.0
%%Title: merc.eps
%%Creator: Maurizio Loreti
%%CreationDate: February 16, 1998
%%BoundingBox: 0 0 380 340
%%Pages: 0
%%DocumentFonts: Helvetica
%%Magnification: 1.0000
%
% Generate a small Mercator grid
%
% Author: Maurizio Loreti, aka MLO or (HAM) I3NOO
% Work: University of Padova - Department of Physics
% Via F. Marzolo, 8 - 35131 PADOVA - Italy
% Phone: ++39(49) 827-7216 FAX: ++39(49) 827-7102
% EMail: loreti@padova.infn.it
% WWW: http://wwwcdf.pd.infn.it/~loreti/mlo.html
%
%%EndComments
%%EndProlog
/white 10 def % Leave a 10pt white border
/text 6 def % Height of the text (6pt)
/thickline 0.5 def % Thick lines are 0.5pt,
/thinline 0.1 def % thin lines 0.1pt wide
/offset 0.5 def % Label offset (both x and y)
white white translate
/width 360 def % Width of the map
/height 320 def % Height of the map
% The height of the BoundingBox is the height of the map, plus the height
% of the white border, plus the height of the text, plus 3pt whitespace;
% the width of the BoundingBox is the width of the map, plus twice the
% width of the white border
/wmiddle width 2 div def % Middle height and width
/hmiddle height 2 div def % of the map
/str 10 string def % Define a string 10 bytes long
/Helvetica-Narrow findfont % Set font to 6pt
text scalefont setfont % Helvetica-Narrow
% Define an array tans[0]..tans[8]; initialise yscale to 0
/tans 8 array def
/yscale 0 def
% Loop on i=0..7; compute x=10..80, then c=ctan(x); store in the
% array ctan[i] the running sum of the c's.
0 1 7 { % Stack content: i
dup % i i
1 add 10 mul % i x
dup % i x x
cos exch % i cos(x) x
sin div % i c
yscale add dup % i yscale+c yscale+c
/yscale exch def % yscale <-- yscale+c
tans % i yscale+c tans
3 1 roll % tans i yscale+c
put % <empty>
} for
/yscale hmiddle yscale div def
% Draw the map
newpath
% First: equator
thickline setlinewidth % Set thick lines
0 hmiddle moveto
width hmiddle lineto stroke
% Second: vertical lines, one every 30 degrees
0 30 width { % Stack content: x
dup 90 mod 0 eq { % if (mod(x,90)==0) continuous
[] 0 setdash % line, else dotted line
}{
[4 3] 0 setdash
} ifelse
dup 180 mod 0 eq { % if (mod(x,180)==0) the line
thickline setlinewidth % is thick; thin otherwise.
}{
thinline setlinewidth
} ifelse
dup dup dup % Stack content: x x x x
0 moveto height lineto stroke % x x
offset add hmiddle offset add moveto % x
10 str cvrs % (x)
show % <empty>
} for
% Third: horizontal lines, ove every 10 degrees from -80 to 80
0 hmiddle translate % Move the origin
0 1 7 { % for i = 0, 1, ...7
dup 7 eq { % Use dashed thin lines if i
[] 0 setdash % is not 7; continuous thick
thickline setlinewidth % lines otherwise.
}{
[4 3] 0 setdash
thinline setlinewidth
} ifelse
dup 6 eq { % Skip the label for 70 degrees
tans exch get % Stack content: tans[i]
yscale mul dup % y y
0 exch moveto % y
width exch lineto stroke % <empty>
}{
dup % Stack content: i i
1 add 10 mul exch % x i
tans exch get % x tans[i]
yscale mul dup dup dup % x y y y y
0 exch moveto % x y y y
width exch lineto stroke % x y y
3 1 roll % y x y
offset add wmiddle offset add exch moveto % y x
dup 10 str cvrs % y x (x)
show % y x
neg exch neg dup dup % -x -y -y -y
0 exch moveto % -x -y -y
width exch lineto stroke % -x -y
offset add wmiddle offset add exch moveto % -x
10 str cvrs % (-x)
show % <empty>
} ifelse
} for
%%Trailer
-------------End included file: merc.eps
--
Maurizio Loreti - Linux Is Not UniX - http://www.pd.infn.it/~loreti/mlo.html
Univ. of Padova, Dept. of Physics - Padova, Italy loreti@pd.infn.it
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads