Changeset 18589 in josm for trunk/test/unit
- Timestamp:
- 2022-11-08T18:51:13+01:00 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r18494 r18589 14 14 import java.util.Collections; 15 15 import java.util.List; 16 import java.util.stream.Collectors; 16 17 import java.util.stream.Stream; 17 18 … … 164 165 } 165 166 167 static Stream<Arguments> testCentroid() { 168 // The expected values use the BigDecimal calculations 169 return Stream.of( 170 Arguments.of(new LatLon(54.10310051693397, 12.094459783282147), 171 new LatLon[]{ 172 new LatLon(54.1031207, 12.094513), 173 new LatLon(54.1030973, 12.0945423), 174 new LatLon(54.1031188, 12.0944413), 175 new LatLon(54.1030578, 12.0945178), 176 new LatLon(54.1030658, 12.0944275), 177 new LatLon(54.1030826, 12.0945434), 178 new LatLon(54.1031079, 12.0944243), 179 new LatLon(54.1030515, 12.094495), 180 new LatLon(54.103094, 12.0944157), 181 new LatLon(54.1031257, 12.0944893), 182 new LatLon(54.1030687, 12.0945348), 183 new LatLon(54.1031251, 12.0944641), 184 new LatLon(54.1030792, 12.0944168), 185 new LatLon(54.1030508, 12.0944698), 186 new LatLon(54.1030559, 12.0944461), 187 new LatLon(54.1031107, 12.0945316) 188 }), 189 Arguments.of(new LatLon(54.10309639216633, 12.09463150330365), 190 new LatLon[]{new LatLon(54.1031205, 12.094653), 191 new LatLon(54.1030621, 12.0946675), 192 new LatLon(54.1030866, 12.0946874), 193 new LatLon(54.1030732, 12.0946816), 194 new LatLon(54.1030766, 12.0945701), 195 new LatLon(54.1031148, 12.0945865), 196 new LatLon(54.1031122, 12.0946719), 197 new LatLon(54.1030551, 12.0946473), 198 new LatLon(54.1031037, 12.0945724), 199 new LatLon(54.1031003, 12.094684), 200 new LatLon(54.1030647, 12.0945821), 201 new LatLon(54.1031219, 12.0946068), 202 new LatLon(54.1031239, 12.0946301), 203 new LatLon(54.1030903, 12.0945667), 204 new LatLon(54.1030564, 12.0946011), 205 new LatLon(54.1030531, 12.0946239) 206 }), 207 Arguments.of(new LatLon(54.103185854296896, 12.09457804609505), 208 new LatLon[] { 209 new LatLon(54.1031981, 12.0945501), 210 new LatLon(54.1031782, 12.0945501), 211 new LatLon(54.1031726, 12.0946082), 212 new LatLon(54.1031955, 12.0946015) 213 }), 214 Arguments.of(new LatLon(54.103180913681705, 12.094425831813119), 215 new LatLon[] { 216 new LatLon(54.1032057, 12.0943903), 217 new LatLon(54.1031517, 12.0944053), 218 new LatLon(54.1031877, 12.0943743), 219 new LatLon(54.1031697, 12.0943743), 220 new LatLon(54.1031517, 12.0944353), 221 new LatLon(54.1031697, 12.0944663), 222 new LatLon(54.1031877, 12.0944663), 223 new LatLon(54.1032057, 12.0944363) 224 }) 225 ); 226 } 227 228 @ParameterizedTest 229 @MethodSource 230 void testCentroid(LatLon expected, LatLon... coordinates) { 231 LatLon actual = ProjectionRegistry.getProjection() 232 .eastNorth2latlon(Geometry.getCentroid(Stream.of(coordinates).map(Node::new).collect(Collectors.toList()))); 233 assertTrue(expected.equalsEpsilon((ILatLon) actual), "Expected " + expected + " but got " + actual); 234 } 235 166 236 /** 167 237 * Test of {@link Geometry#getCentroidEN} method. … … 172 242 EastNorth en2 = new EastNorth(150, 400); 173 243 EastNorth en3 = new EastNorth(200, 200); 174 assertEquals(en1, Geometry.getCentroidEN( Arrays.asList(en1)));244 assertEquals(en1, Geometry.getCentroidEN(Collections.singletonList(en1))); 175 245 assertEquals(new EastNorth(125, 300), Geometry.getCentroidEN(Arrays.asList(en1, en2))); 176 246 assertEquals(new EastNorth(150, 266d + 2d/3d), Geometry.getCentroidEN(Arrays.asList(en1, en2, en3)));
Note:
See TracChangeset
for help on using the changeset viewer.