public class IlvWMSReader extends Object implements IlvMapRegionOfInterestIterator, IlvPersistentObject
URL url = new URL("http://www.roguewave.com"); // This will not work and is only given as an example. Put a real WMS server URL
here!
IlvWMSReader reader = new IlvWMSReader(url);
IlvCoordinateSystem cs = IlvCoordinateSystemProperty.GetCoordinateSystem(manager);
reader.setTransformation(IlvCoordinateTransformation.CreateTransformation(cs,IlvGeographicCoordinateSystem.KERNEL));
String[] layerNames = reader.getAvailableLayers();
reader.setLayerNames(layerNames);
IlvMapFeature feature;
while((feature = reader.getNextFeature()) != null) {
IlvGraphic g = reader.getDefaultFeatureRenderer().makeGraphic(feature, reader.getTransformation());
manager.addObject(g, false);
}
| Constructor and Description |
|---|
IlvWMSReader(IlvInputStream stream)
Constructs an
IlvWMSReader from an IlvInputStream. |
IlvWMSReader(String surl)
Constructs an
IlvWMSreader from a string
representation of a URL. |
IlvWMSReader(URL url)
Constructs an
IlvWMSreader from a URL. |
| Modifier and Type | Method and Description |
|---|---|
protected XMLReader |
createCapabilitiesXMLReader()
Creates a default XML reader used to parse capabilities.
|
void |
dispose()
Releases the resources allocated by the feature iterator
(files, connections, and so on).
|
String[] |
getAvailableLayers()
Returns the names of the available layers.
|
double[] |
getBBox()
Returns the bounding box used for the query to the server.
|
URL |
getCapabilityURL()
Returns the
URL used to retrieve the capabilities of the server. |
IlvCoordinateSystem |
getCoordinateSystem()
Returns the spatial reference system that describes the coordinate
system of geometric coordinates of the map features.
|
IlvFeatureRenderer |
getDefaultFeatureRenderer()
Returns the renderer used to translate map features into
IlvGraphics. |
InputStream |
getErrorStream()
Retrieves the error stream, if an error occurs.
|
File |
getFeaturesFile()
Returns a file with a content suitable for passing to an
IlvFeatureSelectorPanel. |
InputStream |
getFeaturesStream()
Returns a stream with a content suitable for passing to an
IlvFeatureSelectorPanel. |
String |
getImageFormat()
Retrieves the image format used to construct the request.
|
double |
getImageSize()
Returns the requested image size, which is a floating number between 0 (excluded) and 1.
|
Rectangle2D |
getLatLonBounds()
Returns the latitude/longitude bounds for the list of all geometries or null if such is not available.
|
IlvCoordinate |
getLowerRightCorner()
Returns the lower right corner of the rectangle containing all
the map feature of the list, or
null
if the iterator cannot provide this information. |
URL |
getMapURL()
Gets the
URL to be used to retrieve the image from the server. |
static int |
getMaxImageSize()
Returns the maximum image size allowed by this reader
|
IlvMapFeature |
getNextFeature()
Returns the next map feature of the iterator or
null, if the iteration is finished. |
String |
getNextLayerName()
Returns the layer name to be processed in the next call to
getNextFeature. |
IlvWMSLayerNode[] |
getNodes(String[] layers)
Returns the array of the layers which the names are specified as arguments.
|
String |
getRS(boolean check)
Returns the SRS of this reader as specified by
setSRS(String). |
IlvWMSServerNode |
getServer()
Returns the server node.
|
IlvCoordinateTransformation |
getTransformation()
Returns the transformation used to read in images from the WMS.
|
IlvCoordinate |
getUpperLeftCorner()
Returns the upper left corner of the rectangle containing all
the map features of the list, or
null
if the iterator cannot provide this information. |
URL |
getURL()
Returns the URL given at construction time.
|
String |
getVersion()
Returns the version of the supported WMS protocol.
|
static String |
getWKT(String tok)
Returns the Well Known Text corresponding to the SRS whose EPSG number is given as argument.
|
boolean |
isFlatteningLayers()
Indicates if the reader is rendering all the layers into a single image or not.
|
boolean |
isGeoreferenced()
Returns
true if the map reader can provide the
source projection of its map features. |
boolean |
isTransparency()
Indicates if the requested image contains transparent pixels or not.
|
IlvMapFeature |
makeMapFeature(URL u,
IlvWMSLayerNode node)
Constructs the map feature from this
URL. |
URL |
makeURL(IlvWMSLayerNode node)
Creates the
URL that points to the image to retrieve. |
void |
restart()
Rewinds the iterator for a new use.
|
void |
setBBox(double[] box)
Set the bounding box used for the query to the server.
|
void |
setCoordinateSystem(IlvCoordinateSystem cs)
Sets the coordinate system for this reader.
|
void |
setFlatteningLayers(boolean flatten)
Indicates if the reader should render all the layers into a single image.
|
void |
setImageFormat(String f)
Sets the image format to be used in the request.
|
void |
setImageSize(double sz)
Sets the image size requested by this reader.
|
void |
setLayerNames(String[] layerNames)
Sets the names of the layers to be read by this reader.
|
void |
setRegionOfInterest(double lonMin,
double latMin,
double lonMax,
double latMax)
Sets the region of interest to return features for.
|
void |
setRS(String srs)
Sets the SRS of this reader.
|
void |
setTransformation(IlvCoordinateTransformation transformation)
Sets the transformation to use when reading images from the kernel into the
manager coordinate system.
|
void |
setTransparency(boolean tr)
Indicates if the requested image contains transparent pixels or not.
|
void |
setVersion(String version)
Sets the version number to be used in the request to the server.
|
void |
write(IlvOutputStream stream)
Writes this reader to an
IlvOutputStream. |
public IlvWMSReader(URL url)
IlvWMSreader from a URL.url - The URL of the server.public IlvWMSReader(String surl) throws MalformedURLException
IlvWMSreader from a string
representation of a URL.surl - The String representation of the URL.MalformedURLExceptionpublic IlvWMSReader(IlvInputStream stream) throws IlvReadFileException
IlvWMSReader from an IlvInputStream.stream - The stream to read from.IlvReadFileException - if an error occurspublic void write(IlvOutputStream stream) throws IOException
IlvOutputStream.write in interface IlvPersistentObjectstream - The stream to write to.IOException - if an error occurspublic String getVersion()
public void restart()
restart in interface IlvMapReusableFeatureIteratorprotected XMLReader createCapabilitiesXMLReader() throws ParserConfigurationException, SAXException
SAXParserFactory instance.ParserConfigurationException - if there is a parser configuration error.SAXException - if the XML description cannot be parsed properly.SAXParserFactory.newSAXParser()public URL getCapabilityURL() throws MalformedURLException
URL used to retrieve the capabilities of the server.URL used to retrieve the capabilities of the server.MalformedURLExceptionpublic void setLayerNames(String[] layerNames)
layerNames - An array of strings containing the list of layer names
to be read.public void setFlatteningLayers(boolean flatten)
flatten - Set to true to render all the layers into a single image,
or false to produce an IlvMapFeature for each layer.public boolean isFlatteningLayers()
true if the reader is rendering all the layers into a single image,
otherwise false.public IlvMapFeature getNextFeature() throws IOException
null, if the iteration is finished.
The features returned are features containing IlvMapRasterGeometry geometries.getNextFeature in interface IlvMapFeatureIteratornull, if the iteration is finished.IOExceptionpublic URL getURL()
public URL getMapURL()
URL to be used to retrieve the image from the server.URL to be used to retrieve the image from the server or
null, if no feature is available.public URL makeURL(IlvWMSLayerNode node)
URL that points to the image to retrieve.node - The IlvWMSLayerNode.URL.public void setImageSize(double sz)
sz - The requested image size, between 0 (excluded) and one (included).public double getImageSize()
setImageSize(double)public String getRS(boolean check)
setSRS(String).check - Specifies if the method should check for SRS validity.public void setRS(String srs)
srs - The SRS to set.public void setVersion(String version)
version - The version number to be used in the request to the server.public void setImageFormat(String f)
f - The image format to be used in the request.public String getImageFormat()
setImageFormat, then this format is returned.
Otherwise the first of the image formats specified in the capabilities is returned, if any.public void setTransparency(boolean tr)
tr - Set to true to retrieve a transparent image, otherwise false.public boolean isTransparency()
true if the requested image contains transparent pixels, otherwise false.public static String getWKT(String tok)
tok - The EPSG SRS numberpublic IlvMapFeature makeMapFeature(URL u, IlvWMSLayerNode node) throws IOException
URL.u - The URL, pointing to the image to be retrieved.node - The IlvWMSLayerNodeIlvMapFeature with an IlvMapRasterGeometry.IOExceptionpublic InputStream getErrorStream()
getNextFeature().null, if no error occurred.public boolean isGeoreferenced()
true if the map reader can provide the
source projection of its map features.
This reader is georeferenced, so this method returns true.isGeoreferenced in interface IlvMapFeatureIteratorpublic void setCoordinateSystem(IlvCoordinateSystem cs)
cs - The coordinate system to be set.public IlvCoordinateSystem getCoordinateSystem()
getCoordinateSystem in interface IlvMapFeatureIteratornull
if the coordinate system is unknown.public IlvCoordinate getUpperLeftCorner()
null
if the iterator cannot provide this information.getUpperLeftCorner in interface IlvMapFeatureIteratorpublic IlvCoordinate getLowerRightCorner()
null
if the iterator cannot provide this information.getLowerRightCorner in interface IlvMapFeatureIteratorpublic IlvFeatureRenderer getDefaultFeatureRenderer()
IlvGraphics.
This implementation returns an IlvRasterImageRenderer.getDefaultFeatureRenderer in interface IlvMapFeatureIteratorIlvGraphics.public void dispose()
dispose in interface IlvMapFeatureIteratorpublic IlvWMSServerNode getServer()
public void setRegionOfInterest(double lonMin,
double latMin,
double lonMax,
double latMax)
IlvMapFeatureIterator.getNextFeature() method should not return any feature which geometry is outside this area.setRegionOfInterest in interface IlvMapRegionOfInterestIteratorlonMin - longitude min in radians.latMin - latitude min in radians.lonMax - longitude max in radians.latMax - latitude max in radians.public Rectangle2D getLatLonBounds()
getLatLonBounds in interface IlvMapRegionOfInterestIteratorpublic void setTransformation(IlvCoordinateTransformation transformation)
transformation - The transformation used to read images.public IlvCoordinateTransformation getTransformation()
public File getFeaturesFile() throws IOException
IlvFeatureSelectorPanel.
It is the responsibility of the caller to delete this file.File containing the available features.IOExceptionpublic InputStream getFeaturesStream() throws IOException
IlvFeatureSelectorPanel.InputStream containing the available features.IOExceptionpublic String[] getAvailableLayers()
public IlvWMSLayerNode[] getNodes(String[] layers)
layers - The name of the layers to retrieve.public String getNextLayerName()
getNextFeature.getNextFeature.public double[] getBBox()
public void setBBox(double[] box)
box - the bounding box to use.public static int getMaxImageSize()
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.