Changeset 12257 in osm for applications


Ignore:
Timestamp:
2008-12-08T00:46:41+01:00 (16 years ago)
Author:
pieren
Message:

Grid detail fixing cells sizes in crossing ways detection is now different for the three existing projections (size closer than earlier). Not a definitive solution. Fixes heap memory exception with Lambert.

Location:
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/OSMValidatorPlugin.java

    r11974 r12257  
    2626import org.openstreetmap.josm.actions.UploadAction;
    2727import org.openstreetmap.josm.actions.UploadAction.UploadHook;
     28import org.openstreetmap.josm.data.projection.Epsg4326;
     29import org.openstreetmap.josm.data.projection.Lambert;
     30import org.openstreetmap.josm.data.projection.Mercator;
    2831import org.openstreetmap.josm.gui.MapFrame;
    2932import org.openstreetmap.josm.gui.layer.Layer;
     
    4043import org.openstreetmap.josm.plugins.validator.tests.SelfIntersectingWay;
    4144import org.openstreetmap.josm.plugins.validator.tests.SimilarNamedWays;
    42 import org.openstreetmap.josm.plugins.validator.tests.TagChecker;
    4345import org.openstreetmap.josm.plugins.validator.tests.UnclosedWays;
    4446import org.openstreetmap.josm.plugins.validator.tests.UnconnectedWays;
     
    6870    /** The list of errors per layer*/
    6971    Map<Layer, List<TestError>> layerErrors = new HashMap<Layer, List<TestError>>();
     72   
     73    /** Grid detail, multiplier of east,north values for valuable cell sizing */
     74    public static double griddetail;
    7075
    7176    public Collection<String> ignoredErrors = new TreeSet<String>();
     
    96101    public OSMValidatorPlugin() {
    97102        plugin = this;
     103        initializeGridDetail();
    98104        initializeTests(getTests());
    99105        loadIgnoredErrors();
     
    226232
    227233    /**
     234     * Initialize grid details based on current projection system. Values based on
     235     * the original value fixed for EPSG:4326 (10000) using heuristics (that is, test&error
     236     * until most bugs were discovered while keeping the processing time reasonable)
     237     */
     238    public void initializeGridDetail() {
     239        if (Main.proj.toString().equals(new Epsg4326().toString()))
     240            OSMValidatorPlugin.griddetail = 10000;
     241        else if (Main.proj.toString().equals(new Mercator().toString()))
     242            OSMValidatorPlugin.griddetail = 100000;
     243        else if (Main.proj.toString().equals(new Lambert().toString()))
     244            OSMValidatorPlugin.griddetail = 0.1;
     245    }
     246   
     247    /**
    228248     * Initializes all tests
    229249     * @param allTests The tests to initialize
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/CrossingWays.java

    r11530 r12257  
    1515import org.openstreetmap.josm.data.osm.Way;
    1616import org.openstreetmap.josm.data.osm.WaySegment;
     17import org.openstreetmap.josm.plugins.validator.OSMValidatorPlugin;
    1718import org.openstreetmap.josm.plugins.validator.Severity;
    1819import org.openstreetmap.josm.plugins.validator.Test;
     
    138139        {
    139140                List<List<ExtendedSegment>> cells = new ArrayList<List<ExtendedSegment>>();
    140                 for( Point2D cell : Util.getSegmentCells(n1, n2, 10000) )
     141                for( Point2D cell : Util.getSegmentCells(n1, n2, OSMValidatorPlugin.griddetail) )
    141142                {
    142143                        List<ExtendedSegment> segments = cellSegments.get( cell );
  • applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/util/Util.java

    r11530 r12257  
    1313import org.openstreetmap.josm.data.osm.Way;
    1414import org.openstreetmap.josm.plugins.PluginInformation;
     15import org.openstreetmap.josm.plugins.validator.OSMValidatorPlugin;
    1516
    1617/**
     
    8788
    8889                // First, round coordinates
    89                 long x0 = Math.round(n1.eastNorth.east()  * 10000);
    90                 long y0 = Math.round(n1.eastNorth.north() * 10000);
    91                 long x1 = Math.round(n2.eastNorth.east()  * 10000);
    92                 long y1 = Math.round(n2.eastNorth.north() * 10000);
     90                long x0 = Math.round(n1.eastNorth.east()  * OSMValidatorPlugin.griddetail);
     91                long y0 = Math.round(n1.eastNorth.north() * OSMValidatorPlugin.griddetail);
     92                long x1 = Math.round(n2.eastNorth.east()  * OSMValidatorPlugin.griddetail);
     93                long y1 = Math.round(n2.eastNorth.north() * OSMValidatorPlugin.griddetail);
    9394
    9495                // Start of the way
     
    118119
    119120                // Then floor coordinates, in case the way is in the border of the cell.
    120                 x0 = (long)Math.floor(n1.eastNorth.east()  * 10000);
    121                 y0 = (long)Math.floor(n1.eastNorth.north() * 10000);
    122                 x1 = (long)Math.floor(n2.eastNorth.east()  * 10000);
    123                 y1 = (long)Math.floor(n2.eastNorth.north() * 10000);
     121                x0 = (long)Math.floor(n1.eastNorth.east()  * OSMValidatorPlugin.griddetail);
     122                y0 = (long)Math.floor(n1.eastNorth.north() * OSMValidatorPlugin.griddetail);
     123                x1 = (long)Math.floor(n2.eastNorth.east()  * OSMValidatorPlugin.griddetail);
     124                y1 = (long)Math.floor(n2.eastNorth.north() * OSMValidatorPlugin.griddetail);
    124125
    125126                // Start of the way
     
    164165         * @return A list with the coordinates of all cells
    165166         */
    166         public static List<Point2D> getSegmentCells(Node n1, Node n2, int gridDetail)
     167        public static List<Point2D> getSegmentCells(Node n1, Node n2, double gridDetail)
    167168        {
    168169                List<Point2D> cells = new ArrayList<Point2D>();
Note: See TracChangeset for help on using the changeset viewer.