| | 519 | * Gets a list of all OSM id's of the object's parent(s) with a specified key. |
| | 520 | * |
| | 521 | * @param env the environment |
| | 522 | * @param key the OSM key |
| | 523 | * @param keyValue the regex value of the OSM key |
| | 524 | * @return a list of non-null values of the OSM id's from the object's parent(s) |
| | 525 | * @since xxx |
| | 526 | */ |
| | 527 | public static List<IPrimitive> parent_osm_primitives(final Environment env, String key, String keyValue) { |
| | 528 | if (env.parent == null) { |
| | 529 | if (env.osm != null) { |
| | 530 | final ArrayList<IPrimitive> parents = new ArrayList<>(); |
| | 531 | for (IPrimitive parent : env.osm.getReferrers()) { |
| | 532 | if ((key == null || parent.get(key) != null) |
| | 533 | && (keyValue == null || regexp_test(keyValue, parent.get(key)))) { |
| | 534 | parents.add(parent); |
| | 535 | } |
| | 536 | } |
| | 537 | return new ArrayList<>(parents); |
| | 538 | } |
| | 539 | return Collections.emptyList(); |
| | 540 | } |
| | 541 | return Collections.singletonList(env.parent); |
| | 542 | } |
| | 543 | |
| | 544 | /** |
| | 545 | * Gets a list of all OSM id's of the object's parent(s) with a specified key. |
| | 546 | * |
| | 547 | * @param env the environment |
| | 548 | * @param key the OSM key |
| | 549 | * @return a list of non-null values of the OSM id's from the object's parent(s) |
| | 550 | * @since xxx |
| | 551 | */ |
| | 552 | public static List<IPrimitive> parent_osm_primitives(final Environment env, String key) { // NO_UCD (unused code) |
| | 553 | return parent_osm_primitives(env, key, null); |
| | 554 | } |
| | 555 | |
| | 556 | /** |
| | 557 | * Gets a list of all OSM id's of the object's parent(s). |
| | 558 | * |
| | 559 | * @param env the environment |
| | 560 | * @return a list of non-null values of the OSM id's from the object's parent(s) |
| | 561 | * @since xxx |
| | 562 | */ |
| | 563 | public static List<IPrimitive> parent_osm_primitives(final Environment env) { // NO_UCD (unused code) |
| | 564 | return parent_osm_primitives(env, null, null); |
| | 565 | } |
| | 566 | |
| | 567 | /** |
| | 568 | * Convert Primitives to a string |
| | 569 | * |
| | 570 | * @param primitives The primitives to convert |
| | 571 | * @return A list of strings in the format type + id (in the list order) |
| | 572 | * @see SimplePrimitiveId#toSimpleId |
| | 573 | * @since xxx |
| | 574 | */ |
| | 575 | public static List<String> convert_primitives_to_string(List<IPrimitive> primitives) { |
| | 576 | return primitives.stream().map(Functions::convert_primitive_to_string).collect(Collectors.toList()); |
| | 577 | } |
| | 578 | |
| | 579 | /** |
| | 580 | * Convert a primitive to a string |
| | 581 | * |
| | 582 | * @param primitive The primitive to convert |
| | 583 | * @return A string in the format type + id |
| | 584 | * @see SimplePrimitiveId#toSimpleId |
| | 585 | * @since xxx |
| | 586 | */ |
| | 587 | public static String convert_primitive_to_string(IPrimitive primitive) { |
| | 588 | return SimplePrimitiveId.toSimpleId(primitive); |
| | 589 | } |
| | 590 | |
| | 591 | /** |