Everything works fine now in my Tomcat 5.5.17.
Naturally, the NullPointerExceptions on your webserver disappeared
after I submitted my last post.
Previously I thought fsps were just another nice-to-have. However, I
am positively surprised - FSPs make playing with frink much more
enjoyable. In my humble opinion it's similar to, but more comfortable
than, the "Programming Mode" in the frink AWT GUI.
>
> I have written several libraries and sample programs that may help
> you in this:
>
> High-accuracy navigation libraries for lat/long manipulation,
> including very accurate algorithms for navigation on an ellipsoidal
earth:
> http://futureboy.us/fsp/colorize.fsp?fileName=navigation.frink
>
> A web page that uses this library (and draws maps in Google Maps and
> Google Earth once you put numbers into the forms.) Use the "view
> source" link at bottom.)
> http://futureboy.us/fsp/geocaching.fsp
>
> Program to write very simple Google Earth .kml files (currently just
> one point.)
> http://futureboy.us/fsp/colorize.fsp?fileName=GoogleEarth.frink
>
> And a FSP page that uses the above library to render the kml file:
> http://futureboy.us/fsp/highlight.fsp?fileName=GoogleEarth.fsp
> (this is called from geocaching.fsp)
Nice - I'll have a look at this, or try it ASAP.
>> So, maybe I'll create a ajax-y Google maps App that calls my custom
fsp behind the scenes. Fun!
Maybe I'll write/generate some javascript right inside the FSP. Maybe
I'll write another non-fsp page that consumes the results from the FSP.
>
> I wish you luck on it! I'd be interested in seeing it!
>
FYI: Now I have this ... a customized solar.fsp
Sun diameter: 2m.
The Coordinates are chosen so that the scaled inner solar system can
be aligned along a N-S passing street in Potsdam, Germany. Does not
have to be high accuracy.
The FSP is 95% your code, but it does almost everything what I wanted
in the first place. The coordinates of the sun are hard-wired, yes.
Dwarf planet data are from wikipedia. I hope I got them right. Sedna's
orbit is extremely elliptical and not well-known.
How can I round the output of the DM[] function? Does it "conforms" to
anything?
52 degrees, 22.822396234874070424 arcmin
To the format[unit] function I added a "default"
return unit
(unaltered), in case the input is not handled by the if statements.
I hope yahoo does not cripple the html code in this post...
Knut
##########################
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML LANG="en">
<HEAD>
<TITLE>Model Solar System</TITLE>
<META HTTP-EQUIV="Default-Style" CONTENT="Spaceship">
<LINK REL="StyleSheet" HREF="/frinkdocs/spaceship.css"
TYPE="text/css" TITLE="Spaceship">
<LINK REL="Alternate StyleSheet" HREF="/frinkdocs/apeairy.css"
TYPE="text/css" TITLE="APE Airy">
<LINK REL="Alternate StyleSheet" HREF="/frinkdocs/style.css"
TYPE="text/css"
TITLE="APE Classic">
<LINK REL="Alternate StyleSheet" HREF="/frinkdocs/style2.css"
TYPE="text/css"
TITLE="Compact">
<LINK REL="icon" HREF="/images/futureboyicon.png" TYPE="image/png">
</HEAD>
<BODY>
<H1>Model Solar System</H1>
<%
ceresdist = 2.77 au
ceresradius = 975 km / 2
orcusdist = 39.34 au
orcusradius = 946.3 km / 2
quaoardist = 43.607 au
quaoarradius = 1260 km / 2
erisdist = 67.7 au
erisradius = 2400 km / 2
sednadist = 525.86 au
sednaradius = 1500 km / 2
proximacentauridist = 4.22 ly
proximacentauriradius = 0.145 sunradius
betacentauridist = 4.36 ly
betacentauriradius = 0.865 sunradius
alphacentauridist = 4.37 ly // 277600 au
alphacentauriradius = 1.227 sunradius
barnardstardist = 5.98 ly
barnardstarradius = 0.2 sunradius
planets = [["Mercury",mercurydist,2
mercuryradius],["Venus",venusdist,2 venusradius],["Earth",earthdist,2
earthradius],["Mars",marsdist,2 marsradius],["Ceres",ceresdist,2
ceresradius],["Jupiter",jupiterdist,2
jupiterradius],["Saturn",saturndist,2
saturnradius],["Uranus",uranusdist,2
uranusradius],["Neptune",neptunedist,2
neptuneradius],["Pluto",plutodist,2 plutoradius],
["Orcus",orcusdist,2 orcusradius],
["Quaoar",quaoardist,2 quaoarradius],
["Eris",erisdist,2 erisradius],
["Sedna",sednadist,2 sednaradius],
["ProximaCentauri",proximacentauridist,2 proximacentauriradius],
["BetaCentauri",betacentauridist,2 betacentauriradius],
["AlphaCentauri",alphacentauridist,2 alphacentauriradius],
["BarnardsStar",barnardstardist,2 barnardstarradius]]
names = dict[]
names@"scaledSundiam" = 2 sunradius
for [name, dist, diam] planets
{
names@"scaled${name}dist" = dist
names@"scaled${name}diam" = diam
}
scale = undef
for [name] keys[names]
{
enteredscale = eval[name]
if enteredscale
scale = eval[enteredscale] / names@name
}
if (scale != undef)
{
if ! (scale conforms 1)
println["<P CLASS=\"warning\">Error: You must enter a length
<EM>including</EM> the units of measure, like <CODE CLASS=\"input\">1
foot</CODE>.</P>"]
else
{
println["<H3>Scale Sizes</H3>"]
println["<P>Scale is 1:" + round[1/scale,1] + "</P>"]
%>
<TABLE BORDER=1 CELLPADDING=4>
<TR><TH>Name</TH><TH>Distance from
Sun</TH><TH>Diameter</TH><TH>Geogr. Coord.
<TR><TD>Sun</TD><TD></TD>
<TD><%= format[2 sunradius scale] %></TD>
<TD>(52° 22' 46.65'' N, 13° 03' 57.32 E)</TD>
<%
for [name, dist, diam] planets
{
println["<TR><TD>$name"]
println["<TD>"+ format[dist scale]]
println["<TD>"+ format[diam scale]]
geolat = DM[DMS[52, 22, 46.65] + dist/earthradius * scale]
if (dist * scale conforms meter)
{
println["<TD>" + format[geolat] + " N, 13° 03' 57.32 E
</TD>" ]
}
} %>
</TABLE>
<P><B>Scaled speed of light: </B> <%= format[c scale] %></P>
<HR>
<%
}
}
format[unit] :=
{
if (unit conforms meter)
{
if (unit > 1 km)
return round[unit, .0001 km] -> ["km", "m"]
if (unit > 1 m)
return round[unit, .001 m] -> ["m", "cm"]
if (unit > .1 m)
return round[unit, .0001 m] -> ["cm"]
return round[unit, .001 mm] -> "mm"
}
if (unit conforms mph)
{
if (unit > 0.1 mph)
return format[unit, "km/hour", 3]
return format[unit, "km/hour", 3]
}
return unit
}
//from the units.txt file
//DMS[d,m=0,s=0] :=
//{
// if d<0 degrees
// -(-d degrees + m arcmin + s arcsec)
// else
// d degrees + m arcmin + s arcsec
//}
%>
<H3>Define Your Scale</H3>
<P>
This page calculates the sizes of objects in a
model solar system.</A>
</P>
<P>
To determine a scale, enter a scaled size in <B>only one</B> of the
boxes
below. The size should be entered <EM>both</EM> as the number
<EM>and</EM>
its units of measurement, for example, if you want Jupiter to be 6
feet 6
inches in diameter, enter <B>6.5 feet</B> or, alternately, <B>6
feet + 6
in</B> (the plus sign is necessary) in the box for Jupiter's diameter.
</P>
<P>
You can use just about any length (usually in lowercase) in singular or
plural, such as foot, feet, meter, meters, m, inch, inches, in, miles,
yards, cm, mm, millimeters, centimeters, cm, micrometers,
nanometers, nm,
gigameters, Gm, rods, furlongs, kilometers, km, league, <A
HREF="solar.fsp?scaledPlutodist=marathon">marathon</A>, etc.
</P>
<FORM ACTION="solar.fsp" METHOD="POST">
<TABLE BORDER=0>
<TR><TH>Name<TH>Distance from Sun<TH>Diameter
<TR><TD>Sun<TD><TD><INPUT TYPE="TEXT" NAME="scaledSundiam">
<% for [name, dist, diam] planets
println["<TR><TD>$name<TD><INPUT TYPE=\"TEXT\"
NAME=\"scaled${name}dist\"><TD><INPUT TYPE=\"TEXT\"
NAME=\"scaled${name}diam\">"]
%>
</TABLE>
<INPUT TYPE="SUBMIT" VALUE="Calculate">
</FORM>
</BODY>
</HTML>