Count number of ways in a bounding box

I would like to perform a bounding-box query and count the number of ways, stopping when I reach a threshold. I don’t see how to do this in osmosis, so I’m open to any command-line tool that can do it for me. This is in order to create a binary search tree for the planet.osm file.

Any ideas?

I do not know of any existing tool capable of doing this. You will probably need to write your own…

Didn’t you link to an autosplitter which is used for garmin maps?

Splitterp splits OSM data based on a questimate of the resulting Garmin map tile size, not based upon a number of ways.