Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java	(revision 18874)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Functions.java	(revision 18875)
@@ -43,8 +43,8 @@
 import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
 import org.openstreetmap.josm.tools.RotationAngle;
+import org.openstreetmap.josm.tools.RotationAngle.WayDirectionRotationAngle;
 import org.openstreetmap.josm.tools.StreamUtils;
 import org.openstreetmap.josm.tools.Territories;
 import org.openstreetmap.josm.tools.Utils;
-import org.openstreetmap.josm.tools.RotationAngle.WayDirectionRotationAngle;
 
 /**
@@ -411,4 +411,7 @@
      */
     public static List<String> tag_regex(final Environment env, String keyRegex, String flags) {
+        if (env.osm == null) {
+            return Collections.emptyList();
+        }
         int f = parse_regex_flags(flags);
         Pattern compiled = Pattern.compile(keyRegex, f);
@@ -626,5 +629,5 @@
      */
     public static boolean has_tag_key(final Environment env, String key) {
-        return env.osm.hasKey(key);
+        return env.osm != null ? env.osm.hasKey(key) : false;
     }
 
@@ -941,5 +944,5 @@
      */
     public static long osm_id(final Environment env) {
-        return env.osm.getUniqueId();
+        return env.osm != null ? env.osm.getUniqueId() : 0;
     }
 
@@ -952,5 +955,5 @@
      */
     public static String osm_user_name(final Environment env) {
-        return env.osm.getUser().getName();
+        return env.osm != null ? env.osm.getUser().getName() : null;
     }
 
@@ -963,5 +966,5 @@
      */
     public static long osm_user_id(final Environment env) {
-        return env.osm.getUser().getId();
+        return env.osm != null ? env.osm.getUser().getId() : 0;
     }
 
@@ -974,5 +977,5 @@
      */
     public static int osm_version(final Environment env) {
-        return env.osm.getVersion();
+        return env.osm != null ? env.osm.getVersion() : 0;
     }
 
@@ -985,5 +988,5 @@
      */
     public static int osm_changeset_id(final Environment env) {
-        return env.osm.getChangesetId();
+        return env.osm != null ? env.osm.getChangesetId() : 0;
     }
 
@@ -996,5 +999,5 @@
      */
     public static int osm_timestamp(final Environment env) {
-        return env.osm.getRawTimestamp();
+        return env.osm != null ? env.osm.getRawTimestamp() : 0;
     }
 
@@ -1197,5 +1200,9 @@
      */
     public static boolean is_right_hand_traffic(Environment env) {
-        return RightAndLefthandTraffic.isRightHandTraffic(center(env));
+        final LatLon center = center(env);
+        if (center != null) {
+            return RightAndLefthandTraffic.isRightHandTraffic(center);
+        }
+        return false;
     }
 
@@ -1261,5 +1268,5 @@
      */
     public static int number_of_tags(Environment env) {
-        return env.osm.getNumKeys();
+        return env.osm != null ? env.osm.getNumKeys() : 0;
     }
 
@@ -1271,5 +1278,5 @@
      */
     public static Object setting(Environment env, String key) {
-        return env.source.settingValues.get(key);
+        return env.source != null ? env.source.settingValues.get(key) : null;
     }
 
@@ -1281,5 +1288,10 @@
      */
     public static LatLon center(Environment env) {
-        return env.osm instanceof Node ? ((Node) env.osm).getCoor() : env.osm.getBBox().getCenter();
+        if (env.osm instanceof ILatLon) {
+            return new LatLon(((ILatLon) env.osm).lat(), ((ILatLon) env.osm).lon());
+        } else if (env.osm != null) {
+            return env.osm.getBBox().getCenter();
+        }
+        return null;
     }
 
@@ -1316,5 +1328,9 @@
      */
     public static boolean at(Environment env, double lat, double lon) {
-        return new LatLon(lat, lon).equalsEpsilon(center(env), ILatLon.MAX_SERVER_PRECISION);
+        final ILatLon center = center(env);
+        if (center != null) {
+            return new LatLon(lat, lon).equalsEpsilon(center, ILatLon.MAX_SERVER_PRECISION);
+        }
+        return false;
     }
 
