/** * common base class for the map-filters * * @author ab */ package btools.mapsplitter; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.HashMap; import btools.util.DiffCoderDataOutputStream; public abstract class MapCreatorBase implements WayListener, NodeListener, RelationListener { private DiffCoderDataOutputStream[] tileOutStreams; protected File outTileDir; protected HashMap tags; public void putTag( String key, String value ) { if ( tags == null ) tags = new HashMap(); tags.put( key, value ); } public String getTag( String key ) { return tags == null ? null : tags.get( key ); } public HashMap getTagsOrNull() { return tags; } public void setTags( HashMap tags ) { this.tags = tags; } protected static long readId( DataInputStream is) throws IOException { int offset = is.readByte(); if ( offset == 32 ) return -1; long i = is.readInt(); i = i << 5; return i | offset; } protected static void writeId( DataOutputStream o, long id ) throws IOException { if ( id == -1 ) { o.writeByte( 32 ); return; } int offset = (int)( id & 0x1f ); int i = (int)( id >> 5 ); o.writeByte( offset ); o.writeInt( i ); } protected static File[] sortBySizeAsc( File[] files ) { int n = files.length; long[] sizes = new long[n]; File[] sorted = new File[n]; for( int i=0; i