Ticket #24739: 24739.patch

File 24739.patch, 2.4 KB (added by GerdP, 8 weeks ago)

Simple approach to fix the problem, works also for gpx files containing routes

  • src/org/openstreetmap/josm/data/gpx/GpxData.java

     
    719719     * To get bounds as read from metadata, see {@link #getMetaBounds()}.<br>
    720720     * To get downloaded areas, see {@link #dataSources}.<br>
    721721     *
     722     * @return the bounds
     723     * @see #getMetaBounds()
     724     * @see #dataSources
     725     */
     726    public synchronized Bounds recalculateBounds() {
     727        return recalculateBounds(false);
     728    }
     729
     730    /**
     731     * Calculates the bounding box of available data and returns it.
     732     * The bounds are not stored internally, but recalculated every time
     733     * this function is called.<br>
     734     * To get bounds as read from metadata, see {@link #getMetaBounds()}.<br>
     735     * To get downloaded areas, see {@link #dataSources}.<br>
     736     *
    722737     * FIXME might perhaps use visitor pattern?
     738     * @param ignoreWaypoints if true, data from privateWaypoints is ignored
    723739     * @return the bounds
    724740     * @see #getMetaBounds()
    725741     * @see #dataSources
     742     * @since xxx
    726743     */
    727     public synchronized Bounds recalculateBounds() {
     744    public synchronized Bounds recalculateBounds(boolean ignoreWaypoints) {
    728745        Bounds bounds = null;
    729         for (WayPoint wpt : privateWaypoints) {
    730             if (bounds == null) {
    731                 bounds = new Bounds(wpt.getCoor());
    732             } else {
    733                 bounds.extend(wpt.getCoor());
     746        if (!ignoreWaypoints) {
     747            for (WayPoint wpt : privateWaypoints) {
     748                if (bounds == null) {
     749                    bounds = new Bounds(wpt.getCoor());
     750                } else {
     751                    bounds.extend(wpt.getCoor());
     752                }
    734753            }
    735754        }
    736755        for (GpxRoute rte : privateRoutes) {
  • src/org/openstreetmap/josm/gui/layer/GpxLayer.java

     
    395395    @Override
    396396    public void visitBoundingBox(BoundingXYVisitor v) {
    397397        if (data != null) {
    398             v.visit(data.recalculateBounds());
     398            v.visit(data.recalculateBounds(true));
    399399        }
    400400    }
    401401