From 309b9b3bbc7e863e780158a738598ad8f9bcd2b0 Mon Sep 17 00:00:00 2001 From: Arndt Brenschede Date: Sun, 19 Jan 2014 11:22:32 +0100 Subject: [PATCH] Added pbf-parser + mapcreation-scripts --- .gitignore | 1 + .../java/btools/mapcreator/WayLinker.java | 2 +- brouter-routing-app/.gitignore | 1 + .../gen/btools/routingapp/BuildConfig.java | 5 - .../btools/routingapp/IBRouterService.java | 136 --------- .../gen/btools/routingapp/R.java | 22 -- misc/pbfparser/.gitignore | 2 + misc/pbfparser/BPbfBlobDecoder.java | 270 ++++++++++++++++++ misc/pbfparser/BPbfFieldDecoder.java | 85 ++++++ misc/pbfparser/OsmParser.java | 110 +++++++ misc/pbfparser/README.txt | 17 ++ misc/pbfparser/compile_parser.bat | 1 + misc/scripts/mapcreation/BRouterTests.java | 28 ++ misc/scripts/mapcreation/all.brf | 18 ++ misc/scripts/mapcreation/cronjob.sh | 3 + .../scripts/mapcreation/process_pbf_planet.sh | 46 +++ misc/scripts/mapcreation/routetest.sh | 29 ++ 17 files changed, 612 insertions(+), 164 deletions(-) create mode 100644 brouter-routing-app/.gitignore delete mode 100644 brouter-routing-app/gen/btools/routingapp/BuildConfig.java delete mode 100644 brouter-routing-app/gen/btools/routingapp/IBRouterService.java delete mode 100644 brouter-routing-app/gen/btools/routingapp/R.java create mode 100644 misc/pbfparser/.gitignore create mode 100644 misc/pbfparser/BPbfBlobDecoder.java create mode 100644 misc/pbfparser/BPbfFieldDecoder.java create mode 100644 misc/pbfparser/OsmParser.java create mode 100644 misc/pbfparser/README.txt create mode 100644 misc/pbfparser/compile_parser.bat create mode 100644 misc/scripts/mapcreation/BRouterTests.java create mode 100644 misc/scripts/mapcreation/all.brf create mode 100644 misc/scripts/mapcreation/cronjob.sh create mode 100644 misc/scripts/mapcreation/process_pbf_planet.sh create mode 100644 misc/scripts/mapcreation/routetest.sh diff --git a/.gitignore b/.gitignore index 2f7896d..e11adc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target/ +*.BAK \ No newline at end of file diff --git a/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java b/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java index 1e6b502..0dabc7d 100644 --- a/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java +++ b/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java @@ -88,7 +88,7 @@ public class WayLinker extends MapCreatorBase // read this tile's nodes readingBorder = false; - new NodeIterator( this, false ).processFile( nodeFile ); + new NodeIterator( this, true ).processFile( nodeFile ); // freeze the nodes-map FrozenLongMap nodesMapFrozen = new FrozenLongMap( nodesMap ); diff --git a/brouter-routing-app/.gitignore b/brouter-routing-app/.gitignore new file mode 100644 index 0000000..e8e450b --- /dev/null +++ b/brouter-routing-app/.gitignore @@ -0,0 +1 @@ +gen/ diff --git a/brouter-routing-app/gen/btools/routingapp/BuildConfig.java b/brouter-routing-app/gen/btools/routingapp/BuildConfig.java deleted file mode 100644 index ba033d3..0000000 --- a/brouter-routing-app/gen/btools/routingapp/BuildConfig.java +++ /dev/null @@ -1,5 +0,0 @@ -package btools.routingapp; - -public final class BuildConfig { - public static final boolean DEBUG = true; -} diff --git a/brouter-routing-app/gen/btools/routingapp/IBRouterService.java b/brouter-routing-app/gen/btools/routingapp/IBRouterService.java deleted file mode 100644 index 93ec321..0000000 --- a/brouter-routing-app/gen/btools/routingapp/IBRouterService.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * This file is auto-generated. DO NOT MODIFY. - * Original file: C:\\brouter\\brouter-routing-app\\src\\main\\java\\btools\\routingapp\\IBRouterService.aidl - */ -package btools.routingapp; -public interface IBRouterService extends android.os.IInterface -{ -/** Local-side IPC implementation stub class. */ -public static abstract class Stub extends android.os.Binder implements btools.routingapp.IBRouterService -{ -private static final java.lang.String DESCRIPTOR = "btools.routingapp.IBRouterService"; -/** Construct the stub at attach it to the interface. */ -public Stub() -{ -this.attachInterface(this, DESCRIPTOR); -} -/** - * Cast an IBinder object into an btools.routingapp.IBRouterService interface, - * generating a proxy if needed. - */ -public static btools.routingapp.IBRouterService asInterface(android.os.IBinder obj) -{ -if ((obj==null)) { -return null; -} -android.os.IInterface iin = obj.queryLocalInterface(DESCRIPTOR); -if (((iin!=null)&&(iin instanceof btools.routingapp.IBRouterService))) { -return ((btools.routingapp.IBRouterService)iin); -} -return new btools.routingapp.IBRouterService.Stub.Proxy(obj); -} -@Override public android.os.IBinder asBinder() -{ -return this; -} -@Override public boolean onTransact(int code, android.os.Parcel data, android.os.Parcel reply, int flags) throws android.os.RemoteException -{ -switch (code) -{ -case INTERFACE_TRANSACTION: -{ -reply.writeString(DESCRIPTOR); -return true; -} -case TRANSACTION_getTrackFromParams: -{ -data.enforceInterface(DESCRIPTOR); -android.os.Bundle _arg0; -if ((0!=data.readInt())) { -_arg0 = android.os.Bundle.CREATOR.createFromParcel(data); -} -else { -_arg0 = null; -} -java.lang.String _result = this.getTrackFromParams(_arg0); -reply.writeNoException(); -reply.writeString(_result); -return true; -} -} -return super.onTransact(code, data, reply, flags); -} -private static class Proxy implements btools.routingapp.IBRouterService -{ -private android.os.IBinder mRemote; -Proxy(android.os.IBinder remote) -{ -mRemote = remote; -} -@Override public android.os.IBinder asBinder() -{ -return mRemote; -} -public java.lang.String getInterfaceDescriptor() -{ -return DESCRIPTOR; -} -//param params--> Map of params: -// "pathToFileResult"-->String with the path to where the result must be saved, including file name and extension -// -->if null, the track is passed via the return argument -// "maxRunningTime"-->String with a number of seconds for the routing timeout, default = 60 -// "trackFormat"-->[kml|gpx] default = gpx -// "lats"-->double[] array of latitudes; 2 values at least. -// "lons"-->double[] array of longitudes; 2 values at least. -// "nogoLats"-->double[] array of nogo latitudes; may be null. -// "nogoLons"-->double[] array of nogo longitudes; may be null. -// "nogoRadi"-->double[] array of nogo radius in meters; may be null. -// "fast"-->[0|1] -// "v"-->[motorcar|bicycle|foot] -//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong -//call in a background thread, heavy task! - -@Override public java.lang.String getTrackFromParams(android.os.Bundle params) throws android.os.RemoteException -{ -android.os.Parcel _data = android.os.Parcel.obtain(); -android.os.Parcel _reply = android.os.Parcel.obtain(); -java.lang.String _result; -try { -_data.writeInterfaceToken(DESCRIPTOR); -if ((params!=null)) { -_data.writeInt(1); -params.writeToParcel(_data, 0); -} -else { -_data.writeInt(0); -} -mRemote.transact(Stub.TRANSACTION_getTrackFromParams, _data, _reply, 0); -_reply.readException(); -_result = _reply.readString(); -} -finally { -_reply.recycle(); -_data.recycle(); -} -return _result; -} -} -static final int TRANSACTION_getTrackFromParams = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0); -} -//param params--> Map of params: -// "pathToFileResult"-->String with the path to where the result must be saved, including file name and extension -// -->if null, the track is passed via the return argument -// "maxRunningTime"-->String with a number of seconds for the routing timeout, default = 60 -// "trackFormat"-->[kml|gpx] default = gpx -// "lats"-->double[] array of latitudes; 2 values at least. -// "lons"-->double[] array of longitudes; 2 values at least. -// "nogoLats"-->double[] array of nogo latitudes; may be null. -// "nogoLons"-->double[] array of nogo longitudes; may be null. -// "nogoRadi"-->double[] array of nogo radius in meters; may be null. -// "fast"-->[0|1] -// "v"-->[motorcar|bicycle|foot] -//return null if all ok and no path given, the track if ok and path given, an error message if it was wrong -//call in a background thread, heavy task! - -public java.lang.String getTrackFromParams(android.os.Bundle params) throws android.os.RemoteException; -} diff --git a/brouter-routing-app/gen/btools/routingapp/R.java b/brouter-routing-app/gen/btools/routingapp/R.java deleted file mode 100644 index cf5a5e4..0000000 --- a/brouter-routing-app/gen/btools/routingapp/R.java +++ /dev/null @@ -1,22 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package btools.routingapp; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} diff --git a/misc/pbfparser/.gitignore b/misc/pbfparser/.gitignore new file mode 100644 index 0000000..f3d4651 --- /dev/null +++ b/misc/pbfparser/.gitignore @@ -0,0 +1,2 @@ +*.jar +btools/ diff --git a/misc/pbfparser/BPbfBlobDecoder.java b/misc/pbfparser/BPbfBlobDecoder.java new file mode 100644 index 0000000..2db9dad --- /dev/null +++ b/misc/pbfparser/BPbfBlobDecoder.java @@ -0,0 +1,270 @@ +package btools.mapcreator; + +import com.google.protobuf.InvalidProtocolBufferException; +import org.openstreetmap.osmosis.osmbinary.Fileformat; +import org.openstreetmap.osmosis.osmbinary.Osmformat; +import btools.util.LongList; + +import java.io.IOException; +import java.util.*; +import java.util.logging.Level; +import java.util.zip.DataFormatException; +import java.util.zip.Inflater; + +/** + * Converts PBF block data into decoded entities ready to be passed into an Osmosis pipeline. This + * class is designed to be passed into a pool of worker threads to allow multi-threaded decoding. + *

+ * @author Brett Henderson + */ +public class BPbfBlobDecoder +{ + private String blobType; + private byte[] rawBlob; + + private OsmParser parser; + + /** + * Creates a new instance. + *

+ * @param blobType The type of blob. + * @param rawBlob The raw data of the blob. + * @param listener The listener for receiving decoding results. + */ + public BPbfBlobDecoder( String blobType, byte[] rawBlob, OsmParser parser ) + { + this.blobType = blobType; + this.rawBlob = rawBlob; + this.parser = parser; + } + + public void process() throws Exception + { + if ("OSMHeader".equals(blobType)) + { + processOsmHeader(readBlobContent()); + + } else if ("OSMData".equals(blobType)) + { + processOsmPrimitives(readBlobContent()); + + } else + { + System.out.println("Skipping unrecognised blob type " + blobType); + } + } + + private byte[] readBlobContent() throws IOException + { + Fileformat.Blob blob = Fileformat.Blob.parseFrom(rawBlob); + byte[] blobData; + + if (blob.hasRaw()) + { + blobData = blob.getRaw().toByteArray(); + } else if (blob.hasZlibData()) + { + Inflater inflater = new Inflater(); + inflater.setInput(blob.getZlibData().toByteArray()); + blobData = new byte[blob.getRawSize()]; + try + { + inflater.inflate(blobData); + } catch (DataFormatException e) + { + throw new RuntimeException("Unable to decompress PBF blob.", e); + } + if (!inflater.finished()) + { + throw new RuntimeException("PBF blob contains incomplete compressed data."); + } + } else + { + throw new RuntimeException("PBF blob uses unsupported compression, only raw or zlib may be used."); + } + + return blobData; + } + + private void processOsmHeader( byte[] data ) throws InvalidProtocolBufferException + { + Osmformat.HeaderBlock header = Osmformat.HeaderBlock.parseFrom(data); + + // Build the list of active and unsupported features in the file. + List supportedFeatures = Arrays.asList("OsmSchema-V0.6", "DenseNodes"); + List activeFeatures = new ArrayList(); + List unsupportedFeatures = new ArrayList(); + for (String feature : header.getRequiredFeaturesList()) + { + if (supportedFeatures.contains(feature)) + { + activeFeatures.add(feature); + } else + { + unsupportedFeatures.add(feature); + } + } + + // We can't continue if there are any unsupported features. We wait + // until now so that we can display all unsupported features instead of + // just the first one we encounter. + if (unsupportedFeatures.size() > 0) + { + throw new RuntimeException("PBF file contains unsupported features " + unsupportedFeatures); + } + + } + + private Map buildTags( List keys, List values, BPbfFieldDecoder fieldDecoder ) + { + + Iterator keyIterator = keys.iterator(); + Iterator valueIterator = values.iterator(); + if (keyIterator.hasNext()) + { + Map tags = new HashMap(); + while (keyIterator.hasNext()) + { + String key = fieldDecoder.decodeString(keyIterator.next()); + String value = fieldDecoder.decodeString(valueIterator.next()); + tags.put(key, value); + } + return tags; + } + return null; + } + + private void processNodes( List nodes, BPbfFieldDecoder fieldDecoder ) + { + for (Osmformat.Node node : nodes) + { + Map tags = buildTags(node.getKeysList(), node.getValsList(), fieldDecoder); + + parser.addNode( node.getId(), tags, fieldDecoder.decodeLatitude(node + .getLat()), fieldDecoder.decodeLatitude(node.getLon())); + } + } + + private void processNodes( Osmformat.DenseNodes nodes, BPbfFieldDecoder fieldDecoder ) + { + List idList = nodes.getIdList(); + List latList = nodes.getLatList(); + List lonList = nodes.getLonList(); + + Iterator keysValuesIterator = nodes.getKeysValsList().iterator(); + + long nodeId = 0; + long latitude = 0; + long longitude = 0; + + for (int i = 0; i < idList.size(); i++) + { + // Delta decode node fields. + nodeId += idList.get(i); + latitude += latList.get(i); + longitude += lonList.get(i); + + // Build the tags. The key and value string indexes are sequential + // in the same PBF array. Each set of tags is delimited by an index + // with a value of 0. + Map tags = null; + while (keysValuesIterator.hasNext()) + { + int keyIndex = keysValuesIterator.next(); + if (keyIndex == 0) + { + break; + } + int valueIndex = keysValuesIterator.next(); + + if (tags == null) + { + tags = new HashMap(); + } + + tags.put(fieldDecoder.decodeString(keyIndex), fieldDecoder.decodeString(valueIndex)); + } + + parser.addNode( nodeId, tags, ((double) latitude) / 10000000, ((double) longitude) / 10000000); + } + } + + private void processWays( List ways, BPbfFieldDecoder fieldDecoder ) + { + for (Osmformat.Way way : ways) + { + Map tags = buildTags(way.getKeysList(), way.getValsList(), fieldDecoder); + + // Build up the list of way nodes for the way. The node ids are + // delta encoded meaning that each id is stored as a delta against + // the previous one. + long nodeId = 0; + LongList wayNodes = new LongList( 16 ); + for (long nodeIdOffset : way.getRefsList()) + { + nodeId += nodeIdOffset; + wayNodes.add(nodeId); + } + + parser.addWay( way.getId(), tags, wayNodes ); + } + } + + private LongList buildRelationMembers( + List memberIds, List memberRoles, List memberTypes, + BPbfFieldDecoder fieldDecoder ) + { + LongList wayIds = new LongList( 16 ); + + + Iterator memberIdIterator = memberIds.iterator(); + Iterator memberRoleIterator = memberRoles.iterator(); + Iterator memberTypeIterator = memberTypes.iterator(); + + // Build up the list of relation members for the way. The member ids are + // delta encoded meaning that each id is stored as a delta against + // the previous one. + long refId = 0; + while (memberIdIterator.hasNext()) + { + Osmformat.Relation.MemberType memberType = memberTypeIterator.next(); + refId += memberIdIterator.next(); + + String role = fieldDecoder.decodeString( memberRoleIterator.next() ); + + if ( memberType == Osmformat.Relation.MemberType.WAY ) // currently just waymembers + { + wayIds.add( refId ); + } + } + return wayIds; + } + + private void processRelations( List relations, BPbfFieldDecoder fieldDecoder ) + { + for (Osmformat.Relation relation : relations) + { + Map tags = buildTags(relation.getKeysList(), relation.getValsList(), fieldDecoder); + + LongList wayIds = buildRelationMembers( relation.getMemidsList(), relation.getRolesSidList(), + relation.getTypesList(), fieldDecoder); + + parser.addRelation( relation.getId(), tags, wayIds ); + } + } + + private void processOsmPrimitives( byte[] data ) throws InvalidProtocolBufferException + { + Osmformat.PrimitiveBlock block = Osmformat.PrimitiveBlock.parseFrom(data); + BPbfFieldDecoder fieldDecoder = new BPbfFieldDecoder(block); + + for (Osmformat.PrimitiveGroup primitiveGroup : block.getPrimitivegroupList()) + { + processNodes(primitiveGroup.getDense(), fieldDecoder); + processNodes(primitiveGroup.getNodesList(), fieldDecoder); + processWays(primitiveGroup.getWaysList(), fieldDecoder); + processRelations(primitiveGroup.getRelationsList(), fieldDecoder); + } + } + +} diff --git a/misc/pbfparser/BPbfFieldDecoder.java b/misc/pbfparser/BPbfFieldDecoder.java new file mode 100644 index 0000000..be27ea1 --- /dev/null +++ b/misc/pbfparser/BPbfFieldDecoder.java @@ -0,0 +1,85 @@ +package btools.mapcreator; + +import java.util.Date; + +import org.openstreetmap.osmosis.osmbinary.Osmformat; + +/** + * Manages decoding of the lower level PBF data structures. + *

+ * @author Brett Henderson + *

+ */ +public class BPbfFieldDecoder +{ + private static final double COORDINATE_SCALING_FACTOR = 0.000000001; + private String[] strings; + private int coordGranularity; + private long coordLatitudeOffset; + private long coordLongitudeOffset; + private int dateGranularity; + + /** + * Creates a new instance. + *

+ * @param primitiveBlock The primitive block containing the fields to be decoded. + */ + public BPbfFieldDecoder( Osmformat.PrimitiveBlock primitiveBlock ) + { + this.coordGranularity = primitiveBlock.getGranularity(); + this.coordLatitudeOffset = primitiveBlock.getLatOffset(); + this.coordLongitudeOffset = primitiveBlock.getLonOffset(); + this.dateGranularity = primitiveBlock.getDateGranularity(); + + Osmformat.StringTable stringTable = primitiveBlock.getStringtable(); + strings = new String[stringTable.getSCount()]; + for (int i = 0; i < strings.length; i++) + { + strings[i] = stringTable.getS(i).toStringUtf8(); + } + } + + /** + * Decodes a raw latitude value into degrees. + *

+ * @param rawLatitude The PBF encoded value. + * @return The latitude in degrees. + */ + public double decodeLatitude( long rawLatitude ) + { + return COORDINATE_SCALING_FACTOR * (coordLatitudeOffset + (coordGranularity * rawLatitude)); + } + + /** + * Decodes a raw longitude value into degrees. + *

+ * @param rawLongitude The PBF encoded value. + * @return The longitude in degrees. + */ + public double decodeLongitude( long rawLongitude ) + { + return COORDINATE_SCALING_FACTOR * (coordLongitudeOffset + (coordGranularity * rawLongitude)); + } + + /** + * Decodes a raw timestamp value into a Date. + *

+ * @param rawTimestamp The PBF encoded timestamp. + * @return The timestamp as a Date. + */ + public Date decodeTimestamp( long rawTimestamp ) + { + return new Date(dateGranularity * rawTimestamp); + } + + /** + * Decodes a raw string into a String. + *

+ * @param rawString The PBF encoding string. + * @return The string as a String. + */ + public String decodeString( int rawString ) + { + return strings[rawString]; + } +} diff --git a/misc/pbfparser/OsmParser.java b/misc/pbfparser/OsmParser.java new file mode 100644 index 0000000..76105e1 --- /dev/null +++ b/misc/pbfparser/OsmParser.java @@ -0,0 +1,110 @@ +package btools.mapcreator; + +import java.io.*; +import java.util.*; +import java.util.zip.*; +import btools.util.*; + +import org.openstreetmap.osmosis.osmbinary.Fileformat; + +/** + * Parser for OSM data + * + * @author ab + */ +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 + { + this.nListener = nListener; + this.wListener = wListener; + this.rListener = rListener; + + System.out.println( "*** PBF Parsing: " + mapFile ); + + // once more for testing + int rawBlobCount = 0; + DataInputStream dis = new DataInputStream( new BufferedInputStream ( new FileInputStream( mapFile ) ) ); + for(;;) + { + int headerLength; + try + { + headerLength = dis.readInt(); + } + catch (EOFException e) + { + break; + } + + byte[] headerBuffer = new byte[headerLength]; + dis.readFully(headerBuffer); + Fileformat.BlobHeader blobHeader = Fileformat.BlobHeader.parseFrom(headerBuffer); + + byte[] blobData = new byte[blobHeader.getDatasize()]; + dis.readFully(blobData); + + new BPbfBlobDecoder( blobHeader.getType(), blobData, this ).process(); + + rawBlobCount++; + } + dis.close(); + System.out.println( "read raw blobs: " + rawBlobCount ); + } + + + + public void addNode( long nid, Map tags, double lat, double lon ) + { + NodeData n = new NodeData( nid, lon, lat ); + n.setTags( (HashMap)tags ); + try + { + nListener.nextNode( n ); + } + catch( Exception e ) + { + throw new RuntimeException( "error writing node: " + e ); + } + } + + public void addWay( long wid, Map tags, LongList nodes ) + { + WayData w = new WayData( wid, nodes ); + w.setTags( (HashMap)tags ); + + try + { + wListener.nextWay( w ); + } + catch( Exception e ) + { + throw new RuntimeException( "error writing way: " + e ); + } + } + + public void addRelation( long rid, Map tags, LongList wayIds ) + { + RelationData r = new RelationData( rid, wayIds ); + r.setTags( (HashMap)tags ); + + try + { + rListener.nextRelation( r ); + } + catch( Exception e ) + { + throw new RuntimeException( "error writing relation: " + e ); + } + } + +} diff --git a/misc/pbfparser/README.txt b/misc/pbfparser/README.txt new file mode 100644 index 0000000..67181db --- /dev/null +++ b/misc/pbfparser/README.txt @@ -0,0 +1,17 @@ +The pbf-parse is not included in the regular source tree +to avoid the library dependencies to "osmosis" and "protobuf" + +In order to run the mapcreator from a pbf-file (as it is +done in the process_pbf_planet.sh script included in +the git-repo), you have to build yourself the "pbfparser.jar" +by doing the following: + +-> get osmosis.jar +-> get protobuf.jar +-> copy the brouter...with_dependencies.jar and name it brouter.jar +-> compile the PBF-Parser using: + javac -d . -cp protobuf.jar;osmosis.jar;brouter.jar *.java +-> pack protobuf.jar + osmosis.jar + btools/**.class alltogether in a jar "pbfparser.jar" + +Alternativly, you can run the Mapcreator against a *xml.bz2 Database-Extract, +then you don't need the pbf-parser. diff --git a/misc/pbfparser/compile_parser.bat b/misc/pbfparser/compile_parser.bat new file mode 100644 index 0000000..6036270 --- /dev/null +++ b/misc/pbfparser/compile_parser.bat @@ -0,0 +1 @@ +javac -d . -cp protobuf.jar;osmosis.jar;brouter.jar BPbfFieldDecoder.java BPbfBlobDecoder.java OsmParser.java diff --git a/misc/scripts/mapcreation/BRouterTests.java b/misc/scripts/mapcreation/BRouterTests.java new file mode 100644 index 0000000..3148929 --- /dev/null +++ b/misc/scripts/mapcreation/BRouterTests.java @@ -0,0 +1,28 @@ +import java.io.*; + +public class BRouterTests +{ + public static void main( String[] args ) throws Exception + { + BufferedReader br = new BufferedReader( new FileReader( args[0] ) ); + + String lastname = "ups"; + for(;;) + { + + String line = br.readLine(); + if ( line == null ) break; + line = line.trim(); + if ( line.length() == 0 ) continue; + if ( !Character.isDigit( line.charAt( 0 ) ) ) + { + lastname = line; + continue; + } + + System.out.println( "/java/bin/java -Xmx32m -jar brouter.jar segments " + line + " /var/www/brouter/profiles2/trekking.brf" ); + System.out.println( "mv mytrack0.gpx gpx/" + lastname + ".gpx" ); + System.out.println( "mv mylog0.csv csv/" + lastname + ".csv" ); + } + } +} diff --git a/misc/scripts/mapcreation/all.brf b/misc/scripts/mapcreation/all.brf new file mode 100644 index 0000000..11de5a5 --- /dev/null +++ b/misc/scripts/mapcreation/all.brf @@ -0,0 +1,18 @@ +---context:global # following code refers to global config + +# the elevation parameters + +assign downhillcost 0 +assign downhillcutoff 1.5 +assign uphillcost 0 +assign uphillcutoff 1.5 + +---context:way # following code refers to way-tags + +assign turncost 0 +assign initialcost 0 +assign costfactor 1 + +---context:node # following code refers to node tags + +assign initialcost 0 diff --git a/misc/scripts/mapcreation/cronjob.sh b/misc/scripts/mapcreation/cronjob.sh new file mode 100644 index 0000000..6ad7de6 --- /dev/null +++ b/misc/scripts/mapcreation/cronjob.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd /root/osm +nohup ./process_pbf_planet.sh & diff --git a/misc/scripts/mapcreation/process_pbf_planet.sh b/misc/scripts/mapcreation/process_pbf_planet.sh new file mode 100644 index 0000000..6bf9af1 --- /dev/null +++ b/misc/scripts/mapcreation/process_pbf_planet.sh @@ -0,0 +1,46 @@ +#!/bin/bash +set -e +wget -N http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf + +if test lastmaprun.date -nt planet-latest.osm.pbf; then + echo "no osm update, exiting" + exit 0 +fi + +touch lastmaprun.date + +rm -rf /var/www/brouter/segments2_lastrun + +mkdir tmp +cd tmp +mkdir nodetiles +/java/bin/java -Xmx256m -Xms256m -Xmn32m -cp ../pbfparser.jar:../brouter.jar btools.mapcreator.OsmCutter ../lookups.dat nodetiles ways.dat cycleways.dat ../planet-latest.osm.pbf + +mkdir ftiles +/java/bin/java -Xmx512M -Xms512M -Xmn32M -cp ../brouter.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeFilter nodetiles ways.dat ftiles + +mkdir waytiles +/java/bin/java -Xmx2600M -Xms2600M -Xmn32M -cp ../brouter.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayCutter ftiles ways.dat waytiles cycleways.dat + +mkdir waytiles55 +/java/bin/java -Xmx2600M -Xms2600M -Xmn32M -cp ../brouter.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayCutter5 ftiles waytiles waytiles55 bordernids.dat + +mkdir nodes55 +/java/bin/java -Xmx128M -Xms128M -Xmn32M -cp ../brouter.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeCutter ftiles nodes55 + +mkdir unodes55 +/java/bin/java -Xmx2600M -Xms2600M -Xmn32M -cp ../brouter.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.PosUnifier nodes55 unodes55 bordernids.dat bordernodes.dat /private-backup/srtm + +mkdir segments +mkdir segments/carsubset + +/java/bin/java -Xmx2600M -Xms2600M -Xmn32M -cp ../brouter.jar -DuseDenseMaps=true btools.mapcreator.WayLinker unodes55 waytiles55 bordernodes.dat ../lookups.dat ../car-test.brf segments/carsubset cd5 +/java/bin/java -Xmx2600M -Xms2600M -Xmn32M -cp ../brouter.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.WayLinker unodes55 waytiles55 bordernodes.dat ../lookups.dat ../all.brf segments rd5 + +cd .. +rm -rf segments +mv tmp/segments segments +rm -rf tmp +cp /var/www/brouter/segments2/.htaccess segments +mv /var/www/brouter/segments2 /var/www/brouter/segments2_lastrun +mv segments /var/www/brouter/segments2 diff --git a/misc/scripts/mapcreation/routetest.sh b/misc/scripts/mapcreation/routetest.sh new file mode 100644 index 0000000..c0ef85c --- /dev/null +++ b/misc/scripts/mapcreation/routetest.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -e +/java/bin/javac -d . BRouterTests.java +rm -rf troutes +mkdir troutes +cd troutes +mkdir gpxold +mkdir gpxnew +mkdir csvold +mkdir csvnew +/java/bin/javac -d . ../BRouterTests.java +/java/bin/java -cp . BRouterTests ../examples.txt > dotests.sh +chmod +x dotests.sh +ln -s gpxnew gpx +ln -s csvnew csv +ln -s /var/www/brouter/segments2_lastrun segments +cp /usr/lib/cgi-bin/brouter64.jar brouter.jar +./dotests.sh +rm gpx +rm csv +rm segments +ln -s gpxold gpx +ln -s csvold csv +ln -s /var/www/brouter/segments2 segments +./dotests.sh +rm gpx +rm csv +rm segments +rm *.class