Ignore:
Timestamp:
2017-05-13T14:56:51+02:00 (7 years ago)
Author:
zverik
Message:

Updated possible roles and did a little refactoring

Location:
applications/editors/josm/plugins/reltoolbox/src/relcontext
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/ChosenRelation.java

    r33265 r33311  
    1717import org.openstreetmap.josm.data.osm.Node;
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive;
    19 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    2019import org.openstreetmap.josm.data.osm.Relation;
    2120import org.openstreetmap.josm.data.osm.Way;
     
    150149        g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f * opacity));
    151150
    152         drawRelations(g, mv, bbox, chosenRelation, new HashSet<>());
     151        drawRelations(g, mv, bbox, chosenRelation, new HashSet<Relation>());
    153152
    154153        g.setComposite(oldComposite);
     
    160159            visitedRelations.add(rel);
    161160            for (OsmPrimitive element : rel.getMemberPrimitives()) {
    162                 if (element.getType() == OsmPrimitiveType.NODE) {
    163                     Node node = (Node) element;
    164                     Point center = mv.getPoint(node);
    165                     g.drawOval(center.x - 4, center.y - 4, 9, 9);
    166                 } else if (element.getType() == OsmPrimitiveType.WAY) {
    167                     Way way = (Way) element;
    168                     if (way.getNodesCount() >= 2) {
    169                         GeneralPath b = new GeneralPath();
    170                         Point p = mv.getPoint(way.getNode(0));
    171                         b.moveTo(p.x, p.y);
    172                         for (int i = 1; i < way.getNodesCount(); i++) {
    173                             p = mv.getPoint(way.getNode(i));
    174                             b.lineTo(p.x, p.y);
    175                         }
    176                         g.draw(b);
    177                     }
    178                 } else if (element.getType() == OsmPrimitiveType.RELATION) {
    179                     Color oldColor = g.getColor();
    180                     g.setColor(Color.magenta);
    181                     drawRelations(g, mv, bbox, (Relation) element, visitedRelations);
    182                     g.setColor(oldColor);
     161                if (null != element.getType()) switch(element.getType()) {
     162                    case NODE:
     163                        Node node = (Node) element;
     164                        Point center = mv.getPoint(node);
     165                        g.drawOval(center.x - 4, center.y - 4, 9, 9);
     166                        break;
     167                    case WAY:
     168                        Way way = (Way) element;
     169                        if (way.getNodesCount() >= 2) {
     170                            GeneralPath b = new GeneralPath();
     171                            Point p = mv.getPoint(way.getNode(0));
     172                            b.moveTo(p.x, p.y);
     173                            for (int i = 1; i < way.getNodesCount(); i++) {
     174                                p = mv.getPoint(way.getNode(i));
     175                                b.lineTo(p.x, p.y);
     176                            }
     177                            g.draw(b);
     178                        }   break;
     179                    case RELATION:
     180                        Color oldColor = g.getColor();
     181                        g.setColor(Color.magenta);
     182                        drawRelations(g, mv, bbox, (Relation) element, visitedRelations);
     183                        g.setColor(oldColor);
     184                        break;
     185                    default:
     186                        break;
    183187                }
    184                 // todo: closedway, multipolygon - ?
    185188            }
    186189        }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/RelContextDialog.java

    r33265 r33311  
    443443            while (r.ready()) {
    444444                String line = r.readLine();
    445                 StringTokenizer t = new StringTokenizer(line, " ,;:\"");
    446                 if (t.hasMoreTokens()) {
    447                     String type = t.nextToken();
     445                String[] typeAndRoles = line.split(":", 2);
     446                if (typeAndRoles.length == 2 && typeAndRoles[1].length() > 0) {
     447                    String type = typeAndRoles[0].trim();
     448                    StringTokenizer t = new StringTokenizer(typeAndRoles[1], " ,;\"");
    448449                    List<String> roles = new ArrayList<>();
    449450                    while (t.hasMoreTokens()) {
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/possible_roles.txt

    r30841 r33311  
    1 boundary: admin_centre, label, subarea
    2 route: forward, backward, stop, platform, stop_exit_only, stop_entry_only, platform_exit_only, platform_entry_only
     1associatedStreet: street, house
     2boundary: admin_centre, label, subarea, outer, inner
     3bridge: across, outline, edge, on_bridge
     4building: outline, part, contains, label, entrance, address, ridge, edge
     5destination_sign: to, from, intersection, sign
     6enforcement: device, from, to, force
     7provides_feature: target, address, entrance, parking
    38public_transport: stop, platform
    49restriction: from, to, via, location_hint
    5 enforcement: device, from, to, force
    6 destination_sign: to, from, intersection, sign
     10route: route, forward, backward, north, south, east, west, stop, link, stop, forward:stop, backward:stop, platform, guidepost, stop_exit_only, stop_entry_only, platform_exit_only, platform_entry_only
    711site: perimeter, entrance, label
    8 bridge: across, under, outline, edge
    9 tunnel: through, outline, edge
     12sled: sled, alternative, walk
     13street: street, address, house, associated
    1014surveillance: camera, extent, visible, hidden
    11 street: street, address, house, associated
    12 collection: member, street, river, railway, address, associated
    13 associatedStreet: street, house
    14 lane_restriction: from, to, via
     15tunnel: through, outline, edge, in_tunnel
     16waterway: main_stream, side_stream, spring
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/MultipolygonFixer.java

    r32395 r33311  
    8282            if (m.isWay()) {
    8383                String role = null;
    84                 if (outerWays.contains(m.getMember())) {
     84                if (outerWays.contains((Way)m.getMember())) {
    8585                    role = "outer";
    86                 } else if (innerWays.contains(m.getMember())) {
     86                } else if (innerWays.contains((Way)m.getMember())) {
    8787                    role = "inner";
    8888                }
  • applications/editors/josm/plugins/reltoolbox/src/relcontext/relationfix/RelationFixer.java

    r32395 r33311  
    22package relcontext.relationfix;
    33
     4import java.util.*;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
    6 import java.util.ArrayList;
    7 import java.util.List;
    87
    98import javax.swing.Action;
     
    2524    public RelationFixer(String... types) {
    2625        applicableTypes = new ArrayList<>();
    27         for (String type: types) {
    28             applicableTypes.add(type);
    29         }
     26        applicableTypes.addAll(Arrays.asList(types));
    3027    }
    3128
Note: See TracChangeset for help on using the changeset viewer.