Package gov.nasa.worldwind.layers
Class BasicLayerFactory
- java.lang.Object
-
- gov.nasa.worldwind.BasicFactory
-
- gov.nasa.worldwind.layers.BasicLayerFactory
-
- All Implemented Interfaces:
Factory
public class BasicLayerFactory extends BasicFactory
A factory that createsLayer
instances.
-
-
Constructor Summary
Constructors Constructor Description BasicLayerFactory()
Creates an instance of BasicLayerFactory; otherwise does nothing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
createFromConfigSource(java.lang.Object configSource, AVList params)
Creates a layer or layer list from a general configuration source.protected Layer
createFromLayerDocument(org.w3c.dom.Element domElement, AVList params)
Create a layer described by an XML layer description.protected LayerList
createLayerList(org.w3c.dom.Element[] layerElements, AVList params)
Create a list of layers described by an array of XML layer description elements.protected LayerList[]
createLayerLists(org.w3c.dom.Element[] elements, AVList params)
Create a collection of layer lists and their included layers described by an array of XML layer-list description elements.protected Layer
createShapefileLayer(org.w3c.dom.Element domElement, AVList params)
Creates a shapefile layer described by an XML layer description.protected Layer
createTiledImageLayer(org.w3c.dom.Element domElement, AVList params)
Create aTiledImageLayer
layer described by an XML layer description.protected Layer
doCreateFromCapabilities(OGCCapabilities caps, AVList params)
Implemented by subclasses to perform the actual object creation.protected java.lang.Object
doCreateFromElement(org.w3c.dom.Element domElement, AVList params)
Create the objects described in an XML element containing layer and/or layer-list descriptions.-
Methods inherited from class gov.nasa.worldwind.BasicFactory
create, create, createFromCapabilities, doCreateFromCapabilities
-
-
-
-
Method Detail
-
createFromConfigSource
public java.lang.Object createFromConfigSource(java.lang.Object configSource, AVList params)
Creates a layer or layer list from a general configuration source. The source can be one of the following:- a
URL
- a
File
- a
InputStream
Element
- a
String
holding a file name, a name of a resource on the classpath, or a string representation of a URL
For tiled image layers, this maps the
serviceName
attribute of theLayer/Service
element of the XML configuration file to the appropriate base tiled image layer type. Service types recognized are:- "WMS" for layers that draw their data from a WMS web service.
- "WWTileService" for layers that draw their data from a WorldWind tile service.
- "Offline" for layers that draw their data only from the local cache.
- Specified by:
createFromConfigSource
in interfaceFactory
- Overrides:
createFromConfigSource
in classBasicFactory
- Parameters:
configSource
- the configuration source. See above for supported types.params
- key-value parameters to override or supplement the information provided in the specified configuration source. May be null.- Returns:
- a layer or layer list.
- Throws:
java.lang.IllegalArgumentException
- if the configuration file name is null or an empty string.WWUnrecognizedException
- if the layer service type is unrecognized.WWRuntimeException
- if object creation fails. The exception indicating the source of the failure is included as theThrowable.initCause(Throwable)
.
- a
-
doCreateFromCapabilities
protected Layer doCreateFromCapabilities(OGCCapabilities caps, AVList params)
Description copied from class:BasicFactory
Implemented by subclasses to perform the actual object creation. This default implementation always returns null.- Overrides:
doCreateFromCapabilities
in classBasicFactory
- Parameters:
caps
- the capabilities document.params
- a list of configuration properties. These properties override any specified in the capabilities document. The list should contain theAVKey.LAYER_NAMES
property for services that define layers, indicating which named layers described in the capabilities document to create. If this argumet is null or contains no layers, the first named layer is used.- Returns:
- the requested object.
-
doCreateFromElement
protected java.lang.Object doCreateFromElement(org.w3c.dom.Element domElement, AVList params) throws java.lang.Exception
Create the objects described in an XML element containing layer and/or layer-list descriptions. Nested layer lists and included layers are created recursively.- Overrides:
doCreateFromElement
in classBasicFactory
- Parameters:
domElement
- an XML element describing the layers and/or layer lists.params
- any properties to apply when creating the included layers.- Returns:
- a
Layer
,LayerList
or array ofLayerList
s, as described by the specified description. - Throws:
java.lang.Exception
- if an exception occurs during creation. Exceptions occurring during creation of internal layers or layer lists are not re-thrown but are logged. The layer or layer list associated with the exception is not contained in the returned object.
-
createLayerLists
protected LayerList[] createLayerLists(org.w3c.dom.Element[] elements, AVList params)
Create a collection of layer lists and their included layers described by an array of XML layer-list description elements.Any exceptions occurring during creation of the layer lists or their included layers are logged and not re-thrown. The layers associated with the exceptions are not included in the returned layer list.
- Parameters:
elements
- the XML elements describing the layer lists to create.params
- any parameters to apply when creating the included layers.- Returns:
- an array containing the specified layer lists.
-
createLayerList
protected LayerList createLayerList(org.w3c.dom.Element[] layerElements, AVList params)
Create a list of layers described by an array of XML layer description elements.Any exceptions occurring during creation of the layers are logged and not re-thrown. The layers associated with the exceptions are not included in the returned layer list.
- Parameters:
layerElements
- the XML elements describing the layers to create.params
- any parameters to apply when creating the layers.- Returns:
- a layer list containing the specified layers.
-
createFromLayerDocument
protected Layer createFromLayerDocument(org.w3c.dom.Element domElement, AVList params)
Create a layer described by an XML layer description.- Parameters:
domElement
- the XML element describing the layer to create.params
- any parameters to apply when creating the layer.- Returns:
- a new layer
- Throws:
WWUnrecognizedException
- if the layer type or service type given in the describing element is unrecognized.- See Also:
createTiledImageLayer(org.w3c.dom.Element, gov.nasa.worldwind.avlist.AVList)
-
createTiledImageLayer
protected Layer createTiledImageLayer(org.w3c.dom.Element domElement, AVList params)
Create aTiledImageLayer
layer described by an XML layer description.- Parameters:
domElement
- the XML element describing the layer to create. The element must inculde a service name identifying the type of service to use to retrieve layer data. Recognized service types are "Offline", "WWTileService" and "OGC:WMS".params
- any parameters to apply when creating the layer.- Returns:
- a new layer
- Throws:
WWUnrecognizedException
- if the service type given in the describing element is unrecognized.
-
createShapefileLayer
protected Layer createShapefileLayer(org.w3c.dom.Element domElement, AVList params)
Creates a shapefile layer described by an XML layer description. This delegates layer construction to the factory class associated with the configuration key "gov.nasa.worldwind.avkey.ShapefileLayerFactory".- Parameters:
domElement
- the XML element describing the layer to create. The element must contain the shapefile location, and may contain elements specifying shapefile attribute mappings, shape attributes to assign to created shapes, and layer properties.params
- any parameters to apply when creating the layer.- Returns:
- a new layer
-
-