distgeocode: greatcircle ok , pythagorean wrong

Post Reply
bart
Posts: 251
Joined: Wed Apr 26, 2000 12:42 am

distgeocode: greatcircle ok , pythagorean wrong

Post by bart »

The attached code snippet produces incorrect distances when using the 'pythagorean' option to calulate distance, but is correct under 'great circle'. There are no indexes on my test tables. Texis version 05.01.1109947850 .

<$cat=($cat+ '%' )>
<apicp allinear 1>
<$null="">
<if $q neq "" and $where eq "">
<$cat="">
</if>
<sql row max=50 "select distgeocode(Geo, $curgeo, 'pythagorean' ) distance,
Link,Title,Body,City,State
from mytable where tablecat matches $cat and Title\Body like $q order by 1">
<div class=result>
<a href=$Link><b><fmt %s $Title></b></a> ($City,$State - <fmt "%.1f miles" $distance> )<br>
<fetch "" $Body>
<urltext>
<rex ">>=.{,160}[^\space]*" $ret>
$ret ...
</div>
<br>
</sql>
bart
Posts: 251
Joined: Wed Apr 26, 2000 12:42 am

distgeocode: greatcircle ok , pythagorean wrong

Post by bart »

I did some more research, and it pretty clear what the problem is with pythagorean. Im curious about the following though:

<script language=vortex>
<a name=main>
<$sch="
csv
keepfirst
field lon long 1
field lat long 2
">
<$points="
-810000 , 410000
-810100 , 410000
-810100 , 410100
-810000 , 410100
-810000 , 410000
-820000 , 410000
-820000 , 420000
">
<timport row $sch $points>
<geo2code $lat $lon>
<$geo=$ret>
<if $llat neq "">
<$pythagoras=(distgeocode($lgeo, $geo, 'pythagorean' ))>
<$greatcircle=(distgeocode($lgeo, $geo))>
$llon,$llat to $lon,$lat= pythagorean:$pythagoras great-circle:$greatcircle<fmt "<br>\n">
</if>
<$lgeo=$geo>
<$llon=$lon>
<$llat=$lat>
</timport>
</a>
</script>

Produces:

-810000,410000 to -810100,410000= pythagorean:0.0177778 great-circle:0.926446
-810100,410000 to -810100,410100= pythagorean:0.0177778 great-circle:1.22747
-810100,410100 to -810000,410100= pythagorean:0.0177778 great-circle:0.926196
-810000,410100 to -810000,410000= pythagorean:0.0177778 great-circle:1.22747
-810000,410000 to -820000,410000= pythagorean:0.995556 great-circle:51.8807
-820000,410000 to -820000,420000= pythagorean:1.00444 great-circle:69.3521

Can you explain the great circle answers? Is this because of limited resolution in the geocode?

Oyeah! as long as you're in there fixing the code, would you mind adding the function to give direction as well as distance? Degrees would be great, but ill settle for NSEW.

TIA
User avatar
jason112
Site Admin
Posts: 347
Joined: Tue Oct 26, 2004 5:35 pm

distgeocode: greatcircle ok , pythagorean wrong

Post by jason112 »

> Can you explain the great circle answers?
> Is this because of limited resolution in the geocode?

Could be a problem with occuring at internal boundaries
of geocode, I'll trace through the code and see what's
going on.

> Oyeah! as long as you're in there fixing the code, would
> you mind adding the function to give direction as well
> as distance?

The function <code2bearing> has already been planned. :) Will try to get that out soon.
Post Reply