Page 1 of 1

deleting pos lines in sqlite map db

Posted: Sun Aug 31, 2014 14:52
by mike
Hi,

will there be any problems if i delete some well selected pos lines from sqlite db?

What i need to know is, will deleted lines (entries) be regenerated from seed if not found?
So i could write an SQL Query to delete all sectors which i dont want to preserve.

like delete all pos where pos(x,y,z) is not in myRange.

e.g. delete all except posXYZtoPos(0,0,0 to 100,100,100)

Re: deleting pos lines in sqlite map db

Posted: Sun Aug 31, 2014 15:06
by Sokomine
mike wrote: What i need to know is, will deleted lines (entries) be regenerated from seed if not found?
So i could write an SQL Query to delete all sectors which i dont want to preserve.
That ought to work well. The only thing you might have to take into consideration is that mapgen generates several mapblocks (16x16x16 blocks) in one go as one chunk (usually 5x5x5 mapblocks, so 80x80x80 blocks). I don't know what will happen if you delete only part of a chunk.
mike wrote: e.g. delete all except posXYZtoPos(0,0,0 to 100,100,100)
You'll have to transform the pos index into coordinates first, but yes, it ought to work then.

Re: deleting pos lines in sqlite map db

Posted: Sun Aug 31, 2014 17:12
by mike
If this is that easy wouldnt it be a function for worldedit or an script?

Re: deleting pos lines in sqlite map db

Posted: Sun Aug 31, 2014 18:31
by Sokomine
mike wrote: If this is that easy wouldnt it be a function for worldedit or an script?
This is nothing WorldEdit can do, as WorldEdit runs while the server is running. This kind of work is better done while the world is not loaded. The necessary commands depend on the database backend. sqlite3 is easier to handle in that regard than leveldb.

Re: deleting pos lines in sqlite map db

Posted: Tue Sep 02, 2014 17:05
by sfan5
If you delete a MapBlock from the database it will get regenerated when you visit the area again.

Re: deleting pos lines in sqlite map db

Posted: Wed Sep 03, 2014 18:59
by mike
so i dont have to care if i have to delete a set or just random picks?

Re: deleting pos lines in sqlite map db

Posted: Wed Sep 03, 2014 19:21
by sfan5
Yep

Re: deleting pos lines in sqlite map db

Posted: Wed Sep 03, 2014 20:11
by mike
is there any code for generating the coords except the one from db spec page?

Re: deleting pos lines in sqlite map db

Posted: Thu Sep 04, 2014 08:21
by sfan5
Here's a small python program that does what you want: http://sprunge.us/KOhi
X, Y and Z are MapBlock coords. not node coords.

Example:
You want to delete the 16x16x16 cube the node (-123, 456, 25) belongs to:
-123 / 16 = -7
456 / 16 = 28
25 / 16 = 1
-> ./pos2dbpos.py -7 28 1
Then delete that entry in the database.

Re: deleting pos lines in sqlite map db

Posted: Thu Sep 04, 2014 14:19
by twoelk
Not code but some playing with spreadsheets.

Beware might contain mistakes. Use with care.
Is extracted from some other project of mine therefore might have vital parts missing.

Re: deleting pos lines in sqlite map db

Posted: Thu Sep 04, 2014 15:37
by mike
That looks good.
So if i calculate like this for one node, then maximum 16 nodes in all directions will be deleted?

Next i have to think how to write a script which deletes all except "active" played map.
I cant delete e.g. block 123456 until inf. I hate unnormalized databases ;-)