1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm;
|
---|
3 |
|
---|
4 | /**
|
---|
5 | * IRelation captures the common functions of {@link Relation} and {@link RelationData}.
|
---|
6 | * @since 4098
|
---|
7 | */
|
---|
8 | public interface IRelation extends IPrimitive {
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Returns the number of members.
|
---|
12 | * @return number of members
|
---|
13 | */
|
---|
14 | int getMembersCount();
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Returns id of the member at given index.
|
---|
18 | * @param idx member index
|
---|
19 | * @return id of the member at given index
|
---|
20 | */
|
---|
21 | long getMemberId(int idx);
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Returns role of the member at given index.
|
---|
25 | * @param idx member index
|
---|
26 | * @return role of the member at given index
|
---|
27 | */
|
---|
28 | String getRole(int idx);
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Returns type of the member at given index.
|
---|
32 | * @param idx member index
|
---|
33 | * @return type of the member at given index
|
---|
34 | */
|
---|
35 | OsmPrimitiveType getMemberType(int idx);
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * Determines if at least one child primitive is incomplete.
|
---|
39 | *
|
---|
40 | * @return true if at least one child primitive is incomplete
|
---|
41 | * @since 13564
|
---|
42 | */
|
---|
43 | default boolean hasIncompleteMembers() {
|
---|
44 | return false;
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | default int compareTo(IPrimitive o) {
|
---|
49 | return o instanceof IRelation ? Long.compare(getUniqueId(), o.getUniqueId()) : -1;
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | default String getDisplayName(NameFormatter formatter) {
|
---|
54 | return formatter.format(this);
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Determines if this relation is a boundary.
|
---|
59 | * @return {@code true} if a boundary relation
|
---|
60 | */
|
---|
61 | default boolean isBoundary() {
|
---|
62 | return "boundary".equals(get("type"));
|
---|
63 | }
|
---|
64 |
|
---|
65 | @Override
|
---|
66 | default boolean isMultipolygon() {
|
---|
67 | return "multipolygon".equals(get("type")) || isBoundary();
|
---|
68 | }
|
---|
69 | }
|
---|