public final class GeoTools extends Object
String
constants in this class.
There are many aspects to the configuration of GeoTools:
getDefaultHints()
, the
default values can be provided in application code, or specified using system properties.
init(InitialContext)
method allowing to tell GeoTools about the JNDI context to use.
FactoryFinder
s and register additional
"Factory Iterators" for GeoTools to search using the addFactoryIteratorProvider(org.geotools.util.factory.FactoryIteratorProvider)
method.
Modifier and Type | Field and Description |
---|---|
static String |
CRS_AUTHORITY_EXTRA_DIRECTORY
The system property key for the default value to be
assigned to the
CRS_AUTHORITY_EXTRA_DIRECTORY
hint. |
static String |
DATE_TIME_FORMAT_HANDLING
The system property key for the default value to be
assigned to the
Hints.DATE_TIME_FORMAT_HANDLING hint. |
static Predicate<String> |
DEFAULT_JNDI_VALIDATOR
Default JNDI name validator, allows lookups only on names without a scheme, or using the
java scheme. |
static String |
ENCODE_WKT
The system property key for the default value to be
assigned to the
Hints.ENCODE_EWKT hint. |
static String |
ENTITY_RESOLVER
The system property key for the default value to be
assigned to the
ENTITY_RESOLVER hint. |
static String |
EPSG_DATA_SOURCE
The system property key for the default value to be
assigned to the
EPSG_DATA_SOURCE hint. |
static String |
FORCE_LONGITUDE_FIRST_AXIS_ORDER
The system property key for the default value to be
assigned to the
FORCE_LONGITUDE_FIRST_AXIS_ORDER hint. |
static String |
HTTP_CLIENT
The system property key for the default value to be
assigned to the
Hints.HTTP_CLIENT hint. |
static String |
HTTP_LOGGING
The system property key for the default value to be
assigned to the
Hints.HTTP_LOGGING hint. |
static String |
LOCAL_DATE_TIME_HANDLING
The system property key for the default value to be
assigned to the
Hints.LOCAL_DATE_TIME_HANDLING hint. |
static String |
RESAMPLE_TOLERANCE
The system property key for the default value to be
assigned to the
RESAMPLE_TOLERANCE hint. |
Modifier and Type | Method and Description |
---|---|
static void |
addChangeListener(ChangeListener listener)
Adds the specified listener to the list of objects to inform when system-wide configuration
changed.
|
static void |
addClassLoader(ClassLoader classLoader)
Adds a class loader to be included in the list of class loaders that are used to locate
GeoTools plug-ins.
|
static Hints |
addDefaultHints(Hints hints)
Used to combine provided hints with global GeoTools defaults.
|
static void |
addFactoryIteratorProvider(FactoryIteratorProvider provider)
Adds an alternative way to search for factory implementations.
|
static void |
clearInitialContext()
Clears the initial context (closes it if not null)
|
static void |
fireConfigurationChanged()
Informs every listeners that system-wide configuration changed.
|
static String |
fixName(Context context,
String name)
Deprecated.
With no replacement, GeoTools now uses JNDI lookups as instructed in
#jndiLookup(String) , but does not put any object in the contex, the downstream *
application should do it if necessary instead. |
static String |
fixName(String name)
Deprecated.
With no replacement, GeoTools now uses JNDI lookups as instructed in
jndiLookup(String) , but does not put any object in the contex, the downstream
application should do it if necessary instead. |
static String |
getAboutInfo()
Returns summary information about GeoTools and the current environment.
|
static Properties |
getBuildProperties()
Returns the raw properties object containing all properties about this GeoTools build.
|
static String |
getBuildRevision()
Reports back the vcs revision at which the version of GeoTools was built.
|
static String |
getBuildTimestamp()
Reports back the timestamp at which the version of GeoTools of built.
|
static Hints |
getDefaultHints()
Returns the default set of hints used for the various utility classes.
|
static EntityResolver |
getEntityResolver(Hints hints)
Returns the default entity resolver, used to configure
SAXParser . |
static String |
getEnvironmentInfo()
Returns summary information about the GeoTools version and the host environment.
|
static String |
getGeoToolsJarInfo()
Returns the names of the GeoTools jars on the classpath.
|
static InitialContext |
getInitialContext()
Deprecated.
Please use
jndiLookup(String) instead, or provide an InitialContext to the init(InitialContext) method and use it directly. |
static Manifest |
getManifest(Class<?> type)
Lookup the MANIFEST.MF for the provided class.
|
static Version |
getVersion()
Reports back the version of GeoTools being used.
|
static Version |
getVersion(Class<?> type)
Lookup version for provided class.
|
static void |
init()
Initializes GeoTools for use.
|
static void |
init(Hints hints)
Initializes GeoTools for use.
|
static void |
init(InitialContext initialContext)
Provides GeoTools with the JNDI context for resource lookup.
|
static boolean |
isJNDIAvailable()
Checks if JNDI is available, either because it was initialized, or because it was possible to
create one.
|
static Object |
jndiLookup(String name)
Looks up an object from the JNDI
InitialContext . |
static void |
main(String... args)
Reports the GeoTools version number to the standard output stream.
|
static void |
removeChangeListener(ChangeListener listener)
Removes the specified listener from the list of objects to inform when system-wide
configuration changed.
|
static void |
removeFactoryIteratorProvider(FactoryIteratorProvider provider)
Removes a provider that was previously added.
|
static void |
setJNDINameValidator(Predicate<String> validator)
Sets up a function that will be called to validate the JNDI lookups.
|
static void |
setLoggerFactory(LoggerFactory<?> factory)
Sets the global logger factory.
|
public static final String CRS_AUTHORITY_EXTRA_DIRECTORY
CRS_AUTHORITY_EXTRA_DIRECTORY
hint.public static final String EPSG_DATA_SOURCE
EPSG_DATA_SOURCE
hint.public static final String FORCE_LONGITUDE_FIRST_AXIS_ORDER
FORCE_LONGITUDE_FIRST_AXIS_ORDER
hint.
This setting can provide a transition path for projects expecting a (longitude, latitude) axis order on a system-wide level. Application developpers can set the default value as below:
Note that this system property applies mostly to the default EPSG factory. Most other factories (System.setProperty(FORCE_LONGITUDE_FIRST_AXIS_ORDER, "true");
"CRS"
, "AUTO"
, etc.) don't need this property since
they use (longitude, latitude) axis order by design.public static final String ENTITY_RESOLVER
ENTITY_RESOLVER
hint.
This setting specifies the XML Entity resolver to be used when configuring a SAXParser
public static final String RESAMPLE_TOLERANCE
RESAMPLE_TOLERANCE
hint.
This setting specifies the tolerance used when linearizing warp transformation into piecewise linear ones, by default it is 0.333 pixels
public static final String LOCAL_DATE_TIME_HANDLING
Hints.LOCAL_DATE_TIME_HANDLING
hint.
This setting specifies if dates shall be treated as local dates ignoring time zones.
Hints.LOCAL_DATE_TIME_HANDLING
,
getDefaultHints()
,
Constant Field Valuespublic static final String DATE_TIME_FORMAT_HANDLING
Hints.DATE_TIME_FORMAT_HANDLING
hint.
This setting specifies if GML 2 temporal data shall be formatted using same approach as GML 3+.
Hints.DATE_TIME_FORMAT_HANDLING
,
getDefaultHints()
,
Constant Field Valuespublic static final String ENCODE_WKT
Hints.ENCODE_EWKT
hint.
This setting specifies if geometries with CoordinateReferenceSystem
in the user data shall be encoded as
EWKT or not.
Hints.ENCODE_EWKT
,
getDefaultHints()
,
Constant Field Valuespublic static final String HTTP_CLIENT
Hints.HTTP_CLIENT
hint.
This setting specifies whether we wan't to use a special http client
Hints.HTTP_CLIENT
,
getDefaultHints()
,
Constant Field Valuespublic static final String HTTP_LOGGING
Hints.HTTP_LOGGING
hint.
This setting specifies whether we want to log all http requests.
Hints.HTTP_LOGGING
,
getDefaultHints()
,
Constant Field Valuespublic static String getAboutInfo()
public static String getEnvironmentInfo()
public static String getGeoToolsJarInfo()
public static String getBuildRevision()
public static String getBuildTimestamp()
public static Properties getBuildProperties()
Example from the 14.3 release:
public static Version getVersion()
public static Version getVersion(Class<?> type)
Version number is determined by either:
public static Manifest getManifest(Class<?> type)
This can be used to quickly verify packaging information.
public static void setLoggerFactory(LoggerFactory<?> factory)
This method is the same as calling Logging#setLoggerFactory(factory)
to configure
both Logging.ALL
logger creation.
GeoTools provides logback, log4j, reload4j, and commons-logging factories. This method exists to allow you supply your own implementation (when using a GeoTools library in an exotic environment like Eclipse, OC4J or your application).
If null
is used, the Java logging formatter for console output is replaced by a monoline formatter.
factory
- The logger factory to use, or null for native java util logging.Logging.setLoggerFactory(LoggerFactory)
public static void init(Hints hints)
org.geotools
and javax.media.jai
namespace sent to logger are redirected to SL4J API used by logback.
org.geotools
and javax.media.jai
namespace sent to Java
logger are redirected to Log4J API.
org.geotools
and javax.media.jai
namespace sent to Java
logger are redirected to Log4J 1 API used by
Reload4J.
org.geotools
and javax.media.jai
namespaces
sent to the Java logger are redirected to
Commons-logging.
In addition, the default hints are initialized to the
specified hints
.
Invoking this method is not required fpr the GeoTools library to function. It is just a convenience method for overwriting select Java and GeoTools default settings. Supplying these defaults is not desirable in all settings, such as writing test cases.
Example of typical invocation in a GeoServer environment:
Hints hints = new Hints();
hints.put(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, Boolean.TRUE);
hints.put(Hints.FORCE_AXIS_ORDER_HONORING, "http");
GeoTools.init(hints);
hints
- The hints to use.Logging.setLoggerFactory(String)
,
Logging.forceMonolineConsoleOutput()
,
Hints.putSystemDefault(java.awt.RenderingHints)
,
getDefaultHints()
public static void init()
Primary task is setting up the Java logging framework with a logging factory (if it has not been done already):
org.geotools
and javax.media.jai
namespace sent to logger are redirected to SL4J API used by logback.
org.geotools
and javax.media.jai
namespace sent to Java
logger are redirected to Log4J API.
org.geotools
and javax.media.jai
namespace sent to Java
logger are redirected to Log4J 1 API used by
Reload4J.
org.geotools
and javax.media.jai
namespaces sent to the Java logger are redirected
to Commons-logging.
Invoking this method is not required fpr the GeoTools library to function. It is just a convenience method for overwriting select Java and GeoTools default settings. Supplying these defaults is not always desirable, for example when quickly writing test cases.
public static void init(InitialContext initialContext)
initialContext
- The initial context to use for JNDI lookupjndiLookup(String)
public static Hints getDefaultHints()
GeoTools
class.
Hints.putSystemDefault(java.awt.RenderingHints)
or init(org.geotools.util.factory.Hints)
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.
public static Hints addDefaultHints(Hints hints)
public static EntityResolver getEntityResolver(Hints hints)
SAXParser
.hints
- An optional set of hints, or null
if none, see Hints.ENTITY_RESOLVER
.null
)@Deprecated public static InitialContext getInitialContext() throws NamingException
jndiLookup(String)
instead, or provide an InitialContext
to the init(InitialContext)
method and use it directly.null
).NamingException
- if the initial context can't be created.public static boolean isJNDIAvailable()
public static void setJNDINameValidator(Predicate<String> validator)
validator
- A function returning true if the lookups are meant to be performed, false
otherwise.public static Object jndiLookup(String name) throws NamingException
InitialContext
. By default, it only allows lookups
with no scheme, or inside the java
scheme. One can set up a custom name
validation routine usingname
- NamingException
public static void clearInitialContext() throws NamingException
NamingException
@Deprecated public static String fixName(String name)
jndiLookup(String)
, but does not put any object in the contex, the downstream
application should do it if necessary instead.InitialContext
. GeoTools uses "jdbc:EPSG"
internally, but many
implementaitons use the form "jdbc/EPSG"
. Calling this method before use will set the
name right.name
- Name of the form "jdbc:EPSG"
, or null
.Context.composeName(String,String)
, or null
if the
given name was null.@Deprecated public static String fixName(Context context, String name)
#jndiLookup(String)
, but does not put any object in the contex, the downstream *
application should do it if necessary instead.fixName(String)
, but uses the specified context instead of the GeoTools
one.context
- The context to use, or null
if none.name
- Name of the form "jdbc:EPSG"
, or null
.Context.composeName(String,String)
, or null
if the
given name was null.public static void addFactoryIteratorProvider(FactoryIteratorProvider provider)
FactoryRegistry
has a
default mechanism bundled in it, which uses the content of all META-INF/services
directories found on the classpath. This addFactoryIteratorProvider
method allows to
specify additional discovery algorithms. It may be useful in the context of some frameworks
that use the constructor injection pattern, like the Spring framework.provider
- A new provider for factory iterators.public static void removeFactoryIteratorProvider(FactoryIteratorProvider provider)
provider
- The provider to remove.public static void addChangeListener(ChangeListener listener)
listener
- The listener to add.public static void removeChangeListener(ChangeListener listener)
listener
- The listener to remove.public static void fireConfigurationChanged()
public static void addClassLoader(ClassLoader classLoader)
Client code that calls this method may also need to call FactoryRegistry.scanForPlugins()
on any existing registry to force it to clear its cache and
use the added class loader to locate plugins.
classLoader
- The class loader.public static void main(String... args)
args
- Command line arguments.Copyright © 1996–2023 Geotools. All rights reserved.