本文整理了Java中org.geotools.factory.Hints.put()
方法的一些代码示例,展示了Hints.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hints.put()
方法的具体详情如下:
包路径:org.geotools.factory.Hints
类名称:Hints
方法名:put
[英]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#getPropertieswith keys defined by the String constants in the GeoTools class.
[中]将提示值添加到GeoTools#GetDefaultHits集。默认提示可以通过调用此putDefaultHint方法、GeoTools#init方法或System#GetProperties添加,键由GeoTools类中的字符串常量定义。
代码示例来源: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-coverage
/**
* Sets the GRID_COVERAGE_PROCESSOR hint to the specified value.
* This is used by {@link BufferedProcessor} only.
*/
final void setProcessor(final AbstractProcessor processor) {
hints.put(Hints.GRID_COVERAGE_PROCESSOR, processor);
}
代码示例来源:origin: org.geotools/gt2-coverage
/**
* Constructs a default coverage processor. The {@link #scanForPlugins} method will be
* automatically invoked the first time an operation is required. Additional operations
* can be added by subclasses with the {@link #addOperation} method. Rendering hints will
* be initialized with the following hints:
* <p>
* <ul>
* <li>{@link JAI#KEY_REPLACE_INDEX_COLOR_MODEL} set to {@link Boolean#FALSE}.</li>
* <li>{@link JAI#KEY_TRANSFORM_ON_COLORMAP} set to {@link Boolean#FALSE}.</li>
* </ul>
*
* @param hints A set of additional rendering hints, or {@code null} if none.
*/
public DefaultProcessor(final RenderingHints hints) {
registry = new FactoryRegistry(Collections.singleton(Operation.class));
this.hints = new Hints(hints);
this.hints.put(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE);
this.hints.put(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.FALSE);
this.hints.put(Hints.GRID_COVERAGE_PROCESSOR, this); // Must overwrites user setting.
}
代码示例来源:origin: org.geotools/gt2-geometry
/** Just the defaults, use GeometryFactoryFinder for the rest */
public ComplexFactoryImpl( Hints hints ) {
if (hints == null) {
this.crs = DefaultGeographicCRS.WGS84;
hints = GeoTools.getDefaultHints();
hints.put(Hints.CRS, crs );
}
else {
this.crs = (CoordinateReferenceSystem) hints.get( Hints.CRS );
if( crs == null ){
throw new NullPointerException("A CRS Hint is required in order to use ComplexFactoryImpl");
}
}
hintsWeCareAbout.put(Hints.CRS, crs );
}
代码示例来源:origin: org.geotools/gt2-geometry
/**
* @param crs
*/
public PrimitiveFactoryImpl(CoordinateReferenceSystem crs, PositionFactory positionFactory) {
this.crs = crs;
if( crs == null ){
throw new NullPointerException("A non null crs is required in order to use PrimitiveFactoryImpl");
}
if (positionFactory == null) {
Hints hints = GeoTools.getDefaultHints();
hints.put(Hints.CRS, crs );
this.positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
}
else {
this.positionFactory = positionFactory;
}
geomValidate = true;
hintsWeCareAbout.put(Hints.CRS, crs );
hintsWeCareAbout.put(Hints.POSITION_FACTORY, positionFactory );
hintsWeCareAbout.put(Hints.GEOMETRY_VALIDATE, geomValidate );
}
代码示例来源:origin: org.geotools/gt2-main
/**
* Create a new FeatureTypeFactory with the given typeName.
*
* @param name The typeName of the feature to create.
*
* @return A new FeatureTypeFactory instance.
*
* @throws FactoryConfigurationError If there exists a configuration error.
*/
public static FeatureTypeFactory newInstance(String typeName)
throws FactoryConfigurationError {
// warning not sure if CommonFactoryFinder is going to cache the instance or not?
//
Hints hints = GeoTools.getDefaultHints();
if( hints == null ){
hints = new Hints( Hints.FEATURE_TYPE_FACTORY_NAME, typeName );
}
else {
hints.put( Hints.FEATURE_TYPE_FACTORY_NAME, typeName );
}
hints.put( Hints.FEATURE_TYPE_FACTORY_NAME, typeName );
return CommonFactoryFinder.getFeatureTypeFactory( hints );
}
代码示例来源:origin: org.geotools/gt-coverage
/**
* Constructs a default coverage processor. The {@link #scanForPlugins} method will be
* automatically invoked the first time an operation is required. Additional operations
* can be added by subclasses with the {@link #addOperation} method. Rendering hints will
* be initialized with the following hints:
* <p>
* <ul>
* <li>{@link JAI#KEY_REPLACE_INDEX_COLOR_MODEL} set to {@link Boolean#FALSE}.</li>
* <li>{@link JAI#KEY_TRANSFORM_ON_COLORMAP} set to {@link Boolean#FALSE}.</li>
* </ul>
*
* @param hints A set of additional rendering hints, or {@code null} if none.
*/
public CoverageProcessor(final RenderingHints hints) {
registry = new FactoryRegistry(Arrays.asList(new Class<?>[] {
Operation.class
}));
this.hints = new Hints();
this.hints.put(JAI.KEY_REPLACE_INDEX_COLOR_MODEL, Boolean.FALSE);
this.hints.put(JAI.KEY_TRANSFORM_ON_COLORMAP, Boolean.FALSE);
// override with user hints
if(hints!=null)
this.hints.add(hints);
}
代码示例来源:origin: org.geotools/gt2-geometry
/** Just the defaults, use GeometryFactoryFinder for the rest */
public GeometryFactoryImpl( Hints hints ) {
if (hints == null) {
this.crs = DefaultGeographicCRS.WGS84;
hints = GeoTools.getDefaultHints();
hints.put(Hints.CRS, crs );
}
else {
this.crs = (CoordinateReferenceSystem) hints.get( Hints.CRS );
if( crs == null ){
throw new NullPointerException("A CRS Hint is required in order to use GeometryFactoryImpl");
}
}
this.positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
hintsWeCareAbout.put(Hints.CRS, crs );
hintsWeCareAbout.put(Hints.POSITION_FACTORY, positionFactory );
}
代码示例来源:origin: org.geotools/gt-legacy
/**
* Create a new FeatureTypeFactory with the given typeName.
*
* @param name The typeName of the feature to create.
*
* @return A new FeatureTypeFactory instance.
*
* @throws FactoryRegistryException If there exists a configuration error.
*/
public static FeatureTypeFactory newInstance(String typeName)
throws FactoryRegistryException {
// warning not sure if CommonFactoryFinder is going to cache the instance or not?
//
Hints hints = GeoTools.getDefaultHints();
if( hints == null ){
hints = new Hints( Hints.FEATURE_TYPE_FACTORY_NAME, typeName );
}
else {
hints.put( Hints.FEATURE_TYPE_FACTORY_NAME, typeName );
}
hints.put( Hints.FEATURE_TYPE_FACTORY_NAME, typeName );
return new DefaultFeatureTypeFactory();
}
代码示例来源:origin: org.geotools/gt2-geometry
/** Just the defaults, use GeometryFactoryFinder for the rest */
public PrimitiveFactoryImpl( Hints hints ) {
if (hints == null) {
this.crs = DefaultGeographicCRS.WGS84;
hints = GeoTools.getDefaultHints();
hints.put(Hints.CRS, crs );
geomValidate = true;
hints.put(Hints.GEOMETRY_VALIDATE, geomValidate);
}
else {
this.crs = (CoordinateReferenceSystem) hints.get( Hints.CRS );
if( crs == null ){
throw new NullPointerException("A CRS Hint is required in order to use PrimitiveFactoryImpl");
}
geomValidate = (Boolean) hints.get( Hints.GEOMETRY_VALIDATE );
if (geomValidate == null) {
geomValidate = true;
}
}
this.positionFactory = GeometryFactoryFinder.getPositionFactory(hints);
hintsWeCareAbout.put(Hints.CRS, crs );
hintsWeCareAbout.put(Hints.POSITION_FACTORY, positionFactory );
hintsWeCareAbout.put(Hints.GEOMETRY_VALIDATE, geomValidate );
}
代码示例来源:origin: org.geotools/gt-coverage
/**
* Creates a new instance of GeoTiffMetadata2CRSAdapter
*
* @param hints
* a map of hints to locate the authority and object factories.
* (can be null)
*/
public GeoTiffMetadata2CRSAdapter(Hints hints) {
final Hints tempHints = hints != null ? new Hints(hints) : DEFAULT_HINTS;
this.hints = (Hints) tempHints.clone();
allAuthoritiesFactory = hints != null ? new AllAuthoritiesFactory(this.hints):
DEFAULT_ALLAUTHORITIES_FACTORY;
// factory = new ThreadedEpsgFactory(hints);
datumObjFactory = ReferencingFactoryFinder.getDatumFactory(this.hints);
crsFactory = ReferencingFactoryFinder.getCRSFactory(this.hints);
csFactory = ReferencingFactoryFinder.getCSFactory(this.hints);
tempHints.put(Hints.DATUM_AUTHORITY_FACTORY, allAuthoritiesFactory);
tempHints.put(Hints.CS_FACTORY, csFactory);
tempHints.put(Hints.CRS_FACTORY, crsFactory);
tempHints.put(Hints.MATH_TRANSFORM_FACTORY, mtFactory);
factories = ReferencingFactoryContainer.instance(tempHints);
}
代码示例来源:origin: locationtech/geowave
public Query invertQuery(
@DescribeParameter(
name = "outputBBOX",
description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv,
@DescribeParameter(
name = "outputWidth",
description = "Width of the output raster") final Integer argOutputWidth,
@DescribeParameter(
name = "outputHeight",
description = "Height of the output raster") final Integer argOutputHeight,
@DescribeParameter(
name = "pixelSize",
description = "The pixel size to base subsampling on") final Double pixelSize,
final Query targetQuery,
final GridGeometry targetGridGeometry) throws ProcessException {
// add to the query hints
targetQuery.getHints().put(SUBSAMPLE_ENABLED, true);
targetQuery.getHints().put(OUTPUT_WIDTH, argOutputWidth);
targetQuery.getHints().put(OUTPUT_HEIGHT, argOutputHeight);
targetQuery.getHints().put(OUTPUT_BBOX, argOutputEnv);
if (pixelSize != null) {
targetQuery.getHints().put(PIXEL_SIZE, pixelSize);
}
return targetQuery;
}
}
代码示例来源:origin: locationtech/geowave
public Query invertQuery(
@DescribeParameter(
name = "outputBBOX",
description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv,
@DescribeParameter(
name = "outputWidth",
description = "Width of the output raster") final Integer argOutputWidth,
@DescribeParameter(
name = "outputHeight",
description = "Height of the output raster") final Integer argOutputHeight,
@DescribeParameter(
name = "pixelSize",
description = "The pixel size to decimate by") final Double pixelSize,
final Query targetQuery,
final GridGeometry targetGridGeometry) throws ProcessException {
// add to the query hints
targetQuery.getHints().put(OUTPUT_WIDTH, argOutputWidth);
targetQuery.getHints().put(OUTPUT_HEIGHT, argOutputHeight);
targetQuery.getHints().put(OUTPUT_BBOX, argOutputEnv);
if (pixelSize != null) {
targetQuery.getHints().put(PIXEL_SIZE, pixelSize);
}
return targetQuery;
}
}
代码示例来源:origin: org.geotools/gt-metadata
/**
* Adds a hint value to the set of {@linkplain GeoTools#getDefaultHints default hints}.
* Default hints can be added by call to this {@code putDefaultHint} method, to the
* {@link GeoTools#init} method or by {@linkplain System#getProperties system properties}
* with keys defined by the {@link String} constants in the {@link GeoTools} class.
*
* @param key The hint key.
* @param value The hint value.
* @return The previous value of the specified key, or {@code null} if none.
* @throws IllegalArgumentException If {@link Hints.Key#isCompatibleValue()}
* returns {@code false} for the specified value.
*
* @since 2.4
*/
public static Object putSystemDefault(final RenderingHints.Key key, final Object value) {
final boolean changed;
final Object old;
synchronized (GLOBAL) {
changed = ensureSystemDefaultLoaded();
old = GLOBAL.put(key, value);
}
if (changed || !Utilities.equals(value, old)) {
GeoTools.fireConfigurationChanged();
}
return old;
}
代码示例来源:origin: org.geotools/gt2-metadata
/**
* Adds a hint value to the set of {@linkplain GeoTools#getDefaultHints default hints}.
* Default hints can be added by call to this {@code putDefaultHint} method, to the
* {@link GeoTools#init} method or by {@linkplain System#getProperties system properties}
* with keys defined by the {@link String} constants in the {@link GeoTools} class.
*
* @param key The hint key.
* @param value The hint value.
* @return The previous value of the specified key, or {@code null} if none.
* @throws IllegalArgumentException If {@link Hints.Key#isCompatibleValue()}
* returns {@code false} for the specified value.
*
* @since 2.4
*/
public static Object putSystemDefault(final RenderingHints.Key key, final Object value) {
final boolean changed;
final Object old;
synchronized (GLOBAL) {
changed = ensureSystemDefaultLoaded();
old = GLOBAL.put(key, value);
}
if (changed || !Utilities.equals(value, old)) {
GeoTools.fireConfigurationChanged();
}
return old;
}
代码示例来源:origin: org.geoserver.csw/csw-core
adapted.getHints().put(GetRecords.KEY_BASEURL, request.getBaseUrl());
代码示例来源:origin: org.locationtech.geogig/geogig-datastore
@Test
public void testRespectsSuppliedGeometryFactory() throws Exception {
SimpleFeatureSource source = this.linesSource;
Query query = new Query();
GeometryFactory suppliedGeomFac = new GeometryFactory(
new PrecisionModel(PrecisionModel.FLOATING_SINGLE));
query.getHints().put(Hints.JTS_GEOMETRY_FACTORY, suppliedGeomFac);
SimpleFeature[] collection = (SimpleFeature[]) source.getFeatures(query).toArray();
assertEquals(3, collection.length);
for (SimpleFeature f : collection) {
Geometry g = (Geometry) f.getDefaultGeometry();
assertSame(suppliedGeomFac, g.getFactory());
}
}
代码示例来源:origin: locationtech/geogig
@Test
public void testRespectsSuppliedGeometryFactory() throws Exception {
SimpleFeatureSource source = this.linesSource;
Query query = new Query();
GeometryFactory suppliedGeomFac = new GeometryFactory(
new PrecisionModel(PrecisionModel.FLOATING_SINGLE));
query.getHints().put(Hints.JTS_GEOMETRY_FACTORY, suppliedGeomFac);
SimpleFeature[] collection = (SimpleFeature[]) source.getFeatures(query).toArray();
assertEquals(3, collection.length);
for (SimpleFeature f : collection) {
Geometry g = (Geometry) f.getDefaultGeometry();
assertSame(suppliedGeomFac, g.getFactory());
}
}
代码示例来源:origin: locationtech/geogig
@Test
public void testScreenMap() throws Exception {
// Test a single point to make sure the feature tree itself (with the same bounds as the
// point it contains) doesn't write to the ScreenMap
deleteAndAdd(points2);
deleteAndAdd(points3);
geogig.command(CommitOp.class).setMessage("drop to 1 point").call();
Query query = new Query(pointsName);
ScreenMap screenMap = new ScreenMap(-180, -90, 360, 180);
screenMap.setSpans(1.0, 1.0);
screenMap.setTransform(IdentityTransform.create(2));
query.getHints().put(Hints.SCREENMAP, screenMap);
SimpleFeatureIterator iter = pointsSource.getFeatures(query).features();
assertTrue(iter.hasNext());
assertEquals(points1.getIdentifier().getID(), iter.next().getID());
assertTrue(screenMap.get(boundsOf(points1)));
}
代码示例来源:origin: org.locationtech.geogig/geogig-datastore
@Test
public void testScreenMap() throws Exception {
// Test a single point to make sure the feature tree itself (with the same bounds as the
// point it contains) doesn't write to the ScreenMap
deleteAndAdd(points2);
deleteAndAdd(points3);
geogig.command(CommitOp.class).setMessage("drop to 1 point").call();
Query query = new Query(pointsName);
ScreenMap screenMap = new ScreenMap(-180, -90, 360, 180);
screenMap.setSpans(1.0, 1.0);
screenMap.setTransform(IdentityTransform.create(2));
query.getHints().put(Hints.SCREENMAP, screenMap);
SimpleFeatureIterator iter = pointsSource.getFeatures(query).features();
assertTrue(iter.hasNext());
assertEquals(points1.getIdentifier().getID(), iter.next().getID());
assertTrue(screenMap.get(boundsOf(points1)));
}
内容来源于网络,如有侵权,请联系作者删除!