From 07c297a95a6d5fb024a1754b5efa869172b16656 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 18 Oct 2020 02:28:44 +0200 Subject: [PATCH] Fix parse complex properties --- .../java/net/osmand/render/RenderingRule.java | 9 +++-- .../osmand/render/RenderingRuleProperty.java | 36 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java index e597386d47..88a7fc83dc 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRule.java @@ -58,14 +58,13 @@ public class RenderingRule { attributesRef[i] = storage.getRenderingAttributeRule(vl.substring(1)); } else if (property.isString()) { intProperties[i] = storage.getDictionaryValue(vl); - } else if (property.isFloat()) { - if (floatProperties == null) { + } else { + float floatVal = property.parseFloatValue(vl); + if (floatProperties == null && floatVal != 0) { // lazy creates floatProperties = new float[attributes.size()]; + floatProperties[i] = property.parseFloatValue(vl); } - floatProperties[i] = property.parseFloatValue(vl); - intProperties[i] = property.parseIntValue(vl); - } else { intProperties[i] = property.parseIntValue(vl); } i++; diff --git a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleProperty.java b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleProperty.java index 228430b01f..322a734980 100644 --- a/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleProperty.java +++ b/OsmAnd-java/src/main/java/net/osmand/render/RenderingRuleProperty.java @@ -155,12 +155,7 @@ public class RenderingRuleProperty { try { int colon = value.indexOf(':'); if(colon != -1) { - int c = 0; - if(colon > 0) { - c += (int) Float.parseFloat(value.substring(0, colon)); - } - c += (int) Float.parseFloat(value.substring(colon + 1)); - return c; + return (int) Float.parseFloat(value.substring(colon + 1)); } return (int) Float.parseFloat(value); } catch (NumberFormatException e) { @@ -190,30 +185,35 @@ public class RenderingRuleProperty { } catch (NumberFormatException e) { log.error("Rendering parse " + value + " in " + attrName); } - return -1; + return 0; } else { return -1; } } - public float parseFloatValue(String value){ - if(type == FLOAT_TYPE){ - try { + public float parseFloatValue(String value) { + try { + if (type == FLOAT_TYPE) { int colon = value.indexOf(':'); - if(colon != -1) { - if(colon > 0) { + if (colon != -1) { + if (colon > 0) { return Float.parseFloat(value.substring(0, colon)); - } + } return 0; } return Float.parseFloat(value); - } catch (NumberFormatException e) { - log.error("Rendering parse " + value + " in " + attrName); + + } else if (type == INT_TYPE) { + int colon = value.indexOf(':'); + if (colon != -1 && colon > 0) { + return Float.parseFloat(value.substring(0, colon)); + } + return 0; } - return -1; - } else { - return -1; + } catch (NumberFormatException e) { + log.error("Rendering parse " + value + " in " + attrName); } + return 0; }