Oracle Maps 8-17
■
min_tile_width specifies the width of map tiles at the highest zoom level. The width is specified in map data units.
■
max_tile_width specifies the width of the map tiles at the lowest zoom level. The width is specified in map data units.
For the map tile server to be able to generate the definitions of individual zoom levels automatically, you must specify either of the following combinations of the preceding
attributes:
■
levels, min_scale, and max_scale
■
levels, min_tile_width, and max_tile_width When the zoom levels are defined this way, the map tile server automatically derives
the definition of all the individual zoom levels and updates the XML definition with the zoom_level elements generated for the zoom levels. You can then make
adjustments to each zoom level if you want.
Each zoom level is assigned a zoom level number by the map tile server based on the order in which the zoom levels are defined. The first zoom level defined in the zoom_
levels element is zoom level 0, the second zoom level is zoom level 1, and so on. These zoom level numbers are used in the tile requests to refer to the predefined zoom
levels.
The zoom_level element specifies a predefined zoom level, and it has several attributes. The description attribute is optional and specifies the text description of
the zoom level. The level_name attribute is optional and specifies the name of the zoom level. The scale attribute specifies the map scale of the zoom level; it is
required if the attributes tile_width and tile_height are not defined. The tile_ width and tile_height attributes specify the tile width and height, respectively, in
map data units. The fetch_larger_tiles attribute is optional and specifies whether to fetch larger map images instead of the small map image tiles; a value of
TRUE the default means that larger map images that may consist multiple map tiles will be fetched and broken into small map image tiles, which might save network
round trips between the map tile server and the map services provider.
In the zoom_level element, you must specify either the scale attribute or both the tile_width and tile_height elements.
The tile_bound element within the zoom_level element optionally specifies the bounding box of the cached map tiles for the zoom level. The map tile server only
fetches tiles inside this box, and returns a blank tile if the requested tile is outside this box. The bounding box is specified by a rectangle specified in map data coordinate
system. The rectangle is specified by a coordinates element explained earlier in this section If you specify the tile_bound element within the zoom_level
element, it overrides the overall cache bounding box settings specified by the tile_ bound element that is above it in the XML hierarchy.
8.2.3 External Map Source Adapter
An external map source adapter is the interface between a map tile server and an external map services provider. When a map image tile needs to be fetched from the
external map services provider, the map tile server calls the adapter with information about the zoom level, size, and location of the tile. The adapter then constructs a
provider-specific request, sends the request to the external map services provider, and return the resulting image tile to the map tile server.
8-18 Oracle Fusion Middleware Users Guide for Oracle MapViewer
The external map source adapter is a Java class that must extends the abstract Java class oracle.mapviewer.share.mapcache.MapSourceAdapter, which is
defined as follows:
public abstract class MapSourceAdapter {
public abstract String getMapTileRequestTileDefinition tile; public byte[] getTileImageBytesTileDefinition tile ;
public Properties getProperties ; }
An adapter that extends this class must implement the following method:
■
public String getMapTileRequestTileDefinition tile This method should implement the logic to construct the HTTP request string that
can be sent to the map services provider to fetch the map image tile. For example, if the URL of a map tile is
http:myhostmymapserver?par1=v1par2=v2par3=v3, the HTTP request string returned by this method should be par1_v1par2=v2par3=v3.
When the map tile server cannot find a specific map tile, it calls the getTileImageBytes method to fetch the binary data of the tile image, and that
method calls the getMapTileRequest method to construct the map tile request before fetching the tile. The getMapTileRequest method takes one parameter: a
TileDefinition object that specifies the zoom level, bounding box, image size and image format of the requested tile. This method returns the HTTP request
string.
The map source adapter also inherits all methods implemented in class MapSourceAdapter. Among them, the following methods are more important than
the others:
■
public byte[] getTileImageBytesTileDefinition tile This method fetches the actual binary map tile image data from the external map
service provider. This method is already implemented. It calls the abstract method getMapTileRequest to construct the map tile request and sends the request to
the external map services provider. If the map tiles cannot be fetched by sending HTTP requests, you can override this method to implement the appropriate logic
to fetch an image tile from the map source. This method takes one parameter: a TileDefinition object that specifies the zoom level, bounding box, image size,
and image format of the requested tile. This method returns the binary tile image data encoded in the image format specified in the map tile layer configuration
settings.
■
public Properties getProperties This method returns the provider-specific parameters defined in the map tile layer
configuration settings explained in Section 8.2.2.2
. The MapSourceAdapter and TileDefinition classes are packaged inside
mvclient.jar, which can be found under the directory MAPVIEWER_ HOME
webWEBlib. Example 8–4
shows an external map source adapter.
Example 8–4 External Map Source Adapter
This is a sample map source adapter that can be used to fetch map tiles from a MapViewer instance.
Oracle Maps 8-19
package mcsadapter ; import java.awt.Dimension;
import java.net.URL; import java.util.Properties;
import oracle.lbs.mapclient.MapViewer; import oracle.lbs.mapcommon.MapResponse;
import oracle.mapviewer.share.mapcache.; The map source adapter must extend class
oracle.lbs.mapcache.cache.MapSourceAdapter. public class MVAdapter extends MapSourceAdapter
{ Gets the map tile request string that is to be sent to the map
service provider URL. param tile tile definition
return request string public String getMapTileRequestTileDefinition tile
{ Get map source specified parameters
Properties props = this.getProperties ; String dataSource = props.getPropertydata_source ;
String baseMap = props.getPropertybase_map ; Use oracle.lbs.mapclient.MapViewer to construct the request string
MapViewer mv = new MapViewerthis.getMapServiceURL ; mv.setDataSourceNamedataSource;
mv.setBaseMapNamebaseMap; mv.setDeviceSizenew Dimensiontile.getImageWidth,
tile.getImageHeight; mv.setCenterAndSizetile.getBoundingBox.getCenterX,
tile.getBoundingBox.getCenterY, tile.getBoundingBox.getHeight;
int format = MapResponse.FORMAT_PNG_STREAM ; String req = null ;
switchtile.getImageFormat {
case TileDefinition.FORMAT_GIF: mv.setImageFormatMapResponse.FORMAT_GIF_URL;
req = mv.getMapRequest.toXMLString.replaceFirst format=\GIF_URL\, format=\GIF_STREAM\ ;
break ; case TileDefinition.FORMAT_PNG:
mv.setImageFormatMapResponse.FORMAT_PNG_URL; req = mv.getMapRequest.toXMLString.replaceFirst
format=\PNG_URL\, format=\PNG_STREAM\ ; break ;
case TileDefinition.FORMAT_JPEG: mv.setImageFormatMapResponse.FORMAT_JPEG_URL;
req = mv.getMapRequest.toXMLString.replaceFirst format=\JPEG_URL\, format=\JPEG_STREAM\;
break ; }
byte[] reqStr = null ;
8-20 Oracle Fusion Middleware Users Guide for Oracle MapViewer
try {
reqStr = req.getBytesUTF8 ; }
catchException e {}
Return the request string. return xml_request=+ new StringreqStr;
} }
Example 8–5 shows the implementation of the
MapSourceAdapter.getTileImageBytes method.
Example 8–5 MapSourceAdapter.getTileImageBytes Implementation
Fetches the map image tile from the external map service provider by sending the HTTP map tile request to the map service provider, and
return the binary tile image data. You can rewrite this method so that the adapter can fetch the tile from an external map service provider
that does not accept HTTP requests at all. param tile the tile definition
return the binary tile image data. throws Exception
public byte[] getTileImageBytesTileDefinition tile throws Exception
{ construct request string
String request = getMapTileRequesttile ; ifrequest == null
{ throw new ExceptionNull map tile request string in map source adapter ;
} set proxy settings
Proxy proxy = null ; If the proxyHost is NONE, the request is sent directly to the
external server. If the proxyHost is a valid host, that host will be used as the proxy server. If the proxyHost is empty of omitted,
the global proxy setting in mapViewerConfig.xml will be in effect. boolean noProxy = NONE.equalsIgnoreCasegetProxyHost ;
ifgetProxyHost=null noProxy {
SocketAddress addr = new InetSocketAddressproxyHost, proxyPort; proxy = new ProxyProxy.Type.HTTP, addr;
} send the request and get the tile image binary
PrintWriter wr = null ; BufferedInputStream bis = null;
try {
String urlStr = mapServiceURL ; ifGET.equalsIgnoreCasehttpMethod
urlStr = mapServiceURL + ? + request ;
Oracle Maps 8-21
log.finesthttp +httpMethod+: +urlStr; URL url = new URLurlStr;
Open a URL connection based on current proxy setting URLConnection conn =
proxy=null? url.openConnectionproxy: noProxy? url.openConnectionProxy.NO_PROXY:
url.openConnection ; conn.setConnectTimeouttimeOut;
ifGET.equalsIgnoreCasegetHTTPMethod conn.connect;
else {
conn.setDoOutputtrue; wr = new PrintWriterconn.getOutputStream;
wr.printrequest; wr.flush;
wr.close; wr = null ;
} bis = new BufferedInputStreamconn.getInputStream;
byte[] result = toBytesbis ; bis.close;
bis = null ; return result;
} catchException ioe
{ throw new ExceptionFailed to fetch external map tile., ioe;
} finally
{ try
{ ifbis = null
{ bis.close;
bis = null; }
ifwr = null {
wr.close; wr = null;
} }
catchIOException ioee {
throw ioee; }
} }
8.3 Feature of Interest FOI Server
A feature of interest FOI is a business entity or geographical feature that can be manipulated or interacted with by a JavaScript map client running in the Web browser.
FOI data is dynamically displayed and is not part of the map tile layer. FOIs can be any spatial geometry type, such as points, line strings, and polygons. The ability to
search, browse, inspect, and interact with FOIs is essential for location-based services.