** Implementation of the geopoly_area(X) function.
**
** If the input is a well-formed Geopoly BLOB then return the area
-** enclosed by the polygon. Otherwise return NULL.
+** enclosed by the polygon. If the polygon circulates clockwise instead
+** of counterclockwise (as it should) then return the negative of the
+** enclosed area. Otherwise return NULL.
*/
static void geopolyAreaFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
+ GeoPoly *p = geopolyFuncParam(context, argv[0]);
+ if( p ){
+ double rArea = 0.0;
+ int ii;
+ for(ii=0; ii<p->nVertex-1; ii++){
+ rArea += (p->a[ii*2] - p->a[ii*2+2]) /* (x0 - x1) */
+ * (p->a[ii*2+1] + p->a[ii*2+3]) /* (y0 + y1) */
+ * 0.5;
+ }
+ rArea += (p->a[ii*2] - p->a[0]) /* (xN - x0) */
+ * (p->a[ii*2+1] + p->a[1]) /* (yN + y0) */
+ * 0.5;
+ sqlite3_result_double(context, rArea);
+ sqlite3_free(p);
+ }
}
-C Fix\sa\stypo\sin\sthe\shelp\smessage\sfrom\sthe\s".sha3sum"\scommand\sin\sthe\sCLI.
-D 2018-05-11T14:02:17.043
+C Add\sthe\sgeopoly_read()\sSQL\sfunction\sto\sthe\sgeopoly.c\sextension.
+D 2018-05-11T15:38:03.123
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
F ext/misc/eval.c 6ea9b22a5fa0dd973b67ca4e53555be177bc0b7b263aadf1024429457c82c0e3
F ext/misc/fileio.c 48c7751c78fc4cdd29d8c862fd2f3f98bbfefa2a3cf1ca1496df4bf02eb8cded
F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
-F ext/misc/geopoly.c 5c980f724ac01d075ecadd0b6e8e009224c62cb723f0d972f0d620eeb4397461
+F ext/misc/geopoly.c 1e0cf4b36dda931335ac593c405b00faaccb67c442b765eb1a5a501e69d29222
F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c
F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984
F ext/misc/memvfs.c ab36f49e02ebcdf85a1e08dc4d8599ea8f343e073ac9e0bca18a98b7e1ec9567
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 2b8fd3b49724a613d95e1fe2c6898b6f82188b680a668c9e9b4189156cb84a5e
-R 617713a8dfac5b80e84319ec62d9a0c0
+P e76f676c120cd503e4a7b7cc636250ace68f4eafbbe304a8fcf503614e1b9ad0
+R e59fb5b809946c39215a5cc2b908f045
U drh
-Z 67ab7cbe7e5ad9551be269975079e952
+Z ee1d0fae34c255e3ce33f1c92519c313