Merge branch 'master' into engine-mode
This commit is contained in:
commit
fcab1a31fd
61 changed files with 389 additions and 507 deletions
|
@ -287,9 +287,9 @@ public final class MicroCache2 extends MicroCache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int encodeMicroCache(byte[] buffer) {
|
public int encodeMicroCache(byte[] buffer) {
|
||||||
HashMap<Long, Integer> idMap = new HashMap<Long, Integer>();
|
HashMap<Long, Integer> idMap = new HashMap<>();
|
||||||
for (int n = 0; n < size; n++) { // loop over nodes
|
for (int n = 0; n < size; n++) { // loop over nodes
|
||||||
idMap.put(Long.valueOf(expandId(faid[n])), Integer.valueOf(n));
|
idMap.put(expandId(faid[n]), n);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntegerFifo3Pass linkCounts = new IntegerFifo3Pass(256);
|
IntegerFifo3Pass linkCounts = new IntegerFifo3Pass(256);
|
||||||
|
@ -404,7 +404,7 @@ public final class MicroCache2 extends MicroCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
long link64 = ((long) ilonlink) << 32 | ilatlink;
|
long link64 = ((long) ilonlink) << 32 | ilatlink;
|
||||||
Integer idx = idMap.get(Long.valueOf(link64));
|
Integer idx = idMap.get(link64);
|
||||||
boolean isInternal = idx != null;
|
boolean isInternal = idx != null;
|
||||||
|
|
||||||
if (isReverse && isInternal) {
|
if (isReverse && isInternal) {
|
||||||
|
|
|
@ -39,7 +39,7 @@ public final class StatCoderContext extends BitCoderContext {
|
||||||
public void assignBits(String name) {
|
public void assignBits(String name) {
|
||||||
long bitpos = getWritingBitPosition();
|
long bitpos = getWritingBitPosition();
|
||||||
if (statsPerName == null) {
|
if (statsPerName == null) {
|
||||||
statsPerName = new TreeMap<String, long[]>();
|
statsPerName = new TreeMap<>();
|
||||||
}
|
}
|
||||||
long[] stats = statsPerName.get(name);
|
long[] stats = statsPerName.get(name);
|
||||||
if (stats == null) {
|
if (stats == null) {
|
||||||
|
|
|
@ -58,7 +58,7 @@ public final class TagValueCoder {
|
||||||
TagValueSet dummy = new TagValueSet(nextTagValueSetId++);
|
TagValueSet dummy = new TagValueSet(nextTagValueSetId++);
|
||||||
identityMap.put(dummy, dummy);
|
identityMap.put(dummy, dummy);
|
||||||
}
|
}
|
||||||
PriorityQueue<TagValueSet> queue = new PriorityQueue<TagValueSet>(2 * identityMap.size(), new TagValueSet.FrequencyComparator());
|
PriorityQueue<TagValueSet> queue = new PriorityQueue<>(2 * identityMap.size(), new TagValueSet.FrequencyComparator());
|
||||||
queue.addAll(identityMap.values());
|
queue.addAll(identityMap.values());
|
||||||
while (queue.size() > 1) {
|
while (queue.size() > 1) {
|
||||||
TagValueSet node = new TagValueSet(nextTagValueSetId++);
|
TagValueSet node = new TagValueSet(nextTagValueSetId++);
|
||||||
|
@ -79,7 +79,7 @@ public final class TagValueCoder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TagValueCoder() {
|
public TagValueCoder() {
|
||||||
identityMap = new HashMap<TagValueSet, TagValueSet>();
|
identityMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object decodeTree(BitCoderContext bc, DataBuffers buffers, TagValueValidator validator) {
|
private Object decodeTree(BitCoderContext bc, DataBuffers buffers, TagValueValidator validator) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class OsmNogoPolygon extends OsmNodeNamed {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final List<Point> points = new ArrayList<Point>();
|
public final List<Point> points = new ArrayList<>();
|
||||||
|
|
||||||
public final boolean isClosed;
|
public final boolean isClosed;
|
||||||
|
|
||||||
|
|
|
@ -53,14 +53,14 @@ public final class OsmTrack {
|
||||||
|
|
||||||
public Map<String, String> params;
|
public Map<String, String> params;
|
||||||
|
|
||||||
public List<OsmNodeNamed> pois = new ArrayList<OsmNodeNamed>();
|
public List<OsmNodeNamed> pois = new ArrayList<>();
|
||||||
|
|
||||||
public static class OsmPathElementHolder {
|
public static class OsmPathElementHolder {
|
||||||
public OsmPathElement node;
|
public OsmPathElement node;
|
||||||
public OsmPathElementHolder nextHolder;
|
public OsmPathElementHolder nextHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OsmPathElement> nodes = new ArrayList<OsmPathElement>();
|
public List<OsmPathElement> nodes = new ArrayList<>();
|
||||||
|
|
||||||
private CompactLongMap<OsmPathElementHolder> nodesMap;
|
private CompactLongMap<OsmPathElementHolder> nodesMap;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public final class OsmTrack {
|
||||||
|
|
||||||
public void registerDetourForId(long id, OsmPathElement detour) {
|
public void registerDetourForId(long id, OsmPathElement detour) {
|
||||||
if (detourMap == null) {
|
if (detourMap == null) {
|
||||||
detourMap = new CompactLongMap<OsmPathElementHolder>();
|
detourMap = new CompactLongMap<>();
|
||||||
}
|
}
|
||||||
OsmPathElementHolder nh = new OsmPathElementHolder();
|
OsmPathElementHolder nh = new OsmPathElementHolder();
|
||||||
nh.node = detour;
|
nh.node = detour;
|
||||||
|
@ -98,12 +98,12 @@ public final class OsmTrack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyDetours(OsmTrack source) {
|
public void copyDetours(OsmTrack source) {
|
||||||
detourMap = source.detourMap == null ? null : new FrozenLongMap<OsmPathElementHolder>(source.detourMap);
|
detourMap = source.detourMap == null ? null : new FrozenLongMap<>(source.detourMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDetours(OsmTrack source) {
|
public void addDetours(OsmTrack source) {
|
||||||
if (detourMap != null) {
|
if (detourMap != null) {
|
||||||
CompactLongMap<OsmPathElementHolder> tmpDetourMap = new CompactLongMap<OsmPathElementHolder>();
|
CompactLongMap<OsmPathElementHolder> tmpDetourMap = new CompactLongMap<>();
|
||||||
|
|
||||||
List oldlist = ((FrozenLongMap) detourMap).getValueList();
|
List oldlist = ((FrozenLongMap) detourMap).getValueList();
|
||||||
long[] oldidlist = ((FrozenLongMap) detourMap).getKeyArray();
|
long[] oldidlist = ((FrozenLongMap) detourMap).getKeyArray();
|
||||||
|
@ -124,7 +124,7 @@ public final class OsmTrack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
detourMap = new FrozenLongMap<OsmPathElementHolder>(tmpDetourMap);
|
detourMap = new FrozenLongMap<>(tmpDetourMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ public final class OsmTrack {
|
||||||
|
|
||||||
public void appendDetours(OsmTrack source) {
|
public void appendDetours(OsmTrack source) {
|
||||||
if (detourMap == null) {
|
if (detourMap == null) {
|
||||||
detourMap = source.detourMap == null ? null : new CompactLongMap<OsmPathElementHolder>();
|
detourMap = source.detourMap == null ? null : new CompactLongMap<>();
|
||||||
}
|
}
|
||||||
if (source.detourMap != null) {
|
if (source.detourMap != null) {
|
||||||
int pos = nodes.size() - source.nodes.size() + 1;
|
int pos = nodes.size() - source.nodes.size() + 1;
|
||||||
|
@ -160,7 +160,7 @@ public final class OsmTrack {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildMap() {
|
public void buildMap() {
|
||||||
nodesMap = new CompactLongMap<OsmPathElementHolder>();
|
nodesMap = new CompactLongMap<>();
|
||||||
for (OsmPathElement node : nodes) {
|
for (OsmPathElement node : nodes) {
|
||||||
long id = node.getIdFromPos();
|
long id = node.getIdFromPos();
|
||||||
OsmPathElementHolder nh = new OsmPathElementHolder();
|
OsmPathElementHolder nh = new OsmPathElementHolder();
|
||||||
|
@ -175,11 +175,11 @@ public final class OsmTrack {
|
||||||
nodesMap.fastPut(id, nh);
|
nodesMap.fastPut(id, nh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodesMap = new FrozenLongMap<OsmPathElementHolder>(nodesMap);
|
nodesMap = new FrozenLongMap<>(nodesMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> aggregateMessages() {
|
private List<String> aggregateMessages() {
|
||||||
ArrayList<String> res = new ArrayList<String>();
|
ArrayList<String> res = new ArrayList<>();
|
||||||
MessageData current = null;
|
MessageData current = null;
|
||||||
for (OsmPathElement n : nodes) {
|
for (OsmPathElement n : nodes) {
|
||||||
if (n.message != null && n.message.wayKeyValues != null) {
|
if (n.message != null && n.message.wayKeyValues != null) {
|
||||||
|
@ -201,7 +201,7 @@ public final class OsmTrack {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> aggregateSpeedProfile() {
|
private List<String> aggregateSpeedProfile() {
|
||||||
ArrayList<String> res = new ArrayList<String>();
|
ArrayList<String> res = new ArrayList<>();
|
||||||
int vmax = -1;
|
int vmax = -1;
|
||||||
int vmaxe = -1;
|
int vmaxe = -1;
|
||||||
int vmin = -1;
|
int vmin = -1;
|
||||||
|
@ -1332,7 +1332,7 @@ public final class OsmTrack {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
node = nodes.get(nodeNr);
|
node = nodes.get(nodeNr);
|
||||||
List<VoiceHint> inputs = new ArrayList<VoiceHint>();
|
List<VoiceHint> inputs = new ArrayList<>();
|
||||||
while (node != null) {
|
while (node != null) {
|
||||||
if (node.origin != null) {
|
if (node.origin != null) {
|
||||||
VoiceHint input = new VoiceHint();
|
VoiceHint input = new VoiceHint();
|
||||||
|
|
|
@ -274,7 +274,7 @@ public final class RoutingContext {
|
||||||
public void cleanNogoList(List<OsmNode> waypoints) {
|
public void cleanNogoList(List<OsmNode> waypoints) {
|
||||||
nogopoints_all = nogopoints;
|
nogopoints_all = nogopoints;
|
||||||
if (nogopoints == null) return;
|
if (nogopoints == null) return;
|
||||||
List<OsmNodeNamed> nogos = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> nogos = new ArrayList<>();
|
||||||
for (OsmNodeNamed nogo : nogopoints) {
|
for (OsmNodeNamed nogo : nogopoints) {
|
||||||
boolean goodGuy = true;
|
boolean goodGuy = true;
|
||||||
for (OsmNode wp : waypoints) {
|
for (OsmNode wp : waypoints) {
|
||||||
|
@ -386,7 +386,7 @@ public final class RoutingContext {
|
||||||
|
|
||||||
public void setWaypoint(OsmNodeNamed wp, OsmNodeNamed pendingEndpoint, boolean endpoint) {
|
public void setWaypoint(OsmNodeNamed wp, OsmNodeNamed pendingEndpoint, boolean endpoint) {
|
||||||
keepnogopoints = nogopoints;
|
keepnogopoints = nogopoints;
|
||||||
nogopoints = new ArrayList<OsmNodeNamed>();
|
nogopoints = new ArrayList<>();
|
||||||
nogopoints.add(wp);
|
nogopoints.add(wp);
|
||||||
if (keepnogopoints != null) nogopoints.addAll(keepnogopoints);
|
if (keepnogopoints != null) nogopoints.addAll(keepnogopoints);
|
||||||
isEndpoint = endpoint;
|
isEndpoint = endpoint;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class RoutingEngine extends Thread {
|
||||||
public final static int BROUTER_ENGINEMODE_GETELEV = 2;
|
public final static int BROUTER_ENGINEMODE_GETELEV = 2;
|
||||||
|
|
||||||
private NodesCache nodesCache;
|
private NodesCache nodesCache;
|
||||||
private SortedHeap<OsmPath> openSet = new SortedHeap<OsmPath>();
|
private SortedHeap<OsmPath> openSet = new SortedHeap<>();
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
|
||||||
protected List<OsmNodeNamed> waypoints = null;
|
protected List<OsmNodeNamed> waypoints = null;
|
||||||
|
@ -179,7 +179,7 @@ public class RoutingEngine extends Thread {
|
||||||
OsmTrack[] refTracks = new OsmTrack[nsections]; // used ways for alternatives
|
OsmTrack[] refTracks = new OsmTrack[nsections]; // used ways for alternatives
|
||||||
OsmTrack[] lastTracks = new OsmTrack[nsections];
|
OsmTrack[] lastTracks = new OsmTrack[nsections];
|
||||||
OsmTrack track = null;
|
OsmTrack track = null;
|
||||||
ArrayList<String> messageList = new ArrayList<String>();
|
ArrayList<String> messageList = new ArrayList<>();
|
||||||
for (int i = 0; ; i++) {
|
for (int i = 0; ; i++) {
|
||||||
track = findTrack(refTracks, lastTracks);
|
track = findTrack(refTracks, lastTracks);
|
||||||
track.message = "track-length = " + track.distance + " filtered ascend = " + track.ascend
|
track.message = "track-length = " + track.distance + " filtered ascend = " + track.ascend
|
||||||
|
@ -433,7 +433,7 @@ public class RoutingEngine extends Thread {
|
||||||
try {
|
try {
|
||||||
MatchedWaypoint seedPoint = new MatchedWaypoint();
|
MatchedWaypoint seedPoint = new MatchedWaypoint();
|
||||||
seedPoint.waypoint = waypoints.get(0);
|
seedPoint.waypoint = waypoints.get(0);
|
||||||
List<MatchedWaypoint> listOne = new ArrayList<MatchedWaypoint>();
|
List<MatchedWaypoint> listOne = new ArrayList<>();
|
||||||
listOne.add(seedPoint);
|
listOne.add(seedPoint);
|
||||||
matchWaypointsToNodes(listOne);
|
matchWaypointsToNodes(listOne);
|
||||||
|
|
||||||
|
@ -508,7 +508,7 @@ public class RoutingEngine extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchedWaypoints == null) { // could exist from the previous alternative level
|
if (matchedWaypoints == null) { // could exist from the previous alternative level
|
||||||
matchedWaypoints = new ArrayList<MatchedWaypoint>();
|
matchedWaypoints = new ArrayList<>();
|
||||||
for (int i = 0; i < nUnmatched; i++) {
|
for (int i = 0; i < nUnmatched; i++) {
|
||||||
MatchedWaypoint mwp = new MatchedWaypoint();
|
MatchedWaypoint mwp = new MatchedWaypoint();
|
||||||
mwp.waypoint = waypoints.get(i);
|
mwp.waypoint = waypoints.get(i);
|
||||||
|
@ -1064,7 +1064,7 @@ public class RoutingEngine extends Thread {
|
||||||
|
|
||||||
private OsmTrack findTrack(String operationName, MatchedWaypoint startWp, MatchedWaypoint endWp, OsmTrack costCuttingTrack, OsmTrack refTrack, boolean fastPartialRecalc) {
|
private OsmTrack findTrack(String operationName, MatchedWaypoint startWp, MatchedWaypoint endWp, OsmTrack costCuttingTrack, OsmTrack refTrack, boolean fastPartialRecalc) {
|
||||||
try {
|
try {
|
||||||
List<OsmNode> wpts2 = new ArrayList<OsmNode>();
|
List<OsmNode> wpts2 = new ArrayList<>();
|
||||||
if (startWp != null) wpts2.add(startWp.waypoint);
|
if (startWp != null) wpts2.add(startWp.waypoint);
|
||||||
if (endWp != null) wpts2.add(endWp.waypoint);
|
if (endWp != null) wpts2.add(endWp.waypoint);
|
||||||
routingContext.cleanNogoList(wpts2);
|
routingContext.cleanNogoList(wpts2);
|
||||||
|
@ -1157,7 +1157,7 @@ public class RoutingEngine extends Thread {
|
||||||
addToOpenset(startPath1);
|
addToOpenset(startPath1);
|
||||||
addToOpenset(startPath2);
|
addToOpenset(startPath2);
|
||||||
}
|
}
|
||||||
ArrayList<OsmPath> openBorderList = new ArrayList<OsmPath>(4096);
|
ArrayList<OsmPath> openBorderList = new ArrayList<>(4096);
|
||||||
boolean memoryPanicMode = false;
|
boolean memoryPanicMode = false;
|
||||||
boolean needNonPanicProcessing = false;
|
boolean needNonPanicProcessing = false;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class SuspectInfo {
|
||||||
public int triggers;
|
public int triggers;
|
||||||
|
|
||||||
public static void addSuspect(Map<Long, SuspectInfo> map, long id, int prio, int trigger) {
|
public static void addSuspect(Map<Long, SuspectInfo> map, long id, int prio, int trigger) {
|
||||||
Long iD = Long.valueOf(id);
|
Long iD = id;
|
||||||
SuspectInfo info = map.get(iD);
|
SuspectInfo info = map.get(iD);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
info = new SuspectInfo();
|
info = new SuspectInfo();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class VoiceHint {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (badWays == null) {
|
if (badWays == null) {
|
||||||
badWays = new ArrayList<MessageData>();
|
badWays = new ArrayList<>();
|
||||||
}
|
}
|
||||||
badWays.add(badWay);
|
badWays.add(badWay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
||||||
public class VoiceHintList {
|
public class VoiceHintList {
|
||||||
private String transportMode;
|
private String transportMode;
|
||||||
int turnInstructionMode;
|
int turnInstructionMode;
|
||||||
List<VoiceHint> list = new ArrayList<VoiceHint>();
|
List<VoiceHint> list = new ArrayList<>();
|
||||||
|
|
||||||
public void setTransportMode(boolean isCar, boolean isBike) {
|
public void setTransportMode(boolean isCar, boolean isBike) {
|
||||||
transportMode = isCar ? "car" : (isBike ? "bike" : "foot");
|
transportMode = isCar ? "car" : (isBike ? "bike" : "foot");
|
||||||
|
|
|
@ -55,7 +55,7 @@ public final class VoiceHintProcessor {
|
||||||
* @return voice hints, in forward order
|
* @return voice hints, in forward order
|
||||||
*/
|
*/
|
||||||
public List<VoiceHint> process(List<VoiceHint> inputs) {
|
public List<VoiceHint> process(List<VoiceHint> inputs) {
|
||||||
List<VoiceHint> results = new ArrayList<VoiceHint>();
|
List<VoiceHint> results = new ArrayList<>();
|
||||||
double distance = 0.;
|
double distance = 0.;
|
||||||
float roundAboutTurnAngle = 0.f; // sums up angles in roundabout
|
float roundAboutTurnAngle = 0.f; // sums up angles in roundabout
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ public final class VoiceHintProcessor {
|
||||||
// go through the hint list again in reverse order (=travel direction)
|
// go through the hint list again in reverse order (=travel direction)
|
||||||
// and filter out non-significant hints and hints too close to its predecessor
|
// and filter out non-significant hints and hints too close to its predecessor
|
||||||
|
|
||||||
List<VoiceHint> results2 = new ArrayList<VoiceHint>();
|
List<VoiceHint> results2 = new ArrayList<>();
|
||||||
int i = results.size();
|
int i = results.size();
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
VoiceHint hint = results.get(--i);
|
VoiceHint hint = results.get(--i);
|
||||||
|
@ -241,7 +241,7 @@ public final class VoiceHintProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VoiceHint> postProcess(List<VoiceHint> inputs, double catchingRange, double minRange) {
|
public List<VoiceHint> postProcess(List<VoiceHint> inputs, double catchingRange, double minRange) {
|
||||||
List<VoiceHint> results = new ArrayList<VoiceHint>();
|
List<VoiceHint> results = new ArrayList<>();
|
||||||
double distance = 0;
|
double distance = 0;
|
||||||
VoiceHint inputLast = null;
|
VoiceHint inputLast = null;
|
||||||
ArrayList<VoiceHint> tmpList = new ArrayList<>();
|
ArrayList<VoiceHint> tmpList = new ArrayList<>();
|
||||||
|
|
|
@ -36,10 +36,10 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
|
|
||||||
public String _modelClass;
|
public String _modelClass;
|
||||||
|
|
||||||
private Map<String, Integer> lookupNumbers = new HashMap<String, Integer>();
|
private Map<String, Integer> lookupNumbers = new HashMap<>();
|
||||||
private List<BExpressionLookupValue[]> lookupValues = new ArrayList<BExpressionLookupValue[]>();
|
private List<BExpressionLookupValue[]> lookupValues = new ArrayList<>();
|
||||||
private List<String> lookupNames = new ArrayList<String>();
|
private List<String> lookupNames = new ArrayList<>();
|
||||||
private List<int[]> lookupHistograms = new ArrayList<int[]>();
|
private List<int[]> lookupHistograms = new ArrayList<>();
|
||||||
private boolean[] lookupIdxUsed;
|
private boolean[] lookupIdxUsed;
|
||||||
|
|
||||||
private boolean lookupDataFrozen = false;
|
private boolean lookupDataFrozen = false;
|
||||||
|
@ -50,7 +50,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
private BitCoderContext ctxEndode = new BitCoderContext(abBuf);
|
private BitCoderContext ctxEndode = new BitCoderContext(abBuf);
|
||||||
private BitCoderContext ctxDecode = new BitCoderContext(new byte[0]);
|
private BitCoderContext ctxDecode = new BitCoderContext(new byte[0]);
|
||||||
|
|
||||||
private Map<String, Integer> variableNumbers = new HashMap<String, Integer>();
|
private Map<String, Integer> variableNumbers = new HashMap<>();
|
||||||
|
|
||||||
private float[] variableData;
|
private float[] variableData;
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getKeyValueList(boolean inverseDirection, byte[] ab) {
|
public List<String> getKeyValueList(boolean inverseDirection, byte[] ab) {
|
||||||
ArrayList<String> res = new ArrayList<String>();
|
ArrayList<String> res = new ArrayList<>();
|
||||||
decode(lookupData, inverseDirection, ab);
|
decode(lookupData, inverseDirection, ab);
|
||||||
for (int inum = 0; inum < lookupValues.size(); inum++) { // loop over lookup names
|
for (int inum = 0; inum < lookupValues.size(); inum++) { // loop over lookup names
|
||||||
BExpressionLookupValue[] va = lookupValues.get(inum);
|
BExpressionLookupValue[] va = lookupValues.get(inum);
|
||||||
|
@ -429,7 +429,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
|
|
||||||
|
|
||||||
public void dumpStatistics() {
|
public void dumpStatistics() {
|
||||||
TreeMap<String, String> counts = new TreeMap<String, String>();
|
TreeMap<String, String> counts = new TreeMap<>();
|
||||||
// first count
|
// first count
|
||||||
for (String name : lookupNumbers.keySet()) {
|
for (String name : lookupNumbers.keySet()) {
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
@ -528,7 +528,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown name, create
|
// unknown name, create
|
||||||
num = Integer.valueOf(lookupValues.size());
|
num = lookupValues.size();
|
||||||
lookupNumbers.put(name, num);
|
lookupNumbers.put(name, num);
|
||||||
lookupNames.add(name);
|
lookupNames.add(name);
|
||||||
lookupValues.add(new BExpressionLookupValue[]{new BExpressionLookupValue("")
|
lookupValues.add(new BExpressionLookupValue[]{new BExpressionLookupValue("")
|
||||||
|
@ -815,7 +815,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
private List<BExpression> _parseFile(File file) throws Exception {
|
private List<BExpression> _parseFile(File file) throws Exception {
|
||||||
_br = new BufferedReader(new FileReader(file));
|
_br = new BufferedReader(new FileReader(file));
|
||||||
_readerDone = false;
|
_readerDone = false;
|
||||||
List<BExpression> result = new ArrayList<BExpression>();
|
List<BExpression> result = new ArrayList<>();
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
BExpression exp = BExpression.parse(this, 0);
|
BExpression exp = BExpression.parse(this, 0);
|
||||||
if (exp == null) break;
|
if (exp == null) break;
|
||||||
|
@ -855,7 +855,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||||
Integer num = variableNumbers.get(name);
|
Integer num = variableNumbers.get(name);
|
||||||
if (num == null) {
|
if (num == null) {
|
||||||
if (create) {
|
if (create) {
|
||||||
num = Integer.valueOf(variableNumbers.size());
|
num = variableNumbers.size();
|
||||||
variableNumbers.put(name, num);
|
variableNumbers.put(name, num);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class BExpressionLookupValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAlias(String alias) {
|
public void addAlias(String alias) {
|
||||||
if (aliases == null) aliases = new ArrayList<String>();
|
if (aliases == null) aliases = new ArrayList<>();
|
||||||
aliases.add(alias);
|
aliases.add(alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public final class BExpressionMetaData {
|
||||||
public short lookupMinorVersion = -1;
|
public short lookupMinorVersion = -1;
|
||||||
public short minAppVersion = -1;
|
public short minAppVersion = -1;
|
||||||
|
|
||||||
private Map<String, BExpressionContext> listeners = new HashMap<String, BExpressionContext>();
|
private Map<String, BExpressionContext> listeners = new HashMap<>();
|
||||||
|
|
||||||
public void registerListener(String context, BExpressionContext ctx) {
|
public void registerListener(String context, BExpressionContext ctx) {
|
||||||
listeners.put(context, ctx);
|
listeners.put(context, ctx);
|
||||||
|
|
|
@ -2,11 +2,12 @@ plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':brouter-codec')
|
implementation project(':brouter-codec')
|
||||||
implementation project(':brouter-util')
|
implementation project(':brouter-util')
|
||||||
implementation project(':brouter-expressions')
|
implementation project(':brouter-expressions')
|
||||||
|
|
||||||
|
implementation group: 'org.openstreetmap.osmosis', name: 'osmosis-osm-binary', version: '0.48.3'
|
||||||
|
|
||||||
testImplementation('junit:junit:4.13.1')
|
testImplementation('junit:junit:4.13.1')
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,18 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import org.openstreetmap.osmosis.osmbinary.Fileformat;
|
import org.openstreetmap.osmosis.osmbinary.Fileformat;
|
||||||
import org.openstreetmap.osmosis.osmbinary.Osmformat;
|
import org.openstreetmap.osmosis.osmbinary.Osmformat;
|
||||||
|
|
||||||
import btools.util.LongList;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.zip.DataFormatException;
|
import java.util.zip.DataFormatException;
|
||||||
import java.util.zip.Inflater;
|
import java.util.zip.Inflater;
|
||||||
|
|
||||||
|
import btools.util.LongList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts PBF block data into decoded entities ready to be passed into an Osmosis pipeline. This
|
* 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.
|
* class is designed to be passed into a pool of worker threads to allow multi-threaded decoding.
|
||||||
|
@ -82,8 +86,8 @@ public class BPbfBlobDecoder {
|
||||||
|
|
||||||
// Build the list of active and unsupported features in the file.
|
// Build the list of active and unsupported features in the file.
|
||||||
List<String> supportedFeatures = Arrays.asList("OsmSchema-V0.6", "DenseNodes");
|
List<String> supportedFeatures = Arrays.asList("OsmSchema-V0.6", "DenseNodes");
|
||||||
List<String> activeFeatures = new ArrayList<String>();
|
List<String> activeFeatures = new ArrayList<>();
|
||||||
List<String> unsupportedFeatures = new ArrayList<String>();
|
List<String> unsupportedFeatures = new ArrayList<>();
|
||||||
for (String feature : header.getRequiredFeaturesList()) {
|
for (String feature : header.getRequiredFeaturesList()) {
|
||||||
if (supportedFeatures.contains(feature)) {
|
if (supportedFeatures.contains(feature)) {
|
||||||
activeFeatures.add(feature);
|
activeFeatures.add(feature);
|
||||||
|
@ -106,7 +110,7 @@ public class BPbfBlobDecoder {
|
||||||
Iterator<Integer> keyIterator = keys.iterator();
|
Iterator<Integer> keyIterator = keys.iterator();
|
||||||
Iterator<Integer> valueIterator = values.iterator();
|
Iterator<Integer> valueIterator = values.iterator();
|
||||||
if (keyIterator.hasNext()) {
|
if (keyIterator.hasNext()) {
|
||||||
Map<String, String> tags = new HashMap<String, String>();
|
Map<String, String> tags = new HashMap<>();
|
||||||
while (keyIterator.hasNext()) {
|
while (keyIterator.hasNext()) {
|
||||||
String key = fieldDecoder.decodeString(keyIterator.next());
|
String key = fieldDecoder.decodeString(keyIterator.next());
|
||||||
String value = fieldDecoder.decodeString(valueIterator.next());
|
String value = fieldDecoder.decodeString(valueIterator.next());
|
||||||
|
@ -155,7 +159,7 @@ public class BPbfBlobDecoder {
|
||||||
int valueIndex = keysValuesIterator.next();
|
int valueIndex = keysValuesIterator.next();
|
||||||
|
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
tags = new HashMap<String, String>();
|
tags = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
tags.put(fieldDecoder.decodeString(keyIndex), fieldDecoder.decodeString(valueIndex));
|
tags.put(fieldDecoder.decodeString(keyIndex), fieldDecoder.decodeString(valueIndex));
|
|
@ -5,19 +5,27 @@ import java.io.BufferedOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
public class ConvertLidarTile {
|
public class ConvertLidarTile {
|
||||||
public static int NROWS;
|
private static int NROWS;
|
||||||
public static int NCOLS;
|
private static int NCOLS;
|
||||||
|
|
||||||
public static final short NODATA2 = -32767; // hgt-formats nodata
|
public static final short NODATA2 = -32767; // hgt-formats nodata
|
||||||
public static final short NODATA = Short.MIN_VALUE;
|
public static final short NODATA = Short.MIN_VALUE;
|
||||||
|
|
||||||
|
private static final String HGT_FILE_EXT = ".hgt";
|
||||||
|
private static final int HGT_BORDER_OVERLAP = 1;
|
||||||
|
private static final int HGT_3ASEC_ROWS = 1201; // 3 arc second resolution (90m)
|
||||||
|
private static final int HGT_3ASEC_FILE_SIZE = HGT_3ASEC_ROWS * HGT_3ASEC_ROWS * Short.BYTES;
|
||||||
|
private static final int HGT_1ASEC_ROWS = 3601; // 1 arc second resolution (30m)
|
||||||
|
|
||||||
static short[] imagePixels;
|
static short[] imagePixels;
|
||||||
|
|
||||||
private static void readHgtZip(String filename, int rowOffset, int colOffset) throws Exception {
|
private static void readHgtZip(String filename, int rowOffset, int colOffset) throws Exception {
|
||||||
|
@ -25,8 +33,9 @@ public class ConvertLidarTile {
|
||||||
try {
|
try {
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
ZipEntry ze = zis.getNextEntry();
|
ZipEntry ze = zis.getNextEntry();
|
||||||
if (ze.getName().endsWith(".hgt")) {
|
if (ze == null) break;
|
||||||
readHgtFromStream(zis, rowOffset, colOffset);
|
if (ze.getName().toLowerCase().endsWith(HGT_FILE_EXT)) {
|
||||||
|
readHgtFromStream(zis, rowOffset, colOffset, HGT_3ASEC_ROWS);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,20 +44,20 @@ public class ConvertLidarTile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void readHgtFromStream(InputStream is, int rowOffset, int colOffset)
|
private static void readHgtFromStream(InputStream is, int rowOffset, int colOffset, int rowLength)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
DataInputStream dis = new DataInputStream(new BufferedInputStream(is));
|
DataInputStream dis = new DataInputStream(new BufferedInputStream(is));
|
||||||
for (int ir = 0; ir < 1201; ir++) {
|
for (int ir = 0; ir < rowLength; ir++) {
|
||||||
int row = rowOffset + ir;
|
int row = rowOffset + ir;
|
||||||
|
|
||||||
for (int ic = 0; ic < 1201; ic++) {
|
for (int ic = 0; ic < rowLength; ic++) {
|
||||||
int col = colOffset + ic;
|
int col = colOffset + ic;
|
||||||
|
|
||||||
int i1 = dis.read(); // msb first!
|
int i1 = dis.read(); // msb first!
|
||||||
int i0 = dis.read();
|
int i0 = dis.read();
|
||||||
|
|
||||||
if (i0 == -1 || i1 == -1)
|
if (i0 == -1 || i1 == -1)
|
||||||
throw new RuntimeException("unexcepted end of file reading hgt entry!");
|
throw new RuntimeException("unexpected end of file reading hgt entry!");
|
||||||
|
|
||||||
short val = (short) ((i1 << 8) | i0);
|
short val = (short) ((i1 << 8) | i0);
|
||||||
|
|
||||||
|
@ -61,7 +70,6 @@ public class ConvertLidarTile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void setPixel(int row, int col, short val) {
|
private static void setPixel(int row, int col, short val) {
|
||||||
if (row >= 0 && row < NROWS && col >= 0 && col < NCOLS) {
|
if (row >= 0 && row < NROWS && col >= 0 && col < NCOLS) {
|
||||||
imagePixels[row * NCOLS + col] = val;
|
imagePixels[row * NCOLS + col] = val;
|
||||||
|
@ -186,4 +194,57 @@ public class ConvertLidarTile {
|
||||||
doConvert(args[1], ilon_base, ilat_base, filename30);
|
doConvert(args[1], ilon_base, ilat_base, filename30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SrtmRaster getRaster(File f, double lon, double lat) throws Exception {
|
||||||
|
long fileSize;
|
||||||
|
InputStream inputStream;
|
||||||
|
|
||||||
|
if (f.getName().toLowerCase().endsWith(".zip")) {
|
||||||
|
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(f)));
|
||||||
|
for (; ; ) {
|
||||||
|
ZipEntry ze = zis.getNextEntry();
|
||||||
|
if (ze == null) {
|
||||||
|
throw new FileNotFoundException(f.getName() + " doesn't contain a " + HGT_FILE_EXT + " file.");
|
||||||
|
}
|
||||||
|
if (ze.getName().toLowerCase().endsWith(HGT_FILE_EXT)) {
|
||||||
|
fileSize = ze.getSize();
|
||||||
|
inputStream = zis;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fileSize = f.length();
|
||||||
|
inputStream = new FileInputStream(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rowLength;
|
||||||
|
if (fileSize > HGT_3ASEC_FILE_SIZE) {
|
||||||
|
rowLength = HGT_1ASEC_ROWS;
|
||||||
|
} else {
|
||||||
|
rowLength = HGT_3ASEC_ROWS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// stay at 1 deg * 1 deg raster
|
||||||
|
NROWS = rowLength;
|
||||||
|
NCOLS = rowLength;
|
||||||
|
|
||||||
|
imagePixels = new short[NROWS * NCOLS];
|
||||||
|
|
||||||
|
// prefill as NODATA
|
||||||
|
Arrays.fill(imagePixels, NODATA);
|
||||||
|
readHgtFromStream(inputStream, 0, 0, rowLength);
|
||||||
|
inputStream.close();
|
||||||
|
|
||||||
|
SrtmRaster raster = new SrtmRaster();
|
||||||
|
raster.nrows = NROWS;
|
||||||
|
raster.ncols = NCOLS;
|
||||||
|
raster.halfcol = false; // assume full resolution
|
||||||
|
raster.noDataValue = NODATA;
|
||||||
|
raster.cellsize = 1. / (double) (rowLength - HGT_BORDER_OVERLAP);
|
||||||
|
raster.xllcorner = (int) (lon < 0 ? lon - 1 : lon); //onDegreeStart - raster.cellsize;
|
||||||
|
raster.yllcorner = (int) (lat < 0 ? lat - 1 : lat); //latDegreeStart - raster.cellsize;
|
||||||
|
raster.eval_array = imagePixels;
|
||||||
|
|
||||||
|
return raster;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public abstract class MapCreatorBase implements WayListener, NodeListener, Relat
|
||||||
protected Map<String, String> tags;
|
protected Map<String, String> tags;
|
||||||
|
|
||||||
public void putTag(String key, String value) {
|
public void putTag(String key, String value) {
|
||||||
if (tags == null) tags = new HashMap<String, String>();
|
if (tags == null) tags = new HashMap<>();
|
||||||
tags.put(key, value);
|
tags.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class OsmNodeP extends OsmLinkP {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkDuplicateTargets() {
|
public void checkDuplicateTargets() {
|
||||||
HashMap<OsmNodeP, OsmLinkP> targets = new HashMap<OsmNodeP, OsmLinkP>();
|
HashMap<OsmNodeP, OsmLinkP> targets = new HashMap<>();
|
||||||
|
|
||||||
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
|
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
|
||||||
OsmLinkP link = link0;
|
OsmLinkP link = link0;
|
||||||
|
@ -165,14 +165,14 @@ public class OsmNodeP extends OsmLinkP {
|
||||||
mc.writeVarBytes(getNodeDecsription());
|
mc.writeVarBytes(getNodeDecsription());
|
||||||
|
|
||||||
// buffer internal reverse links
|
// buffer internal reverse links
|
||||||
ArrayList<OsmNodeP> internalReverse = new ArrayList<OsmNodeP>();
|
ArrayList<OsmNodeP> internalReverse = new ArrayList<>();
|
||||||
|
|
||||||
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
|
for (OsmLinkP link0 = getFirstLink(); link0 != null; link0 = link0.getNext(this)) {
|
||||||
OsmLinkP link = link0;
|
OsmLinkP link = link0;
|
||||||
OsmNodeP origin = this;
|
OsmNodeP origin = this;
|
||||||
OsmNodeP target = null;
|
OsmNodeP target = null;
|
||||||
|
|
||||||
ArrayList<OsmNodeP> linkNodes = new ArrayList<OsmNodeP>();
|
ArrayList<OsmNodeP> linkNodes = new ArrayList<>();
|
||||||
linkNodes.add(this);
|
linkNodes.add(this);
|
||||||
|
|
||||||
// first pass just to see if that link is consistent
|
// first pass just to see if that link is consistent
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
package btools.mapcreator;
|
package btools.mapcreator;
|
||||||
|
|
||||||
|
import org.openstreetmap.osmosis.osmbinary.Fileformat;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.EOFException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.util.HashMap;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import btools.util.LongList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parser for OSM data
|
* Parser for OSM data
|
||||||
|
@ -22,179 +29,118 @@ public class OsmParser extends MapCreatorBase {
|
||||||
NodeListener nListener,
|
NodeListener nListener,
|
||||||
WayListener wListener,
|
WayListener wListener,
|
||||||
RelationListener rListener) throws Exception {
|
RelationListener rListener) throws Exception {
|
||||||
|
|
||||||
this.nListener = nListener;
|
this.nListener = nListener;
|
||||||
this.wListener = wListener;
|
this.wListener = wListener;
|
||||||
this.rListener = rListener;
|
this.rListener = rListener;
|
||||||
|
|
||||||
if (mapFile == null) {
|
System.out.println("*** PBF Parsing: " + mapFile);
|
||||||
_br = new BufferedReader(new InputStreamReader(System.in));
|
|
||||||
} else {
|
// once more for testing
|
||||||
if (mapFile.getName().endsWith(".gz")) {
|
int rawBlobCount = 0;
|
||||||
_br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(mapFile))));
|
|
||||||
} else {
|
long bytesRead = 0L;
|
||||||
_br = new BufferedReader(new InputStreamReader(new FileInputStream(mapFile)));
|
Boolean avoidMapPolling = Boolean.getBoolean("avoidMapPolling");
|
||||||
|
|
||||||
|
if (!avoidMapPolling) {
|
||||||
|
// wait for file to become available
|
||||||
|
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)));
|
||||||
|
|
||||||
|
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
String line = _br.readLine();
|
if (!avoidMapPolling) {
|
||||||
if (line == null) break;
|
// continue reading if either more then a 100 MB unread, or the current-size is known for more than 2 Minutes
|
||||||
|
while (currentSize - bytesRead < 100000000L) {
|
||||||
if (checkNode(line)) continue;
|
long newSize = mapFile.length();
|
||||||
if (checkWay(line)) continue;
|
if (newSize != currentSize) {
|
||||||
if (checkRelation(line)) continue;
|
currentSize = newSize;
|
||||||
if (checkChangeset(line)) continue;
|
currentSizeTime = System.currentTimeMillis();
|
||||||
}
|
} else if (System.currentTimeMillis() - currentSizeTime > 120000) {
|
||||||
|
break;
|
||||||
if (mapFile != null) {
|
}
|
||||||
_br.close();
|
if (currentSize - bytesRead < 100000000L) {
|
||||||
}
|
System.out.println("--- waiting for more data, currentSize=" + currentSize + " bytesRead=" + bytesRead);
|
||||||
}
|
Thread.sleep(10000);
|
||||||
|
|
||||||
|
|
||||||
private boolean checkNode(String line) throws Exception {
|
|
||||||
int idx0 = line.indexOf("<node id=\"");
|
|
||||||
if (idx0 < 0) return false;
|
|
||||||
idx0 += 10;
|
|
||||||
int idx1 = line.indexOf('"', idx0);
|
|
||||||
|
|
||||||
long nodeId = Long.parseLong(line.substring(idx0, idx1));
|
|
||||||
|
|
||||||
int idx2 = line.indexOf(" lat=\"");
|
|
||||||
if (idx2 < 0) return false;
|
|
||||||
idx2 += 6;
|
|
||||||
int idx3 = line.indexOf('"', idx2);
|
|
||||||
double lat = Double.parseDouble(line.substring(idx2, idx3));
|
|
||||||
int idx4 = line.indexOf(" lon=\"");
|
|
||||||
if (idx4 < 0) return false;
|
|
||||||
idx4 += 6;
|
|
||||||
int idx5 = line.indexOf('"', idx4);
|
|
||||||
double lon = Double.parseDouble(line.substring(idx4, idx5));
|
|
||||||
|
|
||||||
NodeData n = new NodeData(nodeId, lon, lat);
|
|
||||||
|
|
||||||
if (!line.endsWith("/>")) {
|
|
||||||
// read additional tags
|
|
||||||
for (; ; ) {
|
|
||||||
String l2 = _br.readLine();
|
|
||||||
if (l2 == null) return false;
|
|
||||||
|
|
||||||
int i2;
|
|
||||||
if ((i2 = l2.indexOf("<tag k=\"")) >= 0) { // property-tag
|
|
||||||
i2 += 8;
|
|
||||||
int ri2 = l2.indexOf('"', i2);
|
|
||||||
String key = l2.substring(i2, ri2);
|
|
||||||
i2 = l2.indexOf(" v=\"", ri2);
|
|
||||||
if (i2 >= 0) {
|
|
||||||
i2 += 4;
|
|
||||||
int ri3 = l2.indexOf('"', i2);
|
|
||||||
String value = l2.substring(i2, ri3);
|
|
||||||
|
|
||||||
n.putTag(key, value);
|
|
||||||
}
|
}
|
||||||
} else if (l2.indexOf("</node>") >= 0) { // end-tag
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
nListener.nextNode(n);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
int headerLength;
|
||||||
private boolean checkWay(String line) throws Exception {
|
try {
|
||||||
int idx0 = line.indexOf("<way id=\"");
|
headerLength = dis.readInt();
|
||||||
if (idx0 < 0) return false;
|
bytesRead += 4;
|
||||||
|
} catch (EOFException e) {
|
||||||
idx0 += 9;
|
|
||||||
int idx1 = line.indexOf('"', idx0);
|
|
||||||
long id = Long.parseLong(line.substring(idx0, idx1));
|
|
||||||
|
|
||||||
WayData w = new WayData(id);
|
|
||||||
|
|
||||||
// read the nodes
|
|
||||||
for (; ; ) {
|
|
||||||
String l2 = _br.readLine();
|
|
||||||
if (l2 == null) return false;
|
|
||||||
|
|
||||||
int i2;
|
|
||||||
if ((i2 = l2.indexOf("<nd ref=\"")) >= 0) { // node reference
|
|
||||||
i2 += 9;
|
|
||||||
int ri2 = l2.indexOf('"', i2);
|
|
||||||
long nid = Long.parseLong(l2.substring(i2, ri2));
|
|
||||||
w.nodes.add(nid);
|
|
||||||
} else if ((i2 = l2.indexOf("<tag k=\"")) >= 0) { // property-tag
|
|
||||||
i2 += 8;
|
|
||||||
int ri2 = l2.indexOf('"', i2);
|
|
||||||
String key = l2.substring(i2, ri2);
|
|
||||||
i2 = l2.indexOf(" v=\"", ri2);
|
|
||||||
if (i2 >= 0) {
|
|
||||||
i2 += 4;
|
|
||||||
int ri3 = l2.indexOf('"', i2);
|
|
||||||
String value = l2.substring(i2, ri3);
|
|
||||||
w.putTag(key, value);
|
|
||||||
}
|
|
||||||
} else if (l2.indexOf("</way>") >= 0) { // end-tag
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] headerBuffer = new byte[headerLength];
|
||||||
|
dis.readFully(headerBuffer);
|
||||||
|
bytesRead += headerLength;
|
||||||
|
Fileformat.BlobHeader blobHeader = Fileformat.BlobHeader.parseFrom(headerBuffer);
|
||||||
|
|
||||||
|
byte[] blobData = new byte[blobHeader.getDatasize()];
|
||||||
|
dis.readFully(blobData);
|
||||||
|
bytesRead += blobData.length;
|
||||||
|
|
||||||
|
new BPbfBlobDecoder(blobHeader.getType(), blobData, this).process();
|
||||||
|
|
||||||
|
rawBlobCount++;
|
||||||
}
|
}
|
||||||
wListener.nextWay(w);
|
dis.close();
|
||||||
return true;
|
System.out.println("read raw blobs: " + rawBlobCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkChangeset(String line) throws Exception {
|
|
||||||
int idx0 = line.indexOf("<changeset id=\"");
|
|
||||||
if (idx0 < 0) return false;
|
|
||||||
|
|
||||||
if (!line.endsWith("/>")) {
|
public void addNode(long nid, Map<String, String> tags, double lat, double lon) {
|
||||||
int loopcheck = 0;
|
NodeData n = new NodeData(nid, lon, lat);
|
||||||
for (; ; ) {
|
n.setTags((HashMap<String, String>) tags);
|
||||||
String l2 = _br.readLine();
|
try {
|
||||||
if (l2.indexOf("</changeset>") >= 0 || ++loopcheck > 10000) break;
|
nListener.nextNode(n);
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("error writing node: " + e);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkRelation(String line) throws Exception {
|
public void addWay(long wid, Map<String, String> tags, LongList nodes) {
|
||||||
int idx0 = line.indexOf("<relation id=\"");
|
WayData w = new WayData(wid, nodes);
|
||||||
if (idx0 < 0) return false;
|
w.setTags((HashMap<String, String>) tags);
|
||||||
|
|
||||||
idx0 += 14;
|
try {
|
||||||
int idx1 = line.indexOf('"', idx0);
|
wListener.nextWay(w);
|
||||||
long rid = Long.parseLong(line.substring(idx0, idx1));
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("error writing way: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RelationData r = new RelationData(rid);
|
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);
|
||||||
|
|
||||||
// read the nodes
|
try {
|
||||||
for (; ; ) {
|
rListener.nextRelation(r);
|
||||||
String l2 = _br.readLine();
|
if (fromWid == null || toWid == null || viaNid == null || viaNid.size() != 1) {
|
||||||
if (l2 == null) return false;
|
// dummy-TR for each viaNid
|
||||||
|
for (int vi = 0; vi < (viaNid == null ? 0 : viaNid.size()); vi++) {
|
||||||
int i2;
|
rListener.nextRestriction(r, 0L, 0L, viaNid.get(vi));
|
||||||
if ((i2 = l2.indexOf("<member type=\"way\" ref=\"")) >= 0) { // node reference
|
|
||||||
i2 += 24;
|
|
||||||
int ri2 = l2.indexOf('"', i2);
|
|
||||||
long wid = Long.parseLong(l2.substring(i2, ri2));
|
|
||||||
r.ways.add(wid);
|
|
||||||
} else if ((i2 = l2.indexOf("<tag k=\"")) >= 0) { // property-tag
|
|
||||||
i2 += 8;
|
|
||||||
int ri2 = l2.indexOf('"', i2);
|
|
||||||
String key = l2.substring(i2, ri2);
|
|
||||||
i2 = l2.indexOf(" v=\"", ri2);
|
|
||||||
if (i2 >= 0) {
|
|
||||||
i2 += 4;
|
|
||||||
int ri3 = l2.indexOf('"', i2);
|
|
||||||
String value = l2.substring(i2, ri3);
|
|
||||||
r.putTag(key, value);
|
|
||||||
}
|
}
|
||||||
} else if (l2.indexOf("</relation>") >= 0) { // end-tag
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
rListener.nextRelation(r);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class OsmTrafficMap {
|
||||||
public OsmTrafficElement next;
|
public OsmTrafficElement next;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompactLongMap<OsmTrafficElement> map = new CompactLongMap<OsmTrafficElement>();
|
private CompactLongMap<OsmTrafficElement> map = new CompactLongMap<>();
|
||||||
|
|
||||||
public void loadAll(File file, int minLon, int minLat, int maxLon, int maxLat, boolean includeMotorways) throws Exception {
|
public void loadAll(File file, int minLon, int minLat, int maxLon, int maxLat, boolean includeMotorways) throws Exception {
|
||||||
load(file, minLon, minLat, maxLon, maxLat, includeMotorways);
|
load(file, minLon, minLat, maxLon, maxLat, includeMotorways);
|
||||||
|
@ -107,7 +107,7 @@ public class OsmTrafficMap {
|
||||||
is.close();
|
is.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
map = new FrozenLongMap<OsmTrafficElement>(map);
|
map = new FrozenLongMap<>(map);
|
||||||
System.out.println("read traffic-elements: " + trafficElements);
|
System.out.println("read traffic-elements: " + trafficElements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import btools.util.CompactLongSet;
|
import btools.util.CompactLongSet;
|
||||||
|
@ -37,7 +38,24 @@ public class PosUnifier extends MapCreatorBase {
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
System.out.println("*** PosUnifier: Unify position values and enhance elevation");
|
System.out.println("*** PosUnifier: Unify position values and enhance elevation");
|
||||||
if (args.length != 5) {
|
if (args.length == 3) {
|
||||||
|
PosUnifier posu = new PosUnifier();
|
||||||
|
posu.srtmdir = (args[0]);
|
||||||
|
posu.srtmmap = new HashMap<>();
|
||||||
|
double lon = Double.parseDouble(args[1]);
|
||||||
|
double lat = Double.parseDouble(args[2]);
|
||||||
|
|
||||||
|
NodeData n = new NodeData(1, lon, lat);
|
||||||
|
SrtmRaster srtm = posu.hgtForNode(n.ilon, n.ilat);
|
||||||
|
short selev = Short.MIN_VALUE;
|
||||||
|
if (srtm == null) {
|
||||||
|
srtm = posu.srtmForNode(n.ilon, n.ilat);
|
||||||
|
}
|
||||||
|
if (srtm != null) selev = srtm.getElevation(n.ilon, n.ilat);
|
||||||
|
posu.resetSrtm();
|
||||||
|
System.out.println("-----> selv for " + lat + ", " + lon + " = " + selev + " = " + (selev / 4.));
|
||||||
|
return;
|
||||||
|
} else if (args.length != 5) {
|
||||||
System.out.println("usage: java PosUnifier <node-tiles-in> <node-tiles-out> <bordernids-in> <bordernodes-out> <srtm-data-dir>");
|
System.out.println("usage: java PosUnifier <node-tiles-in> <node-tiles-out> <bordernids-in> <bordernodes-out> <srtm-data-dir>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,9 +97,13 @@ public class PosUnifier extends MapCreatorBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void nextNode(NodeData n) throws Exception {
|
public void nextNode(NodeData n) throws Exception {
|
||||||
SrtmRaster srtm = srtmForNode(n.ilon, n.ilat);
|
n.selev = Short.MIN_VALUE;
|
||||||
n.selev = srtm == null ? Short.MIN_VALUE : srtm.getElevation(n.ilon, n.ilat);
|
SrtmRaster srtm = hgtForNode(n.ilon, n.ilat);
|
||||||
|
if (srtm == null) {
|
||||||
|
srtm = srtmForNode(n.ilon, n.ilat);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (srtm != null) n.selev = srtm.getElevation(n.ilon, n.ilat);
|
||||||
findUniquePos(n);
|
findUniquePos(n);
|
||||||
|
|
||||||
n.writeTo(nodesOutStream);
|
n.writeTo(nodesOutStream);
|
||||||
|
@ -93,6 +115,7 @@ public class PosUnifier extends MapCreatorBase {
|
||||||
@Override
|
@Override
|
||||||
public void nodeFileEnd(File nodeFile) throws Exception {
|
public void nodeFileEnd(File nodeFile) throws Exception {
|
||||||
nodesOutStream.close();
|
nodesOutStream.close();
|
||||||
|
resetSrtm();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkAdd(int lon, int lat) {
|
private boolean checkAdd(int lon, int lat) {
|
||||||
|
@ -157,7 +180,6 @@ public class PosUnifier extends MapCreatorBase {
|
||||||
lastSrtmRaster = srtmmap.get(filename);
|
lastSrtmRaster = srtmmap.get(filename);
|
||||||
if (lastSrtmRaster == null && !srtmmap.containsKey(filename)) {
|
if (lastSrtmRaster == null && !srtmmap.containsKey(filename)) {
|
||||||
File f = new File(new File(srtmdir), filename + ".bef");
|
File f = new File(new File(srtmdir), filename + ".bef");
|
||||||
System.out.println("checking: " + f + " ilon=" + ilon + " ilat=" + ilat);
|
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
System.out.println("*** reading: " + f);
|
System.out.println("*** reading: " + f);
|
||||||
try {
|
try {
|
||||||
|
@ -172,10 +194,12 @@ public class PosUnifier extends MapCreatorBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
f = new File(new File(srtmdir), filename + ".zip");
|
f = new File(new File(srtmdir), filename + ".zip");
|
||||||
System.out.println("reading: " + f + " ilon=" + ilon + " ilat=" + ilat);
|
// System.out.println("reading: " + f + " ilon=" + ilon + " ilat=" + ilat);
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
try {
|
try {
|
||||||
lastSrtmRaster = new SrtmData(f).getRaster();
|
lastSrtmRaster = new SrtmData(f).getRaster();
|
||||||
|
srtmmap.put(filename, lastSrtmRaster);
|
||||||
|
return lastSrtmRaster;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("**** ERROR reading " + f + " ****");
|
System.out.println("**** ERROR reading " + f + " ****");
|
||||||
}
|
}
|
||||||
|
@ -185,8 +209,49 @@ public class PosUnifier extends MapCreatorBase {
|
||||||
return lastSrtmRaster;
|
return lastSrtmRaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SrtmRaster hgtForNode(int ilon, int ilat) throws Exception {
|
||||||
|
double lon = (ilon - 180000000) / 1000000.;
|
||||||
|
double lat = (ilat - 90000000) / 1000000.;
|
||||||
|
|
||||||
|
String filename = buildHgtFilename(lat, lon);
|
||||||
|
lastSrtmRaster = srtmmap.get(filename);
|
||||||
|
if (lastSrtmRaster == null) {
|
||||||
|
File f = new File(new File(srtmdir), filename + ".hgt");
|
||||||
|
if (f.exists()) {
|
||||||
|
lastSrtmRaster = new ConvertLidarTile().getRaster(f, lon, lat);
|
||||||
|
srtmmap.put(filename, lastSrtmRaster);
|
||||||
|
return lastSrtmRaster;
|
||||||
|
}
|
||||||
|
f = new File(new File(srtmdir), filename + ".zip");
|
||||||
|
if (f.exists()) {
|
||||||
|
lastSrtmRaster = new ConvertLidarTile().getRaster(f, lon, lat);
|
||||||
|
srtmmap.put(filename, lastSrtmRaster);
|
||||||
|
return lastSrtmRaster;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lastSrtmRaster;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildHgtFilename(double llat, double llon) {
|
||||||
|
int lat = (int) llat;
|
||||||
|
int lon = (int) llon;
|
||||||
|
|
||||||
|
String latPref = "N";
|
||||||
|
if (lat < 0) {
|
||||||
|
latPref = "S";
|
||||||
|
lat = -lat + 1;
|
||||||
|
}
|
||||||
|
String lonPref = "E";
|
||||||
|
if (lon < 0) {
|
||||||
|
lonPref = "W";
|
||||||
|
lon = -lon + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.format(Locale.US, "%s%02d%s%03d", latPref, lat, lonPref, lon);
|
||||||
|
}
|
||||||
|
|
||||||
private void resetSrtm() {
|
private void resetSrtm() {
|
||||||
srtmmap = new HashMap<String, SrtmRaster>();
|
srtmmap = new HashMap<>();
|
||||||
lastSrtmLonIdx = -1;
|
lastSrtmLonIdx = -1;
|
||||||
lastSrtmLatIdx = -1;
|
lastSrtmLatIdx = -1;
|
||||||
lastSrtmRaster = null;
|
lastSrtmRaster = null;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class RelationMerger extends MapCreatorBase {
|
||||||
// expctxStat = new BExpressionContext("way");
|
// expctxStat = new BExpressionContext("way");
|
||||||
|
|
||||||
// *** read the relation file into sets for each processed tag
|
// *** read the relation file into sets for each processed tag
|
||||||
routesets = new HashMap<String, CompactLongSet>();
|
routesets = new HashMap<>();
|
||||||
routesetall = new CompactLongSet();
|
routesetall = new CompactLongSet();
|
||||||
DataInputStream dis = createInStream(relationFileIn);
|
DataInputStream dis = createInStream(relationFileIn);
|
||||||
try {
|
try {
|
||||||
|
@ -130,7 +130,7 @@ public class RelationMerger extends MapCreatorBase {
|
||||||
if (routeset.contains(data.wid)) {
|
if (routeset.contains(data.wid)) {
|
||||||
int sepIdx = key.lastIndexOf('_');
|
int sepIdx = key.lastIndexOf('_');
|
||||||
String tagname = key.substring(0, sepIdx);
|
String tagname = key.substring(0, sepIdx);
|
||||||
int val = Integer.valueOf(key.substring(sepIdx + 1));
|
int val = Integer.parseInt(key.substring(sepIdx + 1));
|
||||||
expctxReport.addSmallestLookupValue(tagname, val);
|
expctxReport.addSmallestLookupValue(tagname, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class RelationStatistics extends MapCreatorBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(File relationFileIn) throws Exception {
|
public void process(File relationFileIn) throws Exception {
|
||||||
HashMap<String, long[]> relstats = new HashMap<String, long[]>();
|
HashMap<String, long[]> relstats = new HashMap<>();
|
||||||
|
|
||||||
DataInputStream dis = createInStream(relationFileIn);
|
DataInputStream dis = createInStream(relationFileIn);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
||||||
private void reset() {
|
private void reset() {
|
||||||
minLon = -1;
|
minLon = -1;
|
||||||
minLat = -1;
|
minLat = -1;
|
||||||
nodesMap = new CompactLongMap<OsmNodeP>();
|
nodesMap = new CompactLongMap<>();
|
||||||
borderSet = new CompactLongSet();
|
borderSet = new CompactLongSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
||||||
new NodeIterator(this, true).processFile(nodeFile);
|
new NodeIterator(this, true).processFile(nodeFile);
|
||||||
|
|
||||||
// freeze the nodes-map
|
// freeze the nodes-map
|
||||||
FrozenLongMap<OsmNodeP> nodesMapFrozen = new FrozenLongMap<OsmNodeP>(nodesMap);
|
FrozenLongMap<OsmNodeP> nodesMapFrozen = new FrozenLongMap<>(nodesMap);
|
||||||
nodesMap = nodesMapFrozen;
|
nodesMap = nodesMapFrozen;
|
||||||
|
|
||||||
File restrictionFile = fileFromTemplate(wayfile, new File(nodeTilesIn.getParentFile(), "restrictions55"), "rt5");
|
File restrictionFile = fileFromTemplate(wayfile, new File(nodeTilesIn.getParentFile(), "restrictions55"), "rt5");
|
||||||
|
@ -415,7 +415,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
||||||
int nLatSegs = (maxLat - minLat) / 1000000;
|
int nLatSegs = (maxLat - minLat) / 1000000;
|
||||||
|
|
||||||
// sort the nodes into segments
|
// sort the nodes into segments
|
||||||
LazyArrayOfLists<OsmNodeP> seglists = new LazyArrayOfLists<OsmNodeP>(nLonSegs * nLatSegs);
|
LazyArrayOfLists<OsmNodeP> seglists = new LazyArrayOfLists<>(nLonSegs * nLatSegs);
|
||||||
for (OsmNodeP n : nodesList) {
|
for (OsmNodeP n : nodesList) {
|
||||||
if (n == null || n.getFirstLink() == null || n.isTransferNode())
|
if (n == null || n.getFirstLink() == null || n.isTransferNode())
|
||||||
continue;
|
continue;
|
||||||
|
@ -450,7 +450,7 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
||||||
if (seglists.getSize(tileIndex) > 0) {
|
if (seglists.getSize(tileIndex) > 0) {
|
||||||
List<OsmNodeP> nlist = seglists.getList(tileIndex);
|
List<OsmNodeP> nlist = seglists.getList(tileIndex);
|
||||||
|
|
||||||
LazyArrayOfLists<OsmNodeP> subs = new LazyArrayOfLists<OsmNodeP>(ncaches);
|
LazyArrayOfLists<OsmNodeP> subs = new LazyArrayOfLists<>(ncaches);
|
||||||
byte[][] subByteArrays = new byte[ncaches][];
|
byte[][] subByteArrays = new byte[ncaches][];
|
||||||
for (int ni = 0; ni < nlist.size(); ni++) {
|
for (int ni = 0; ni < nlist.size(); ni++) {
|
||||||
OsmNodeP n = nlist.get(ni);
|
OsmNodeP n = nlist.get(ni);
|
||||||
|
@ -473,14 +473,14 @@ public class WayLinker extends MapCreatorBase implements Runnable {
|
||||||
MicroCache mc = new MicroCache2(size, abBuf2, lonIdxDiv, latIdxDiv, divisor);
|
MicroCache mc = new MicroCache2(size, abBuf2, lonIdxDiv, latIdxDiv, divisor);
|
||||||
|
|
||||||
// sort via treemap
|
// sort via treemap
|
||||||
TreeMap<Integer, OsmNodeP> sortedList = new TreeMap<Integer, OsmNodeP>();
|
TreeMap<Integer, OsmNodeP> sortedList = new TreeMap<>();
|
||||||
for (OsmNodeP n : subList) {
|
for (OsmNodeP n : subList) {
|
||||||
long longId = n.getIdFromPos();
|
long longId = n.getIdFromPos();
|
||||||
int shrinkid = mc.shrinkId(longId);
|
int shrinkid = mc.shrinkId(longId);
|
||||||
if (mc.expandId(shrinkid) != longId) {
|
if (mc.expandId(shrinkid) != longId) {
|
||||||
throw new IllegalArgumentException("inconstistent shrinking: " + longId);
|
throw new IllegalArgumentException("inconstistent shrinking: " + longId);
|
||||||
}
|
}
|
||||||
sortedList.put(Integer.valueOf(shrinkid), n);
|
sortedList.put(shrinkid, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (OsmNodeP n : sortedList.values()) {
|
for (OsmNodeP n : sortedList.values()) {
|
||||||
|
|
|
@ -9,8 +9,10 @@ import java.net.URL;
|
||||||
public class MapcreatorTest {
|
public class MapcreatorTest {
|
||||||
@Test
|
@Test
|
||||||
public void mapcreatorTest() throws Exception {
|
public void mapcreatorTest() throws Exception {
|
||||||
URL mapurl = this.getClass().getResource("/dreieich.osm.gz");
|
System.setProperty("avoidMapPolling", "true");
|
||||||
Assert.assertNotNull("test-osm-map dreieich.osm not found", mapurl);
|
|
||||||
|
URL mapurl = this.getClass().getResource("/dreieich.pbf");
|
||||||
|
Assert.assertNotNull("test-osm-map dreieich.pbf not found", mapurl);
|
||||||
File mapFile = new File(mapurl.getFile());
|
File mapFile = new File(mapurl.getFile());
|
||||||
File workingDir = mapFile.getParentFile();
|
File workingDir = mapFile.getParentFile();
|
||||||
File profileDir = new File(workingDir, "/../../../../misc/profiles2");
|
File profileDir = new File(workingDir, "/../../../../misc/profiles2");
|
||||||
|
|
BIN
brouter-map-creator/src/test/resources/dreieich.pbf
Normal file
BIN
brouter-map-creator/src/test/resources/dreieich.pbf
Normal file
Binary file not shown.
|
@ -95,7 +95,7 @@ public final class NodesCache {
|
||||||
fileRows = new OsmFile[180][];
|
fileRows = new OsmFile[180][];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fileCache = new HashMap<String, PhysicalFile>(4);
|
fileCache = new HashMap<>(4);
|
||||||
fileRows = new OsmFile[180][];
|
fileRows = new OsmFile[180][];
|
||||||
dataBuffers = new DataBuffers();
|
dataBuffers = new DataBuffers();
|
||||||
secondarySegmentsDir = StorageConfigHelper.getSecondarySegmentDir(segmentDir);
|
secondarySegmentsDir = StorageConfigHelper.getSecondarySegmentDir(segmentDir);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class OsmNodePairSet {
|
||||||
|
|
||||||
private void addPair(long n1, long n2) {
|
private void addPair(long n1, long n2) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
map = new CompactLongMap<OsmNodePair>();
|
map = new CompactLongMap<>();
|
||||||
}
|
}
|
||||||
npairs++;
|
npairs++;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Map;
|
||||||
import btools.util.ByteArrayUnifier;
|
import btools.util.ByteArrayUnifier;
|
||||||
|
|
||||||
public final class OsmNodesMap {
|
public final class OsmNodesMap {
|
||||||
private Map<OsmNode, OsmNode> hmap = new HashMap<OsmNode, OsmNode>(4096);
|
private Map<OsmNode, OsmNode> hmap = new HashMap<>(4096);
|
||||||
|
|
||||||
private ByteArrayUnifier abUnifier = new ByteArrayUnifier(16384, false);
|
private ByteArrayUnifier abUnifier = new ByteArrayUnifier(16384, false);
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public final class OsmNodesMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void collectOutreachers() {
|
public void collectOutreachers() {
|
||||||
nodes2check = new ArrayList<OsmNode>(nodesCreated);
|
nodes2check = new ArrayList<>(nodesCreated);
|
||||||
nodesCreated = 0;
|
nodesCreated = 0;
|
||||||
for (OsmNode n : hmap.values()) {
|
for (OsmNode n : hmap.values()) {
|
||||||
addActiveNode(nodes2check, n);
|
addActiveNode(nodes2check, n);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort result list
|
// sort result list
|
||||||
comparator = new Comparator<MatchedWaypoint>() {
|
comparator = new Comparator<>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(MatchedWaypoint mw1, MatchedWaypoint mw2) {
|
public int compare(MatchedWaypoint mw1, MatchedWaypoint mw2) {
|
||||||
int cmpDist = Double.compare(mw1.radius, mw2.radius);
|
int cmpDist = Double.compare(mw1.radius, mw2.radius);
|
||||||
|
|
|
@ -488,11 +488,11 @@ public class BInstallerActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadDiffVersionTiles() {
|
private void downloadDiffVersionTiles() {
|
||||||
downloadAll(new ArrayList<Integer>(), DownloadWorker.VALUE_SEGMENT_DIFFS);
|
downloadAll(new ArrayList<>(), DownloadWorker.VALUE_SEGMENT_DIFFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dropDiffVersionTiles() {
|
private void dropDiffVersionTiles() {
|
||||||
downloadAll(new ArrayList<Integer>(), DownloadWorker.VALUE_SEGMENT_DROPDIFFS);
|
downloadAll(new ArrayList<>(), DownloadWorker.VALUE_SEGMENT_DROPDIFFS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDownloadRunning(Class<?> serviceClass) {
|
private boolean isDownloadRunning(Class<?> serviceClass) {
|
||||||
|
|
|
@ -211,8 +211,8 @@ public class BRouterService extends Service {
|
||||||
private void readNogos(BRouterWorker worker, String baseDir) throws Exception {
|
private void readNogos(BRouterWorker worker, String baseDir) throws Exception {
|
||||||
// add nogos from waypoint database
|
// add nogos from waypoint database
|
||||||
CoordinateReader cor = CoordinateReader.obtainValidReader(baseDir, true);
|
CoordinateReader cor = CoordinateReader.obtainValidReader(baseDir, true);
|
||||||
worker.nogoList = new ArrayList<OsmNodeNamed>(cor.nogopoints);
|
worker.nogoList = new ArrayList<>(cor.nogopoints);
|
||||||
worker.nogoPolygonsList = new ArrayList<OsmNodeNamed>();
|
worker.nogoPolygonsList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fileEqual(byte[] fileBytes, File file) throws Exception {
|
private boolean fileEqual(byte[] fileBytes, File file) throws Exception {
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class BRouterWorker {
|
||||||
String straight = params.getString("straight");
|
String straight = params.getString("straight");
|
||||||
String[] sa = straight.split(",");
|
String[] sa = straight.split(",");
|
||||||
for (int i = 0; i < sa.length; i++) {
|
for (int i = 0; i < sa.length; i++) {
|
||||||
int v = Integer.valueOf(sa[i]);
|
int v = Integer.parseInt(sa[i]);
|
||||||
if (waypoints.size() > v) waypoints.get(v).direct = true;
|
if (waypoints.size() > v) waypoints.get(v).direct = true;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
@ -132,7 +132,7 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containsKey("extraParams")) { // add user params
|
if (params.containsKey("extraParams")) { // add user params
|
||||||
if (rc.keyValues == null) rc.keyValues = new HashMap<String, String>();
|
if (rc.keyValues == null) rc.keyValues = new HashMap<>();
|
||||||
StringTokenizer tk = new StringTokenizer(extraParams, "?&");
|
StringTokenizer tk = new StringTokenizer(extraParams, "?&");
|
||||||
while (tk.hasMoreTokens()) {
|
while (tk.hasMoreTokens()) {
|
||||||
String t = tk.nextToken();
|
String t = tk.nextToken();
|
||||||
|
@ -224,7 +224,7 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OsmNodeNamed> readPositions(Bundle params) {
|
private List<OsmNodeNamed> readPositions(Bundle params) {
|
||||||
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> wplist = new ArrayList<>();
|
||||||
|
|
||||||
double[] lats = params.getDoubleArray("lats");
|
double[] lats = params.getDoubleArray("lats");
|
||||||
double[] lons = params.getDoubleArray("lons");
|
double[] lons = params.getDoubleArray("lons");
|
||||||
|
@ -334,7 +334,7 @@ public class BRouterWorker {
|
||||||
|
|
||||||
String[] lonLatRadList = nogos.split("\\|");
|
String[] lonLatRadList = nogos.split("\\|");
|
||||||
|
|
||||||
List<OsmNodeNamed> nogoList = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> nogoList = new ArrayList<>();
|
||||||
for (int i = 0; i < lonLatRadList.length; i++) {
|
for (int i = 0; i < lonLatRadList.length; i++) {
|
||||||
String[] lonLatRad = lonLatRadList[i].split(",");
|
String[] lonLatRad = lonLatRadList[i].split(",");
|
||||||
String nogoWeight = "NaN";
|
String nogoWeight = "NaN";
|
||||||
|
@ -363,7 +363,7 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OsmNodeNamed> readNogoPolygons(Bundle params) {
|
private List<OsmNodeNamed> readNogoPolygons(Bundle params) {
|
||||||
List<OsmNodeNamed> result = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> result = new ArrayList<>();
|
||||||
parseNogoPolygons(params.getString("polylines"), result, false);
|
parseNogoPolygons(params.getString("polylines"), result, false);
|
||||||
parseNogoPolygons(params.getString("polygons"), result, true);
|
parseNogoPolygons(params.getString("polygons"), result, true);
|
||||||
return result.size() > 0 ? result : null;
|
return result.size() > 0 ? result : null;
|
||||||
|
@ -408,7 +408,7 @@ public class BRouterWorker {
|
||||||
|
|
||||||
String[] lonLatNameList = pois.split("\\|");
|
String[] lonLatNameList = pois.split("\\|");
|
||||||
|
|
||||||
List<OsmNodeNamed> poisList = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> poisList = new ArrayList<>();
|
||||||
for (int i = 0; i < lonLatNameList.length; i++) {
|
for (int i = 0; i < lonLatNameList.length; i++) {
|
||||||
String[] lonLatName = lonLatNameList[i].split(",");
|
String[] lonLatName = lonLatNameList[i].split(",");
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class ConfigMigration {
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
|
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<>();
|
||||||
br = new BufferedReader(new FileReader(dstFile));
|
br = new BufferedReader(new FileReader(dstFile));
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
|
@ -76,7 +76,7 @@ public class ConfigMigration {
|
||||||
BufferedReader br = null;
|
BufferedReader br = null;
|
||||||
BufferedWriter bw = null;
|
BufferedWriter bw = null;
|
||||||
File configFile = new File(segmentDir, "storageconfig.txt");
|
File configFile = new File(segmentDir, "storageconfig.txt");
|
||||||
List<String> lines = new ArrayList<String>();
|
List<String> lines = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
br = new BufferedReader(new FileReader(configFile));
|
br = new BufferedReader(new FileReader(configFile));
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class ServiceModeConfig {
|
||||||
profile = tk.nextToken();
|
profile = tk.nextToken();
|
||||||
if (tk.hasMoreTokens()) params = tk.nextToken();
|
if (tk.hasMoreTokens()) params = tk.nextToken();
|
||||||
else params = "noparams";
|
else params = "noparams";
|
||||||
nogoVetos = new TreeSet<String>();
|
nogoVetos = new TreeSet<>();
|
||||||
while (tk.hasMoreTokens()) {
|
while (tk.hasMoreTokens()) {
|
||||||
nogoVetos.add(tk.nextToken());
|
nogoVetos.add(tk.nextToken());
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public class ServiceModeConfig {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.params = params;
|
this.params = params;
|
||||||
nogoVetos = new TreeSet<String>();
|
nogoVetos = new TreeSet<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toLine() {
|
public String toLine() {
|
||||||
|
|
|
@ -8,8 +8,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Area {
|
public class Area {
|
||||||
private List<Polygon> poslist = new ArrayList<Polygon>();
|
private List<Polygon> poslist = new ArrayList<>();
|
||||||
private List<Polygon> neglist = new ArrayList<Polygon>();
|
private List<Polygon> neglist = new ArrayList<>();
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
Area a = new Area(new File(args[0]));
|
Area a = new Area(new File(args[0]));
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class BRouter {
|
||||||
maxRunningTime = Integer.parseInt(sMaxRunningTime) * 1000;
|
maxRunningTime = Integer.parseInt(sMaxRunningTime) * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> wplist = new ArrayList<>();
|
||||||
wplist.add(from);
|
wplist.add(from);
|
||||||
wplist.add(to);
|
wplist.add(to);
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class BRouter {
|
||||||
System.out.println("usage: java -jar brouter.jar <segmentdir> <lon-from> <lat-from> <lon-to> <lat-to> <profile>");
|
System.out.println("usage: java -jar brouter.jar <segmentdir> <lon-from> <lat-from> <lon-to> <lat-to> <profile>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> wplist = new ArrayList<>();
|
||||||
wplist.add(readPosition(args, 1, "from"));
|
wplist.add(readPosition(args, 1, "from"));
|
||||||
RoutingEngine re = null;
|
RoutingEngine re = null;
|
||||||
if ("seed".equals(args[3])) {
|
if ("seed".equals(args[3])) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
||||||
|
|
||||||
public class IpAccessMonitor {
|
public class IpAccessMonitor {
|
||||||
private static Object sync = new Object();
|
private static Object sync = new Object();
|
||||||
private static Map<String, Long> ipAccess = new HashMap<String, Long>();
|
private static Map<String, Long> ipAccess = new HashMap<>();
|
||||||
private static long MAX_IDLE = 900000; // 15 minutes
|
private static long MAX_IDLE = 900000; // 15 minutes
|
||||||
private static long CLEANUP_INTERVAL = 10000; // 10 seconds
|
private static long CLEANUP_INTERVAL = 10000; // 10 seconds
|
||||||
private static long lastCleanup;
|
private static long lastCleanup;
|
||||||
|
@ -14,7 +14,7 @@ public class IpAccessMonitor {
|
||||||
long t = System.currentTimeMillis();
|
long t = System.currentTimeMillis();
|
||||||
synchronized (sync) {
|
synchronized (sync) {
|
||||||
Long lastTime = ipAccess.get(ip);
|
Long lastTime = ipAccess.get(ip);
|
||||||
ipAccess.put(ip, Long.valueOf(t));
|
ipAccess.put(ip, t);
|
||||||
return lastTime == null || t - lastTime.longValue() > MAX_IDLE;
|
return lastTime == null || t - lastTime.longValue() > MAX_IDLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class IpAccessMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void cleanup(long t) {
|
private static void cleanup(long t) {
|
||||||
HashMap<String, Long> newMap = new HashMap<String, Long>(ipAccess.size());
|
HashMap<String, Long> newMap = new HashMap<>(ipAccess.size());
|
||||||
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
|
for (Map.Entry<String, Long> e : ipAccess.entrySet()) {
|
||||||
if (t - e.getValue().longValue() <= MAX_IDLE) {
|
if (t - e.getValue().longValue() <= MAX_IDLE) {
|
||||||
newMap.put(e.getKey(), e.getValue());
|
newMap.put(e.getKey(), e.getValue());
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class Polygon {
|
||||||
private int maxy = Integer.MIN_VALUE;
|
private int maxy = Integer.MIN_VALUE;
|
||||||
|
|
||||||
public Polygon(BufferedReader br) throws IOException {
|
public Polygon(BufferedReader br) throws IOException {
|
||||||
ArrayList<String> lines = new ArrayList<String>();
|
ArrayList<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
for (; ; ) {
|
for (; ; ) {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
|
|
|
@ -198,17 +198,17 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
} else if ("timode".equals(e.getKey())) {
|
} else if ("timode".equals(e.getKey())) {
|
||||||
rc.turnInstructionMode = Integer.parseInt(e.getValue());
|
rc.turnInstructionMode = Integer.parseInt(e.getValue());
|
||||||
} else if ("heading".equals(e.getKey())) {
|
} else if ("heading".equals(e.getKey())) {
|
||||||
rc.startDirection = Integer.valueOf(Integer.parseInt(e.getValue()));
|
rc.startDirection = Integer.parseInt(e.getValue());
|
||||||
rc.forceUseStartDirection = true;
|
rc.forceUseStartDirection = true;
|
||||||
} else if (e.getKey().startsWith("profile:")) {
|
} else if (e.getKey().startsWith("profile:")) {
|
||||||
if (rc.keyValues == null) {
|
if (rc.keyValues == null) {
|
||||||
rc.keyValues = new HashMap<String, String>();
|
rc.keyValues = new HashMap<>();
|
||||||
}
|
}
|
||||||
rc.keyValues.put(e.getKey().substring(8), e.getValue());
|
rc.keyValues.put(e.getKey().substring(8), e.getValue());
|
||||||
} else if (e.getKey().equals("straight")) {
|
} else if (e.getKey().equals("straight")) {
|
||||||
String[] sa = e.getValue().split(",");
|
String[] sa = e.getValue().split(",");
|
||||||
for (int i = 0; i < sa.length; i++) {
|
for (int i = 0; i < sa.length; i++) {
|
||||||
int v = Integer.valueOf(sa[i]);
|
int v = Integer.parseInt(sa[i]);
|
||||||
if (wplist.size() > v) wplist.get(v).direct = true;
|
if (wplist.size() > v) wplist.get(v).direct = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,7 +297,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
|
|
||||||
ProfileCache.setSize(2 * maxthreads);
|
ProfileCache.setSize(2 * maxthreads);
|
||||||
|
|
||||||
PriorityQueue<RouteServer> threadQueue = new PriorityQueue<RouteServer>();
|
PriorityQueue<RouteServer> threadQueue = new PriorityQueue<>();
|
||||||
|
|
||||||
ServerSocket serverSocket = args.length > 5 ? new ServerSocket(Integer.parseInt(args[3]), 100, InetAddress.getByName(args[5])) : new ServerSocket(Integer.parseInt(args[3]));
|
ServerSocket serverSocket = args.length > 5 ? new ServerSocket(Integer.parseInt(args[3]), 100, InetAddress.getByName(args[5])) : new ServerSocket(Integer.parseInt(args[3]));
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
||||||
|
|
||||||
|
|
||||||
private static Map<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
|
private static Map<String, String> getUrlParams(String url) throws UnsupportedEncodingException {
|
||||||
HashMap<String, String> params = new HashMap<String, String>();
|
HashMap<String, String> params = new HashMap<>();
|
||||||
String decoded = URLDecoder.decode(url, "UTF-8");
|
String decoded = URLDecoder.decode(url, "UTF-8");
|
||||||
StringTokenizer tk = new StringTokenizer(decoded, "?&");
|
StringTokenizer tk = new StringTokenizer(decoded, "?&");
|
||||||
while (tk.hasMoreTokens()) {
|
while (tk.hasMoreTokens()) {
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class SuspectManager extends Thread {
|
||||||
bw.write("<table>\n");
|
bw.write("<table>\n");
|
||||||
File countryParent = new File("worldpolys" + country);
|
File countryParent = new File("worldpolys" + country);
|
||||||
File[] files = countryParent.listFiles();
|
File[] files = countryParent.listFiles();
|
||||||
TreeSet<String> names = new TreeSet<String>();
|
TreeSet<String> names = new TreeSet<>();
|
||||||
for (File f : files) {
|
for (File f : files) {
|
||||||
String name = f.getName();
|
String name = f.getName();
|
||||||
if (name.endsWith(".poly")) {
|
if (name.endsWith(".poly")) {
|
||||||
|
@ -580,7 +580,7 @@ public class SuspectManager extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, SuspectList> allSuspectsMap = new HashMap<String, SuspectList>();
|
private static Map<String, SuspectList> allSuspectsMap = new HashMap<>();
|
||||||
|
|
||||||
private static SuspectList getDailySuspectsIfLoaded() throws IOException {
|
private static SuspectList getDailySuspectsIfLoaded() throws IOException {
|
||||||
synchronized (allSuspectsMap) {
|
synchronized (allSuspectsMap) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class ProfileUploadHandler {
|
||||||
fileWriter.flush();
|
fileWriter.flush();
|
||||||
//System.out.println("data: |" + sw.toString() + "|");
|
//System.out.println("data: |" + sw.toString() + "|");
|
||||||
|
|
||||||
Map<String, String> responseData = new HashMap<String, String>();
|
Map<String, String> responseData = new HashMap<>();
|
||||||
responseData.put("profileid", CUSTOM_PREFIX + id);
|
responseData.put("profileid", CUSTOM_PREFIX + id);
|
||||||
|
|
||||||
validateProfile(id, responseData);
|
validateProfile(id, responseData);
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class ServerHandler extends RequestHandler {
|
||||||
if (coords.length < 2)
|
if (coords.length < 2)
|
||||||
throw new IllegalArgumentException("we need two lat/lon points at least!");
|
throw new IllegalArgumentException("we need two lat/lon points at least!");
|
||||||
|
|
||||||
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> wplist = new ArrayList<>();
|
||||||
for (int i = 0; i < coords.length; i++) {
|
for (int i = 0; i < coords.length; i++) {
|
||||||
String[] lonLat = coords[i].split(",");
|
String[] lonLat = coords[i].split(",");
|
||||||
if (lonLat.length < 2)
|
if (lonLat.length < 2)
|
||||||
|
@ -213,7 +213,7 @@ public class ServerHandler extends RequestHandler {
|
||||||
|
|
||||||
String[] lonLatNameList = pois.split("\\|");
|
String[] lonLatNameList = pois.split("\\|");
|
||||||
|
|
||||||
List<OsmNodeNamed> poisList = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> poisList = new ArrayList<>();
|
||||||
for (int i = 0; i < lonLatNameList.length; i++) {
|
for (int i = 0; i < lonLatNameList.length; i++) {
|
||||||
String[] lonLatName = lonLatNameList[i].split(",");
|
String[] lonLatName = lonLatNameList[i].split(",");
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ public class ServerHandler extends RequestHandler {
|
||||||
|
|
||||||
String[] lonLatRadList = nogos.split("\\|");
|
String[] lonLatRadList = nogos.split("\\|");
|
||||||
|
|
||||||
List<OsmNodeNamed> nogoList = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> nogoList = new ArrayList<>();
|
||||||
for (int i = 0; i < lonLatRadList.length; i++) {
|
for (int i = 0; i < lonLatRadList.length; i++) {
|
||||||
String[] lonLatRad = lonLatRadList[i].split(",");
|
String[] lonLatRad = lonLatRadList[i].split(",");
|
||||||
String nogoWeight = "NaN";
|
String nogoWeight = "NaN";
|
||||||
|
@ -266,7 +266,7 @@ public class ServerHandler extends RequestHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OsmNodeNamed> readNogoPolygons() {
|
private List<OsmNodeNamed> readNogoPolygons() {
|
||||||
List<OsmNodeNamed> result = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> result = new ArrayList<>();
|
||||||
parseNogoPolygons(params.get("polylines"), result, false);
|
parseNogoPolygons(params.get("polylines"), result, false);
|
||||||
parseNogoPolygons(params.get("polygons"), result, true);
|
parseNogoPolygons(params.get("polygons"), result, true);
|
||||||
return result.size() > 0 ? result : null;
|
return result.size() > 0 ? result : null;
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
* @author ab
|
* @author ab
|
||||||
*/
|
*/
|
||||||
public class DenseLongMap {
|
public class DenseLongMap {
|
||||||
private List<byte[]> blocklist = new ArrayList<byte[]>(4096);
|
private List<byte[]> blocklist = new ArrayList<>(4096);
|
||||||
|
|
||||||
private int blocksize; // bytes per bitplane in one block
|
private int blocksize; // bytes per bitplane in one block
|
||||||
private int blocksizeBits;
|
private int blocksizeBits;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class FrozenLongMap<V> extends CompactLongMap<V> {
|
||||||
size = map.size();
|
size = map.size();
|
||||||
|
|
||||||
faid = new long[size];
|
faid = new long[size];
|
||||||
flv = new ArrayList<V>(size);
|
flv = new ArrayList<>(size);
|
||||||
|
|
||||||
map.moveToFrozenArrays(faid, flv);
|
map.moveToFrozenArrays(faid, flv);
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class LazyArrayOfLists<E> {
|
||||||
private List<ArrayList<E>> lists;
|
private List<ArrayList<E>> lists;
|
||||||
|
|
||||||
public LazyArrayOfLists(int size) {
|
public LazyArrayOfLists(int size) {
|
||||||
lists = new ArrayList<ArrayList<E>>(size);
|
lists = new ArrayList<>(size);
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
lists.add(null);
|
lists.add(null);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class LazyArrayOfLists<E> {
|
||||||
public List<E> getList(int idx) {
|
public List<E> getList(int idx) {
|
||||||
ArrayList<E> list = lists.get(idx);
|
ArrayList<E> list = lists.get(idx);
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = new ArrayList<E>();
|
list = new ArrayList<>();
|
||||||
lists.set(idx, list);
|
lists.set(idx, list);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
|
|
|
@ -22,14 +22,14 @@ public class CompactMapTest {
|
||||||
|
|
||||||
private void hashMapComparison(int mapsize, int trycount) {
|
private void hashMapComparison(int mapsize, int trycount) {
|
||||||
Random rand = new Random(12345);
|
Random rand = new Random(12345);
|
||||||
HashMap<Long, String> hmap = new HashMap<Long, String>();
|
HashMap<Long, String> hmap = new HashMap<>();
|
||||||
CompactLongMap<String> cmap_slow = new CompactLongMap<String>();
|
CompactLongMap<String> cmap_slow = new CompactLongMap<>();
|
||||||
CompactLongMap<String> cmap_fast = new CompactLongMap<String>();
|
CompactLongMap<String> cmap_fast = new CompactLongMap<>();
|
||||||
|
|
||||||
for (int i = 0; i < mapsize; i++) {
|
for (int i = 0; i < mapsize; i++) {
|
||||||
String s = "" + i;
|
String s = "" + i;
|
||||||
long k = mapsize < 10 ? i : rand.nextInt(20000);
|
long k = mapsize < 10 ? i : rand.nextInt(20000);
|
||||||
Long KK = new Long(k);
|
Long KK = k;
|
||||||
|
|
||||||
if (!hmap.containsKey(KK)) {
|
if (!hmap.containsKey(KK)) {
|
||||||
hmap.put(KK, s);
|
hmap.put(KK, s);
|
||||||
|
@ -40,11 +40,11 @@ public class CompactMapTest {
|
||||||
|
|
||||||
for (int i = 0; i < trycount * 2; i++) {
|
for (int i = 0; i < trycount * 2; i++) {
|
||||||
if (i == trycount) {
|
if (i == trycount) {
|
||||||
cmap_slow = new FrozenLongMap<String>(cmap_slow);
|
cmap_slow = new FrozenLongMap<>(cmap_slow);
|
||||||
cmap_fast = new FrozenLongMap<String>(cmap_fast);
|
cmap_fast = new FrozenLongMap<>(cmap_fast);
|
||||||
}
|
}
|
||||||
long k = mapsize < 10 ? i : rand.nextInt(20000);
|
long k = mapsize < 10 ? i : rand.nextInt(20000);
|
||||||
Long KK = new Long(k);
|
Long KK = k;
|
||||||
String s = hmap.get(KK);
|
String s = hmap.get(KK);
|
||||||
|
|
||||||
boolean contained = hmap.containsKey(KK);
|
boolean contained = hmap.containsKey(KK);
|
||||||
|
|
|
@ -22,13 +22,13 @@ public class CompactSetTest {
|
||||||
|
|
||||||
private void hashSetComparison(int setsize, int trycount) {
|
private void hashSetComparison(int setsize, int trycount) {
|
||||||
Random rand = new Random(12345);
|
Random rand = new Random(12345);
|
||||||
HashSet<Long> hset = new HashSet<Long>();
|
HashSet<Long> hset = new HashSet<>();
|
||||||
CompactLongSet cset_slow = new CompactLongSet();
|
CompactLongSet cset_slow = new CompactLongSet();
|
||||||
CompactLongSet cset_fast = new CompactLongSet();
|
CompactLongSet cset_fast = new CompactLongSet();
|
||||||
|
|
||||||
for (int i = 0; i < setsize; i++) {
|
for (int i = 0; i < setsize; i++) {
|
||||||
long k = setsize < 10 ? i : rand.nextInt(20000);
|
long k = setsize < 10 ? i : rand.nextInt(20000);
|
||||||
Long KK = new Long(k);
|
Long KK = k;
|
||||||
|
|
||||||
if (!hset.contains(KK)) {
|
if (!hset.contains(KK)) {
|
||||||
hset.add(KK);
|
hset.add(KK);
|
||||||
|
@ -43,7 +43,7 @@ public class CompactSetTest {
|
||||||
cset_fast = new FrozenLongSet(cset_fast);
|
cset_fast = new FrozenLongSet(cset_fast);
|
||||||
}
|
}
|
||||||
long k = setsize < 10 ? i : rand.nextInt(20000);
|
long k = setsize < 10 ? i : rand.nextInt(20000);
|
||||||
Long KK = new Long(k);
|
Long KK = k;
|
||||||
|
|
||||||
boolean contained = hset.contains(KK);
|
boolean contained = hset.contains(KK);
|
||||||
Assert.assertEquals("contains missmatch (slow)", contained, cset_slow.contains(k));
|
Assert.assertEquals("contains missmatch (slow)", contained, cset_slow.contains(k));
|
||||||
|
|
|
@ -16,21 +16,21 @@ public class DenseLongMapTest {
|
||||||
|
|
||||||
private void hashMapComparison(int mapsize, int trycount, long keyrange) {
|
private void hashMapComparison(int mapsize, int trycount, long keyrange) {
|
||||||
Random rand = new Random(12345);
|
Random rand = new Random(12345);
|
||||||
HashMap<Long, Integer> hmap = new HashMap<Long, Integer>();
|
HashMap<Long, Integer> hmap = new HashMap<>();
|
||||||
DenseLongMap dmap = new DenseLongMap(512);
|
DenseLongMap dmap = new DenseLongMap(512);
|
||||||
|
|
||||||
for (int i = 0; i < mapsize; i++) {
|
for (int i = 0; i < mapsize; i++) {
|
||||||
int value = i % 255;
|
int value = i % 255;
|
||||||
long k = (long) (rand.nextDouble() * keyrange);
|
long k = (long) (rand.nextDouble() * keyrange);
|
||||||
Long KK = new Long(k);
|
Long KK = k;
|
||||||
|
|
||||||
hmap.put(KK, new Integer(value));
|
hmap.put(KK, value);
|
||||||
dmap.put(k, value); // duplicate puts allowed!
|
dmap.put(k, value); // duplicate puts allowed!
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < trycount; i++) {
|
for (int i = 0; i < trycount; i++) {
|
||||||
long k = (long) (rand.nextDouble() * keyrange);
|
long k = (long) (rand.nextDouble() * keyrange);
|
||||||
Long KK = new Long(k);
|
Long KK = k;
|
||||||
Integer VV = hmap.get(KK);
|
Integer VV = hmap.get(KK);
|
||||||
int hvalue = VV == null ? -1 : VV.intValue();
|
int hvalue = VV == null ? -1 : VV.intValue();
|
||||||
int dvalue = dmap.getInt(k);
|
int dvalue = dmap.getInt(k);
|
||||||
|
@ -48,17 +48,17 @@ public class DenseLongMapTest {
|
||||||
int trycount = 100000;
|
int trycount = 100000;
|
||||||
|
|
||||||
Random rand = new Random(12345);
|
Random rand = new Random(12345);
|
||||||
HashSet<Long> hset = new HashSet<Long>();
|
HashSet<Long> hset = new HashSet<>();
|
||||||
|
|
||||||
DenseLongMap dmap = new DenseLongMap(512);
|
DenseLongMap dmap = new DenseLongMap(512);
|
||||||
for (int i = 0; i < mapputs; i++) {
|
for (int i = 0; i < mapputs; i++) {
|
||||||
long k = (long) (rand.nextDouble() * keyrange);
|
long k = (long) (rand.nextDouble() * keyrange);
|
||||||
hset.add(new Long(k));
|
hset.add(k);
|
||||||
dmap.put(k, 0);
|
dmap.put(k, 0);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < trycount; i++) {
|
for (int i = 0; i < trycount; i++) {
|
||||||
long k = (long) (rand.nextDouble() * keyrange);
|
long k = (long) (rand.nextDouble() * keyrange);
|
||||||
boolean hcontains = hset.contains(new Long(k));
|
boolean hcontains = hset.contains(k);
|
||||||
boolean dcontains = dmap.getInt(k) == 0;
|
boolean dcontains = dmap.getInt(k) == 0;
|
||||||
|
|
||||||
if (hcontains != dcontains) {
|
if (hcontains != dcontains) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Random;
|
||||||
public class SortedHeapTest {
|
public class SortedHeapTest {
|
||||||
@Test
|
@Test
|
||||||
public void sortedHeapTest1() {
|
public void sortedHeapTest1() {
|
||||||
SortedHeap<String> sh = new SortedHeap<String>();
|
SortedHeap<String> sh = new SortedHeap<>();
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
for (int i = 0; i < 100000; i++) {
|
for (int i = 0; i < 100000; i++) {
|
||||||
int val = rnd.nextInt(1000000);
|
int val = rnd.nextInt(1000000);
|
||||||
|
@ -34,7 +34,7 @@ public class SortedHeapTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sortedHeapTest2() {
|
public void sortedHeapTest2() {
|
||||||
SortedHeap<String> sh = new SortedHeap<String>();
|
SortedHeap<String> sh = new SortedHeap<>();
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
for (int i = 0; i < 100000; i++) {
|
for (int i = 0; i < 100000; i++) {
|
||||||
sh.add(i, "" + i);
|
sh.add(i, "" + i);
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
<exclude name="OneDeclarationPerLine" />
|
<exclude name="OneDeclarationPerLine" />
|
||||||
<exclude name="OverrideBothEqualsAndHashcode" />
|
<exclude name="OverrideBothEqualsAndHashcode" />
|
||||||
<exclude name="PreserveStackTrace" />
|
<exclude name="PreserveStackTrace" />
|
||||||
<exclude name="PrimitiveWrapperInstantiation" />
|
|
||||||
<exclude name="ReturnEmptyCollectionRatherThanNull" />
|
<exclude name="ReturnEmptyCollectionRatherThanNull" />
|
||||||
<exclude name="UncommentedEmptyConstructor" />
|
<exclude name="UncommentedEmptyConstructor" />
|
||||||
<exclude name="UncommentedEmptyMethodBody" />
|
<exclude name="UncommentedEmptyMethodBody" />
|
||||||
|
@ -48,4 +47,11 @@
|
||||||
<exclude name="MethodNamingConventions" />
|
<exclude name="MethodNamingConventions" />
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
<!-- Rules similar to Android Studio code inspection default settings -->
|
||||||
|
<!-- <rule ref="category/java/bestpractices.xml/UnusedAssignment" /> -->
|
||||||
|
<rule ref="category/java/codestyle.xml/UseDiamondOperator" />
|
||||||
|
<!-- <rule ref="category/java/design.xml/ImmutableField" /> -->
|
||||||
|
<!-- Will be added in PMD 7 -->
|
||||||
|
<!-- <rule ref="category/java/codestyle.xml/UnnecessaryBoxing" /> -->
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
|
|
@ -86,7 +86,7 @@ GEM
|
||||||
activesupport (>= 2)
|
activesupport (>= 2)
|
||||||
nokogiri (>= 1.4)
|
nokogiri (>= 1.4)
|
||||||
http_parser.rb (0.8.0)
|
http_parser.rb (0.8.0)
|
||||||
i18n (1.12.0)
|
i18n (1.13.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
jekyll (3.9.3)
|
jekyll (3.9.3)
|
||||||
addressable (~> 2.4)
|
addressable (~> 2.4)
|
||||||
|
@ -210,7 +210,7 @@ GEM
|
||||||
jekyll-feed (~> 0.9)
|
jekyll-feed (~> 0.9)
|
||||||
jekyll-seo-tag (~> 2.1)
|
jekyll-seo-tag (~> 2.1)
|
||||||
minitest (5.18.0)
|
minitest (5.18.0)
|
||||||
nokogiri (1.14.3-x86_64-linux)
|
nokogiri (1.15.0-x86_64-linux)
|
||||||
racc (~> 1.4)
|
racc (~> 1.4)
|
||||||
octokit (4.25.1)
|
octokit (4.25.1)
|
||||||
faraday (>= 1, < 3)
|
faraday (>= 1, < 3)
|
||||||
|
@ -258,4 +258,4 @@ DEPENDENCIES
|
||||||
wdm (~> 0.1.1)
|
wdm (~> 0.1.1)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.2.32
|
2.4.12
|
||||||
|
|
|
@ -13,43 +13,6 @@ also build them yourself from an OSM dump (e.g. planet or [GeoFabrik
|
||||||
extract](https://download.geofabrik.de/))
|
extract](https://download.geofabrik.de/))
|
||||||
|
|
||||||
|
|
||||||
## Build the pbfparser
|
|
||||||
|
|
||||||
First, there are two file formats available to download OSM data: `bzip`-ed
|
|
||||||
XML files (very large) and `.pbf`
|
|
||||||
([Protobuf](https://github.com/protocolbuffers/protobuf) format) which is much
|
|
||||||
more efficient. If you want to use the latter one, you will have to build the
|
|
||||||
`pbfparser` (located in `misc/pbfparser` first):
|
|
||||||
|
|
||||||
* Download [the latest
|
|
||||||
version](https://github.com/openstreetmap/osmosis/releases)
|
|
||||||
of [Osmosis](https://wiki.openstreetmap.org/wiki/Osmosis) and unzip it
|
|
||||||
somewhere.
|
|
||||||
* Copy the `lib/default/protobuf-java-*.jar` and
|
|
||||||
`lib/default/osmosis-osm-binary-*.jar` files from the unzipped Osmosis
|
|
||||||
archive to `misc/pbfparser/protobuf.jar` and `misc/pbfparser/osmosis.jar`.
|
|
||||||
* Build BRouter and copy
|
|
||||||
`brouter-server/build/libs/brouter-*-all.jar` to
|
|
||||||
`misc/pbfparser/brouter.jar`.
|
|
||||||
* You can build the `pbfparser` using, in the `misc/pbfparser/`
|
|
||||||
folder,
|
|
||||||
|
|
||||||
```
|
|
||||||
javac -d . -cp "brouter.jar:protobuf.jar:osmosis.jar" *.java
|
|
||||||
```
|
|
||||||
|
|
||||||
* Finally, you can build a `jar` file from these files using
|
|
||||||
|
|
||||||
```
|
|
||||||
jar cf pbfparser.jar btools/**/*.class
|
|
||||||
```
|
|
||||||
|
|
||||||
_Note:_ If the `jar` file is not properly created, everything else will seem
|
|
||||||
to work normally but there will not be any data extracted from the OSM data
|
|
||||||
dump. You can check what is actually inside the built `jar` file using
|
|
||||||
`jar tf pbfparser.jar`.
|
|
||||||
|
|
||||||
|
|
||||||
## Run the map creation script
|
## Run the map creation script
|
||||||
|
|
||||||
If you want to have elevation information in the generated segments files, you
|
If you want to have elevation information in the generated segments files, you
|
||||||
|
|
3
misc/pbfparser/.gitignore
vendored
3
misc/pbfparser/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
||||||
*.jar
|
|
||||||
*.BAK
|
|
||||||
btools/
|
|
|
@ -1,136 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
||||||
long bytesRead = 0L;
|
|
||||||
|
|
||||||
// wait for file to become available
|
|
||||||
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)));
|
|
||||||
|
|
||||||
|
|
||||||
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) {
|
|
||||||
long newSize = mapFile.length();
|
|
||||||
if (newSize != currentSize) {
|
|
||||||
currentSize = newSize;
|
|
||||||
currentSizeTime = System.currentTimeMillis();
|
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int headerLength;
|
|
||||||
try {
|
|
||||||
headerLength = dis.readInt();
|
|
||||||
bytesRead += 4;
|
|
||||||
} catch (EOFException e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] headerBuffer = new byte[headerLength];
|
|
||||||
dis.readFully(headerBuffer);
|
|
||||||
bytesRead += headerLength;
|
|
||||||
Fileformat.BlobHeader blobHeader = Fileformat.BlobHeader.parseFrom(headerBuffer);
|
|
||||||
|
|
||||||
byte[] blobData = new byte[blobHeader.getDatasize()];
|
|
||||||
dis.readFully(blobData);
|
|
||||||
bytesRead += blobData.length;
|
|
||||||
|
|
||||||
new BPbfBlobDecoder(blobHeader.getType(), blobData, this).process();
|
|
||||||
|
|
||||||
rawBlobCount++;
|
|
||||||
}
|
|
||||||
dis.close();
|
|
||||||
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(tags);
|
|
||||||
try {
|
|
||||||
nListener.nextNode(n);
|
|
||||||
} 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);
|
|
||||||
|
|
||||||
try {
|
|
||||||
wListener.nextWay(w);
|
|
||||||
} 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);
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("error writing relation", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
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 from https://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.zip
|
|
||||||
-> copy lib/default/osmosis-osm-binary-*.jar in the archive to osmosis.jar in
|
|
||||||
this folder
|
|
||||||
-> copy lib/default/protobuf-java-*.jar in the archive to protobuf.jar in this
|
|
||||||
folder
|
|
||||||
-> copy the brouter-server/build/libs/brouter-...-all.jar to
|
|
||||||
brouter.jar in this folder
|
|
||||||
-> compile the PBF-Parser using:
|
|
||||||
javac -d . -cp protobuf.jar:osmosis.jar:brouter.jar *.java
|
|
||||||
-> pack all the compiled class files together in a jar
|
|
||||||
"pbfparser.jar" with "jar cf pbfparser.jar btools/**/*.class"
|
|
||||||
|
|
||||||
Alternatively, just for testing you can run the Mapcreator against a *xml.bz2 Database-Extract,
|
|
||||||
then you don't need the pbf-parser. However, the XML-Parser does not (yet) parse
|
|
||||||
Turn-Restrictions, so really just for testing...
|
|
|
@ -1 +0,0 @@
|
||||||
javac -d . -cp pbfparser.jar;brouter.jar BPbfFieldDecoder.java BPbfBlobDecoder.java OsmParser.java
|
|
|
@ -24,14 +24,11 @@ touch lastmaprun.date
|
||||||
|
|
||||||
rm -rf /var/www/brouter/segments4_lastrun
|
rm -rf /var/www/brouter/segments4_lastrun
|
||||||
|
|
||||||
JAVA='/java/bin/java -Xmx2600m -Xms2600m -Xmn32m'
|
JAVA='java -Xmx2600m -Xms2600m -Xmn32m'
|
||||||
|
|
||||||
BROUTER_PROFILES=$(realpath "../../profiles2")
|
BROUTER_PROFILES=$(realpath "../../profiles2")
|
||||||
|
|
||||||
BROUTER_JAR=$(realpath $(ls ../../../brouter-server/build/libs/brouter-*-all.jar))
|
BROUTER_JAR=$(realpath $(ls ../../../brouter-server/build/libs/brouter-*-all.jar))
|
||||||
OSMOSIS_JAR=$(realpath "../../pbfparser/osmosis.jar")
|
|
||||||
PROTOBUF_JAR=$(realpath "../../pbfparser/protobuf.jar")
|
|
||||||
PBFPARSER_JAR=$(realpath "../../pbfparser/pbfparser.jar")
|
|
||||||
|
|
||||||
PLANET_FILE=${PLANET_FILE:-$(realpath "./planet-latest.osm.pbf")}
|
PLANET_FILE=${PLANET_FILE:-$(realpath "./planet-latest.osm.pbf")}
|
||||||
# Download SRTM zip files from
|
# Download SRTM zip files from
|
||||||
|
@ -43,7 +40,7 @@ SRTM_PATH="/private-backup/srtm"
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
cd tmp
|
cd tmp
|
||||||
mkdir nodetiles
|
mkdir nodetiles
|
||||||
${JAVA} -cp "${OSMOSIS_JAR}:${PROTOBUF_JAR}:${PBFPARSER_JAR}:${BROUTER_JAR}" btools.mapcreator.OsmCutter ${BROUTER_PROFILES}/lookups.dat nodetiles ways.dat relations.dat restrictions.dat ${BROUTER_PROFILES}/all.brf ${PLANET_FILE}
|
${JAVA} -cp ${BROUTER_JAR} -DavoidMapPolling=true btools.mapcreator.OsmCutter ${BROUTER_PROFILES}/lookups.dat nodetiles ways.dat relations.dat restrictions.dat ${BROUTER_PROFILES}/all.brf ${PLANET_FILE}
|
||||||
|
|
||||||
mkdir ftiles
|
mkdir ftiles
|
||||||
${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeFilter nodetiles ways.dat ftiles
|
${JAVA} -cp ${BROUTER_JAR} -Ddeletetmpfiles=true -DuseDenseMaps=true btools.mapcreator.NodeFilter nodetiles ways.dat ftiles
|
||||||
|
|
|
@ -15,7 +15,7 @@ mkdir waytiles
|
||||||
mkdir waytiles55
|
mkdir waytiles55
|
||||||
mkdir nodes55
|
mkdir nodes55
|
||||||
|
|
||||||
../../jdk8/bin/java -Xmx6144M -Xms6144M -Xmn256M -cp ../pbfparser.jar:../brouter_fc.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.util.StackSampler btools.mapcreator.OsmFastCutter ../lookups.dat nodetiles waytiles nodes55 waytiles55 bordernids.dat relations.dat restrictions.dat ../all.brf ../trekking.brf ../softaccess.brf ../planet-new.osm.pbf
|
../../jdk8/bin/java -Xmx6144M -Xms6144M -Xmn256M -cp ../brouter_fc.jar -Ddeletetmpfiles=true -DuseDenseMaps=true btools.util.StackSampler btools.mapcreator.OsmFastCutter ../lookups.dat nodetiles waytiles nodes55 waytiles55 bordernids.dat relations.dat restrictions.dat ../all.brf ../trekking.brf ../softaccess.brf ../planet-new.osm.pbf
|
||||||
|
|
||||||
mv ../planet-latest.osm.pbf ../planet-old.osm.pbf
|
mv ../planet-latest.osm.pbf ../planet-old.osm.pbf
|
||||||
mv ../planet-new.osm.pbf ../planet-latest.osm.pbf
|
mv ../planet-new.osm.pbf ../planet-latest.osm.pbf
|
||||||
|
|
Loading…
Reference in a new issue