Changeset 18875 in josm for trunk/src/org
- Timestamp:
- 2023-10-23T21:06:35+02:00 (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
r18829 r18875 43 43 import org.openstreetmap.josm.tools.RightAndLefthandTraffic; 44 44 import org.openstreetmap.josm.tools.RotationAngle; 45 import org.openstreetmap.josm.tools.RotationAngle.WayDirectionRotationAngle; 45 46 import org.openstreetmap.josm.tools.StreamUtils; 46 47 import org.openstreetmap.josm.tools.Territories; 47 48 import org.openstreetmap.josm.tools.Utils; 48 import org.openstreetmap.josm.tools.RotationAngle.WayDirectionRotationAngle;49 49 50 50 /** … … 411 411 */ 412 412 public static List<String> tag_regex(final Environment env, String keyRegex, String flags) { 413 if (env.osm == null) { 414 return Collections.emptyList(); 415 } 413 416 int f = parse_regex_flags(flags); 414 417 Pattern compiled = Pattern.compile(keyRegex, f); … … 626 629 */ 627 630 public static boolean has_tag_key(final Environment env, String key) { 628 return env.osm.hasKey(key); 631 return env.osm != null ? env.osm.hasKey(key) : false; 629 632 } 630 633 … … 941 944 */ 942 945 public static long osm_id(final Environment env) { 943 return env.osm.getUniqueId(); 946 return env.osm != null ? env.osm.getUniqueId() : 0; 944 947 } 945 948 … … 952 955 */ 953 956 public static String osm_user_name(final Environment env) { 954 return env.osm.getUser().getName(); 957 return env.osm != null ? env.osm.getUser().getName() : null; 955 958 } 956 959 … … 963 966 */ 964 967 public static long osm_user_id(final Environment env) { 965 return env.osm.getUser().getId(); 968 return env.osm != null ? env.osm.getUser().getId() : 0; 966 969 } 967 970 … … 974 977 */ 975 978 public static int osm_version(final Environment env) { 976 return env.osm.getVersion(); 979 return env.osm != null ? env.osm.getVersion() : 0; 977 980 } 978 981 … … 985 988 */ 986 989 public static int osm_changeset_id(final Environment env) { 987 return env.osm.getChangesetId(); 990 return env.osm != null ? env.osm.getChangesetId() : 0; 988 991 } 989 992 … … 996 999 */ 997 1000 public static int osm_timestamp(final Environment env) { 998 return env.osm.getRawTimestamp(); 1001 return env.osm != null ? env.osm.getRawTimestamp() : 0; 999 1002 } 1000 1003 … … 1197 1200 */ 1198 1201 public static boolean is_right_hand_traffic(Environment env) { 1199 return RightAndLefthandTraffic.isRightHandTraffic(center(env)); 1202 final LatLon center = center(env); 1203 if (center != null) { 1204 return RightAndLefthandTraffic.isRightHandTraffic(center); 1205 } 1206 return false; 1200 1207 } 1201 1208 … … 1261 1268 */ 1262 1269 public static int number_of_tags(Environment env) { 1263 return env.osm.getNumKeys(); 1270 return env.osm != null ? env.osm.getNumKeys() : 0; 1264 1271 } 1265 1272 … … 1271 1278 */ 1272 1279 public static Object setting(Environment env, String key) { 1273 return env.source.settingValues.get(key); 1280 return env.source != null ? env.source.settingValues.get(key) : null; 1274 1281 } 1275 1282 … … 1281 1288 */ 1282 1289 public static LatLon center(Environment env) { 1283 return env.osm instanceof Node ? ((Node) env.osm).getCoor() : env.osm.getBBox().getCenter(); 1290 if (env.osm instanceof ILatLon) { 1291 return new LatLon(((ILatLon) env.osm).lat(), ((ILatLon) env.osm).lon()); 1292 } else if (env.osm != null) { 1293 return env.osm.getBBox().getCenter(); 1294 } 1295 return null; 1284 1296 } 1285 1297 … … 1316 1328 */ 1317 1329 public static boolean at(Environment env, double lat, double lon) { 1318 return new LatLon(lat, lon).equalsEpsilon(center(env), ILatLon.MAX_SERVER_PRECISION); 1330 final ILatLon center = center(env); 1331 if (center != null) { 1332 return new LatLon(lat, lon).equalsEpsilon(center, ILatLon.MAX_SERVER_PRECISION); 1333 } 1334 return false; 1319 1335 } 1320 1336
Note:
See TracChangeset
for help on using the changeset viewer.