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

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

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

GeoTools.getDefaultHints介绍

[英]Returns the default set of hints used for the various utility classes. This default set is determined by:

  • The System#getProperties system properties available. Some property keys are enumerated in the GeoTools class.
  • Any hints added by call to the Hints#putSystemDefault or #init method.

Long term plan: We would like to transition the utility classes to being injected with their required factories, either by taking Hints as part of their constructor, or otherwise. Making this change would be a three step process 1) create instance methods for each static final class method 2) create an singleton instance of the class 3) change each static final class method into a call to the singleton. With this in place we could then encourage client code to make use of utility class instances before eventually retiring the static final methods.
[中]返回用于各种实用程序类的默认提示集。此默认设置由以下因素确定:
*系统#getProperties系统属性可用。某些属性键在GeoTools类中枚举。
*通过调用hints#putSystemDefault或#init方法添加的任何提示。
长期计划:我们希望通过将提示作为构造函数的一部分或其他方式,将实用程序类转换为注入它们所需的工厂。进行此更改需要三个步骤:1)为每个静态最终类方法创建实例方法2)创建类的单例实例3)将每个静态最终类方法更改为对单例的调用。这样,我们就可以鼓励客户机代码在最终停用静态final方法之前使用实用程序类实例。

代码示例

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

/** Builds the default coverage contained in the current store */
public CoverageInfo buildCoverage(String coverageName) throws Exception {
  if (store == null || !(store instanceof CoverageStoreInfo)) {
    throw new IllegalStateException("Coverage store not set.");
  }
  CoverageStoreInfo csinfo = (CoverageStoreInfo) store;
  GridCoverage2DReader reader =
      (GridCoverage2DReader)
          catalog.getResourcePool()
              .getGridCoverageReader(csinfo, GeoTools.getDefaultHints());
  if (reader == null)
    throw new Exception(
        "Unable to acquire a reader for this coverage with format: "
            + csinfo.getFormat().getName());
  return buildCoverage(reader, coverageName, null);
}

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

/**
 * Builds the default coverage contained in the current store
 *
 * @param nativeCoverageName the native name for the coverage
 * @param specifiedName the published name for the coverage. If null, the name will be
 *     determined from the coverage store.
 * @return coverage for the specified name
 * @throws Exception if the coverage store was not found or could not be read, or if the
 *     coverage could not be created.
 */
public CoverageInfo buildCoverageByName(String nativeCoverageName, String specifiedName)
    throws Exception {
  if (store == null || !(store instanceof CoverageStoreInfo)) {
    throw new IllegalStateException("Coverage store not set.");
  }
  CoverageStoreInfo csinfo = (CoverageStoreInfo) store;
  GridCoverage2DReader reader =
      (GridCoverage2DReader)
          catalog.getResourcePool()
              .getGridCoverageReader(csinfo, GeoTools.getDefaultHints());
  if (reader == null)
    throw new Exception(
        "Unable to acquire a reader for this coverage with format: "
            + csinfo.getFormat().getName());
  return buildCoverageInternal(reader, nativeCoverageName, null, specifiedName);
}

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

final Hints defHints = GeoTools.getDefaultHints();

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

/**
 * Returns the GeoTools default hints {@link GeoTools#getDefaultHints()}
 *
 * @return {@link GeoTools#getDefaultHints()}
 * @see Query#getHints()
 */
public Hints getHints() {
  return GeoTools.getDefaultHints();
}

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

final Hints defHints = GeoTools.getDefaultHints();

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

reader =
    (GridCoverage2DReader)
        cinfo.getGridCoverageReader(null, GeoTools.getDefaultHints());

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

(GridCoverage2DReader)
        catalog.getResourcePool()
            .getGridCoverageReader(cinfo, GeoTools.getDefaultHints());
if (coverageName != null) {
  reader = SingleGridCoverage2DReader.wrap(reader, coverageName);

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

/**
 * Create a Stylereader - use if you already have a dom to parse.
 *
 * @param factory The StyleFactory to use to build the style
 */
public SLDParser(StyleFactory factory) {
  this(factory, CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()));
}

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

/** Make sure a JNDI context is available */
  public boolean isAvailable() {
    try {
      GeoTools.getInitialContext(GeoTools.getDefaultHints());
      return true;
    } catch (Exception e) {
      return false;
    }
  }
}

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

/**
 * Constructs an instance wrapping the specified factory with a default cache.
 *
 * <p>The provided authority factory must implement {@link DatumAuthorityFactory}, {@link
 * CSAuthorityFactory}, {@link CRSAuthorityFactory} and {@link
 * CoordinateOperationAuthorityFactory} .
 *
 * @param factory The factory to cache. Can not be {@code null}.
 */
public CachedAuthorityDecorator(final AuthorityFactory factory) {
  this(factory, createCache(GeoTools.getDefaultHints()));
}

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

/**
 * Use the supplied StyleFactory when building styles
 *
 * @param styleFactory the StyleFactory to use in building Styles
 */
public StyleBuilder(StyleFactory styleFactory) {
  this(styleFactory, CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()));
}

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

/**
 * Use the supplied FilterFactory when building styles
 *
 * @param filterFactory Use this FilterFactory to build the style
 */
public StyleBuilder(FilterFactory filterFactory) {
  this(CommonFactoryFinder.getStyleFactory(GeoTools.getDefaultHints()), filterFactory);
}

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

/**
 * Returns all the {@link Format}s that can read the supplied {@link Object} o.
 *
 * @param o is the object to search a {@link Format} that is able to read
 * @return an unmodifiable {@link Set} comprising all the {@link Format} that can read the
 *     {@link Object} o.
 */
public static synchronized Set<AbstractGridFormat> findFormats(Object o) {
  return findFormats(o, GeoTools.getDefaultHints());
}

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

/**
 * Tells me if this {@link Format} can read the provided <code>input</code>.
 *
 * @param input The input object to test for suitability.
 * @return True if this format can read this object, False otherwise.
 */
public boolean accepts(Object source) {
  return accepts(source, GeoTools.getDefaultHints());
}

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

r = (GridCoverage2DReader) ci.getGridCoverageReader(null, GeoTools.getDefaultHints());
assertTrue(
    CRS.equalsIgnoreMetadata(
r = (GridCoverage2DReader) rpool.getGridCoverageReader(store, GeoTools.getDefaultHints());
assertTrue(
    CRS.equalsIgnoreMetadata(

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

public MarkImpl(String name) {
  this(CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()), null);
  LOGGER.fine("creating " + name + " type mark");
  setWellKnownName(name);
}

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

@Test
public void testDropCoverageStore() throws Exception {
  // build the store
  Catalog cat = getCatalog();
  CatalogBuilder cb = new CatalogBuilder(cat);
  CoverageStoreInfo store = cb.buildCoverageStore("dem");
  store.setURL(MockData.class.getResource("tazdem.tiff").toExternalForm());
  store.setType("GeoTIFF");
  cat.add(store);
  // build the coverage
  cb.setStore(store);
  CoverageInfo ci = cb.buildCoverage();
  cat.add(ci);
  // build the layer
  LayerInfo layer = cb.buildLayer(ci);
  cat.add(layer);
  // grab a reader just to inizialize the code
  ci.getGridCoverage(null, null);
  ci.getGridCoverageReader(null, GeoTools.getDefaultHints());
  // now drop the store
  CascadeDeleteVisitor visitor = new CascadeDeleteVisitor(cat);
  visitor.visit(store);
  // and reload (GEOS-4782 -> BOOM!)
  getGeoServer().reload();
}

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

private static LazySet<ProjectionHandlerFactory> getProjectionHandlerFactories() {
  Hints hints = GeoTools.getDefaultHints();
  return new LazySet<ProjectionHandlerFactory>(
      registry.getFactories(ProjectionHandlerFactory.class, null, hints));
}

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

@Test
public void testStartupListener() {
  Hints hints = GeoTools.getDefaultHints();
  final Object factory = hints.get(Hints.GRID_COVERAGE_FACTORY);
  assertNotNull(factory);
  assertTrue(factory instanceof GridCoverageFactory);
  final Object datumShift = hints.get(Hints.LENIENT_DATUM_SHIFT);
  assertNotNull(datumShift);
  assertTrue((Boolean) datumShift);
  final Object tolerance = hints.get(Hints.COMPARISON_TOLERANCE);
  assertNotNull(tolerance);
  assertEquals(CUSTOM_TOLERANCE, (Double) tolerance, 1e-12d);
  final Object filterFactory = hints.get(Hints.FILTER_FACTORY);
  assertNotNull(filterFactory);
  assertTrue(filterFactory instanceof FilterFactory);
  final Object styleFactory = hints.get(Hints.STYLE_FACTORY);
  assertNotNull(styleFactory);
  assertTrue(styleFactory instanceof StyleFactory);
  final Object featureFactory = hints.get(Hints.FEATURE_FACTORY);
  assertNotNull(featureFactory);
  assertTrue(featureFactory instanceof FeatureFactory);
  final Object executorService = hints.get(Hints.EXECUTOR_SERVICE);
  assertNotNull(executorService);
  assertTrue(executorService instanceof ExecutorService);
}

代码示例来源: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);
}

相关文章