heres an optomization if you use the other distance formula:

distance = squareroot((x2-x1)^2 + (y2-y1)^2)

the square root takes a long time to compute, but the other math doesnt take
too long.  You might thing about squaring both sides and getting..

distance^2 = (x2-x1)^2 + (y2-y1)^2

that should be faster to calculate on the fly than trig and how you would
use it would be if you wanted a list of all locations where the distance was
less than 21, since both sides are squared you would check to see where the
distance was less than 441 (21^2).

When you get your results and want to display actual distances you could
just square root them at that time

----- Original Message ----- 
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 01, 2004 7:33 AM
Subject: Re: Witango-Talk: Distance Calculations - Sort on..., search on...


> Jonah,
>
> to avoid a lot of calculations: I have allready short the formula. The
> enclosed formula was only to show how it works finally.
> Also I store allready the result for "SIN(<@COLUMN 'Adressen.Geo_Breite'>)
/
> COS(<@COLUMN 'Adressen.Geo_Breite'>)" in the database :-))
>
> But this don't help me to make the sort or to make a search in a radius
:-((
>
> regards
>
> Daniel
>
> ----- Original Message ----- 
> From: "Jonah Simpson" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, October 31, 2004 9:10 PM
> Subject: Re: Witango-Talk: Distance Calculations - Sort on..., search
on...
>
>
> > Hey Daniel!
> >
> > What database are you using? I know MySQL can do the trigonometric
> > functions in a select statement and you could order your result from
> > the database...
> >
> > Doing trig functions is pretty gross efficiency wise. You might want
> > to store some of the functions that aren't going to change in your
> > location table. ie. Have columns for:
> > SIN(<@COLUMN 'Adressen.Geo_Breite'>)
> > COS(<@COLUMN 'Adressen.Geo_Breite'>)
> > in the same table that Adressen.Geo_Breite is stored in. As well,
> > pre-calculate:
> > COS(@@User$Breite_1) and
> > SIN(@@User$Breite_1) to avoid doing this calculation 2500 times.
> >
> > You might want to play with that formula and optimize it. I'm not
> > super hot with my trig identites, but I'm sure you could put it into a
> > form that allows you to store as much information in the database as
> > possible. Then you would only have to do a couple of calculations in
> > your actual select statement.
> >
> > Interesting problem...let us know what route you eventually take.
> >
> > Cheers,
> > Jonah Simpson
> > [EMAIL PROTECTED]
> >
> >
> > On Sun, 31 Oct 2004 19:22:39 +0100, [EMAIL PROTECTED]
> > <[EMAIL PROTECTED]> wrote:
> >>
> >> Distance Calculation is no problem, that works. Here the formula:
> >>
> >>
> >> <@CALC EXPR="ACOS(SIN(@@User$Breite_1)*SIN(<@COLUMN
> >> 'Adressen.Geo_Breite'>)
> >> + COS(@@User$Breite_1)*COS(<@COLUMN
'Adressen.Geo_Breite'>)*COS(<@COLUMN
> >> 'Adressen.Geo_laenge'>-@@User$Laenge_1)) * 6378,388" Precision="1">
> >>
> >> The problem what I have is:
> >>
> >> 1) To do a sort of the result (OK, I can do it in a array, but this
need
> >> to
> >> much RAM [more as 2500 records, nearly 50x on one time])
> >>
> >> 2) To do a search in a specified area like "show me all points near x
> >> miles(km).
> >>
> >> One way what make sense is to store the formula in the database, but
> >> - if i make a assign to a variable, then Witango store only the result.
> >> What
> >> I like to store is the formula-text:
> >>
> >>
> >> Second problem: I can't do a sort on the stored formula (Sort command:
> >> <@COLUMN 'Adressen.formel' Encoding="Metahtml">)
> >>
> >> Any Successions ?
> >>
> >> THX for help
> >>
> >> regards
> >>
> >> Daniel
> >>
> >>
________________________________________________________________________
> >> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> > ________________________________________________________________________
> > TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf
> >
>
> ________________________________________________________________________
> TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to