From a881eec9b170781c2d46704971161abd724b5c2f Mon Sep 17 00:00:00 2001 From: Meibes <26258451+Meibes@users.noreply.github.com> Date: Tue, 22 Dec 2020 18:04:33 +0100 Subject: [PATCH] OSMUtils.isArea improvements (#798) --- .../oscim/tiling/source/mapfile/OSMUtils.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/vtm/src/org/oscim/tiling/source/mapfile/OSMUtils.java b/vtm/src/org/oscim/tiling/source/mapfile/OSMUtils.java index 70947fd1..6611615e 100644 --- a/vtm/src/org/oscim/tiling/source/mapfile/OSMUtils.java +++ b/vtm/src/org/oscim/tiling/source/mapfile/OSMUtils.java @@ -1,7 +1,8 @@ /* * Copyright 2010, 2011, 2012, 2013 mapsforge.org - * Copyright 2015-2016 devemux86 + * Copyright 2015-2020 devemux86 * Copyright 2015-2016 lincomatic + * Copyright 2020 Meibes * * 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 @@ -19,10 +20,27 @@ package org.oscim.tiling.source.mapfile; import org.oscim.core.MapElement; import org.oscim.core.Tag; +import java.util.HashSet; import java.util.Locale; +import java.util.Set; public final class OSMUtils { + private static final Set areaKeys = new HashSet<>(); + + static { + areaKeys.add("building"); + areaKeys.add("highway"); + areaKeys.add("natural"); + areaKeys.add("landuse"); + areaKeys.add("amenity"); + areaKeys.add("barrier"); + areaKeys.add("leisure"); + areaKeys.add("railway"); + areaKeys.add("area"); + areaKeys.add("aeroway"); + } + /** * Heuristic to determine from attributes if a map element is likely to be an area. * Precondition for this call is that the first and last node of a map element are the @@ -41,8 +59,11 @@ public final class OSMUtils { for (int i = 0; i < mapElement.tags.size(); i++) { Tag tag = mapElement.tags.get(i); String key = tag.key.toLowerCase(Locale.ENGLISH); - String value = tag.value.toLowerCase(Locale.ENGLISH); + if (!areaKeys.contains(key)) { + continue; + } if ("area".equals(key)) { + String value = tag.value.toLowerCase(Locale.ENGLISH); // obvious result if (("yes").equals(value) || ("y").equals(value) || ("true").equals(value)) { return true; @@ -60,6 +81,7 @@ public final class OSMUtils { result = false; } if ("railway".equals(key)) { + String value = tag.value.toLowerCase(Locale.ENGLISH); // there is more to the railway tag then just rails, this excludes the // most common railway lines from being detected as areas if they are closed. // Since this method is only called if the first and last node are the same