/ Check-in [690dd18a]
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

 ```489 490 491 492 493 494 495 496 497 498 499 500 501 502 .... 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 ``` ``` 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); } } #define GEOPOLY_PI 3.1415926535897932385 /* Fast approximation for cosine(X) for X between -0.5*pi and 2*pi */ static double geopolyCosine(double r){ assert( r>=-0.5*GEOPOLY_PI && r<=2.0*GEOPOLY_PI ); ................................................................................ { geopolyWithinFunc, 2, 1, "geopoly_within" }, { geopolyContainsPointFunc, 3, 1, "geopoly_contains_point" }, { geopolyOverlapFunc, 2, 1, "geopoly_overlap" }, { geopolyDebugFunc, 1, 0, "geopoly_debug" }, { geopolyBBoxFunc, 1, 1, "geopoly_bbox" }, { geopolyXformFunc, 7, 1, "geopoly_xform" }, { geopolyRegularFunc, 4, 1, "geopoly_regular" }, }; static const struct { void (*xStep)(sqlite3_context*,int,sqlite3_value**); void (*xFinal)(sqlite3_context*); const char *zName; } aAgg[] = { { geopolyBBoxStep, geopolyBBoxFinal, "geopoly_group_bbox" }, ``` ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ``` ```489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 .... 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 ``` ``` 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); } } /* ** Implementation of the geopoly_reverse(X) function. ** ** Reverse the order of the vertexes in polygon X. This can be used ** to convert an historical polygon that uses a clockwise rotation into ** a well-formed GeoJSON polygon that uses counter-clockwise rotation. */ static void geopolyReverseFunc( sqlite3_context *context, int argc, sqlite3_value **argv ){ GeoPoly *p = geopolyFuncParam(context, argv[0], 0); if( p ){ int ii, jj; for(ii=2, jj=p->nVertex*2 - 4; iia[ii]; p->a[ii] = p->a[jj]; p->a[jj] = t; t = p->a[ii+1]; p->a[ii+1] = p->a[jj+1]; p->a[jj+1] = t; } sqlite3_result_blob(context, p->hdr, 4+8*p->nVertex, SQLITE_TRANSIENT); sqlite3_free(p); } } #define GEOPOLY_PI 3.1415926535897932385 /* Fast approximation for cosine(X) for X between -0.5*pi and 2*pi */ static double geopolyCosine(double r){ assert( r>=-0.5*GEOPOLY_PI && r<=2.0*GEOPOLY_PI ); ................................................................................ { geopolyWithinFunc, 2, 1, "geopoly_within" }, { geopolyContainsPointFunc, 3, 1, "geopoly_contains_point" }, { geopolyOverlapFunc, 2, 1, "geopoly_overlap" }, { geopolyDebugFunc, 1, 0, "geopoly_debug" }, { geopolyBBoxFunc, 1, 1, "geopoly_bbox" }, { geopolyXformFunc, 7, 1, "geopoly_xform" }, { geopolyRegularFunc, 4, 1, "geopoly_regular" }, { geopolyReverseFunc, 1, 1, "geopoly_reverse" }, }; static const struct { void (*xStep)(sqlite3_context*,int,sqlite3_value**); void (*xFinal)(sqlite3_context*); const char *zName; } aAgg[] = { { geopolyBBoxStep, geopolyBBoxFinal, "geopoly_group_bbox" }, ```