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 |
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 |
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)
Converts a GeoTools name to the syntax used by the specified JNDI context.
|
static String |
fixName(String name)
Converts a GeoTools name to the syntax used by the GeoTools
JNDI context.
|
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(Hints hints)
Returns the default initial context.
|
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 applicationContext)
Provides GeoTools with the JNDI context for resource lookup.
|
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.
|
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 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 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:
type
- public static Manifest getManifest(Class<?> type)
This can be used to quickly verify packaging information.
type
- public void setLoggerFactory(LoggerFactory<?> factory)
This method is the same as Logging.GEOTOOLS.setLoggerFactory(factory)
. GeoTools
ships with support for Commons-logging and log4j. This method exists to allow you supply
your own implementation (this is sometimes required when using a GeoTools application in an
exotic environment like Eclipse, OC4J or your application).
factory
- The logger factory to use.Logging.setLoggerFactory(LoggerFactory)
public static void init(Hints hints)
org.geotools
namespace sent to the Java logger are redirected
to Commons-logging.
org.geotools
namespace sent to the
Java logger are redirected to Log4J.
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()
org.geotools
namespace sent to the Java logger are redirected
to Commons-logging.
org.geotools
namespace sent to the
Java logger are redirected to Log4J.
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.
public static void init(InitialContext applicationContext)
applicationContext
- The initial context to use.getInitialContext(org.geotools.util.factory.Hints)
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)
hints
- public static EntityResolver getEntityResolver(Hints hints)
SAXParser
.hints
- An optional set of hints, or null
if none, see Hints.ENTITY_RESOLVER
.null
)public static InitialContext getInitialContext(Hints hints) throws NamingException
hints
- An optional set of hints, or null
if none.null
).NamingException
- if the initial context can't be created.init(InitialContext)
public static void clearInitialContext() throws NamingException
NamingException
public static String fixName(String name)
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.public static String fixName(Context context, String name)
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–2019 Geotools. All rights reserved.