variable length tag descriptions (first shot)

This commit is contained in:
Arndt 2014-05-18 19:17:05 +02:00
parent 6768a197ba
commit a145230e0f
23 changed files with 860 additions and 124 deletions

View file

@ -13,7 +13,7 @@ public class NodeData extends MapCreatorBase
public long nid;
public int ilon;
public int ilat;
public long description;
public byte[] description;
public short selev = Short.MIN_VALUE;
public NodeData( long id, double lon, double lat )
@ -29,18 +29,18 @@ public class NodeData extends MapCreatorBase
ilon = dis.readInt();
ilat = dis.readInt();
int mode = dis.readByte();
if ( ( mode & 1 ) != 0 ) description = dis.readLong();
if ( ( mode & 1 ) != 0 ) { int dlen = dis.readByte(); description = new byte[dlen]; dis.readFully( description ); }
if ( ( mode & 2 ) != 0 ) selev = dis.readShort();
}
}
public void writeTo( DataOutputStream dos ) throws Exception
{
writeId( dos, nid );
dos.writeInt( ilon );
dos.writeInt( ilat );
int mode = ( description == 0L ? 0 : 1 ) | ( selev == Short.MIN_VALUE ? 0 : 2 );
int mode = ( description == null ? 0 : 1 ) | ( selev == Short.MIN_VALUE ? 0 : 2 );
dos.writeByte( (byte)mode );
if ( ( mode & 1 ) != 0 ) dos.writeLong( description );
if ( ( mode & 1 ) != 0 ) { dos.writeByte( description.length ); dos.write( description ); }
if ( ( mode & 2 ) != 0 ) dos.writeShort( selev );
}
}