Changeset 7237 in josm for trunk/src/org


Ignore:
Timestamp:
2014-06-10T12:03:16+02:00 (10 years ago)
Author:
bastiK
Message:

fixed #10130 - add mapcss expression to get number of tags

new mapcss expression to print debugging output to the console

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r7083 r7237  
    632632    }
    633633
     634    public final int getNumKeys() {
     635        return keys == null ? 0 : keys.length / 2;
     636    }
     637   
    634638    @Override
    635639    public final Collection<String> keySet() {
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r7193 r7237  
    1818import java.util.Collections;
    1919import java.util.List;
     20import java.util.Objects;
    2021import java.util.regex.Matcher;
    2122import java.util.regex.Pattern;
     
    624625        }
    625626       
     627        /**
     628         * check if there is right-hand traffic at the current location
     629         * @param env the environment
     630         * @return true if there is right-hand traffic
     631         * @since 7193
     632         */
    626633        public static boolean is_right_hand_traffic(Environment env) {
    627634            if (env.osm instanceof Node)
    628635                return RightAndLefthandTraffic.isRightHandTraffic(((Node) env.osm).getCoor());
    629636            return RightAndLefthandTraffic.isRightHandTraffic(env.osm.getBBox().getCenter());
     637        }
     638       
     639        /**
     640         * Prints the object to the command line (for debugging purpose).
     641         * @param o the object
     642         * @return the same object, unchanged
     643         */
     644        public static Object print(Object o) {
     645            System.out.print(o == null ? "none" : o.toString());
     646            return o;
     647        }
     648
     649        /**
     650         * Prints the object to the command line, with new line at the end
     651         * (for debugging purpose).
     652         * @param o the object
     653         * @return the same object, unchanged
     654         */
     655        public static Object println(Object o) {
     656            System.out.println(o == null ? "none" : o.toString());
     657            return o;
     658        }
     659       
     660        /**
     661         * Get the number of tags for the current primitive.
     662         * @param env
     663         * @return number of tags
     664         */
     665        public static int number_of_tags(Environment env) {
     666            return env.osm.getNumKeys();
    630667        }
    631668    }
Note: See TracChangeset for help on using the changeset viewer.