]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the geopoly_reverse() function to the GeoPoly extension.
authordrh <drh@noemail.net>
Mon, 8 Oct 2018 12:58:59 +0000 (12:58 +0000)
committerdrh <drh@noemail.net>
Mon, 8 Oct 2018 12:58:59 +0000 (12:58 +0000)
FossilOrigin-Name: 690dd18a5768c5a8cdfa92d5b01901c1a7b1fb6ebb90399f56a3112e41609f92

ext/rtree/geopoly.c
manifest
manifest.uuid

index 5b5dc43a0138edcfe7982580b169236b0cd95594..c3f3478b5ca0a6171075c753f8218f1400aaa676 100644 (file)
@@ -494,6 +494,36 @@ static void geopolyAreaFunc(
   }            
 }
 
+/*
+** 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; ii<jj; ii+=2, jj-=2){
+      GeoCoord t = p->a[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
@@ -1721,6 +1751,7 @@ static int sqlite3_geopoly_init(sqlite3 *db){
      { 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**);
index 5f20adeb35355c692e61ce0059c1c967bb57b8e6..7a838f249e7096985638fc01eaa94371ab85201b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sthe\s".help\s-all"\soption\sin\sthe\scommand-line\sshell.
-D 2018-10-06T14:38:17.499
+C Add\sthe\sgeopoly_reverse()\sfunction\sto\sthe\sGeoPoly\sextension.
+D 2018-10-08T12:58:59.969
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in 01e95208a78b57d056131382c493c963518f36da4c42b12a97eb324401b3a334
@@ -361,7 +361,7 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782
 F ext/repair/test/checkindex01.test 6945d0ffc0c1dc993b2ce88036b26e0f5d6fcc65da70fc9df27c2647bb358b0f
 F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
-F ext/rtree/geopoly.c 04db01e24dca675c5ab75110709aed054325f7474b2f567dd98361c373dcff3c
+F ext/rtree/geopoly.c 9d8411b2bcaab719f65acc8a84d16200d5139ac634787df546c31bf9972b34e6
 F ext/rtree/rtree.c 6cc2e673cf1e9ea1619f13ab990f12389dfb951b131acbc2fbe164cee8992a20
 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412
 F ext/rtree/rtree1.test 309afc04d4287542b2cd74f933296832cc681c7b014d9405cb329b62053a5349
@@ -1771,7 +1771,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P ff10d2c7de430c88167b1e6e4f5307eee5d69e22c8d24b2ef4fcb3aea25a92e1
-R 29cbf681583baf68c349077deec43fe7
+P aac8f1dff0728c629b5cbf30369ee91c5862a707ede694dc2628d1d4f5a6c202
+R 6c483dda78db6c9ea6a6a082c4feae71
 U drh
-Z 64cd6344daa5db6811005ab9259da4cc
+Z f525bca01c12c5943b4f7c604400e173
index d13538dc2808f73076c94fc1ff9db86a98d78bde..b8eda6748ba2db6735bd6828c7170ac17eb42aa1 100644 (file)
@@ -1 +1 @@
-aac8f1dff0728c629b5cbf30369ee91c5862a707ede694dc2628d1d4f5a6c202
\ No newline at end of file
+690dd18a5768c5a8cdfa92d5b01901c1a7b1fb6ebb90399f56a3112e41609f92
\ No newline at end of file