MapTileMaker (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.dataAccess.mapTile
Class MapTileMaker

    java.lang.Object
      com.bbn.openmap.image.ImageServer
          com.bbn.openmap.dataAccess.mapTile.MapTileMaker

All Implemented Interfaces:
  EmptyTileHandler, PropertyConsumer

    public class MapTileMaker

extends ImageServer
implements EmptyTileHandler

The MapTileMaker is an ImageServer extension that knows how to create image tile sets, like the kind of tiles used by Google Maps and OpenStreetMap, Tile Map Service (TMS). It uses ZoomLayerMarker objects to define how tiles are created for different zoom levels. You can run this class as an application. With the -create option, it will create a sample properties file to demonstrate what properties are needed to run it.

The properties look much like the ImageServer properties, with a couple of additional values:

     ### MapTileMaker/ImageServer properties ###
     antialiasing=false
     # Image formatter definition
     formatters=formatter1
     # Layer definitions for layers that are available for zoom levels
     layers=layer1 layer2 ...
     rootDir=Path to top level directory for tiles
     zoomLevels=zoom1 zoom2

     formatter1=.class=com.bbn.openmap.image.PNGImageIOFormatter
     layer1.class=com.bbn.openmap.layer.shape.ShapeLayer
     # ... layer1 properties follow, see layer docs for specific properties for that layer

     # Then, for each zoom level
     zoom1.class=com.bbn.openmap.image.ZoomLevelInfo
     #Optional, to limit tile areas created, in sets of 4, must be in lat,lon order
     zoom1.bounds=lat lon lat lon
     zoom1.description=Tiles for zoom level 4
     #Marker names for layers to be rendered, the property prefixes for the layers held by TileMaker
     zoom1.layers=layer1 layer2
     zoom1.name=ZoomLayerInfo 4
     zoom1.zoomLevel=4
     # If defined, copies of zoomLevel tiles will be scaled through range level.
     zoom1.range=0

     # and repeat for every zoomLevel defined

Author:
  dietrick

Field Summary
`protected MapTileCoordinateTransform` | `mtcTransform`
`static java.lang.String` | `ROOT_DIRECTORY_PROPERTY`
`protected java.lang.String` | `rootDir`
`protected int` | `TILE_SIZE`
`static java.lang.String` | `ZOOM_LEVELS_PROPERTY`
`protected java.util.List<ZoomLevelMaker>` | `zoomLevels`

Fields inherited from class com.bbn.openmap.image.ImageServer
`AntiAliasingProperty, background, BackgroundProperty, doAntiAliasing, formatter, imageFormatters, ImageFormattersProperty, ImageServerLayersProperty, layers, logger, OpenMapPrefix, projectionFactory, propertiesPrefix`

Fields inherited from interface com.bbn.openmap.PropertyConsumer
`EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty`

Constructor Summary
`MapTileMaker()` Empty constructor that expects to be configured later.
`MapTileMaker(Layer[] layers, ImageFormatter formatter)` Create an TileMaker from an array of Layers and an ImageFormatter.
`MapTileMaker(java.util.Properties props)` To create the TileMaker, you hand it a set of properties that let it create an array of layers, and also to set the properties for those layers.
`MapTileMaker(java.lang.String prefix, java.util.Properties props)` Same as the other constructor, except that the properties can have a prefix in front of them.
`MapTileMaker(java.lang.String prefix, java.util.Properties props, java.util.Map<java.lang.String,Layer> instantiatedLayers)` Create an TileMaker that should be configured with a Properties file.

Method Summary
`void` | `createDefaultZoomLevels(int maxZoomLevel)`
`java.awt.image.BufferedImage` | `getImageForEmptyTile(java.lang.String imagePath, int x, int y, int zoomLevel, MapTileCoordinateTransform mtcTransform, Projection proj)` EmptyTileHandler method, called when a MapTileFactory needs to create and return a missing tile.
`java.util.Properties` | `getProperties(java.util.Properties props)` Part of the PropertyConsumer interface.
`java.util.Properties` | `getPropertyInfo(java.util.Properties props)` Part of the PropertyConsumer interface.
`java.lang.String` | `getRootDir()`
`java.util.List<ZoomLevelMaker>` | `getZoomLevels()`
`java.awt.geom.Point2D` | `latLonToTileUV(java.awt.geom.Point2D latlon, int zoom)`
`java.awt.geom.Point2D` | `latLonToTileUV(java.awt.geom.Point2D latlon, int zoom, java.awt.geom.Point2D ret)`
`static void` | `main(java.lang.String[] args)`
`byte[]` | `makeTile(double uvx, double uvy, int zoomLevel, java.util.List<Layer> layers, Proj proj, java.awt.Paint background)` Creating a tile more freely, when you have a set of layers you want to draw into the tile.
`byte[]` | `makeTile(double uvx, double uvy, ZoomLevelMaker zoomInfo, Proj proj)` Creating the tile using the ImageServer methodology, knowing that the MapTileMaker has been configured with an openmap.properties.file and knows about layers and their marker names.
`java.lang.String` | `makeTileFile(double uvx, double uvy, ZoomLevelMaker zoomInfo, Proj proj)` The main call to make for a tile to be created.
`void` | `makeTiles()` Main call to make a set of tiles.
`void` | `setProperties(java.lang.String prefix, java.util.Properties props)` Set the layers and image type in the properties.
`void` | `setRootDir(java.lang.String rootDir)`
`void` | `setZoomLevels(java.util.List<ZoomLevelMaker> zoomLevels)`
`LatLonPoint` | `tileUVToLatLon(java.awt.geom.Point2D tileUV, int zoom)`
`LatLonPoint` | `tileUVToLatLon(java.awt.geom.Point2D tileUV, int zoom, LatLonPoint ret)`

Methods inherited from class com.bbn.openmap.image.ImageServer
`calculateVisibleLayerMask, createGraphics, createImage, createImage, createImage, createImage, createImage, createImage, createImageFile, createImageFromLayers, createImageFromLayers, getBackground, getBackground, getDoAntiAliasing, getFormattedImage, getFormatter, getFormatters, getFormatters, getLayers, getLayers, getLayers, getMaskedLayers, getProjectionFactory, getPropertyPrefix, getTransparent, setBackground, setDoAntiAliasing, setFormatter, setFormatter, setFormatters, setLayers, setProjectionFactory, setProperties, setProperties, setPropertyPrefix, setTransparent, writeImageFile`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ROOT_DIRECTORY_PROPERTY

    public static final java.lang.String ROOT_DIRECTORY_PROPERTY

See Also:
  Constant Field Values

### ZOOM_LEVELS_PROPERTY

    public static final java.lang.String ZOOM_LEVELS_PROPERTY

See Also:
  Constant Field Values

### rootDir

    protected java.lang.String rootDir

### zoomLevels

    protected java.util.List<ZoomLevelMaker> zoomLevels

### mtcTransform

    protected MapTileCoordinateTransform mtcTransform

### TILE_SIZE

    protected int TILE_SIZE

Constructor Detail

### MapTileMaker

    public MapTileMaker()

  Empty constructor that expects to be configured later.

### MapTileMaker

    public MapTileMaker(java.util.Properties props)

  To create the TileMaker, you hand it a set of properties that let it create an array of layers, and also to set the properties for those layers. The properties file for the ImageServer looks strikingly similar to the openmap.properties file. So, all the layers get set up here...

### MapTileMaker

    public MapTileMaker(java.lang.String prefix,
                        java.util.Properties props)

  Same as the other constructor, except that the properties can have a prefix in front of them. The format of the prefix has to match how the property is specified the the properties file, which may include the period - i.e server1.imageServer.layers, the server1. is the prefix that should get passed in. The ImageMaster does this.

### MapTileMaker

    public MapTileMaker(java.lang.String prefix,
                        java.util.Properties props,
                        java.util.Map<java.lang.String,Layer> instantiatedLayers)

  Create an TileMaker that should be configured with a Properties file. The prefix given is to scope the ImageServer properties to this instance. The Hashtable is for reusing any layers that may already be instantiated.

### MapTileMaker

    public MapTileMaker(Layer[] layers,
                        ImageFormatter formatter)

  Create an TileMaker from an array of Layers and an ImageFormatter. It's assumed that the layers are already configured.

  Parameters:
    `layers` - the array of layers.
    `formatter` - the ImageFormatter to use for the output image format.

Method Detail

### setProperties

    public void setProperties(java.lang.String prefix,
                              java.util.Properties props)

  Description copied from class: `ImageServer`
  Set the layers and image type in the properties. The properties might have a prefix in the file.

  Specified by:
    `setProperties` in interface `PropertyConsumer`
  Overrides:
    `setProperties` in class `ImageServer`
  Parameters:
    `prefix` - a String used by the PropertyConsumer to prepend to each property value it wants to look up - setList.getProperty(prefix.propertyKey). If the prefix had already been set, then the prefix passed in should replace that previous value.
    `props` - a Properties object that the PropertyConsumer can use to retrieve expected properties it can use for configuration.

### getProperties

    public java.util.Properties getProperties(java.util.Properties props)

  Description copied from class: `ImageServer`
  Part of the PropertyConsumer interface.

  Specified by:
    `getProperties` in interface `PropertyConsumer`
  Overrides:
    `getProperties` in class `ImageServer`
  Parameters:
    `props` - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
  Returns:
    Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

### getPropertyInfo

    public java.util.Properties getPropertyInfo(java.util.Properties props)

  Description copied from class: `ImageServer`
  Part of the PropertyConsumer interface.

  Specified by:
    `getPropertyInfo` in interface `PropertyConsumer`
  Overrides:
    `getPropertyInfo` in class `ImageServer`
  Parameters:
    `props` - a Properties object to load the PropertyConsumer properties into. If getList equals null, then a new Properties object should be created.
  Returns:
    Properties object containing PropertyConsumer property values. If getList was not null, this should equal getList. Otherwise, it should be the Properties object created by the PropertyConsumer.

### makeTile

    public byte[] makeTile(double uvx,
                           double uvy,
                           ZoomLevelMaker zoomInfo,
                           Proj proj)

  Creating the tile using the ImageServer methodology, knowing that the MapTileMaker has been configured with an openmap.properties.file and knows about layers and their marker names.

  Parameters:
    `uvx` - uv x pixel coordinate
    `uvy` - uv y pixel coordinate
    `zoomInfo` - zoom level for image tile
    `proj` - projection for tile
  Returns:
    byte[] for raw image bytes

### makeTile

    public byte[] makeTile(double uvx,
                           double uvy,
                           int zoomLevel,
                           java.util.List<Layer> layers,
                           Proj proj,
                           java.awt.Paint background)

  Creating a tile more freely, when you have a set of layers you want to draw into the tile.

  Parameters:
    `uvx` - uv x pixel coordinate
    `uvy` - uv y pixel coordinate
    `zoomLevel` - zoom level for tile
    `layers` - layers to include in image
    `proj` - projection for tile
    `background` - the paint to use for the background of the image.
  Returns:
    byte[] for raw image bytes

### makeTileFile

    public java.lang.String makeTileFile(double uvx,
                                         double uvy,
                                         ZoomLevelMaker zoomInfo,
                                         Proj proj)
                                  throws java.io.IOException

  The main call to make for a tile to be created. This method will cause the correct mapTile method to be called, depending on the configuration of the ZoomLevelMakers.

  Parameters:
    `uvx` -
    `uvy` -
    `zoomInfo` -
    `proj` -
  Returns:
    the final file path used, with any extensions added.
  Throws:
    `java.io.IOException`

### getImageForEmptyTile

    public java.awt.image.BufferedImage getImageForEmptyTile(java.lang.String imagePath,
                                                             int x,
                                                             int y,
                                                             int zoomLevel,
                                                             MapTileCoordinateTransform mtcTransform,
                                                             Projection proj)

  EmptyTileHandler method, called when a MapTileFactory needs to create and return a missing tile.

  Specified by:
    `getImageForEmptyTile` in interface `EmptyTileHandler`
  Parameters:
    `imagePath` - the path of the missing tile that is going to be used as cache lookup later.
    `x` - the uv x coordinate of the tile.
    `y` - the uv y coordinate of the tile.
    `zoomLevel` - the zoom level of the tile.
    `mtcTransform` - the transform that converts x,y coordinates to lat/lon and describes the layout of the uv tile coordinates.
    `proj` - the map projection, in case that matters what should be returned for the empty tile.
  Returns:
    BufferedImage for image tile, or null if there's a problem

### makeTiles

    public void makeTiles()

  Main call to make a set of tiles. The ZoomLevelMaker objects have to be configured correctly. Each ZoomLevelMaker has to have its zoom levels set (initial and range), the bounds of the areas where tiles are desired, and the layers desired on those tiles. For the layers, the ZoomLevelInfo can have a List of Strings corresponding to the property prefixes of the layers already set on the MapTileMaker, or it can have a List of Layer objects to use. The root output directory has to be set in the MapTileMaker. The image formatter also needs to be set.

### getRootDir

    public java.lang.String getRootDir()

### setRootDir

    public void setRootDir(java.lang.String rootDir)

### getZoomLevels

    public java.util.List<ZoomLevelMaker> getZoomLevels()

### setZoomLevels

    public void setZoomLevels(java.util.List<ZoomLevelMaker> zoomLevels)

### createDefaultZoomLevels

    public void createDefaultZoomLevels(int maxZoomLevel)

### latLonToTileUV

    public java.awt.geom.Point2D latLonToTileUV(java.awt.geom.Point2D latlon,
                                                int zoom)

  Parameters:
    `latlon` - a Point2D whose x component is the longitude and y component is the latitude
    `zoom` - Tile Map Service (TMS) style zoom level (0-19 usually)
  Returns:
    The "tile number" whose x and y components each are floating point numbers that represent the distance in number of tiles from the origin of the whole map at this zoom level. At zoom=0, the lat,lon point of 0,0 maps to 0.5,0.5 since there is only one tile at zoom level 0.

### latLonToTileUV

    public java.awt.geom.Point2D latLonToTileUV(java.awt.geom.Point2D latlon,
                                                int zoom,
                                                java.awt.geom.Point2D ret)

### tileUVToLatLon

    public LatLonPoint tileUVToLatLon(java.awt.geom.Point2D tileUV,
                                      int zoom)

  Parameters:
    `tileUV` - a Point2D whose x,y coordinates represent the distance in number of tiles (each 256x256) from the origin (where the origin is 90lat,-180lon)
    `zoom` - Tile Map Service (TMS) style zoom level (0-19 usually)
  Returns:
    a LatLonPoint whose x coordinate is the longitude and y coordinate is the latitude, decimal degrees.

### tileUVToLatLon

    public LatLonPoint tileUVToLatLon(java.awt.geom.Point2D tileUV,
                                      int zoom,
                                      LatLonPoint ret)

### main

    public static void main(java.lang.String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details