Changeset 15442 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2019-10-07T23:48:07+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17495 - limited support of named CRS in GeoJSON import

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/GeoJSONReaderTest.java

    r15427 r15442  
    117117    }
    118118
     119    /**
     120     * Test reading a GeoJSON file with a named CRS.
     121     * @throws Exception in case of error
     122     */
     123    @Test
     124    public void testReadGeoJsonNamedCrs() throws Exception {
     125        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "geocrs.json"))) {
     126            final List<OsmPrimitive> primitives = new ArrayList<>(new GeoJSONReader()
     127                    .doParseDataSet(in, null)
     128                    .getPrimitives(it -> true));
     129                assertEquals(24, primitives.size());
     130                assertTrue(primitives.stream()
     131                        .filter(it -> areEqualNodes(it, new Node(new LatLon(52.5840213, 13.1724145))))
     132                        .findAny().isPresent());
     133        }
     134    }
     135
    119136    private static boolean areEqualNodes(final OsmPrimitive p1, final OsmPrimitive p2) {
    120137        return (p1 instanceof Node)
    121138            && (p2 instanceof Node)
    122             && ((Node) p1).getCoor().equals(((Node) p2).getCoor());
     139            && ((Node) p1).getCoor().equalsEpsilon(((Node) p2).getCoor());
    123140    }
    124141
Note: See TracChangeset for help on using the changeset viewer.