Here is a basic server side script that does one of your calcs Got me interested. You could pass the array to the server side script and have the script Create a new array back to Witango.
Hey, what can I say, it is interesting ;-) Ben Johansen - http://www.pcforge.com Authorized Witango Reseller http://www.pcforge.com/WitangoGoodies.htm Latest downloads & List Archives @ http://www.witango.ws -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Nathan Hitchcock Sent: Wednesday, July 24, 2002 10:29 AM To: Multiple recipients of list witango-talk Subject: Witango-Talk: Is Witango slow at doing nasty math? Greetings, I've just finished a "dealer locator" app that provides a list of store addresses within X miles to given zip code. It's basically that "show me the closest locations to me" feature that every site seems to have now. While it was not the big of a deal to develop, I'm running into some performance issues, and they seem to revolve around Witango's ability to perform complex triginomic calculations. Here's the code that seems to be slowing it down: <@ROWS ARRAY="local$matches"> <@! define variables > <@ASSIGN NAME="lat2" SCOPE="local" VALUE='<@COL 2>'> <@ASSIGN NAME="long2" SCOPE="local" VALUE='<@COL 3>'> <@! calc distance in kilometers > <@ASSIGN NAME="x" SCOPE="local" VALUE='<@CALC EXPR="(sin(@@local$lat1 * @@local$pi / 180) * sin(@@local$lat2 * @@local$pi / 180) + cos(@@local$lat1 * @@local$pi / 180) * cos(@@local$lat2 * @@local$pi / 180) * cos(abs((@@local$long2 * @@local$pi / 180)-(@@local$long1 * @@local$pi / 180))))">'> <@ASSIGN NAME="x" SCOPE="local" VALUE='<@CALC EXPR="atan((sqrt(1-(@@local$x*@@local$x)))/@@local$x)">'> <@ASSIGN NAME="dist_km" SCOPE="local" VALUE='<@CALC EXPR="1.852 * 60.0 * ((@@local$x/@@local$pi)*180)">'> <@! convert distance to miles > <@ASSIGN NAME="dist_mi" SCOPE="local" VALUE='<@CALC EXPR="@@local$dist_km / 1.609344">'> <@! add row to array with distances > <@ASSIGN NAME="row_str" SCOPE="local" VALUE='<@COL 1>,<@COL 2>,<@COL 3>,@@local$dist_mi,<@OMIT STR="<@COL 4>" CHARS=",">,<@OMIT STR="<@COL 5>" CHARS=",">,<@OMIT STR="<@COL 6>" CHARS=",">,<@COL 7>,<@COL 8>'> <@ADDROWS ARRAY="local$matches2" VALUE="<@ARRAY ROWS='1' COLS='9' VALUE='@@local$row_str'>"> </@ROWS> The "matches" array is generated by finding all locations that fit within a pair of lattitude and logitude corrdinates that were calculated in a previous step. Basically, the user enteres a zip code and a desired distance from that zip code and it finds all addresses within that area, leaving you with the "matches" array. The code above then takes that array and determines the exact distance from the target zip code so it can sort the list accordingly. This array can contain anywhere from just a few addresses to thousands. Any thing under about 100 matches it can process in about 3 seconds or less. More than about 100, and the user is twiddling their thumbs in wait. Here's some times I've logged with the assistance of the <@TIMER> tag. MATCHES TIME(MS) 58 1166 79 2033 148 6950 206 12700 291 23617 320 28450 660 113733 Server Specs: Dual 500 PIII, 500 MB Ram, running Win NT 4.0 Does this seem like an excessivly long time to do this kind of math, or is it just me? Would I be better off writing this particular bit of code so that SQL does the math? ________________________________________________________________________ TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED] with unsubscribe witango-talk in the message body
ScriptTest.taf
Description: Binary data
