added startway check
This commit is contained in:
parent
6b4d989868
commit
d2d639666e
@ -161,7 +161,8 @@ public final class MicroCache2 extends MicroCache {
|
||||
int ilontarget = ilon + dlon_remaining;
|
||||
int ilattarget = ilat + dlat_remaining;
|
||||
if (matcher != null) {
|
||||
if (!matcher.start(ilon, ilat, ilontarget, ilattarget)) {
|
||||
boolean useAsStartWay = wayValidator.checkStartWay(wayTags.data);
|
||||
if (!matcher.start(ilon, ilat, ilontarget, ilattarget, useAsStartWay)) {
|
||||
matcher = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,4 +13,6 @@ public interface TagValueValidator {
|
||||
boolean isLookupIdxUsed(int idx);
|
||||
|
||||
void setDecodeForbidden(boolean decodeForbidden);
|
||||
|
||||
boolean checkStartWay(byte[] ab);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ package btools.codec;
|
||||
* matches to the waypoints
|
||||
*/
|
||||
public interface WaypointMatcher {
|
||||
boolean start(int ilonStart, int ilatStart, int ilonTarget, int ilatTarget);
|
||||
boolean start(int ilonStart, int ilatStart, int ilonTarget, int ilatTarget, boolean useAsStartWay);
|
||||
|
||||
void transferNode(int ilon, int ilat);
|
||||
|
||||
|
||||
@ -167,6 +167,10 @@ public final class RoutingContext {
|
||||
defaultC_r = expctxGlobal.getVariableValue("C_r", 0.01f);
|
||||
// Constant power of the biker (in W)
|
||||
bikerPower = expctxGlobal.getVariableValue("bikerPower", 100.f);
|
||||
|
||||
boolean test = expctxGlobal.getVariableValue("check_start_way", 1f) == 1f;
|
||||
if (!test) expctxGlobal.freeNoWays();
|
||||
|
||||
}
|
||||
|
||||
public List<OsmNodeNamed> poipoints;
|
||||
|
||||
@ -80,6 +80,8 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||
|
||||
private BExpressionContext foreignContext;
|
||||
|
||||
public int[] noStartWays = new int[0];
|
||||
|
||||
protected void setInverseVars() {
|
||||
currentVarOffset = nBuildInVars;
|
||||
}
|
||||
@ -187,7 +189,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||
/**
|
||||
* decode a byte-array into a lookup data array
|
||||
*/
|
||||
private void decode(int[] ld, boolean inverseDirection, byte[] ab) {
|
||||
public void decode(int[] ld, boolean inverseDirection, byte[] ab) {
|
||||
BitCoderContext ctx = ctxDecode;
|
||||
ctx.reset(ab);
|
||||
|
||||
@ -954,6 +956,7 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||
|
||||
private String _parseToken() throws Exception {
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
StringBuilder sbcom = new StringBuilder(32);
|
||||
boolean inComment = false;
|
||||
for (; ; ) {
|
||||
int ic = _readerDone ? -1 : _br.read();
|
||||
@ -966,7 +969,33 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||
if (c == '\n') linenr++;
|
||||
|
||||
if (inComment) {
|
||||
sbcom.append(c);
|
||||
if (c == '\r' || c == '\n') inComment = false;
|
||||
if (!inComment) {
|
||||
Integer num = variableNumbers.get("check_start_way");
|
||||
if (num != null && noStartWays.length == 0 && sbcom.toString().contains("noStartWay")) {
|
||||
String var = sbcom.toString().trim();
|
||||
String[] savar = var.split("\\|");
|
||||
if (savar.length == 4) {
|
||||
var = savar[3].substring(savar[3].indexOf("=")+1).trim();
|
||||
String[] sa = var.split(";");
|
||||
for (String s: sa) {
|
||||
String[] sa2 = s.split(",");
|
||||
String name = sa2[0];
|
||||
String value = sa2[1];
|
||||
int nidx = getLookupNameIdx(name);
|
||||
if (nidx == -1) break;
|
||||
int vidx = getLookupValueIdx(nidx, value);
|
||||
int[] tmp = new int[noStartWays.length + 2];
|
||||
if (noStartWays.length > 0) System.arraycopy(noStartWays, 0, tmp, 0, noStartWays.length);
|
||||
noStartWays = tmp;
|
||||
noStartWays[noStartWays.length-2] = nidx;
|
||||
noStartWays[noStartWays.length-1] = vidx;
|
||||
}
|
||||
}
|
||||
}
|
||||
sbcom.setLength(0);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (Character.isWhitespace(c)) {
|
||||
@ -983,4 +1012,21 @@ public abstract class BExpressionContext implements IByteArrayUnifier {
|
||||
return value;
|
||||
}
|
||||
|
||||
int[] ld2 = new int[512];
|
||||
public boolean checkStartWay(byte[] ab) {
|
||||
if (ab == null) return true;
|
||||
Arrays.fill(ld2, 0);
|
||||
decode(ld2, false, ab);
|
||||
for (int i = 0; i < noStartWays.length; i += 2) {
|
||||
int key = noStartWays[i];
|
||||
int value = noStartWays[i+1];
|
||||
if (ld2[key] == value) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void freeNoWays() {
|
||||
noStartWays = new int[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -129,4 +129,6 @@ public final class BExpressionContextWay extends BExpressionContext implements T
|
||||
public void setDecodeForbidden(boolean decodeForbidden) {
|
||||
this.decodeForbidden = decodeForbidden;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -116,7 +116,8 @@ public final class DirectWeaver extends ByteDataWriter {
|
||||
int ilontarget = ilon + dlon_remaining;
|
||||
int ilattarget = ilat + dlat_remaining;
|
||||
if (matcher != null) {
|
||||
if (!matcher.start(ilon, ilat, ilontarget, ilattarget)) {
|
||||
boolean useAsStartWay = wayTags==null || wayValidator.checkStartWay(wayTags.data);
|
||||
if (!matcher.start(ilon, ilat, ilontarget, ilattarget, useAsStartWay)) {
|
||||
matcher = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
||||
private boolean anyUpdate;
|
||||
private int lonLast;
|
||||
private int latLast;
|
||||
boolean useAsStartWay = true;
|
||||
|
||||
private Comparator<MatchedWaypoint> comparator;
|
||||
|
||||
@ -78,6 +79,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
||||
|
||||
//for ( MatchedWaypoint mwp : waypoints )
|
||||
for (int i = 0; i < waypoints.size(); i++) {
|
||||
if (!useAsStartWay && i==0) continue;
|
||||
MatchedWaypoint mwp = waypoints.get(i);
|
||||
|
||||
if (mwp.direct &&
|
||||
@ -141,7 +143,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start(int ilonStart, int ilatStart, int ilonTarget, int ilatTarget) {
|
||||
public boolean start(int ilonStart, int ilatStart, int ilonTarget, int ilatTarget, boolean useAsStartWay) {
|
||||
if (islandPairs.size() > 0) {
|
||||
long n1 = ((long) ilonStart) << 32 | ilatStart;
|
||||
long n2 = ((long) ilonTarget) << 32 | ilatTarget;
|
||||
@ -154,6 +156,7 @@ public final class WaypointMatcherImpl implements WaypointMatcher {
|
||||
lonTarget = ilonTarget;
|
||||
latTarget = ilatTarget;
|
||||
anyUpdate = false;
|
||||
this.useAsStartWay = useAsStartWay;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user