Changeset 8253 in josm for trunk/src


Ignore:
Timestamp:
2015-04-23T19:45:32+02:00 (5 years ago)
Author:
simon04
Message:

fix #11346 - MapCSS: add areasize and waylength functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r8199 r8253  
    2828import org.openstreetmap.josm.data.osm.Node;
    2929import org.openstreetmap.josm.data.osm.OsmPrimitive;
     30import org.openstreetmap.josm.data.osm.Way;
    3031import org.openstreetmap.josm.gui.mappaint.Cascade;
    3132import org.openstreetmap.josm.gui.mappaint.Environment;
     
    3334import org.openstreetmap.josm.io.XmlWriter;
    3435import org.openstreetmap.josm.tools.ColorHelper;
     36import org.openstreetmap.josm.tools.Geometry;
    3537import org.openstreetmap.josm.tools.Predicates;
    3638import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
     
    499501
    500502        /**
     503         * Returns the area of a closed way in square meters or {@code null}.
     504         * @param env the environment
     505         * @return the area of a closed way in square meters or {@code null}
     506         * @see Geometry#closedWayArea(Way)
     507         */
     508        public static Float areasize(final Environment env) {
     509            if (env.osm instanceof Way && ((Way) env.osm).isClosed()) {
     510                return (float) Geometry.closedWayArea((Way) env.osm);
     511            } else {
     512                return null;
     513            }
     514        }
     515
     516        /**
     517         * Returns the length of the way in metres or {@code null}.
     518         * @param env the environment
     519         * @return the length of the way in metres or {@code null}.
     520         * @see Way#getLength()
     521         */
     522        public static Float waylength(final Environment env) {
     523            if (env.osm instanceof Way) {
     524                return (float) ((Way) env.osm).getLength();
     525            } else {
     526                return null;
     527            }
     528        }
     529
     530        /**
    501531         * Function associated to the logical "!" operator.
    502532         * @param b boolean value
Note: See TracChangeset for help on using the changeset viewer.