}
break;
}
- if( geopolySkipSpace(&s)==']' ){
- int nByte = sizeof(GeoPoly) * (s.nVertex-1)*2*sizeof(GeopolyCoord);
- GeoPoly *pOut = sqlite3_malloc64( nByte );
- int x = 1;
+ if( geopolySkipSpace(&s)==']' && s.nVertex>=4 ){
+ int nByte;
+ GeoPoly *pOut;
+ int x = (s.nVertex-1)*2;
+ if( s.a[x]==s.a[0] && s.a[x+1]==s.a[1] ) s.nVertex--;
+ nByte = sizeof(GeoPoly) * (s.nVertex-1)*2*sizeof(GeopolyCoord);
+ pOut = sqlite3_malloc64( nByte );
+ x = 1;
if( pOut==0 ) goto parse_json_err;
pOut->nVertex = s.nVertex;
memcpy(pOut->a, s.a, s.nVertex*2*sizeof(GeopolyCoord));
int i;
sqlite3_str_append(x, "[", 1);
for(i=0; i<p->nVertex; i++){
- sqlite3_str_appendf(x, "[%g,%g]", p->a[i*2], p->a[i*2+1]);
- sqlite3_str_append(x, i==p->nVertex-1 ? "]" : ",", 1);
+ sqlite3_str_appendf(x, "[%!g,%!g],", p->a[i*2], p->a[i*2+1]);
}
+ sqlite3_str_appendf(x, "[%!g,%!g]]", p->a[0], p->a[1]);
sqlite3_result_text(context, sqlite3_str_finish(x), -1, sqlite3_free);
sqlite3_free(p);
}
-C Fix\sthe\sgeopoly_json()\sSQL\sfunction\sso\sthat\sit\sworks.
-D 2018-05-09T15:20:47.783
+C The\stranslation\sin\sand\sout\sof\sGeoJSON\sautomatically\sadds\sor\sremoves\sthe\nredundant\slast\svertex,\sas\snecessary.
+D 2018-05-09T15:27:35.268
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 6f2fe66fdb97d4ed794d3f1ca2f984aa84d2d731704f5d0ec0ed5ef242a921d4
+F ext/misc/geopoly.c 5c980f724ac01d075ecadd0b6e8e009224c62cb723f0d972f0d620eeb4397461
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 5bb9e6a9f19f9d73314b08afbecb13f46b0cf7b27bfb567960d8f60e3a7a74a1
-R 19ac43755ffa82d1ceb67768a613f870
+P 236588d573a007c9c9eb8e337387d3b6318d19c8b8f260fa7324ed8c4e17060b
+R ce0801999b26c2f522e752eaa60d3a97
U drh
-Z f8290016445a89aa601b008a34a72134
+Z f8b6d58cd5211c2e2594239d6fddec6f
-236588d573a007c9c9eb8e337387d3b6318d19c8b8f260fa7324ed8c4e17060b
\ No newline at end of file
+2653bedd9f8237d9ddef533a05e161a6afe6fa4af86fac47407b3df09dc2a9eb
\ No newline at end of file