Reformat whole codebase using Android Studio

This commit is contained in:
Manuel Fuhr 2022-07-11 06:30:17 +02:00
parent d5322667d5
commit c15913c1ab
161 changed files with 15124 additions and 18537 deletions

View file

@ -3,6 +3,7 @@ package btools.mapcreator;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import btools.util.*;
import org.openstreetmap.osmosis.osmbinary.Fileformat;
@ -12,24 +13,22 @@ import org.openstreetmap.osmosis.osmbinary.Fileformat;
*
* @author ab
*/
public class OsmParser extends MapCreatorBase
{
public class OsmParser extends MapCreatorBase {
private BufferedReader _br;
private NodeListener nListener;
private WayListener wListener;
private RelationListener rListener;
public void readMap( File mapFile,
NodeListener nListener,
WayListener wListener,
RelationListener rListener ) throws Exception
{
public void readMap(File mapFile,
NodeListener nListener,
WayListener wListener,
RelationListener rListener) throws Exception {
this.nListener = nListener;
this.wListener = wListener;
this.rListener = rListener;
System.out.println( "*** PBF Parsing: " + mapFile );
System.out.println("*** PBF Parsing: " + mapFile);
// once more for testing
int rawBlobCount = 0;
@ -37,48 +36,38 @@ public class OsmParser extends MapCreatorBase
long bytesRead = 0L;
// wait for file to become available
while( !mapFile.exists() )
{
System.out.println( "--- waiting for " + mapFile + " to become available" );
Thread.sleep( 10000 );
while (!mapFile.exists()) {
System.out.println("--- waiting for " + mapFile + " to become available");
Thread.sleep(10000);
}
long currentSize = mapFile.length();
long currentSizeTime = System.currentTimeMillis();
DataInputStream dis = new DataInputStream( new BufferedInputStream ( new FileInputStream( mapFile ) ) );
DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(mapFile)));
for(;;)
{
for (; ; ) {
// continue reading if either more then a 100 MB unread, or the current-size is known for more then 2 Minutes
while ( currentSize-bytesRead < 100000000L )
{
while (currentSize - bytesRead < 100000000L) {
long newSize = mapFile.length();
if ( newSize != currentSize )
{
if (newSize != currentSize) {
currentSize = newSize;
currentSizeTime = System.currentTimeMillis();
}
else if ( System.currentTimeMillis() - currentSizeTime > 120000 )
{
} else if (System.currentTimeMillis() - currentSizeTime > 120000) {
break;
}
if ( currentSize-bytesRead < 100000000L )
{
System.out.println( "--- waiting for more data, currentSize=" + currentSize + " bytesRead=" + bytesRead );
Thread.sleep( 10000 );
if (currentSize - bytesRead < 100000000L) {
System.out.println("--- waiting for more data, currentSize=" + currentSize + " bytesRead=" + bytesRead);
Thread.sleep(10000);
}
}
int headerLength;
try
{
try {
headerLength = dis.readInt();
bytesRead += 4;
}
catch (EOFException e)
{
} catch (EOFException e) {
break;
}
@ -91,74 +80,57 @@ public class OsmParser extends MapCreatorBase
dis.readFully(blobData);
bytesRead += blobData.length;
new BPbfBlobDecoder( blobHeader.getType(), blobData, this ).process();
new BPbfBlobDecoder(blobHeader.getType(), blobData, this).process();
rawBlobCount++;
}
dis.close();
System.out.println( "read raw blobs: " + rawBlobCount );
System.out.println("read raw blobs: " + rawBlobCount);
}
public void addNode( long nid, Map<String, String> tags, double lat, double lon )
{
NodeData n = new NodeData( nid, lon, lat );
n.setTags( (HashMap<String,String>)tags );
try
{
nListener.nextNode( n );
public void addNode(long nid, Map<String, String> tags, double lat, double lon) {
NodeData n = new NodeData(nid, lon, lat);
n.setTags((HashMap<String, String>) tags);
try {
nListener.nextNode(n);
} catch (Exception e) {
throw new RuntimeException("error writing node: " + e);
}
catch( Exception e )
{
throw new RuntimeException( "error writing node: " + e );
}
}
public void addWay( long wid, Map<String, String> tags, LongList nodes )
{
WayData w = new WayData( wid, nodes );
w.setTags( (HashMap<String,String>)tags );
public void addWay(long wid, Map<String, String> tags, LongList nodes) {
WayData w = new WayData(wid, nodes);
w.setTags((HashMap<String, String>) tags);
try
{
wListener.nextWay( w );
try {
wListener.nextWay(w);
} catch (Exception e) {
throw new RuntimeException("error writing way: " + e);
}
catch( Exception e )
{
throw new RuntimeException( "error writing way: " + e );
}
}
public void addRelation( long rid, Map<String, String> tags, LongList wayIds, LongList fromWid, LongList toWid, LongList viaNid )
{
RelationData r = new RelationData( rid, wayIds );
r.setTags( (HashMap<String,String>)tags );
public void addRelation(long rid, Map<String, String> tags, LongList wayIds, LongList fromWid, LongList toWid, LongList viaNid) {
RelationData r = new RelationData(rid, wayIds);
r.setTags((HashMap<String, String>) tags);
try
{
rListener.nextRelation( r );
if ( fromWid == null || toWid == null || viaNid == null || viaNid.size() != 1 )
{
try {
rListener.nextRelation(r);
if (fromWid == null || toWid == null || viaNid == null || viaNid.size() != 1) {
// dummy-TR for each viaNid
for( int vi = 0; vi < ( viaNid == null ? 0 : viaNid.size() ); vi++ )
{
rListener.nextRestriction( r, 0L, 0L, viaNid.get( vi ) );
for (int vi = 0; vi < (viaNid == null ? 0 : viaNid.size()); vi++) {
rListener.nextRestriction(r, 0L, 0L, viaNid.get(vi));
}
return;
}
for( int fi = 0; fi < fromWid.size(); fi++ )
{
for( int ti = 0; ti < toWid.size(); ti++ )
{
rListener.nextRestriction( r, fromWid.get( fi ), toWid.get( ti ), viaNid.get( 0 ) );
for (int fi = 0; fi < fromWid.size(); fi++) {
for (int ti = 0; ti < toWid.size(); ti++) {
rListener.nextRestriction(r, fromWid.get(fi), toWid.get(ti), viaNid.get(0));
}
}
} catch (Exception e) {
throw new RuntimeException("error writing relation", e);
}
catch( Exception e )
{
throw new RuntimeException( "error writing relation", e );
}
}
}