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

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

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

CoordinateReferenceSystem sourceCRS = featureSource.getInfo().getCRS();
Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG",
    hints);
CoordinateReferenceSystem worldCRS = factory
    .createCoordinateReferenceSystem("EPSG:4326");
Query query = new Query();
query.setCoordinateSystem(sourceCRS);
query.setCoordinateSystemReproject(worldCRS);

代码示例来源:origin: org.geotools/gt2-jts-wrapper

/**
 * Hints constructor for FactoryRegistry
 */
public JTSAggregateFactory( Hints hints ){
  this( (CoordinateReferenceSystem) hints.get( Hints.CRS ) );
}
/**

代码示例来源:origin: stackoverflow.com

File f = new File ( "world.shp" );
 ShapefileDataStore dataStore = new ShapefileDataStore ( f.toURI ().toURL () );
 FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = 
   dataStore.getFeatureSource ();
 String geomAttrName = featureSource.getSchema ()
   .getGeometryDescriptor ().getLocalName ();
 ResourceInfo resourceInfo = featureSource.getInfo ();
 CoordinateReferenceSystem crs = resourceInfo.getCRS ();
 Hints hints = GeoTools.getDefaultHints ();
 hints.put ( Hints.JTS_SRID, 4326 );
 hints.put ( Hints.CRS, crs );
 FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2 ( hints );
 GeometryFactory gf = JTSFactoryFinder.getGeometryFactory ( hints );
 Coordinate land = new Coordinate ( -122.0087, 47.54650 );
 Point pointLand = gf.createPoint ( land );
 Coordinate water = new Coordinate ( 0, 0 );
 Point pointWater = gf.createPoint ( water );
 Intersects filter = ff.intersects ( ff.property ( geomAttrName ), 
   ff.literal ( pointLand ) );
 FeatureCollection<SimpleFeatureType, SimpleFeature> features = featureSource
     .getFeatures ( filter );
 filter = ff.intersects ( ff.property ( geomAttrName ), 
   ff.literal ( pointWater ) );
 features = featureSource.getFeatures ( filter );

代码示例来源:origin: org.geotools/gt2-metadata

/**
 * Adds all specified hints to the system hints. This
 * is for {@link GeoTools#init} implementation only.
 */
static void putSystemDefault(final RenderingHints hints) {
  synchronized (GLOBAL) {
    ensureSystemDefaultLoaded();
    GLOBAL.add(hints);
  }
  GeoTools.fireConfigurationChanged();
}

代码示例来源:origin: org.geotools/gt2-coverage

sameCRS = CRS.equalsIgnoreMetadata(targetCRS, sourceCRS);
  if (sameGG && sameCRS) {
    return sourceCoverage;
  targetHints = new RenderingHints(hints);
} else if (hints != null) {
  targetHints.add(hints);
  final Object property = (hints != null) ? hints.get(Hints.JAI_INSTANCE) : null;
  if (property instanceof JAI) {
    processor = (JAI) property;
    ReferencingFactoryFinder.getCoordinateOperationFactory(hints);
final MathTransformFactory mtFactory =
    ReferencingFactoryFinder.getMathTransformFactory(hints);
      gridRange = CRS.transform(allSteps.inverse(), gridRange);
      targetGG  = new GridGeometry2D(new GeneralGridRange(gridRange), step1, targetCRS);
  step3          = sourceGG.getGridToCRS().inverse();
  sourceEnvelope = sourceCoverage.getEnvelope();
  targetEnvelope = CRS.transform(step2.inverse(), sourceEnvelope);
  targetEnvelope.setCoordinateReferenceSystem(targetCRS);
      for (int i=gridRange.getDimension(); --i>=0;) {
        gridRange.setRange(i, gridRange.getMinimum(i) + 0.5,

代码示例来源:origin: org.geotools/gt-coverage

if(!CRS.equalsIgnoreMetadata(targetCRS, targetGGCRS)&&!CRS.findMathTransform(targetCRS, targetGGCRS).isIdentity()){
      throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$1,"TargetCRS must be compatible with TargetGG CRS"));
    if(hints.containsKey(JAI.KEY_INTERPOLATION))
        interpolation=(Interpolation) hints.get(JAI.KEY_INTERPOLATION);
  hints.put(JAI.KEY_INTERPOLATION,interpolation);
if (!hints.containsKey(JAI.KEY_BORDER_EXTENDER)) {
  hints.put(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_COPY));
if (CRS.equalsIgnoreMetadata(sourceCRS, targetCRS)) {
  targetEnvelope.setCoordinateReferenceSystem(targetCRS);
  targetHints.add(hints);
ImageLayout layout = (ImageLayout) targetHints.get(JAI.KEY_IMAGE_LAYOUT);
if (layout != null) {
  layout = (ImageLayout) layout.clone();
} else {
  layout = new ImageLayout();
final Rectangle targetBB = targetGG.getGridRange2D();
if (isBoundsUndefined(layout, false)) {
  layout.setMinX  (targetBB.x);
targetHints.put(JAI.KEY_IMAGE_LAYOUT, layout);

代码示例来源:origin: org.geotools/gt-render

final MathTransform sourceCRSToDestinationCRSTransformation = CRS.findMathTransform(sourceCoverageCRS, destinationCRS, true);
final MathTransform destinationCRSToSourceCRSTransformation = sourceCRSToDestinationCRSTransformation.inverse();
final boolean doReprojection = !sourceCRSToDestinationCRSTransformation.isIdentity();
    destinationEnvelopeInSourceCRS = CRS.transform(
        destinationCRSToSourceCRSTransformation,
        destinationEnvelope);
    if (!CRS.equalsIgnoreMetadata(destinationCRS,
        DefaultGeographicCRS.WGS84)) {
            destinationEnvelope);
        destinationEnvelopeWGS84
            .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
      } else {
        destinationEnvelopeWGS84 = new GeneralEnvelope(
            destinationEnvelope);
      destinationEnvelopeWGS84 = new GeneralEnvelope(
          destinationEnvelope);
final Interpolation interpolation = (Interpolation) hints.get(JAI.KEY_INTERPOLATION);
if (LOGGER.isLoggable(Level.FINE))
  LOGGER.fine("Using interpolation "+interpolation);
final Hints localHints = this.hints.clone();
if(interpolation instanceof InterpolationNearest){
  localHints.add(new RenderingHints(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE));
  localHints.add(new RenderingHints(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.TRUE));

代码示例来源:origin: org.geotools/gt-imagemosaic

final Rectangle sourceArea = CRS.transform(cropWorldToGrid, intersection).toRectangle2D().getBounds();
    final ImageLayout layout = new ImageLayout();
    layout.setTileHeight(tileDimensions.width).setTileWidth(tileDimensions.height);
    localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));
  } else {
    if (hints != null && hints.containsKey(JAI.KEY_IMAGE_LAYOUT)) {
          final Object layout = hints.get(JAI.KEY_IMAGE_LAYOUT);
          if (layout != null && layout instanceof ImageLayout) {
            localHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, ((ImageLayout) layout).clone()));
  if (hints != null && hints.containsKey(JAI.KEY_TILE_CACHE)){
    final Object cache = hints.get(JAI.KEY_TILE_CACHE);
    if (cache != null && cache instanceof TileCache)
      localHints.add(new RenderingHints(JAI.KEY_TILE_CACHE, (TileCache) cache));
  if (hints != null && hints.containsKey(JAI.KEY_TILE_SCHEDULER)){
            final Object scheduler = hints.get(JAI.KEY_TILE_SCHEDULER);
            if (scheduler != null && scheduler instanceof TileScheduler)
              localHints.add(new RenderingHints(JAI.KEY_TILE_SCHEDULER, (TileScheduler) scheduler));
  if (hints != null && hints.containsKey(JAI.KEY_BORDER_EXTENDER)) {
    final Object extender = hints.get(JAI.KEY_BORDER_EXTENDER);
    if (extender != null && extender instanceof BorderExtender) {
      localHints.add(new RenderingHints(JAI.KEY_BORDER_EXTENDER, (BorderExtender) extender));

代码示例来源:origin: org.geoserver.community/importer-core

public GeoToolsCoverageTransformer(String defaultSRS) {
  // create basic hints
  hints = new Hints(GeoTools.getDefaultHints());
  if (defaultSRS != null) {
    try {
      final CoordinateReferenceSystem crs = CRS.decode(defaultSRS);
      hints.add(new RenderingHints(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM, crs));
    } catch (Exception e) {
      LOGGER.log(Level.FINE, "Cannot parse CRS " + defaultSRS, new Exception());
      hints = new Hints(GeoTools.getDefaultHints());
    }
  }
}

代码示例来源:origin: org.geotools/gt-imagemosaic

this.granuleDescriptor = granuleDescriptor;
this.request=request;
this.hints = new Hints(hints);
if (request.getTileDimensions()!= null) {
  final Dimension tileDimension = request.getTileDimensions();
  if (hints != null && hints.containsKey(JAI.KEY_IMAGE_LAYOUT)){
    final Object layout = this.hints.get(JAI.KEY_IMAGE_LAYOUT);
    if (layout != null && layout instanceof ImageLayout){
      final ImageLayout imageLayout = (ImageLayout) layout;
      imageLayout.setTileHeight(tileDimension.height);
      imageLayout.setTileWidth(tileDimension.width);
    final ImageLayout layout = new ImageLayout();
    layout.setTileWidth(tileDimension.width).setTileHeight(tileDimension.height);
    this.hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout));

代码示例来源:origin: org.geotools/gt-geotiff

if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName())) {
      final GridGeometry2D gg = (GridGeometry2D) param.getValue();
      requestedEnvelope = new GeneralEnvelope((Envelope) gg.getEnvelope2D());
      dim = gg.getGridRange2D().getBounds();
      continue;
newHints= (Hints) hints.clone();
    final ImageLayout layout = new ImageLayout();
    layout.setTileGridXOffset(0);
    layout.setTileGridYOffset(0);
    layout.setTileHeight(suggestedTileSize[1]);
    layout.setTileWidth(suggestedTileSize[0]);
    newHints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));

代码示例来源:origin: org.geotools/gt-imagemosaic

final ImageLayout layout = new ImageLayout(
    rasterBounds.x,
    rasterBounds.y,
        layout.setTileHeight(tileDimensions.width).setTileWidth(tileDimensions.height);
    final RenderingHints localHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout);
    if (hints != null && !hints.isEmpty()){
      if (hints.containsKey(JAI.KEY_TILE_CACHE)){
        final Object tc = hints.get(JAI.KEY_TILE_CACHE);
        if (tc != null && tc instanceof TileCache)
          localHints.add(new RenderingHints(JAI.KEY_TILE_CACHE, (TileCache) tc));
      if (hints != null && hints.containsKey(JAI.KEY_BORDER_EXTENDER)){
        final Object extender = hints.get(JAI.KEY_BORDER_EXTENDER);
        if (extender != null && extender instanceof BorderExtender) {
          localHints.add(new RenderingHints(JAI.KEY_BORDER_EXTENDER, (BorderExtender) extender));
        localHints.add(ImageUtilities.BORDER_EXTENDER_HINTS);
      if (hints.containsKey(JAI.KEY_TILE_SCHEDULER)){
        final Object ts = hints.get(JAI.KEY_TILE_SCHEDULER);
        if (ts != null && ts instanceof TileScheduler)
          localHints.add(new RenderingHints(JAI.KEY_TILE_SCHEDULER, (TileScheduler) ts));

代码示例来源:origin: org.geotools/gt-render

final Hints hints = new Hints(getHints());
final ImageLayout layout = new ImageLayout();
final RenderedImage sourceRaster = source
    .getRenderedImage();
    .getInstance(ColorSpace.CS_GRAY), false, false,
    Transparency.OPAQUE, oldSM.getDataType());
layout.setColorModel(cm);
layout.setSampleModel(cm.createCompatibleSampleModel(oldSM
    .getWidth(), oldSM.getHeight()));
hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
output = (GridCoverage2D) new SelectSampleDimension()
    .doOperation(parameters, hints);

代码示例来源:origin: org.geotools/gt-imageio-ext-gdal

final Object tempCRS = this.hints.get(Hints.DEFAULT_COORDINATE_REFERENCE_SYSTEM);
if (tempCRS != null) {
  this.crs=(CoordinateReferenceSystem) tempCRS;
        this.crs=CRS.parseWKT(wkt);
        final Integer epsgCode = CRS.lookupEpsgCode(this.crs, true);
          this.crs=CRS.decode("EPSG:" + epsgCode);
        this.originalEnvelope=CRS.transform(ProjectiveTransform
            .create(tempTransform), new GeneralEnvelope(
                ((GridEnvelope2D) this.originalGridRange)));
      } catch (IllegalStateException e) {

代码示例来源:origin: org.geotools/gt2-coverage

if (!CRS.equalsIgnoreMetadata(sourceCRS, destinationCRS)) {
  throw new CannotCropException(Errors.format(
      ErrorKeys.MISMATCHED_ENVELOPE_CRS_$2, sourceCRS.getName()
final GeneralEnvelope intersectionEnvelope = new GeneralEnvelope(
    (Envelope) destinationEnvelope);
intersectionEnvelope.setCoordinateReferenceSystem(source
    .getCoordinateReferenceSystem());
intersectionEnvelope.intersect(sourceEnvelope);
if (intersectionEnvelope.isEmpty())
  throw new CannotCropException(Errors
      .create(parameters,
          (hints instanceof Hints) ? (Hints) hints
              : new Hints(hints), source,
          sourceGridToWorld, tolerance);
} else {

代码示例来源:origin: org.geotools/gt2-render

final MathTransform sourceCRSToDestinationCRSTransformation = CRS.findMathTransform(sourceCoverageCRS, destinationCRS, true);
final MathTransform destinationCRSToSourceCRSTransformation = sourceCRSToDestinationCRSTransformation.inverse();
final boolean doReprojection = !sourceCRSToDestinationCRSTransformation.isIdentity();
    destinationEnvelopeInSourceCRS = CRS.transform(
        destinationCRSToSourceCRSTransformation,
        destinationEnvelope);
    if (!CRS.equalsIgnoreMetadata(destinationCRS,
        DefaultGeographicCRS.WGS84)) {
            destinationEnvelope);
        destinationEnvelopeWGS84
            .setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
      } else {
        destinationEnvelopeWGS84 = new GeneralEnvelope(
            destinationEnvelope);
      destinationEnvelopeWGS84 = new GeneralEnvelope(
          destinationEnvelope);
    .get(JAI.KEY_INTERPOLATION);
if (LOGGER.isLoggable(Level.FINE))
  LOGGER.fine(new StringBuffer("Using interpolation ").append(

代码示例来源:origin: locationtech/geogig

private FeatureReader<SimpleFeatureType, SimpleFeature> getReader(Query query) {
  GeometryFactory geometryFactory = (GeometryFactory) query.getHints()
      .get(Hints.JTS_GEOMETRY_FACTORY);
  Integer offset = query.getStartIndex();
  Integer limit = query.isMaxFeaturesUnlimited() ? null : query.getMaxFeatures();
  String[] propertyNames = query.getPropertyNames();
  ScreenMap screenMap = (ScreenMap) query.getHints().get(Hints.SCREENMAP);
  SortBy[] sortBy = query.getSortBy();
  reader = builder.filter(query.getFilter())//
      .geometryFactory(geometryFactory)//
      .offset(offset)//
      .limit(limit)//
      .propertyNames(propertyNames)//
      .screenMap(screenMap)//
      .sortBy(sortBy)//
      .build();
  return reader;
}

代码示例来源:origin: codice/ddf

/**
 * Transform a geometry to EPSG:4326 format with lon/lat coordinate ordering. NOTE: This method
 * will perform the transform swapping coordinates even if the sourceCrsName is EPSG:4326
 *
 * @param geometry - Geometry to transform
 * @param sourceCrsName - Source geometry's coordinate reference system
 * @return Geometry - Transformed geometry into EPSG:4326 lon/lat coordinate system
 */
public static Geometry transformToEPSG4326LonLatFormat(Geometry geometry, String sourceCrsName)
  throws GeoFormatException {
 if (geometry == null) {
  throw new GeoFormatException("Unable to convert null geometry");
 }
 // If we don't have source CRS just return geometry as we can't transform without that
 // information
 if (sourceCrsName == null) {
  return geometry;
 }
 try {
  CoordinateReferenceSystem sourceCrs = CRS.decode(sourceCrsName);
  Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
  CRSAuthorityFactory factory = ReferencingFactoryFinder.getCRSAuthorityFactory("EPSG", hints);
  CoordinateReferenceSystem targetCRS = factory.createCoordinateReferenceSystem(EPSG_4326);
  MathTransform transform = CRS.findMathTransform(sourceCrs, targetCRS);
  return JTS.transform(geometry, transform);
 } catch (FactoryException | TransformException e) {
  throw new GeoFormatException("Unable to convert coordinate to " + EPSG_4326, e);
 }
}

代码示例来源:origin: org.geoserver/wms

FilterFactory2 filterFac = CommonFactoryFinder.getFilterFactory2(GeoTools.getDefaultHints());
      if ((requestedCRS != null) && !CRS.equalsIgnoreMetadata(dataCRS, requestedCRS)) {
        try {
          MathTransform transform = CRS.findMathTransform(requestedCRS, dataCRS, true);
      final CoverageInfo cinfo = requestedLayers[i].getCoverage();
      final GridGeometry2D coverageGeometry=(GridGeometry2D) cinfo.getGrid();
      final GeneralEnvelope requestedEnvelope=new GeneralEnvelope(new ReferencedEnvelope(bbox,requestedCRS));
      final GridCoverage2D coverage=(GridCoverage2D) cinfo.getCoverage(requestedEnvelope, new Rectangle(0,0,width,height));
      final DirectPosition position = new DirectPosition2D(requestedCRS, middle.x, middle.y);
              requestedCRS, targetCRS, new Hints(
                  Hints.LENIENT_DATUM_SHIFT,
                  Boolean.TRUE));

代码示例来源:origin: org.geotools/gt-render

currentSourceCoverage.getRenderedImage()
            .getSampleModel().getDataType());
    layout = new ImageLayout();
    layout.setColorModel(cm);
  } else if (!gg.equals(gridGeometry))
    throw new IllegalArgumentException(Errors.format(
  hints.add(new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout));
op = FormatDescriptor.create(op, Integer.valueOf(op.getSampleModel().getDataType()), hints);
final GridSampleDimension [] sd= new GridSampleDimension[op.getSampleModel().getNumBands()];

相关文章