@After public void tearDown() { TimeZone.setDefault(systemTimeZone); Hints.removeSystemDefault(Hints.LOCAL_DATE_TIME_HANDLING); }
protected void tearDownInternal() throws Exception { System.clearProperty("org.geotools.referencing.forceXY"); Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); CRS.reset("all"); }
@AfterClass public static void tearDown() { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); }
@AfterClass public static void tearDown() { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); }
public void testSRSAxisOrder2() throws Exception { try { Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); CoordinateReferenceSystem crsEN = CRS.decode("EPSG:4326"); assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(crsEN)); CoordinateReferenceSystem crsNE = CRS.decode("urn:ogc:def:crs:EPSG::4326"); assertEquals(AxisOrder.NORTH_EAST, CRS.getAxisOrder(crsNE)); } finally { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); } }
public void testSRSAxisOrder() throws Exception { try { CoordinateReferenceSystem crs = CRS.decode("EPSG:4326"); assertEquals("EPSG:4326", CRS.toSRS(crs)); Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); CRS.reset("ALL"); assertEquals("urn:ogc:def:crs:EPSG::4326", CRS.toSRS(crs)); } finally { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); } }
/** Tests fetching the URN authority when the "longitude first axis order" hint is set. */ @Test public void testWhenForceXY() throws FactoryException { try { Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); try { ReferencingFactoryFinder.getCRSAuthorityFactory("URN:OGC:DEF", null); fail("URN factory should not accept FORCE_LONGITUDE_FIRST_AXIS_ORDER = TRUE"); } catch (FactoryNotFoundException e) { // This is the expected exception. } CoordinateReferenceSystem crs = CRS.decode("URN:OGC:DEF:CRS:CRS:84", true); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); crs = CRS.decode("URN:OGC:DEF:CRS:CRS:84"); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); } finally { Hints.removeSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING); Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); } } }
/** * Tests fetching the HTTP URI CRS factory when the "longitude first axis order" hint is set. * This test ensures that the factory ignores this hint. */ @Test public void testWhenForceXY() throws FactoryException { try { Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); try { ReferencingFactoryFinder.getCRSAuthorityFactory("http://www.opengis.net/def", null); fail("HTTP URI factory should not accept FORCE_LONGITUDE_FIRST_AXIS_ORDER = true"); } catch (FactoryNotFoundException e) { // success } CoordinateReferenceSystem crs = CRS.decode("http://www.opengis.net/def/crs/CRS/0/84", true); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); crs = CRS.decode("http://www.opengis.net/def/crs/CRS/0/84"); assertTrue(CRS.equalsIgnoreMetadata(DefaultGeographicCRS.WGS84, crs)); } finally { Hints.removeSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING); Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); } }
CRS.getAxisOrder(CRS.decode("urn:x-ogc:def:crs:EPSG::4326", true))); } finally { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
/** Tests the (longitude, latitude) axis order for EPSG:4326. */ public void testForcedAxisOrder() throws NoSuchAuthorityCodeException, FactoryException { final CoordinateReferenceSystem crs = CRS.decode("EPSG:4326", true); final CoordinateSystem cs = crs.getCoordinateSystem(); assertEquals(2, cs.getDimension()); CoordinateSystemAxis axis0 = cs.getAxis(0); assertEquals("Long", axis0.getAbbreviation()); CoordinateSystemAxis axis1 = cs.getAxis(1); assertEquals("Lat", axis1.getAbbreviation()); final CoordinateReferenceSystem standard = CRS.decode("EPSG:4326"); assertFalse( "Should not be (long,lat) axis order.", CRS.equalsIgnoreMetadata(crs, standard)); final CoordinateReferenceSystem def; try { assertNull( Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE)); def = CRS.decode("EPSG:4326"); } finally { assertEquals( Boolean.TRUE, Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER)); } assertEquals("Expected (long,lat) axis order.", crs, def); assertSame("Should be back to (lat,long) axis order.", standard, CRS.decode("EPSG:4326")); }
/** Tests the {@link HTTP_AuthorityFactory#defaultAxisOrderHints} method. */ @Test public void testAxisOrderHints() { // The following are required for proper execution of the remaining of this test. assertNull(Hints.getSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER)); assertNull(Hints.getSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING)); // Standard behavior should be to set FORCE_LONGITUDE_FIRST_AXIS_ORDER to false. assertFalse(HTTP_AuthorityFactory.defaultAxisOrderHints(null, "http")); try { // The hints should be ignored. Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); assertFalse(HTTP_AuthorityFactory.defaultAxisOrderHints(null, "http")); // The hints should be honored. Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); assertTrue(HTTP_AuthorityFactory.defaultAxisOrderHints(null, "http")); // The hints should be ignored. Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "urn"); assertFalse(HTTP_AuthorityFactory.defaultAxisOrderHints(null, "http")); // The hints should be honored. Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http, urn"); assertTrue(HTTP_AuthorityFactory.defaultAxisOrderHints(null, "http")); // The hints should be honored. Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "urn, http"); assertTrue(HTTP_AuthorityFactory.defaultAxisOrderHints(null, "http")); } finally { Hints.removeSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER); Hints.removeSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING); } }