org.geotools.util.factory.Hints.putSystemDefault()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.geotools.util.factory.Hints.putSystemDefault()方法的一些代码示例,展示了Hints.putSystemDefault()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hints.putSystemDefault()方法的具体详情如下:
包路径:org.geotools.util.factory.Hints
类名称:Hints
方法名:putSystemDefault

Hints.putSystemDefault介绍

[英]Adds a hint value to the set of GeoTools#getDefaultHints. Default hints can be added by call to this putDefaultHint method, to the GeoTools#init method or by System#getProperties with keys defined by the String constants in the GeoTools class.
[中]将提示值添加到GeoTools#GetDefaultHits集。默认提示可以通过调用此putDefaultHint方法、GeoTools#init方法或System#getProperties添加,键由GeoTools类中的字符串常量定义。

代码示例

代码示例来源:origin: geoserver/geoserver

@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");
  }
}

代码示例来源:origin: geoserver/geoserver

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);

代码示例来源:origin: geoserver/geoserver

|| !"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");

代码示例来源:origin: geotools/geotools

if (hints != null) {
  Hints.putSystemDefault(hints);

代码示例来源:origin: geotools/geotools

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);
  }
}

代码示例来源:origin: geotools/geotools

@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")));
}

代码示例来源:origin: geotools/geotools

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);
  }
}

代码示例来源:origin: geotools/geotools

/** 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);
    }
  }
}

代码示例来源:origin: geotools/geotools

/**
 * 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);
  }
}

代码示例来源:origin: geotools/geotools

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);
}

代码示例来源:origin: geotools/geotools

/** 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);
  }
}

代码示例来源:origin: geotools/geotools

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)));

代码示例来源:origin: geotools/geotools

Locale.setDefault(arguments.locale);
if (arguments.getFlag("-forcexy")) {
  Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);

代码示例来源:origin: geotools/geotools

/** 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"));
}

代码示例来源:origin: geotools/geotools

/**
 * 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");
}

相关文章