file formatting
This commit is contained in:
parent
cc4b8c721f
commit
7b0c4f6910
1 changed files with 46 additions and 50 deletions
|
@ -35,13 +35,12 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
||||||
private static final int SHIFT_COORDINATES = 4;
|
private static final int SHIFT_COORDINATES = 4;
|
||||||
|
|
||||||
private static class RouteTypeCondition {
|
private static class RouteTypeCondition {
|
||||||
|
String condition = "";
|
||||||
|
OpeningHoursParser.OpeningHours hours = null;
|
||||||
|
float floatValue;
|
||||||
|
}
|
||||||
|
|
||||||
String condition = "";
|
|
||||||
OpeningHoursParser.OpeningHours hours = null;
|
|
||||||
float floatValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class RouteTypeRule {
|
public static class RouteTypeRule {
|
||||||
private final static int ACCESS = 1;
|
private final static int ACCESS = 1;
|
||||||
private final static int ONEWAY = 2;
|
private final static int ONEWAY = 2;
|
||||||
|
@ -56,7 +55,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
private int intValue;
|
private int intValue;
|
||||||
private float floatValue;
|
private float floatValue;
|
||||||
private int type;
|
private int type;
|
||||||
private List<RouteTypeCondition> conditions = null;
|
private List<RouteTypeCondition> conditions = null;
|
||||||
private int forward;
|
private int forward;
|
||||||
|
|
||||||
public RouteTypeRule(String t, String v) {
|
public RouteTypeRule(String t, String v) {
|
||||||
|
@ -75,61 +74,61 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int isForward() {
|
public int isForward() {
|
||||||
return forward;
|
return forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTag() {
|
public String getTag() {
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(){
|
public String getValue(){
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean roundabout(){
|
public boolean roundabout(){
|
||||||
return type == ROUNDABOUT;
|
return type == ROUNDABOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean conditional() {
|
public boolean conditional() {
|
||||||
return conditions != null;
|
return conditions != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int onewayDirection(){
|
public int onewayDirection(){
|
||||||
if(type == ONEWAY){
|
if(type == ONEWAY){
|
||||||
return intValue;
|
return intValue;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float maxSpeed(){
|
public float maxSpeed(){
|
||||||
if(type == MAXSPEED){
|
if(type == MAXSPEED){
|
||||||
if(conditions != null) {
|
if(conditions != null) {
|
||||||
Calendar i = Calendar.getInstance();
|
Calendar i = Calendar.getInstance();
|
||||||
i.setTimeInMillis(System.currentTimeMillis());
|
i.setTimeInMillis(System.currentTimeMillis());
|
||||||
for(RouteTypeCondition c : conditions) {
|
for(RouteTypeCondition c : conditions) {
|
||||||
if(c.hours != null && c.hours.isOpenedForTime(i)) {
|
if(c.hours != null && c.hours.isOpenedForTime(i)) {
|
||||||
return c.floatValue;
|
return c.floatValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return floatValue;
|
return floatValue;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int lanes(){
|
public int lanes(){
|
||||||
if(type == LANES){
|
if(type == LANES){
|
||||||
return intValue;
|
return intValue;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String highwayRoad(){
|
public String highwayRoad(){
|
||||||
if(type == HIGHWAY_TYPE){
|
if(type == HIGHWAY_TYPE){
|
||||||
return v;
|
return v;
|
||||||
|
@ -159,23 +158,23 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
type = HIGHWAY_TYPE;
|
type = HIGHWAY_TYPE;
|
||||||
} else if(t.startsWith("access") && v != null){
|
} else if(t.startsWith("access") && v != null){
|
||||||
type = ACCESS;
|
type = ACCESS;
|
||||||
} else if(t.equalsIgnoreCase("maxspeed:conditional") && v != null){
|
} else if(t.equalsIgnoreCase("maxspeed:conditional") && v != null){
|
||||||
conditions = new ArrayList<RouteTypeCondition>();
|
conditions = new ArrayList<RouteTypeCondition>();
|
||||||
String[] cts = v.split(";");
|
String[] cts = v.split(";");
|
||||||
for(String c : cts) {
|
for(String c : cts) {
|
||||||
int ch = c.indexOf('@');
|
int ch = c.indexOf('@');
|
||||||
if (ch > 0) {
|
if (ch > 0) {
|
||||||
RouteTypeCondition cond = new RouteTypeCondition();
|
RouteTypeCondition cond = new RouteTypeCondition();
|
||||||
cond.floatValue = RouteDataObject.parseSpeed(c.substring(0, ch), 0);
|
cond.floatValue = RouteDataObject.parseSpeed(c.substring(0, ch), 0);
|
||||||
cond.condition = c.substring(ch + 1).trim();
|
cond.condition = c.substring(ch + 1).trim();
|
||||||
if (cond.condition.startsWith("(") && cond.condition.endsWith(")")) {
|
if (cond.condition.startsWith("(") && cond.condition.endsWith(")")) {
|
||||||
cond.condition = cond.condition.substring(1, cond.condition.length() - 1).trim();
|
cond.condition = cond.condition.substring(1, cond.condition.length() - 1).trim();
|
||||||
}
|
}
|
||||||
cond.hours = OpeningHoursParser.parseOpenedHours(cond.condition);
|
cond.hours = OpeningHoursParser.parseOpenedHours(cond.condition);
|
||||||
conditions.add(cond);
|
conditions.add(cond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type = MAXSPEED;
|
type = MAXSPEED;
|
||||||
} else if(t.equalsIgnoreCase("maxspeed") && v != null){
|
} else if(t.equalsIgnoreCase("maxspeed") && v != null){
|
||||||
type = MAXSPEED;
|
type = MAXSPEED;
|
||||||
floatValue = RouteDataObject.parseSpeed(v, 0);
|
floatValue = RouteDataObject.parseSpeed(v, 0);
|
||||||
|
@ -187,7 +186,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
type = MAXSPEED;
|
type = MAXSPEED;
|
||||||
forward = -1;
|
forward = -1;
|
||||||
floatValue = RouteDataObject.parseSpeed(v, 0);
|
floatValue = RouteDataObject.parseSpeed(v, 0);
|
||||||
} else if (t.equalsIgnoreCase("lanes") && v != null) {
|
} else if (t.equalsIgnoreCase("lanes") && v != null) {
|
||||||
intValue = -1;
|
intValue = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
type = LANES;
|
type = LANES;
|
||||||
|
@ -198,12 +197,9 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
intValue = Integer.parseInt(v.substring(0, i));
|
intValue = Integer.parseInt(v.substring(0, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RouteRegion extends BinaryIndexPart {
|
public static class RouteRegion extends BinaryIndexPart {
|
||||||
public int regionsRead;
|
public int regionsRead;
|
||||||
List<RouteSubregion> subregions = new ArrayList<RouteSubregion>();
|
List<RouteSubregion> subregions = new ArrayList<RouteSubregion>();
|
||||||
|
|
Loading…
Reference in a new issue