Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.3dtiles to tileset command #62

Merged
merged 7 commits into from
Mar 15, 2017
Merged

.3dtiles to tileset command #62

merged 7 commits into from
Mar 15, 2017

Conversation

lilleyse
Copy link
Contributor

@lilleyse lilleyse commented Mar 8, 2017

Fixes #56

Breaking changes: tileset2sqlite3 is now called tilesetToDatabase. This will need to be fixed elsewhere once a new version of 3d-tiles-tools is published.

@tfili can you quickly check that the sql commands are sane?

@shehzan10 can you do a full review? No rush on this.


module.exports = tilesetToDatabase;

function tilesetToDatabase(inputFile, outputDirectory) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should be databaseToTileset.

}

function readAndWriteFile(outputDirectory, dbGet, index) {
return dbGet('SELECT * FROM media LIMIT 1 OFFSET ?', index)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running a new query for each row isn't efficient. We should do a select in chunks. Maybe like run the query to grab in 10,000 row chunks. You want to be careful with the gzipping and file writing as to not thrash disk IO.

I've done something similar like this:

var offset = 0;
var limit = 10000; // Or some reasonable limit
var asyncLimit = ??; // Number of cores or whatever
var processChunk = function() {
    return dbAll('SELECT * FROM media LIMIT ? OFFSET ?', limit, offset).then(function(rows) {
        if (rows.length === 0) {
            // No more rows left
            return Promise.resolve();
        }
        
        return Promise.map(rows, function(row) {
            // TODO: Handle gzipping/file writing
            ++offset;
        }, {concurrency: asyncLimit})
            .then(function () {
                return processChunk();
            });
    });
};

return processChunk();

@lilleyse
Copy link
Contributor Author

lilleyse commented Mar 8, 2017

Updated. Thanks @tfili that code snippet was very helpful. The command is pretty fast now.

@shehzan10
Copy link
Member

LGTM.

@shehzan10
Copy link
Member

@lilleyse Do you think it would be good to deprecate instead of break this immediately? Probably have tileset2sqlite3 call tilesetToDatabase internally. This would be useful in development as switching between latest master and npm release will not cause any breakage.

@lilleyse
Copy link
Contributor Author

This early in development, I think its fine to have the occasional breaking breaking change as long as it is documented - which means I should document it

@lilleyse
Copy link
Contributor Author

I'll add that and document the rest of the changes since the first release in a bit.

@lilleyse
Copy link
Contributor Author

Ready now.

@shehzan10 shehzan10 merged commit 4a15aab into master Mar 15, 2017
@shehzan10 shehzan10 deleted the sqlite3ToTileset branch March 15, 2017 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unpack a .3dtiles database file
3 participants