@BeforeClass public static final void setUpReferencing() throws Exception { // do we need to reset the referencing subsystem and reorient it with lon/lat order? if (System.getProperty("org.geotools.referencing.forceXY") == null || !"http".equals(Hints.getSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING))) { System.setProperty("org.geotools.referencing.forceXY", "true"); Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); } }
Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); Hints.putSystemDefault(Hints.LENIENT_DATUM_SHIFT, true); Hints.putSystemDefault(Hints.COMPARISON_TOLERANCE, comparisonTolerance); Hints.putSystemDefault( Hints.GRID_COVERAGE_FACTORY, CoverageFactoryFinder.getGridCoverageFactory(defHints)); Hints.putSystemDefault(Hints.FILTER_FACTORY, CommonFactoryFinder.getFilterFactory2(null)); Hints.putSystemDefault(Hints.STYLE_FACTORY, CommonFactoryFinder.getStyleFactory(null)); Hints.putSystemDefault(Hints.FEATURE_FACTORY, CommonFactoryFinder.getFeatureFactory(null)); TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); Hints.putSystemDefault(Hints.EXECUTOR_SERVICE, executor);
|| !"http".equals(Hints.getSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING))) { System.setProperty("org.geotools.referencing.forceXY", "true"); Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING, "http"); CRS.reset("all");
if (hints != null) { Hints.putSystemDefault(hints);
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); } }
@BeforeClass public static void setupCRS() throws FactoryException { CRS.reset("all"); Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); // the following is only to make the test work in Eclipse, where the test // classpath is tainted by the test classpath of dependent modules (whilst in Maven it's // not) Set<CRSAuthorityFactory> factories = ReferencingFactoryFinder.getCRSAuthorityFactories(null); for (CRSAuthorityFactory factory : factories) { if (factory.getClass().getSimpleName().equals("EPSGCRSAuthorityFactory")) { ReferencingFactoryFinder.removeAuthorityFactory(factory); } } assertEquals( AxisOrder.NORTH_EAST, CRS.getAxisOrder(CRS.decode("urn:ogc:def:crs:EPSG::4326"))); }
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); } }
protected void setUp() throws Exception { // this is the only thing that actually forces CRS object to give up // its configuration, necessary when tests are run by Maven, one JVM for all // the tests in this module Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); GeoTools.fireConfigurationChanged(); ft = DataUtilities.createType( "testType", "geom:Point:srid=4326,line:LineString,name:String,id:int"); ff = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints()); reprojector = new ReprojectingFilterVisitor(ff, ft); }
/** 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); } }
Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE); assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", false))); assertEquals(AxisOrder.EAST_NORTH, CRS.getAxisOrder(CRS.decode("EPSG:4326", true)));
Locale.setDefault(arguments.locale); if (arguments.getFlag("-forcexy")) { Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
/** 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 date encoding having {@link Hints#LOCAL_DATE_TIME_HANDLING} activated * * @throws Exception */ @Test public void testLocalEncode() throws Exception { Hints.putSystemDefault(Hints.LOCAL_DATE_TIME_HANDLING, true); // UTC assertDateEquals("2015-09-02", 2015, 9, 2, 0, "UTC"); assertDateEquals("2015-09-02", 2015, 9, 2, 1, "UTC"); assertDateEquals("2015-09-02", 2015, 9, 2, 23, "UTC"); // GMT assertDateEquals("2015-09-02", 2015, 9, 2, 0, "GMT"); assertDateEquals("2015-09-02", 2015, 9, 2, 1, "GMT"); assertDateEquals("2015-09-02", 2015, 9, 2, 23, "GMT"); // CET assertDateEquals("2015-09-02", 2015, 9, 2, 0, "CET"); assertDateEquals("2015-09-02", 2015, 9, 2, 1, "CET"); assertDateEquals("2015-09-02", 2015, 9, 2, 2, "CET"); assertDateEquals("2015-09-02", 2015, 9, 2, 23, "CET"); // EST assertDateEquals("2015-09-02", 2015, 9, 2, 0, "EST"); assertDateEquals("2015-09-02", 2015, 9, 2, 1, "EST"); assertDateEquals("2015-09-02", 2015, 9, 2, 23, "EST"); }