Texis Web Script source code for: /texis/site/demos/map/
Note: Click on links to view the documentation for HTML tags which are special to the Vortex compiler.
<script language=vortex>
<db=/usr1/demo/ns>
<timeout=-1></timeout>
<export $lons $lats $cnts>
<export $uquery url userok>
<uses demonav=demonav><!--simple look and feel module-->

<a name=help>
<center>
<table width=350><tr><td>
The idea for this code example stems from an intelligence application that Thunderstone
worked on in the 80s to correlate the actions of people affiliated with drug
trafficking. 
<p>
It's also interesting on the web too. Try queries like <examples> and you 
should see the correlation between the physical locations that match your query.
<p>
This example demonstrates our unique ability to easily perform complex 
text-retrieval and relational database interactions. This GIS application
was done in less than 250 lines of Texis Web Script code.
<p>
If you are interested in doing something similar yourself then read the
"How it Works" below, and also read through the <A
HREF="/texis/site/tutorial/vxgeo2code.html">section
in the tutorial on geographic searches</A>
<p>
<b>How it Works:</b>
<p>
We have two Texis tables:<p>
The first has Domain Registration data and distilled Web site content that was
obtained 
with our web-crawler <small>(<a href=/texis/site/pages/webinator.html>Webinator</a>)</small> . 
<p>
The second table
has a list of US cities, their longitude, latitude, and population.
<p> 
1: We search the Web site table for your keywords.<p>
2: The City and State are extracted from each match.<p>
3: Group the answers by matches per city.<p>
4: The Longitude and Latitude of each City is looked up.<p>
5: Create a GIF image of North America and plot red-dots that correspond in size to 
   the number of matches.<p>
6: Create the image hyperlink data so you can click on the dots.
  
</td></tr></table>
</center>
</a>


<a name=examples>
<a href=$urlroot?uquery=mountain+climbing>mountain climbing</a>,
<a href=$urlroot?uquery=nuclear+testing>nuclear testing</a>,
<a href=$urlroot?uquery=steel+mill>steel mill</a>, or
<a href=$urlroot?uquery=drilling+for+oil>drilling for oil</a>
</a>

<!----------------------------------------------------------------------------
      Header and Footer HTML
------------------------------------------------------------------------------>

<a name=hdr>
  <demolook title="Thunderstone Texis Code Examples: Web Indexing & GIS Example">
</a>

<a name=ftr>
  <hr>
  <h6 align=right><a href=/>Copyright © 1996 Thunderstone - EPI, Inc.</a></h6>
  </demolook>
</a>

<!----------------------------------------------------------------------------
      The Search Form
------------------------------------------------------------------------------>


<a name=sform>
<form method=post action=$urlroot/>
<input type=submit value="Find:"><input name=uquery size=35 value="$uquery">
<input type=hidden name=Start value="0">
</form>
</a>



<!----------------------------------------------------------------------------
      Generate the map gif file
------------------------------------------------------------------------------>

<a name=themap PUBLIC>
<header name=Content-Type value=image/gif>
<$label= ( 'label=' + $uquery + ' Web Sites' )>
<exec BIN /usr1/demo/ns/gis/domap $label>
 <loop $lons $lats $cnts>
   $lats -$lons $cnts
 </loop></exec><fmt "%s" $ret>
</a>

<!----------------------------------------------------------------------------
      The Search
------------------------------------------------------------------------------>

<a name=search>
<if $uquery neq "">
  <strfmt "http://search.thunderstone.com/texis/websearch15/gisearch.txt?q=%U" $uquery>
  <fetch urls=$ret />
  <lower $ret>
  <rex "[^\x0d\x0a]+" $ret />
  <uniq $ret>
  <$City=$ret>
  <uniqcount>
  <$cnt=$ret>
  <sort $cnt NUM DESC $City> 
  <loop max=25 $City $cnt>
  <sql max=1 "select Lon,Lat from city where Place\State like3 $City">
     <$lons=$lons $Lon>
     <$lats=$lats $Lat>
     <$cnts=$cnts $cnt>
     <$ctys=$ctys $City>
  </sql>
  </loop>
  <if $loop eq 0>
     <h3> Nothing matches $uquery</h3>
     Try using fewer or different terms.
  <else>
    <sort $cnts NUM DESC $ctys $lons $lats> 
     <center>
        <img lowsrc=/site/demos/gis/wait.gif src=$url/themap.gif usemap="#pins" width=550 height=500 border=0>
     </center>
     <loop $lons $lats $ctys $cnts >
         <br>
	 <sum %d 0 $cnts><!-- Coz kai doesn't think it's int -->
         <switch $ret>
           <case gt 5> <big>
           <case gt 3>
           <case gt 1> <small>
         </switch>
         <a href=$url/clickmap.html?x=-$lons&y=$lats>$ctys</a>
         <switch $ret>
           <case gt 5></big>****
           <case gt 3>***
           <case gt 1></small>** 
         </switch>
     </loop>
     <flush> 
     <strfmt 'url=%s/clickmap.html' $url>
     <exec BIN /usr1/demo/ns/gis/domap "imagemap=1" $ret >
        <loop $lons $lats $cnts>
            $lats -$lons $cnts
        </loop>
     </exec>
     <map name="pins">
       <send $ret>
     </map>
  </if>
<else>
   <help>
</if>
</a>
<!----------------------------------------------------------------------------
      What happens when you click on the map points
------------------------------------------------------------------------------>

<a name=clickmap PUBLIC>
<hdr>
<center>   
<sform>
<hr>
<table border=0>
<tr><td valign=top>
   <$x= ($x * -1)>
   <sql max=1 "select * from city where Lat=$y and Lon=$x"></sql>
   <$uquery= ($uquery + ' ' + $Place + ' ' + $State)>
   <strfmt "http://search.thunderstone.com/texis/websearch15/?q=%U&form=n" $uquery>
   <fetch urls=$ret />
   <base href=http://search.thunderstone.com/texis/websearch15/>
   <send $ret> 
</td><td valign=top>
   <$lon= ($x/10000)>
   <$lat= ($y/10000)>
   <center> 
   <b>$Place, $State USA</b><br>
   Population: $Pop<br>
   <small>
      $lat degrees North / $lon degrees West<br>
      Websites containing the term(s): <b>$uquery</b><br>
   </small>
   <br>
   <table>
   <tr><th align=left>Nearby Cities</th><th>State</th><th>Population</th></tr>
   <$yhi=($y+2000)>
   <$ylo=($y-2000)>
   <$xhi=($x+2000)>
   <$xlo=($x-2000)>
   <sql "select * from city 
         where Lat between $ylo and $yhi
         and   Lon between $xlo and $xhi
         order by Pop desc
        ">
      <tr><td>$Place</td><td>$State</td><td align=right>$Pop</td></tr>           
   </sql>
   </table>
   </center>
</td></tr></table>
<ftr>
</a>

<!----------------------------------------------------------------------------
      The main entry point
------------------------------------------------------------------------------>

<a name=main PUBLIC>
<capture><search></capture><$srchout=$ret>
<hdr>
<center>
<sform>
</center>
<fmt %s $srchout>
<ftr>
</a>


</script>

Back to the Code Example List

The Source Viewer is also a Code Example.
Click Here to see its source.
Copyright © 1992-1999 Thunderstone Software
Copyright © 2024 Thunderstone Software LLC. All rights reserved.