Example: Tesselate_Search UDF

Teradata Vantageā„¢ Geospatial Data Types

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1181-162K

Consider the data in the cities_index table that is inserted using the Tessellate_Index method:

   CREATE TABLE cities_index
      (skey INTEGER
      ,cellid INTEGER);

   INSERT INTO cities_index
   SELECT skey,
      cityShape.Tessellate_Index(-180, 0, 0, 90, 500, 500, 1, 0.01, 0)
   FROM sample_cities;

The following statement uses the Tessellate_Search function with the same universe coordinates and grid specifications that were used by tessellate_index:

   SELECT c.skey, c.cityName, s.streetName, s.streetShape
   FROM sample_cities c
       ,cities_index ci
       ,(SELECT streetName, skey, streetShape ,streetShape.ST_MBR_Xmin()
               ,streetShape.ST_MBR_Ymin(), streetShape.ST_MBR_Xmax()
               ,streetShape.ST_MBR_Ymax()
         FROM sample_streets)
         AS s (streetName, skey, streetShape, xmin, ymin, xmax, ymax)
       ,TABLE (SYSSPATIAL.Tessellate_Search (
                   s.skey
                   ,s.xmin, s.ymin, s.xmax, s.ymax
                   ,-180, 0, 0, 90
                   ,500,500
                   ,1, 0.01, 0)) AS t
   WHERE c.skey = ci.skey
   AND ci.cellid = t.cellid
   AND t.out_key = s.skey;