Ticket #16998: 0001-Initial-work-on-getting-get_parent_ids-working.patch

File 0001-Initial-work-on-getting-get_parent_ids-working.patch, 2.1 KB (added by taylor.smock, 8 years ago)

Untested java method for parent_osm_ids (building)

  • src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    From 2759e0dd37585ef45d9be92b1324d005239b21bd Mon Sep 17 00:00:00 2001
    From: Taylor Smock <taylor.smock@kaartgroup.com>
    Date: Fri, 16 Nov 2018 08:44:42 -0700
    Subject: [PATCH] Initial work on getting get_parent_ids working
    
    ---
     .../mappaint/mapcss/ExpressionFactory.java    | 26 +++++++++++++++++++
     1 file changed, 26 insertions(+)
    
    diff --git a/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java b/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
    index f49ac9390..fe98489e6 100644
    a b public final class ExpressionFactory {  
    518518            return env.parent == null ? null : env.parent.getUniqueId();
    519519        }
    520520
     521        /**
     522         * Gets a list of all OSM id's of the object's parent(s).
     523         *
     524         * The values are sorted according to {@link AlphanumComparator}.
     525         * @param env the environment
     526         * @return a list of non-null values of the OSM id's from the object's parent(s)
     527         */
     528        public static List<Long> parent_osm_ids(final Environment env) { // NO_UCD (unused code)
     529            if (env.parent == null) {
     530                if (env.osm != null) {
     531                    final Collection<Long> ids = new TreeSet<>();
     532                    //final Collection<Long> ids = new Collection<>();
     533                    // we don't have a matched parent, so just search all referrers
     534                    for (IPrimitive parent : env.osm.getReferrers()) {
     535                        Long value = parent.getUniqueId();
     536                        if (value != null) {
     537                            ids.add(value);
     538                        }
     539                    }
     540                    return new ArrayList<>(ids);
     541                }
     542                return Collections.emptyList();
     543            }
     544            return Collections.singletonList(parent_osm_id(env));
     545        }
     546
    521547        /**
    522548         * Determines whether the object has a tag with the given key.
    523549         * @param env the environment