Changeset 16663 in josm


Ignore:
Timestamp:
2020-06-17T00:05:03+02:00 (3 weeks ago)
Author:
simon04
Message:

OsmWriter: fix max_lat/max_lon in <changeset>

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmWriter.java

    r14274 r16663  
    313313        }
    314314        if (cs.getMax() != null) {
    315             out.print(" max_lon='"+ DecimalDegreesCoordinateFormat.INSTANCE.lonToString(cs.getMin()) +'\'');
    316             out.print(" max_lat='"+ DecimalDegreesCoordinateFormat.INSTANCE.latToString(cs.getMin()) +'\'');
     315            out.print(" max_lon='"+ DecimalDegreesCoordinateFormat.INSTANCE.lonToString(cs.getMax()) +'\'');
     316            out.print(" max_lat='"+ DecimalDegreesCoordinateFormat.INSTANCE.latToString(cs.getMax()) +'\'');
    317317        }
    318318        out.println(">");
  • trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java

    r14746 r16663  
    99import java.io.OutputStreamWriter;
    1010import java.io.PrintWriter;
     11import java.io.StringWriter;
    1112import java.nio.charset.StandardCharsets;
    1213import java.util.ArrayList;
     
    1617
    1718import org.junit.Test;
     19import org.openstreetmap.josm.data.coor.LatLon;
     20import org.openstreetmap.josm.data.osm.Changeset;
    1821import org.openstreetmap.josm.data.osm.DataSet;
    1922import org.openstreetmap.josm.data.osm.DownloadPolicy;
    2023import org.openstreetmap.josm.data.osm.NodeData;
    2124import org.openstreetmap.josm.data.osm.UploadPolicy;
     25import org.openstreetmap.josm.data.osm.User;
    2226
    2327/**
     
    9195                        .replaceAll("\n", ""));
    9296    }
     97
     98    /**
     99     * Unit test of {@link OsmWriter#visit(Changeset)}.
     100     * @throws IOException if an I/O error occurs
     101     */
     102    @Test
     103    public void testChangeset() throws IOException {
     104        Changeset cs = new Changeset();
     105        cs.setUser(User.getAnonymous());
     106        cs.setId(38038262);
     107        cs.setMin(new LatLon(12., 34.));
     108        cs.setMax(new LatLon(56., 78.));
     109        try (StringWriter stringWriter = new StringWriter();
     110             OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(stringWriter), true, OsmWriter.DEFAULT_API_VERSION)) {
     111            osmWriter.visit(cs);
     112            assertEquals("  <changeset id='38038262' user='&lt;anonymous&gt;' uid='-1' open='false' " +
     113                            "min_lon='34.0' min_lat='12.0' max_lon='78.0' max_lat='56.0'>\n  </changeset>\n",
     114                    stringWriter.toString().replace("\r", ""));
     115        }
     116    }
    93117}
Note: See TracChangeset for help on using the changeset viewer.