org.geotools.util.factory.Hints类的使用及代码示例

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

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

Hints介绍

[英]A set of hints providing control on factories to be used. Those hints are typically used by renderers or org.opengis.coverage.processing.GridCoverageProcessor for example. They provides a way to control low-level details. Example:

CoordinateOperationFactory myFactory = &hellip 
Hints hints = new Hints(Hints. 
#COORDINATE_OPERATION_FACTORY, myFactory); 
AbstractProcessor processor = new DefaultProcessor(hints);

Any hint mentioned by this class is considered to be API, failure to make use of a hint by a GeoTools factory implementation is considered a bug (as it will prevent the use of this library for application specific tasks).

When hints are used in conjunction with the FactoryRegistry we have the complete geotools plugin system. By using hints to allow application code to effect service discovery we allow client code to retarget the geotools library for their needs.
[中]对要使用的工厂提供控制的一组提示。这些提示通常由渲染器或组织使用。opengis。新闻报道处理。例如GridCoverage处理器。它们提供了一种控制低级细节的方法。例子:

CoordinateOperationFactory myFactory = &hellip 
Hints hints = new Hints(Hints. 
#COORDINATE_OPERATION_FACTORY, myFactory); 
AbstractProcessor processor = new DefaultProcessor(hints);

此类提到的任何提示都被视为API,如果GeoTools工厂实现未能使用提示,则被视为错误(因为它将阻止将此库用于特定于应用程序的任务)。
当提示与FactoryRegistry结合使用时,我们就有了完整的geotools插件系统。通过使用提示允许应用程序代码影响服务发现,我们允许客户端代码根据其需要重新定位geotools库。

代码示例

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

if (defHints != null && defHints.containsKey(Hints.EXECUTOR_SERVICE)) {
  executor = (ThreadPoolExecutor) defHints.get(Hints.EXECUTOR_SERVICE);

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

Hints localHints = new Hints(hints);
  if (dynamicAlphaSource != null
      && mergedBands.size() == 1
if (coverages.size() > 1) {
  Hints localHints = new Hints(hints);
  if (dynamicAlphaSource != null) {
    int currentBandCount = countBands(coverages);
  localHints.put(
      JAI.KEY_COLOR_MODEL_FACTORY,
      new ColorModelFactory() {

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

/**
 * Returns the reader hints based on the current WCS configuration
 *
 * @param wcs
 */
public static Hints getReaderHints(WCSInfo wcs) {
  Hints hints = new Hints();
  hints.add(new Hints(Hints.LENIENT_DATUM_SHIFT, Boolean.TRUE));
  if (wcs.getOverviewPolicy() == null) {
    hints.add(new Hints(Hints.OVERVIEW_POLICY, OverviewPolicy.IGNORE));
  } else {
    hints.add(new Hints(Hints.OVERVIEW_POLICY, wcs.getOverviewPolicy()));
  }
  hints.put(
      Hints.DECIMATION_POLICY,
      wcs.isSubsamplingEnabled() ? DecimationPolicy.ALLOW : DecimationPolicy.DISALLOW);
  return hints;
}

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

public GridCoverageReader getGridCoverageReader(ProgressListener listener, Hints hints)
    throws IOException {
  // manage projection policy
  if (this.projectionPolicy == ProjectionPolicy.FORCE_DECLARED) {
    final Hints crsHints =
        new Hints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, this.getCRS());
    if (hints != null) hints.putAll(crsHints);
    else hints = crsHints;
  }
  return catalog.getResourcePool().getGridCoverageReader(this, nativeCoverageName, hints);
}

代码示例来源: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: geotools/geotools

private Hints updateRepositoryHints(CatalogBuilderConfiguration configuration, Hints hints) {
  ImageMosaicReader reader = getImageMosaicReader(hints);
  if (reader != null) {
    Hints readerHints = reader.getHints();
    if (readerHints != null && readerHints.containsKey(Hints.REPOSITORY)) {
      hints.add(new Hints(Hints.REPOSITORY, readerHints.get(Hints.REPOSITORY)));
    }
  }
  return 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

/**
 * Gets the max amount amount of features to keep in memory from the query and system hints
 *
 * @param query
 * @return
 */
static int getMaxFeatures(Query query) {
  Hints hints = null;
  if (query != null) {
    hints = query.getHints();
  }
  int maxFeatures = 1000;
  if (hints != null && hints.get(Hints.MAX_MEMORY_SORT) != null) {
    maxFeatures = (Integer) hints.get(Hints.MAX_MEMORY_SORT);
  } else if (Hints.getSystemDefault(Hints.MAX_MEMORY_SORT) != null) {
    maxFeatures = (Integer) Hints.getSystemDefault(Hints.MAX_MEMORY_SORT);
  }
  return maxFeatures;
}

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

public int removeGranules(Filter filter) {
  return removeGranules(filter, new Hints());
}

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

hints = new Hints(hints);
} else {
  hints = new Hints();
hints.add(new RenderingHints(Hints.REPOSITORY, repository));
if (coverageExecutor != null) {
  hints.add(new RenderingHints(Hints.EXECUTOR_SERVICE, coverageExecutor));

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

public void testMixQueryAll() {
  // mixing Query.ALL equivalents with extra hints did not work
  Query firstQuery = new Query(Query.ALL);
  Query secondQuery = new Query(Query.ALL);
  firstQuery.setHints(new Hints(Hints.USE_PROVIDED_FID, Boolean.TRUE));
  secondQuery.setHints(new Hints(Hints.FEATURE_2D, Boolean.TRUE));
  Query mixed = DataUtilities.mixQueries(firstQuery, secondQuery, "mixer");
  assertEquals(2, mixed.getHints().size());
  assertTrue((Boolean) mixed.getHints().get(Hints.USE_PROVIDED_FID));
  assertTrue((Boolean) mixed.getHints().get(Hints.FEATURE_2D));
}

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

if (this.hints == null) this.hints = new Hints();
if (hints != null) {
  hints.remove(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER);
  this.hints.add(hints);
  this.hints.add(new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE));

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

/**
 * Merges the wrapper hints with the query ones, making sure not to overwrite the query ones
 *
 * @param q
 * @return
 */
protected Query mergeHints(Query q) {
  if (this.hints == null || this.hints.isEmpty()) {
    return q;
  }
  Query clone = new Query(q);
  Hints hints = clone.getHints();
  if (hints == null || hints.isEmpty()) {
    clone.setHints(this.hints);
  } else {
    for (Entry<Object, Object> entry : this.hints.entrySet()) {
      if (!hints.containsKey(entry.getKey())) {
        hints.put(entry.getKey(), entry.getValue());
      }
    }
  }
  return clone;
}

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

Object o = Hints.getSystemDefault(Hints.EXECUTOR_SERVICE);
if (o != null && o instanceof ExecutorService) {
  final ThreadPoolExecutor executor = (ThreadPoolExecutor) o;

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

private void addAlphaColorModelHint(Hints localHints, int currentBandCount) {
  ImageLayout layout = new ImageLayout();
  ColorModel alphaModel = getColorModelWithAlpha(currentBandCount);
  layout.setColorModel(alphaModel);
  localHints.put(JAI.KEY_IMAGE_LAYOUT, layout);
}

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

boolean update = false;
if (auxiliaryFilePath != null) {
  hints.add(new RenderingHints(Utils.AUXILIARY_FILES_PATH, auxiliaryFilePath));
  update = true;
  hints.add(
      new RenderingHints(Utils.AUXILIARY_DATASTORE_PATH, auxiliaryDatastorePath));
  update = true;
    && !hints.containsKey(Utils.PARENT_DIR)) {
  String parentDir = null;
  if (parentReader.parentDirectory != null) {
  hints.add(new RenderingHints(Utils.PARENT_DIR, parentDir));

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

/** */
private void setInterpolationHints() {
  if (interpolation instanceof InterpolationNearest) {
    this.hints.add(new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE));
    this.hints.add(new RenderingHints(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.TRUE));
  } else {
    this.hints.add(new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.TRUE));
    this.hints.add(new RenderingHints(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.FALSE));
  }
}

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

/** 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

/**
 * Set the main parameters of this coverage request, getting basic information from the reader.
 *
 * @param reader a {@link BaseGridCoverage2DReader} from where to get basic coverage properties
 *     as well as basic parameters to be used by the incoming read operations.
 */
private void setBaseParameters(final BaseGridCoverage2DReader reader) {
  input = reader.getInputFile();
  this.coverageEnvelope = reader.getOriginalEnvelope().clone();
  this.coverageRasterArea = ((GridEnvelope2D) reader.getOriginalGridRange());
  this.coverageCRS = reader.getCoordinateReferenceSystem();
  this.coverageName = reader.getCoverageName();
  this.coverageGridToWorld2D = (MathTransform2D) reader.getRaster2Model();
  this.coverageFullResolution = reader.getHighestRes();
  this.hints = reader.getHints().clone();
  this.multiLevelRoi = reader.getMultiLevelRoi();
  if (layout != null) {
    this.hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
  }
}

相关文章