]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the geopoly_svg() SQL function.
authordrh <drh@noemail.net>
Sat, 12 May 2018 21:09:31 +0000 (21:09 +0000)
committerdrh <drh@noemail.net>
Sat, 12 May 2018 21:09:31 +0000 (21:09 +0000)
FossilOrigin-Name: 318ba5f0c52596fc5ceed23a2b7b1ca18644449809890bfed47ab4ee01075060

ext/misc/geopoly.c
manifest
manifest.uuid

index daa9f449b0d25e460a1a72b4880620f17bebee5e..2c403c0cb441763a471a9db5f068c0845727d920 100644 (file)
@@ -345,6 +345,40 @@ static void geopolyJsonFunc(
   }
 }
 
+/*
+** SQL function:     geopoly_svg(X, ....)
+**
+** Interpret X as a polygon and render it as a SVG <polyline>.
+** Additional arguments are added as attributes to the <polyline>.
+*/
+static void geopolySvgFunc(
+  sqlite3_context *context,
+  int argc,
+  sqlite3_value **argv
+){
+  GeoPoly *p = geopolyFuncParam(context, argv[0]);
+  if( p ){
+    sqlite3 *db = sqlite3_context_db_handle(context);
+    sqlite3_str *x = sqlite3_str_new(db);
+    int i;
+    char cSep = '\'';
+    sqlite3_str_appendf(x, "<polyline points=");
+    for(i=0; i<p->nVertex; i++){
+      sqlite3_str_appendf(x, "%c%g,%g", cSep, p->a[i*2], p->a[i*2+1]);
+      cSep = ' ';
+    }
+    sqlite3_str_appendf(x, " %g,%g'", p->a[0], p->a[1]);
+    for(i=1; i<argc; i++){
+      const char *z = (const char*)sqlite3_value_text(argv[i]);
+      if( z && z[0] ){
+        sqlite3_str_appendf(x, " %s", z);
+      }
+    }
+    sqlite3_str_appendf(x, "></polyline>");
+    sqlite3_result_text(context, sqlite3_str_finish(x), -1, sqlite3_free);
+    sqlite3_free(p);
+  }
+}
 
 /*
 ** Implementation of the geopoly_area(X) function.
@@ -811,6 +845,7 @@ int sqlite3_geopoly_init(
      { geopolyAreaFunc,          1,    "geopoly_area"     },
      { geopolyBlobFunc,          1,    "geopoly_blob"     },
      { geopolyJsonFunc,          1,    "geopoly_json"     },
+     { geopolySvgFunc,          -1,    "geopoly_svg"      },
      { geopolyWithinFunc,        3,    "geopoly_within"   },
      { geopolyOverlapFunc,       2,    "geopoly_overlap"  },
      { geopolyDebugFunc,         1,    "geopoly_debug"    },
index f923ef59d9ffa22477e083b67c033331a069de4d..687b3339f6a3776d037a4f6ce9c3bbb6df67af19 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Preliminary\stests\sshow\sgeopoly_overlap()\sis\sworking.
-D 2018-05-12T20:28:51.628
+C Add\sthe\sgeopoly_svg()\sSQL\sfunction.
+D 2018-05-12T21:09:31.743
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da
@@ -279,7 +279,7 @@ F ext/misc/dbdump.c 69ef1be5b210538f77dfcc6fcb55b4b5f5e98b1e0bcfd67d818711e10761
 F ext/misc/eval.c 6ea9b22a5fa0dd973b67ca4e53555be177bc0b7b263aadf1024429457c82c0e3
 F ext/misc/fileio.c 48c7751c78fc4cdd29d8c862fd2f3f98bbfefa2a3cf1ca1496df4bf02eb8cded
 F ext/misc/fuzzer.c 7c64b8197bb77b7d64eff7cac7848870235d4c25
-F ext/misc/geopoly.c 2d3478b322fde9d31d7d02bfe4e3c0cbc43f901991936a7511ecefd0f1770a9b
+F ext/misc/geopoly.c 0ff8defd4c14f696c6f7ae22f5b35684bb5e97d704b1fbcd83a52397ef1d748f
 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c
 F ext/misc/json1.c dbe086615b9546c156bf32b9378fc09383b58bd17513b866cfd24c1e15281984
 F ext/misc/memvfs.c ab36f49e02ebcdf85a1e08dc4d8599ea8f343e073ac9e0bca18a98b7e1ec9567
@@ -1729,7 +1729,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 c857976efba79bd24befec1bd1597cc967dd2f0a39e66087cc9b1663154a05a8
-R f0e2b517cfea19580d6d720b8d793968
+P 77bb7b7d7278725e4e02935d485c3540bb41f4fc29ca8da679b2a380ebc38d7d
+R 45a8a2641f4ccb20c343642fef078d5a
 U drh
-Z a98a635ee795f5a445da6c92e9105b9c
+Z 51ab8a1c4e9dc75f7d7508c91ab6edda
index ae3995d75339708e5fc436c300f830b4a110928e..26f2d72709da78ade90ea486385b46a5670dd392 100644 (file)
@@ -1 +1 @@
-77bb7b7d7278725e4e02935d485c3540bb41f4fc29ca8da679b2a380ebc38d7d
\ No newline at end of file
+318ba5f0c52596fc5ceed23a2b7b1ca18644449809890bfed47ab4ee01075060
\ No newline at end of file