/ Check-in [944e167a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make most geopoly functions pure.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 944e167a98e995c5750c1fcd44df857d6b10c1cbb91731fad2849415c42b2cfc
User & Date: drh 2018-09-28 13:18:24
Context
2018-09-28
14:01
Add the geopoly_regular(X,Y,R,N) function to the geopoly extension. check-in: 4505bbae user: drh tags: trunk
13:18
Make most geopoly functions pure. check-in: 944e167a user: drh tags: trunk
00:16
Rig geopoly to use sqlite3AtoF() if it is available, as that routine is much faster than atof(). check-in: 470c6c07 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/geopoly.c.

  1636   1636     0,                          /* xRollbackTo */
  1637   1637   };
  1638   1638   
  1639   1639   static int sqlite3_geopoly_init(sqlite3 *db){
  1640   1640     int rc = SQLITE_OK;
  1641   1641     static const struct {
  1642   1642       void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
  1643         -    int nArg;
         1643  +    signed char nArg;
         1644  +    unsigned char bPure;
  1644   1645       const char *zName;
  1645   1646     } aFunc[] = {
  1646         -     { geopolyAreaFunc,          1,    "geopoly_area"             },
  1647         -     { geopolyBlobFunc,          1,    "geopoly_blob"             },
  1648         -     { geopolyJsonFunc,          1,    "geopoly_json"             },
  1649         -     { geopolySvgFunc,          -1,    "geopoly_svg"              },
  1650         -     { geopolyWithinFunc,        2,    "geopoly_within"           },
  1651         -     { geopolyContainsPointFunc, 3,    "geopoly_contains_point"   },
  1652         -     { geopolyOverlapFunc,       2,    "geopoly_overlap"          },
  1653         -     { geopolyDebugFunc,         1,    "geopoly_debug"            },
  1654         -     { geopolyBBoxFunc,          1,    "geopoly_bbox"             },
  1655         -     { geopolyXformFunc,         7,    "geopoly_xform"            },
         1647  +     { geopolyAreaFunc,          1, 1,    "geopoly_area"             },
         1648  +     { geopolyBlobFunc,          1, 1,    "geopoly_blob"             },
         1649  +     { geopolyJsonFunc,          1, 1,    "geopoly_json"             },
         1650  +     { geopolySvgFunc,          -1, 1,    "geopoly_svg"              },
         1651  +     { geopolyWithinFunc,        2, 1,    "geopoly_within"           },
         1652  +     { geopolyContainsPointFunc, 3, 1,    "geopoly_contains_point"   },
         1653  +     { geopolyOverlapFunc,       2, 1,    "geopoly_overlap"          },
         1654  +     { geopolyDebugFunc,         1, 0,    "geopoly_debug"            },
         1655  +     { geopolyBBoxFunc,          1, 1,    "geopoly_bbox"             },
         1656  +     { geopolyXformFunc,         7, 1,    "geopoly_xform"            },
  1656   1657     };
  1657   1658     static const struct {
  1658   1659       void (*xStep)(sqlite3_context*,int,sqlite3_value**);
  1659   1660       void (*xFinal)(sqlite3_context*);
  1660   1661       const char *zName;
  1661   1662     } aAgg[] = {
  1662   1663        { geopolyBBoxStep, geopolyBBoxFinal, "geopoly_group_bbox"    },
  1663   1664     };
  1664   1665     int i;
  1665   1666     for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){
         1667  +    int enc = aFunc[i].bPure ? SQLITE_UTF8|SQLITE_DETERMINISTIC : SQLITE_UTF8;
  1666   1668       rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
  1667         -                                 SQLITE_UTF8, 0,
         1669  +                                 enc, 0,
  1668   1670                                    aFunc[i].xFunc, 0, 0);
  1669   1671     }
  1670   1672     for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
  1671   1673       rc = sqlite3_create_function(db, aAgg[i].zName, 1, SQLITE_UTF8, 0,
  1672   1674                                    0, aAgg[i].xStep, aAgg[i].xFinal);
  1673   1675     }
  1674   1676     if( rc==SQLITE_OK ){
  1675   1677       rc = sqlite3_create_module_v2(db, "geopoly", &geopolyModule, 0, 0);
  1676   1678     }
  1677   1679     return rc;
  1678   1680   }