Ticket #1586: regionalNames.patch

File regionalNames.patch, 2.0 KB (added by stephankn, 17 years ago)

patch that implements the functionality

  • src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java

     
    4848        protected Font orderFont;
    4949        protected ElemStyles styles;
    5050        protected double circum;
     51    protected String regionalNameOrder[];
    5152
    5253        protected boolean isZoomOk(ElemStyle e) {
    5354                if (!zoomLevelDisplay) /* show everything if the user wishes so */
     
    230231                if ((p.x < 0) || (p.y < 0) || (p.x > nc.getWidth()) || (p.y > nc.getHeight())) return;
    231232                int w = icon.getIconWidth(), h=icon.getIconHeight();
    232233                icon.paintIcon ( Main.map.mapView, g, p.x-w/2, p.y-h/2 );
    233                 String name = (n.keys==null) ? null : n.keys.get("name");
     234                String name = getNodeName(n);
    234235                if (name!=null && annotate)
    235236                {
    236237                        g.setColor(textColor);
     
    246247                }
    247248        }
    248249
     250    protected String getNodeName(Node n) {
     251        String name = null;
     252        if (n.keys != null) {
     253            for (int i = 0; i < regionalNameOrder.length; i++) {
     254                name = n.keys.get(regionalNameOrder[i]);
     255                if (name != null) break;
     256            }
     257        }
     258        return name;
     259    }
     260
    249261        private void drawSeg(Node n1, Node n2, Color col, boolean showDirection, int width, boolean dashed) {
    250262                if (col != currentColor || width != currentWidth || dashed != currentDashed) {
    251263                        displaySegments(col, width, dashed);
     
    326338                circum = Main.map.mapView.getScale()*100*Main.proj.scaleFactor()*40041455; // circumference of the earth in meter
    327339                styles = MapPaintStyles.getStyles();
    328340                orderFont = new Font(Main.pref.get("mappaint.font","Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
     341            regionalNameOrder = (Main.pref.get("mappaint.nameOrder", "name:en name:de int_name")+" name").split("\\s");
    329342
    330343                if(styles.hasAreas())
    331344                {