Changeset 15359 in josm for trunk


Ignore:
Timestamp:
2019-09-19T13:13:01+02:00 (5 years ago)
Author:
Don-vip
Message:

see #17058, fix #18097 - fix MapCSSTagChecker.getLocation

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/data/validator/territories.mapcss

    r15325 r15359  
    4141  throwOther: tr("{0} without {1}", "{0.tag}", "{1.key}");
    4242  group: tr("Airport tagging");
    43   /* assertNoMatch: "way aeroway=aerodrome faa=OK12"; not properly working due to inside() */
    44   /* assertMatch: "way aeroway=aerodrome faa=ORD"; */
     43  assertNoMatch: "way aeroway=aerodrome faa=OK12";
     44  assertMatch: "way aeroway=aerodrome faa=ORD";
    4545}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r15245 r15359  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.awt.Rectangle;
    76import java.io.BufferedReader;
    87import java.io.IOException;
     
    898897                GeoProperty<Boolean> prop = index.getGeoProperty();
    899898                if (prop instanceof DefaultGeoProperty) {
    900                     Rectangle bounds = ((DefaultGeoProperty) prop).getArea().getBounds();
    901                     return new LatLon(bounds.getCenterY(), bounds.getCenterX());
     899                    return ((DefaultGeoProperty) prop).getRandomLatLon();
    902900                }
    903901            }
  • trunk/src/org/openstreetmap/josm/tools/DefaultGeoProperty.java

    r14484 r15359  
    22package org.openstreetmap.josm.tools;
    33
     4import java.awt.Rectangle;
    45import java.awt.geom.Area;
    56import java.awt.geom.Path2D;
     
    1718
    1819    private final Area area;
     20    private LatLon random;
    1921
    2022    /**
     
    6870        return area;
    6971    }
     72
     73    /**
     74     * Returns a random lat/lon in the area.
     75     * @return a random lat/lon in the area
     76     * @since 15359
     77     */
     78    public final synchronized LatLon getRandomLatLon() {
     79        if (random == null) {
     80            Rectangle r = area.getBounds();
     81            double x, y;
     82            do {
     83                x = r.getX() + r.getWidth() * Math.random();
     84                y = r.getY() + r.getHeight() * Math.random();
     85            } while (!area.contains(x, y));
     86
     87            random = new LatLon(y, x);
     88        }
     89        return random;
     90    }
    7091}
Note: See TracChangeset for help on using the changeset viewer.