diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/DataAvailability.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/DataAvailability.java index be68802..4da9300 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/DataAvailability.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/DataAvailability.java @@ -75,7 +75,7 @@ public class DataAvailability { jsonFile.setMaxAge(SEVEN_DAYS_IN_SECONDS); jsonParser.next(); JsonObject jsonObject = jsonParser.getObject(); - for (Entry entry : jsonObject.entrySet()) { + for (Map.Entry entry : jsonObject.entrySet()) { Logging.debug("{0}: {1}", entry.getKey(), entry.getValue()); if (JsonValue.ValueType.OBJECT == entry.getValue().getValueType() && entry.getValue().asJsonObject().containsKey("countries")) { @@ -156,6 +156,8 @@ public class DataAvailability { } /** + * Get the global i nstance that should be used to check for data availability + * * @return the unique instance */ public static DataAvailability getInstance() { @@ -167,6 +169,8 @@ public class DataAvailability { } /** + * Check if a bbox may have data + * * @param bbox An area that may have data * @return True if one of the corners of the {@code bbox} is in a country with * available data. @@ -177,10 +181,13 @@ public class DataAvailability { corners.add(new LatLon(bbox.getBottomRightLat(), bbox.getTopLeftLon())); corners.add(bbox.getTopLeft()); corners.add(new LatLon(bbox.getTopLeftLat(), bbox.getBottomRightLon())); + corners.add(bbox.getCenter()); return corners.parallelStream().anyMatch(this::hasData); } /** + * Check if a latlon point may have data + * * @param latLon A point that may have data from MapWithAI * @return true if it is in an ares with data from MapWithAI */ @@ -274,7 +281,7 @@ public class DataAvailability { } /** - * Set the URL to use to get MapWithAI information + * Set the URL to use to get MapWithAI information (`sources.json`) * * @param url The URL which serves MapWithAI servers */ @@ -283,7 +290,9 @@ public class DataAvailability { } /** - * @param url The URL which serves MapWithAI servers + * Get the URL for the `sources.json`. + * + * @return The URL which serves MapWithAI servers */ public static String getReleaseUrl() { return defaultServerUrl; diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java index 2525826..f538e08 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/backend/MapWithAIPreferenceHelper.java @@ -66,6 +66,8 @@ public final class MapWithAIPreferenceHelper { } /** + * Check if the user wants to merge buildings and addresses + * * @return {@code true} if we want to automatically merge buildings with * pre-existing addresses */ @@ -74,6 +76,8 @@ public final class MapWithAIPreferenceHelper { } /** + * Check if the user wants to switch layers automatically after adding data. + * * @return {@code true} if we want to automatically switch layers */ public static boolean isSwitchLayers() { @@ -85,6 +89,13 @@ public final class MapWithAIPreferenceHelper { return returnBoolean; } + /** + * Add a MapWithAI url. If both boolean parameters are false, nothing happens. + * + * @param info The info to add + * @param enabled If it should be enabled + * @param permanent If it should be added permanently + */ public static void setMapWithAIUrl(MapWithAIInfo info, boolean enabled, boolean permanent) { if (permanent && enabled) { MapWithAILayerInfo.instance.add(info); @@ -162,6 +173,8 @@ public final class MapWithAIPreferenceHelper { } /** + * Get the tags to replace + * * @return A map of tags to replacement tags (use {@link Tag#ofString} to parse) */ public static Map getReplacementTags() { @@ -172,6 +185,8 @@ public final class MapWithAIPreferenceHelper { } /** + * Set the tags to replace + * * @param tagsToReplace set the tags to replace */ public static void setReplacementTags(Map tagsToReplace) { diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java index cd69d2d..9fa1f49 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/data/mapwithai/MapWithAIInfo.java @@ -25,7 +25,6 @@ import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds; import org.openstreetmap.josm.data.imagery.Shape; import org.openstreetmap.josm.data.sources.SourceInfo; import org.openstreetmap.josm.data.sources.SourcePreferenceEntry; -import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAIInfo.MapWithAIPreferenceEntry; import org.openstreetmap.josm.spi.preferences.Config; import org.openstreetmap.josm.tools.CheckParameterUtil; import org.openstreetmap.josm.tools.Logging; @@ -43,11 +42,12 @@ public class MapWithAIInfo extends /** * when adding a field, also adapt the: {@link #MapWithAIPreferenceEntry * MapWithAIPreferenceEntry object} - * {@link #MapWithAIPreferenceEntry#MapWithAIPreferenceEntry(MapWithAIInfo) + * {@link MapWithAIPreferenceEntry#MapWithAIPreferenceEntry(MapWithAIInfo) * MapWithAIPreferenceEntry constructor} - * {@link #MapWithAIInfo(MapWithAIPreferenceEntry) ImageryInfo constructor} - * {@link #MapWithAIInfo(ImageryInfo) MapWithAIInfo constructor} - * {@link #equalsPref(MapWithAIPreferenceEntry) equalsPref method} + * {@link MapWithAIInfo#MapWithAIInfo(MapWithAIPreferenceEntry) ImageryInfo + * constructor} {@link MapWithAIInfo#MapWithAIInfo(ImageryInfo) MapWithAIInfo + * constructor} {@link MapWithAIInfo#equalsPref(MapWithAIPreferenceEntry) + * equalsPref method} **/ public static class MapWithAIPreferenceEntry extends SourcePreferenceEntry { @StructEntry @@ -64,7 +64,7 @@ public class MapWithAIInfo extends String categories; /** - * Constructs a new empty {@MapWithAIPreferenceEntry} + * Constructs a new empty {@link MapWithAIPreferenceEntry} */ public MapWithAIPreferenceEntry() { // Do nothing @@ -369,13 +369,19 @@ public class MapWithAIInfo extends } /** - * @return The required replacement tags (run first) + * Get the requested tags to replace. These should be run before user requested + * replacements. + * + * @return The required replacement tags */ public Map getReplacementTags() { return replacementTags; } /** + * Set whether or not we should perform conflation using the specified + * conflation URL + * * @param conflation If true, try to use the conflation URL */ public void setConflation(boolean conflation) { @@ -383,6 +389,8 @@ public class MapWithAIInfo extends } /** + * Set the URL to use for conflation purposes. + * * @param conflationUrl Set the conflation url to use. null will disable, but * you should use {@link MapWithAIInfo#setConflation}. */ @@ -391,6 +399,8 @@ public class MapWithAIInfo extends } /** + * Set any parameters that are required/useful for the conflation URL + * * @param parameters Set the conflation parameters */ public void setConflationParameters(JsonArray parameters) { @@ -407,6 +417,9 @@ public class MapWithAIInfo extends } /** + * Set additional categories (you can duplicate the primary category here, but + * you shouldn't) + * * @return Any additional categories */ public List getAdditionalCategories() { diff --git a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/tools/Access.java b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/tools/Access.java index cfa857a..fee7747 100644 --- a/src/main/java/org/openstreetmap/josm/plugins/mapwithai/tools/Access.java +++ b/src/main/java/org/openstreetmap/josm/plugins/mapwithai/tools/Access.java @@ -10,7 +10,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -34,229 +33,221 @@ public final class Access { ALL_TRANSPORT_TYPE("all"), /** - * @see Key:access + * Key:access */ ACCESS_KEY("access", ALL_TRANSPORT_TYPE), // Access tag values /** - * @see Tag:access%3Dyes + * Tag:access%3Dyes */ YES("yes"), /** - * @see Tag:access%3Dofficial + * Tag:access%3Dofficial */ OFFICIAL("official"), /** - * @see Tag:access%3Ddesignated + * Tag:access%3Ddesignated */ DESIGNATED("designated"), /** - * @see Tag:access%3Ddestination + * Tag:access%3Ddestination */ DESTINATION("destination"), /** - * @see Tag:access%3Ddelivery + * Tag:access%3Ddelivery */ DELIVERY("delivery"), /** - * @see Tag:access%3Dcustomers + * Tag:access%3Dcustomers */ CUSTOMERS("customers"), /** - * @see Tag:access%3Dpermissive + * Tag:access%3Dpermissive */ PERMISSIVE("permissive"), /** - * @see Tag:access%3Dagricultural + * Tag:access%3Dagricultural */ AGRICULTURAL("agricultural"), /** - * @see Tag:access%3Dforestry + * Tag:access%3Dforestry */ FORESTRY("forestry"), /** - * @see Tag:access%3Dprivate + * Tag:access%3Dprivate */ PRIVATE("private"), /** - * @see Tag:access%3Dno + * Tag:access%3Dno */ NO("no"), /** - * @see Tag:access%3Ddiscouraged + * Tag:access%3Ddiscouraged */ DISCOURAGED("discouraged"), /** - * @see Tag:access%3Duse_sidepath + * Tag:access%3Duse_sidepath */ USE_SIDEPATH("use_sidepath"), /** - * @see Tag:access%3Ddismount + * Tag:access%3Ddismount */ DISMOUNT("dismount"), // Land /** Land transport types */ LAND_TRANSPORT_TYPE("land", ALL_TRANSPORT_TYPE), /** - * @see Key:vehicle + * Key:vehicle */ VEHICLE("vehicle", LAND_TRANSPORT_TYPE), /** - * @see Key:motor_vehicle + * Key:motor_vehicle */ MOTOR_VEHICLE("motor_vehicle", LAND_TRANSPORT_TYPE), /** - * @see Key:trailer + * Key:trailer */ TRAILER("trailer", LAND_TRANSPORT_TYPE), - /** @see Key:foot */ + /** Key:foot */ FOOT("foot", LAND_TRANSPORT_TYPE), - /** @see Key:ski */ + /** Key:ski */ SKI("ski", LAND_TRANSPORT_TYPE), /** - * @see Key:inline_skates + * Key:inline_skates */ INLINE_SKATES("inline_skates", LAND_TRANSPORT_TYPE), /** - * @see Key:ice_skates + * Key:ice_skates */ ICE_SKATES("ice_skates", LAND_TRANSPORT_TYPE), /** - * @see Key:horse + * Key:horse */ HORSE("horse", LAND_TRANSPORT_TYPE), /** - * @see Key:bicycle + * Key:bicycle */ BICYCLE("bicycle", LAND_TRANSPORT_TYPE), /** - * @see Key:carriage + * Key:carriage */ CARRIAGE("carriage", LAND_TRANSPORT_TYPE), /** - * @see Key:caravan + * Key:caravan */ CARAVAN("caravan", LAND_TRANSPORT_TYPE), /** - * @see Key:motorcycle + * Key:motorcycle */ MOTORCYCLE("motorcycle", LAND_TRANSPORT_TYPE), /** - * @see Key:moped + * Key:moped */ MOPED("moped", LAND_TRANSPORT_TYPE), - /** @see Key:mofa */ + /** Key:mofa */ MOFA("mofa", LAND_TRANSPORT_TYPE), /** - * @see Key:motorcar + * Key:motorcar */ MOTORCAR("motorcar", LAND_TRANSPORT_TYPE), /** - * @see Key:motorhome + * Key:motorhome */ MOTORHOME("motorhome", LAND_TRANSPORT_TYPE), - /** @see Key:psv */ + /** Key:psv */ PSV("psv", LAND_TRANSPORT_TYPE), - /** @see Key:bus */ + /** Key:bus */ BUS("bus", LAND_TRANSPORT_TYPE), - /** @see Key:taxi */ + /** Key:taxi */ TAXI("taxi", LAND_TRANSPORT_TYPE), /** - * @see Key:tourist_bus + * Key:tourist_bus */ TOURIST_BUS("tourist_bus", LAND_TRANSPORT_TYPE), /** - * @see Key:goods + * Key:goods */ GOODS("goods", LAND_TRANSPORT_TYPE), - /** @see Key:hgv */ + /** Key:hgv */ HGV("hgv", LAND_TRANSPORT_TYPE), - /** @see Key:atv */ + /** Key:atv */ ATV("atv", LAND_TRANSPORT_TYPE), /** - * @see Key:snowmobile + * Key:snowmobile */ SNOWMOBILE("snowmobile", LAND_TRANSPORT_TYPE), /** - * @see Key:hgv_articulated + * Key:hgv_articulated */ HGV_ARTICULATED("hgv_articulated", LAND_TRANSPORT_TYPE), - /** @see Key:ski */ + /** Key:ski */ SKI_NORDIC("ski:nordic", LAND_TRANSPORT_TYPE), - /** @see Key:ski */ + /** Key:ski */ SKI_ALPINE("ski:alpine", LAND_TRANSPORT_TYPE), - /** @see Key:ski */ + /** Key:ski */ SKI_TELEMARK("ski:telemark", LAND_TRANSPORT_TYPE), /** - * @see Key:coach + * Key:coach */ COACH("coach", LAND_TRANSPORT_TYPE), /** - * @see Key:golf_cart + * Key:golf_cart */ GOLF_CART("golf_cart", LAND_TRANSPORT_TYPE), /** - * @see Key:minibus + * Key:minibus */ MINIBUS("minibus", LAND_TRANSPORT_TYPE), /** - * @see Key:share_taxi + * Key:share_taxi */ SHARE_TAXI("share_taxi", LAND_TRANSPORT_TYPE), - /** @see Key:hov */ + /** Key:hov */ HOV("hov", LAND_TRANSPORT_TYPE), /** - * @see Key:car_sharing + * Key:car_sharing */ CAR_SHARING("car_sharing", LAND_TRANSPORT_TYPE), /** * Routers should default to {@code yes}, regardless of higher access rules, * assuming it is navigatible by vehicle * - * @see Key:emergency + * Key:emergency */ EMERGENCY("emergency", LAND_TRANSPORT_TYPE), /** - * @see Key:hazmat + * Key:hazmat */ HAZMAT("hazmat", LAND_TRANSPORT_TYPE), /** - * @see Key:disabled + * Key:disabled */ DISABLED("disabled", LAND_TRANSPORT_TYPE), @@ -264,71 +255,69 @@ public final class Access { /** Water transport type */ WATER_TRANSPORT_TYPE("water", ALL_TRANSPORT_TYPE), /** - * @see Key:swimming + * Key:swimming */ SWIMMING("swimming", WATER_TRANSPORT_TYPE), - /** @see Key:boat */ + /** Key:boat */ BOAT("boat", WATER_TRANSPORT_TYPE), /** - * @see Key:fishing_vessel + * Key:fishing_vessel */ FISHING_VESSEL("fishing_vessel", WATER_TRANSPORT_TYPE), - /** @see Key:ship */ + /** Key:ship */ SHIP("ship", WATER_TRANSPORT_TYPE), /** - * @see Key:motorboat + * Key:motorboat */ MOTORBOAT("motorboat", WATER_TRANSPORT_TYPE), /** - * @see Key:sailboat + * Key:sailboat */ SAILBOAT("sailboat", WATER_TRANSPORT_TYPE), /** - * @see Key:canoe + * Key:canoe */ CANOE("canoe", WATER_TRANSPORT_TYPE), /** - * @see Key:passenger + * Key:passenger */ PASSENGER("passenger", WATER_TRANSPORT_TYPE), /** - * @see Key:cargo + * Key:cargo */ CARGO("cargo", WATER_TRANSPORT_TYPE), - /** @see Key:isps */ + /** Key:isps */ ISPS("isps", WATER_TRANSPORT_TYPE), - /** @see Key:bulk */ + /** Key:bulk */ BULK("bulk", WATER_TRANSPORT_TYPE), /** - * @see Key:tanker + * Key:tanker */ TANKER("tanker", WATER_TRANSPORT_TYPE), /** - * @see Key:container + * Key:container */ CONTAINER("container", WATER_TRANSPORT_TYPE), - /** @see Key:imdg */ + /** Key:imdg */ IMDG("imdg", WATER_TRANSPORT_TYPE), /** - * @see Key:tanker + * Key:tanker */ TANKER_GAS("tanker:gas", WATER_TRANSPORT_TYPE), /** - * @see Key:tanker + * Key:tanker */ TANKER_OIL("tanker:oil", WATER_TRANSPORT_TYPE), /** - * @see Key:tanker + * Key:tanker */ TANKER_CHEMICAL("tanker:chemical", WATER_TRANSPORT_TYPE), /** - * @see Key:tanker + * Key:tanker */ TANKER_SINGLEHULL("tanker:singlehull", WATER_TRANSPORT_TYPE), @@ -336,7 +325,7 @@ public final class Access { /** Rail transport type */ RAIL_TRANSPORT_TYPE("rail", ALL_TRANSPORT_TYPE), /** - * @see Key:train + * Key:train */ TRAIN("train", RAIL_TRANSPORT_TYPE); @@ -354,13 +343,17 @@ public final class Access { } /** - * @return The key for the enum + * Get the key for the enum + * + * @return The OpenStreetMap key */ public String getKey() { return key; } /** + * Get the generic type of transport + * * @return The AccessTags transport type * (RAIL_TRANSPORT_TYPE/WATER_TRANSPORT_TYPE/etc) */ @@ -452,8 +445,9 @@ public final class Access { } /** - * Create the default access inheritance, as defined at - * {@link "https://wiki.openstreetmap.org/wiki/Key:access#Transport_mode_restrictions"} + * Create the default access inheritance, as defined at + * Key:access#Transport_mod_restrictions */ private static void defaultInheritance() { addMode(null, AccessTags.ACCESS_KEY); @@ -612,9 +606,8 @@ public final class Access { /** * Get the valid restriction values ({@code unknown} is not included). See * - * @return Valid values for restrictions (unmodifiable) - * @see Key:access#List_of_possible_values + * @return Valid values for restrictions (unmodifiable) Key:access#List_of_possible_values */ public static Set getRestrictionValues() { return Collections.unmodifiableSet(RESTRICTION_VALUES); @@ -623,31 +616,13 @@ public final class Access { /** * Get the valid transport modes. See * - * @return Value transport modes (unmodifiable) - * @see Key:access#Transport_mode_restrictions + * @return Value transport modes (unmodifiable) Key:access#Transport_mode_restrictions */ public static Set getTransportModes() { return Collections.unmodifiableSet(TRANSPORT_MODES); } - /** - * Get the access method hierarchy. - * - * @return The hierarchy for access modes (unmodifiable) - * @see Key:access#Transport_mode_restrictions - */ - public static Map>> getAccessMethods() { - Map>> map = new HashMap<>(); - for (Entry>> entry : map.entrySet()) { - Map> tMap = new HashMap<>(); - entry.getValue().forEach((key, list) -> tMap.put(key, Collections.unmodifiableList(list))); - map.put(entry.getKey(), Collections.unmodifiableMap(tMap)); - } - return Collections.unmodifiableMap(map); - } - /** * Get the implied access values for a primitive *