mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add the randomshape.tcl test-case generator script to the util subdirectory
of the rtree extension. FossilOrigin-Name: 8f48991dcbb01e21d065fbba7782a6d1aebaa8065841a70a76af1e5a21f18ea4
This commit is contained in:
87
ext/rtree/util/randomshape.tcl
Normal file
87
ext/rtree/util/randomshape.tcl
Normal file
@ -0,0 +1,87 @@
|
||||
#!/usr/bin/tclsh
|
||||
#
|
||||
# This script generates a cluster of random polygons that are useful
|
||||
# for testing the geopoly extension.
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# tclsh randomshape.tcl | tee x.sql | sqlite3 >x.html
|
||||
#
|
||||
# The output files are x.sql and x.html. Run the above multiple times
|
||||
# until an interesting "x.html" file is found, then use the "x.sql" inputs
|
||||
# to construct test cases.
|
||||
#
|
||||
proc randomenclosure {cx cy p1 p2 p3 p4} {
|
||||
set r 0
|
||||
set pi 3.145926
|
||||
set pi2 [expr {$pi*2}]
|
||||
set x0 [expr {$cx + rand()*$p3 + $p4}]
|
||||
set ans "\[\[$x0,$cy\]"
|
||||
while {1} {
|
||||
set r [expr {$r+$p1+$p2*rand()}]
|
||||
if {$r>=$pi2} break
|
||||
set m [expr {rand()*$p3 + $p4}]
|
||||
set x [expr {$cx+$m*cos($r)}]
|
||||
set y [expr {$cy+$m*sin($r)}]
|
||||
append ans ",\[$x,$y\]"
|
||||
}
|
||||
append ans ",\[$x0,$cy\]\]"
|
||||
return $ans
|
||||
}
|
||||
proc randomshape1 {} {
|
||||
set cx [expr {100+int(rand()*800)}]
|
||||
set cy [expr {100+int(rand()*600)}]
|
||||
set p1 [expr {rand()*0.1}]
|
||||
set p2 [expr {rand()*0.5+0.5}]
|
||||
set p3 [expr {rand()*100+25}]
|
||||
set p4 [expr {rand()*25}]
|
||||
return [randomenclosure $cx $cy $p1 $p2 $p3 $p4]
|
||||
}
|
||||
proc randomshape1_sm {} {
|
||||
set cx [expr {100+int(rand()*800)}]
|
||||
set cy [expr {100+int(rand()*600)}]
|
||||
set p1 [expr {rand()*0.1}]
|
||||
set p2 [expr {rand()*0.5+0.5}]
|
||||
set p3 [expr {rand()*10+25}]
|
||||
set p4 [expr {rand()*5}]
|
||||
return [randomenclosure $cx $cy $p1 $p2 $p3 $p4]
|
||||
}
|
||||
proc randomshape2 {} {
|
||||
set cx [expr {400+int(rand()*200)}]
|
||||
set cy [expr {300+int(rand()*200)}]
|
||||
set p1 [expr {rand()*0.05}]
|
||||
set p2 [expr {rand()*0.5+0.5}]
|
||||
set p3 [expr {rand()*50+200}]
|
||||
set p4 [expr {rand()*50+100}]
|
||||
return [randomenclosure $cx $cy $p1 $p2 $p3 $p4]
|
||||
}
|
||||
proc randomcolor {} {
|
||||
set n [expr {int(rand()*5)}]
|
||||
return [lindex {red orange green blue purple} $n]
|
||||
}
|
||||
|
||||
puts {.print '<html>'}
|
||||
puts {.print '<svg width="1000" height="800" style="border:1px solid black">'}
|
||||
puts {CREATE TABLE t1(poly,clr);}
|
||||
puts {CREATE TABLE t2(poly,clr);}
|
||||
for {set i 0} {$i<30} {incr i} {
|
||||
puts "INSERT INTO t1(rowid,poly,clr)"
|
||||
puts " VALUES($i,'[randomshape1]','[randomcolor]');"
|
||||
}
|
||||
for {set i 30} {$i<80} {incr i} {
|
||||
puts "INSERT INTO t1(rowid,poly,clr)"
|
||||
puts " VALUES($i,'[randomshape1_sm]','[randomcolor]');"
|
||||
}
|
||||
for {set i 100} {$i<105} {incr i} {
|
||||
puts "INSERT INTO t2(rowid,poly,clr)"
|
||||
puts " VALUES($i,'[randomshape2]','[randomcolor]');"
|
||||
}
|
||||
|
||||
puts {DELETE FROM t1 WHERE geopoly_json(poly) IS NULL;}
|
||||
puts {SELECT geopoly_svg(poly,
|
||||
printf('style="fill:none;stroke:%s;stroke-width:1;"',clr))
|
||||
FROM t1;}
|
||||
puts {SELECT geopoly_svg(poly,
|
||||
printf('style="fill:none;stroke:%s;stroke-width:2;"',clr))
|
||||
FROM t2;}
|
||||
puts {.print '<svg>'}
|
11
manifest
11
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sexcess\smemory\susage\sin\sthe\sJSON\sparser\sof\sGEOPOLY.
|
||||
D 2018-09-06T11:14:17.559
|
||||
C Add\sthe\srandomshape.tcl\stest-case\sgenerator\sscript\sto\sthe\sutil\ssubdirectory\nof\sthe\srtree\sextension.
|
||||
D 2018-09-06T14:01:56.119
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F Makefile.in d06f463c5b623a61ac27f5cb8214fca9e53a6704d34d6b8f2124e2b1b293c88f
|
||||
@ -385,6 +385,7 @@ F ext/rtree/rtreecheck.test 4d29103d1e16fcbf90135d1c637b833688492b063b2971dfb5dc
|
||||
F ext/rtree/rtreeconnect.test 225ad3fcb483d36cbee423a25052a6bbae762c9576ae9268332360c68c170d3d
|
||||
F ext/rtree/sqlite3rtree.h 9c5777af3d2921c7b4ae4954e8e5697502289d28
|
||||
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
||||
F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff
|
||||
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
||||
F ext/rtree/visual01.txt 17c3afefc208c375607aa82242e97fa79c316e539bcd0b7b3e59344c69445d05
|
||||
F ext/session/changeset.c 4ccbaa4531944c24584bf6a61ba3a39c62b6267a
|
||||
@ -1758,7 +1759,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 14c955152d0580abc3df1b363789f2925e013b9c957e550b1e6ebe83a82bae6c
|
||||
R 913d94dd999b47369f6272c91a914e8c
|
||||
P 9057e27e12ded07a9ea0b2868036d3019f7bc5be3a67e3d341f56b762d3de9d9
|
||||
R 3130dca95e718b6cbbaac719dc665d6a
|
||||
U drh
|
||||
Z ffcf16cabc344c45daf16477ee7cef3a
|
||||
Z 0d8f7c300159980e6dfc3b9bdb17b906
|
||||
|
@ -1 +1 @@
|
||||
9057e27e12ded07a9ea0b2868036d3019f7bc5be3a67e3d341f56b762d3de9d9
|
||||
8f48991dcbb01e21d065fbba7782a6d1aebaa8065841a70a76af1e5a21f18ea4
|
Reference in New Issue
Block a user