diff --git a/vtm-android/src/org/oscim/android/theme/AssetsRenderTheme.java b/vtm-android/src/org/oscim/android/theme/AssetsRenderTheme.java
index 8eed44ba..6ec1fb79 100644
--- a/vtm-android/src/org/oscim/android/theme/AssetsRenderTheme.java
+++ b/vtm-android/src/org/oscim/android/theme/AssetsRenderTheme.java
@@ -21,6 +21,7 @@ import android.text.TextUtils;
import org.oscim.theme.IRenderTheme.ThemeException;
import org.oscim.theme.ThemeFile;
import org.oscim.theme.XmlRenderThemeMenuCallback;
+import org.oscim.utils.Utils;
import java.io.IOException;
import java.io.InputStream;
@@ -75,7 +76,7 @@ public class AssetsRenderTheme implements ThemeFile {
if (mInputStream != other.mInputStream) {
return false;
}
- if (mRelativePathPrefix != other.mRelativePathPrefix) {
+ if (!Utils.equals(mRelativePathPrefix, other.mRelativePathPrefix)) {
return false;
}
return true;
diff --git a/vtm-extras/src/org/oscim/tiling/source/oscimap2/OSciMap2TileSource.java b/vtm-extras/src/org/oscim/tiling/source/oscimap2/OSciMap2TileSource.java
index c5f4e286..c69139f7 100644
--- a/vtm-extras/src/org/oscim/tiling/source/oscimap2/OSciMap2TileSource.java
+++ b/vtm-extras/src/org/oscim/tiling/source/oscimap2/OSciMap2TileSource.java
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
+ * Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -147,7 +148,7 @@ public class OSciMap2TileSource extends UrlTileSource {
String key = Tags.keys[mSArray[curTag]];
Tag tag;
- if (key == Tag.KEY_NAME)
+ if (Tag.KEY_NAME.equals(key))
tag = new Tag(key, tagString, false);
else
tag = new Tag(key, tagString, true);
diff --git a/vtm/src/org/oscim/core/Tag.java b/vtm/src/org/oscim/core/Tag.java
index cd76fbb3..62ad590b 100644
--- a/vtm/src/org/oscim/core/Tag.java
+++ b/vtm/src/org/oscim/core/Tag.java
@@ -1,6 +1,7 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013 Hannes Janetzek
+ * Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -17,6 +18,8 @@
*/
package org.oscim.core;
+import org.oscim.utils.Utils;
+
/**
* A tag represents an immutable key-value pair. Keys are always intern().
*/
@@ -107,11 +110,11 @@ public class Tag {
}
Tag other = (Tag) obj;
- if (key != other.key)
+ if (!Utils.equals(key, other.key))
return false;
if (intern && other.intern) {
- if (value == other.value)
+ if (Utils.equals(value, other.value))
return true;
} else if (!intern && value.equals(other.value)) {
diff --git a/vtm/src/org/oscim/core/TagSet.java b/vtm/src/org/oscim/core/TagSet.java
index 54ba9c1f..19325aa6 100644
--- a/vtm/src/org/oscim/core/TagSet.java
+++ b/vtm/src/org/oscim/core/TagSet.java
@@ -1,6 +1,7 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 Andrey Novikov
+ * Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -17,6 +18,8 @@
*/
package org.oscim.core;
+import org.oscim.utils.Utils;
+
import java.util.Arrays;
/**
@@ -84,7 +87,7 @@ public class TagSet {
*/
public Tag get(String key) {
for (int i = 0; i < numTags; i++) {
- if (tags[i].key.equals(key))
+ if (Utils.equals(tags[i].key, key))
return tags[i];
}
return null;
@@ -98,7 +101,7 @@ public class TagSet {
*/
public boolean containsKey(String key) {
for (int i = 0; i < numTags; i++) {
- if (tags[i].key.equals(key))
+ if (Utils.equals(tags[i].key, key))
return true;
}
return false;
@@ -112,7 +115,7 @@ public class TagSet {
*/
public String getValue(String key) {
for (int i = 0; i < numTags; i++) {
- if (tags[i].key.equals(key))
+ if (Utils.equals(tags[i].key, key))
return tags[i].value;
}
return null;
@@ -155,7 +158,7 @@ public class TagSet {
public boolean contains(Tag tag) {
for (int i = 0; i < numTags; i++) {
Tag t = tags[i];
- if ((t == tag) || (t.key.equals(tag.key) && t.value.equals(tag.value)))
+ if ((t == tag) || (Utils.equals(t.key, tag.key) && Utils.equals(t.value, tag.value)))
return true;
}
return false;
@@ -170,8 +173,8 @@ public class TagSet {
*/
public boolean contains(String key, String value) {
for (int i = 0; i < numTags; i++) {
- if (tags[i].key.equals(key))
- return value.equals(tags[i].value);
+ if (Utils.equals(tags[i].key, key))
+ return Utils.equals(tags[i].value, value);
}
return false;
}
diff --git a/vtm/src/org/oscim/layers/tile/vector/OsmTileLayer.java b/vtm/src/org/oscim/layers/tile/vector/OsmTileLayer.java
index 2f3c95ed..1bfda19a 100644
--- a/vtm/src/org/oscim/layers/tile/vector/OsmTileLayer.java
+++ b/vtm/src/org/oscim/layers/tile/vector/OsmTileLayer.java
@@ -1,9 +1,27 @@
+/*
+ * Copyright 2013 Hannes Janetzek
+ * Copyright 2016 devemux86
+ *
+ * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
+ *
+ * This program is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with
+ * this program. If not, see .
+ */
package org.oscim.layers.tile.vector;
import org.oscim.core.Tag;
import org.oscim.core.TagSet;
import org.oscim.layers.tile.TileLoader;
import org.oscim.map.Map;
+import org.oscim.utils.Utils;
public class OsmTileLayer extends VectorTileLayer {
@@ -52,7 +70,7 @@ public class OsmTileLayer extends VectorTileLayer {
Tag t = tags[i];
for (TagReplacement replacement : mTagReplacement) {
- if (t.key == replacement.key) {
+ if (Utils.equals(t.key, replacement.key)) {
mFilteredTags.add(replacement.tag);
continue O;
}
diff --git a/vtm/src/org/oscim/renderer/bucket/PolygonBucket.java b/vtm/src/org/oscim/renderer/bucket/PolygonBucket.java
index 46498cd6..93bec081 100644
--- a/vtm/src/org/oscim/renderer/bucket/PolygonBucket.java
+++ b/vtm/src/org/oscim/renderer/bucket/PolygonBucket.java
@@ -1,6 +1,7 @@
/*
* Copyright 2012 Hannes Janetzek
* Copyright 2016 Longri
+ * Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -150,7 +151,7 @@ public final class PolygonBucket extends RenderBucket {
uMVP = getUniform("u_mvp");
aPos = getAttrib("a_pos");
uColor = getUniform("u_color");
- if (shaderFile == "polygon_layer_tex")
+ if ("polygon_layer_tex".equals(shaderFile))
uScale = getUniform("u_scale");
}
}
@@ -291,14 +292,10 @@ public final class PolygonBucket extends RenderBucket {
* draw polygon buckets (until bucket.next is not polygon bucket)
* using stencil buffer method
*
- * @param buckets layer to draw (referencing vertices in current vbo)
- * @param v GLViewport
- * @param pos used to fade buckets according to 'fade' in
- * layer.area style
- * @param div scale relative to 'base scale' of the tile
- * @param first pass true to clear stencil buffer region
- * @param clipMode clip to first quad in current vbo
- * using CLIP_STENCIL / CLIP_DEPTH
+ * @param buckets layer to draw (referencing vertices in current vbo)
+ * @param v GLViewport
+ * @param div scale relative to 'base scale' of the tile
+ * @param first pass true to clear stencil buffer region
* @return next layer
*/
public static RenderBucket draw(RenderBucket buckets, GLViewport v,
@@ -440,8 +437,8 @@ public final class PolygonBucket extends RenderBucket {
* Draw a tile filling rectangle to set stencil- and depth buffer
* appropriately
*
- * @param first in the first run the clip region is set based on
- * depth buffer and depth buffer is updated
+ * @param clipMode clip to first quad in current vbo
+ * using CLIP_STENCIL / CLIP_DEPTH
*/
static void drawStencilRegion(int clipMode) {
//log.debug("draw stencil {}", clipMode);
diff --git a/vtm/src/org/oscim/theme/MatchingCacheKey.java b/vtm/src/org/oscim/theme/MatchingCacheKey.java
index c888d5c1..790c9228 100644
--- a/vtm/src/org/oscim/theme/MatchingCacheKey.java
+++ b/vtm/src/org/oscim/theme/MatchingCacheKey.java
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
+ * Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -18,6 +19,7 @@ package org.oscim.theme;
import org.oscim.core.Tag;
import org.oscim.core.TagSet;
+import org.oscim.utils.Utils;
class MatchingCacheKey {
int mHash;
@@ -44,7 +46,7 @@ class MatchingCacheKey {
Tag t1 = tags.tags[i];
Tag t2 = compare.mTags[i];
- if (!(t1 == t2 || (t1.key == t2.key && t1.value == t2.value)))
+ if (!(t1 == t2 || (Utils.equals(t1.key, t2.key) && Utils.equals(t1.value, t2.value))))
break;
}
if (i == numTags)
@@ -86,7 +88,7 @@ class MatchingCacheKey {
Tag t1 = mTags[i];
Tag t2 = other.mTags[i];
- if (!(t1 == t2 || (t1.key == t2.key && t1.value == t2.value)))
+ if (!(t1 == t2 || (Utils.equals(t1.key, t2.key) && Utils.equals(t1.value, t2.value))))
return false;
}
return true;
diff --git a/vtm/src/org/oscim/theme/StreamRenderTheme.java b/vtm/src/org/oscim/theme/StreamRenderTheme.java
index b73c65ba..3372b265 100644
--- a/vtm/src/org/oscim/theme/StreamRenderTheme.java
+++ b/vtm/src/org/oscim/theme/StreamRenderTheme.java
@@ -15,6 +15,7 @@
package org.oscim.theme;
import org.oscim.theme.IRenderTheme.ThemeException;
+import org.oscim.utils.Utils;
import java.io.InputStream;
@@ -59,7 +60,7 @@ public class StreamRenderTheme implements ThemeFile {
if (mInputStream != other.mInputStream) {
return false;
}
- if (mRelativePathPrefix != other.mRelativePathPrefix) {
+ if (!Utils.equals(mRelativePathPrefix, other.mRelativePathPrefix)) {
return false;
}
return true;
diff --git a/vtm/src/org/oscim/theme/rule/Rule.java b/vtm/src/org/oscim/theme/rule/Rule.java
index 0485698b..15efe4d5 100644
--- a/vtm/src/org/oscim/theme/rule/Rule.java
+++ b/vtm/src/org/oscim/theme/rule/Rule.java
@@ -20,6 +20,7 @@ package org.oscim.theme.rule;
import org.oscim.core.Tag;
import org.oscim.theme.rule.RuleBuilder.RuleType;
import org.oscim.theme.styles.RenderStyle;
+import org.oscim.utils.Utils;
import java.util.List;
@@ -190,7 +191,7 @@ public class Rule {
@Override
public boolean matchesTags(Tag[] tags) {
for (Tag tag : tags)
- if (mKey == tag.key)
+ if (Utils.equals(mKey, tag.key))
return true;
return false;
@@ -209,7 +210,7 @@ public class Rule {
@Override
public boolean matchesTags(Tag[] tags) {
for (Tag tag : tags)
- if (mValue == tag.value)
+ if (Utils.equals(mValue, tag.value))
return true;
return false;
@@ -231,8 +232,8 @@ public class Rule {
@Override
public boolean matchesTags(Tag[] tags) {
for (Tag tag : tags)
- if (mKey == tag.key)
- return (mValue == tag.value);
+ if (Utils.equals(mKey, tag.key))
+ return (Utils.equals(mValue, tag.value));
return false;
}
@@ -263,7 +264,7 @@ public class Rule {
if (mKeys == null) {
for (Tag tag : tags) {
for (String value : mValues) {
- if (value == tag.value)
+ if (Utils.equals(value, tag.value))
return true;
}
}
@@ -272,12 +273,12 @@ public class Rule {
for (Tag tag : tags)
for (String key : mKeys) {
- if (key == tag.key) {
+ if (Utils.equals(key, tag.key)) {
if (mValues == null)
return true;
for (String value : mValues) {
- if (value == tag.value)
+ if (Utils.equals(value, tag.value))
return true;
}
}
@@ -319,7 +320,7 @@ public class Rule {
for (Tag tag : tags)
for (String value : values)
- if (value == tag.value)
+ if (Utils.equals(value, tag.value))
return !exclusive;
return exclusive;
@@ -328,7 +329,7 @@ public class Rule {
private boolean containsKeys(Tag[] tags) {
for (Tag tag : tags)
for (String key : keys)
- if (key == tag.key)
+ if (Utils.equals(key, tag.key))
return true;
return false;
diff --git a/vtm/src/org/oscim/tiling/source/oscimap4/TileDecoder.java b/vtm/src/org/oscim/tiling/source/oscimap4/TileDecoder.java
index 874e3686..436aa4ce 100644
--- a/vtm/src/org/oscim/tiling/source/oscimap4/TileDecoder.java
+++ b/vtm/src/org/oscim/tiling/source/oscimap4/TileDecoder.java
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
+ * Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -218,12 +219,12 @@ public class TileDecoder extends PbfDecoder {
// FIXME filter out all variable tags
// might depend on theme though
- if (key == Tag.KEY_NAME
- || key == Tag.KEY_HEIGHT
- || key == Tag.KEY_MIN_HEIGHT
- || key == Tag.KEY_HOUSE_NUMBER
- || key == Tag.KEY_REF
- || key == Tag.KEY_ELE)
+ if (Tag.KEY_NAME.equals(key)
+ || Tag.KEY_HEIGHT.equals(key)
+ || Tag.KEY_MIN_HEIGHT.equals(key)
+ || Tag.KEY_HOUSE_NUMBER.equals(key)
+ || Tag.KEY_REF.equals(key)
+ || Tag.KEY_ELE.equals(key))
tag = new Tag(key, val, false);
else
tag = new Tag(key, val, false, true);
diff --git a/vtm/src/org/oscim/utils/Utils.java b/vtm/src/org/oscim/utils/Utils.java
new file mode 100644
index 00000000..78ad635e
--- /dev/null
+++ b/vtm/src/org/oscim/utils/Utils.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2016 devemux86
+ *
+ * This program is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with
+ * this program. If not, see .
+ */
+package org.oscim.utils;
+
+public final class Utils {
+
+ /**
+ * Null safe equals.
+ */
+ public static boolean equals(Object o1, Object o2) {
+ return (o1 == o2) || (o1 != null && o1.equals(o2));
+ }
+
+ private Utils() {
+ throw new IllegalStateException();
+ }
+}