|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.zuercher.gpx2map.source.AbstractCachedMapSource
us.zuercher.gpx2map.source.AbstractTiledUrlMapSource
us.zuercher.gpx2map.source.terraserver_usa.TerraserverUsaMapSource
public class TerraserverUsaMapSource
TerraserverUsaMapSource extends AbstractTiledUrlMapSource
for the
Terraserver USA map server.
The TerraserverUsaMapSource requires the following properties:
Name | Description | Values |
---|---|---|
type | Determines the map type. |
Type 1: 1, USGS_DOQ, DOQ Type 2: 2, USGS_DRG, DRG Type 4: 4, USGS_Urban, USGS_Urban_Area, Urban |
scale | Determines the map scale. | Desired scale in meters/pixel. Acceptable values run from 0.25 to 512, in powers of 2 (e.g., 0.25, 0.5, 1, 2, 4, ...). |
The TerraserverUsaMapSource has no optional properties.
See the
package description
for links to details on how the Terraserver USA map server works.
Nested Class Summary | |
---|---|
private static class |
TerraserverUsaMapSource.StripeDescription
StripeDescription describes the map tiles required from a particular UTM zone. |
Field Summary | |
---|---|
private LatLon |
northWestLatLon
Map boundary: northwest corner. |
private static List<MapSourcePropertyDescriptor> |
PROPERTIES
|
private static String |
PROPERTY_SCALE
Scale property name. |
private static String |
PROPERTY_TYPE
Type property name. |
private int |
rowCount
Number of rows of map tiles in the image. |
private double |
scale
Map scale in meters per pixel. |
private static MapSourcePropertyDescriptor |
SCALE_PROPERTY_DESCRIPTOR
Scale property descriptor. |
private LatLon |
southEastLatLon
Map boundary: southeast corner. |
private int |
startRow
Starting Y coordinate for all map tiles. |
private int |
terraserverScale
Map scale converted to Terraserver scale value. |
private int |
totalColumnCount
Total number of map tile columns in the image. |
private String |
type
Map type. |
private static String |
TYPE_1
Type values. |
private static String |
TYPE_2
|
private static String |
TYPE_4
|
private static MapSourcePropertyDescriptor |
TYPE_PROPERTY_DESCRIPTOR
Type property descriptor. |
private static MapSourcePropertyChoice |
TYPE_USGS_DOQ
Type property descriptor DOQ choice. |
private static MapSourcePropertyChoice |
TYPE_USGS_DRG
Type property descriptor DRG choice. |
private static MapSourcePropertyChoice |
TYPE_USGS_URBAN
Type property descriptor Urban Area choice. |
private int |
typeId
Map type id. |
private static String |
URL
Map tile URL. |
private TreeMap<Integer,TerraserverUsaMapSource.StripeDescription> |
zoneStripeMap
Map of UTM zone to stripe description. |
Constructor Summary | |
---|---|
TerraserverUsaMapSource()
|
Method Summary | |
---|---|
private File |
computeAddrTypeScaleZoneCacheDir(int xAddr,
int zone)
Computes the cache directory for a given Terraserver X coordinate and UTM zone. |
private File |
computeCacheFile(File addrTypeScaleCacheDir,
int yAddr)
Computes the cache file for a given X coordinate directory and the given Y coordinate. |
private void |
computeStripeCoords()
Using the map boundaries, which tiles must be downloaded from which UTM zones. |
Point |
computeTerraServerTileAddress(UTM location)
Computes the Terraserver X/Y coordinates for a given UTM coordinate. |
private File |
computeTerraserverUsaCacheDir()
Computes the cache directory for this map source, relative to the application cache directory. |
private File |
computeTypeCacheDir()
Computes the cache directory for the current map type, based on the Terraserver map source cache directory. |
private File |
computeTypeScaleCacheDir()
Computes the cache directory for the current map scale, based on the current map type's cache directory. |
private File |
computeTypeScaleZoneCacheDir(int zone)
Computes the cache directory for a given map zone, based on the current map scale's cache directory. |
UTM |
computeUtm(int xAddr,
int yAddr,
int zone,
char letter)
Computes the UTM coordinate of the southwest corner of the given Terraserver map tile. |
void |
downloadTiles(ProgressMeter meter)
Downloads map tiles. |
private static MapSourcePropertyChoice[] |
generateScaleChoices()
Creates map scale choices. |
protected int |
getColumnCount()
Returns the total number of columns in the map. |
Dimension |
getImageSize()
Returns the stitched image size. |
double |
getMapScale()
Returns the number of meter per map pixel. |
List<MapSourcePropertyDescriptor> |
getProperties()
Returns a list of all Terraserver USA map source property descriptors . |
protected int |
getRowCount()
Returns the total number of rows in the map. |
protected File |
getTile(int col,
int row)
Returns the location of a given map tile in the cache. |
Dimension |
getTileSize()
Returns the dimensions of a single map tile. |
private int |
getUtmMultiplier()
Returns the multiplier used to convert UTM addresses to Terraserver tile addresses, based on the current map scale and type. |
Point |
mapLocationToPixel(LatLon location)
Maps a location to a pixel on the stitched map. |
Point |
mapLocationToPixel(UTM location)
Maps a location to a pixel on the stitched map. |
private String |
pad(int value,
int digits)
Converts the given integer value into a String that is at least the given number of digits long. |
void |
setBoundingBox(LatLon northWestLatLon,
LatLon southEastLatLon)
Configures the map's boundaries. |
void |
setProperty(String name,
String value)
Sets the given property to the given value. |
void |
setScale(double mpp)
Configures the map scale in meters per pixel. |
void |
setType(String typeName)
Configures the map type by name. |
Methods inherited from class us.zuercher.gpx2map.source.AbstractTiledUrlMapSource |
---|
download, download, getCompressedCacheFileExtension, stitchTiles |
Methods inherited from class us.zuercher.gpx2map.source.AbstractCachedMapSource |
---|
getCacheDir, setCacheDir |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface us.zuercher.gpx2map.source.MapSource |
---|
setCacheDir, stitchTiles |
Field Detail |
---|
private static final String URL
private static final String PROPERTY_TYPE
private static final MapSourcePropertyChoice TYPE_USGS_DOQ
private static final MapSourcePropertyChoice TYPE_USGS_DRG
private static final MapSourcePropertyChoice TYPE_USGS_URBAN
private static final MapSourcePropertyDescriptor TYPE_PROPERTY_DESCRIPTOR
private static final String PROPERTY_SCALE
private static final MapSourcePropertyDescriptor SCALE_PROPERTY_DESCRIPTOR
private static final String TYPE_1
private static final String TYPE_2
private static final String TYPE_4
private static final List<MapSourcePropertyDescriptor> PROPERTIES
private LatLon northWestLatLon
private LatLon southEastLatLon
private String type
TYPE_1
, TYPE_2
, TYPE_4
.
private int typeId
private double scale
private int terraserverScale
private TreeMap<Integer,TerraserverUsaMapSource.StripeDescription> zoneStripeMap
computeStripeCoords()
private int totalColumnCount
private int startRow
private int rowCount
Constructor Detail |
---|
public TerraserverUsaMapSource()
Method Detail |
---|
public void setType(String typeName)
typeName
- one of the names given in TYPE_USGS_DOQ
,
TYPE_USGS_DRG
, or TYPE_USGS_URBAN
.
IllegalMapSourcePropertyValueException
- if typeName is not one
of the legal values.public void setScale(double mpp)
mpp
- map scale in meters per pixel.
IllegalMapSourcePropertyValueException
- if the map scale is not
a power of in range
[0.25, 512].public void setBoundingBox(LatLon northWestLatLon, LatLon southEastLatLon)
setBoundingBox
in interface MapSource
northWestLatLon
- the northwest corner of the mapsouthEastLatLon
- the southeast corner of the mapMapSource.setBoundingBox(LatLon, LatLon)
public void downloadTiles(ProgressMeter meter) throws IOException
We first compute the tiles that we require from each zone and then download all necessary tiles for each zone in succession.
downloadTiles
in interface MapSource
meter
- a progress meter
IOException
- if there's an error downloading tilesMapSource.downloadTiles(ProgressMeter)
private void computeStripeCoords()
zoneStripeMap
with the results.
In simple cases, data is only required from a single zone.
public Point mapLocationToPixel(LatLon location)
Conversions
to convert the location to a UTM
coordinate
and calls mapLocationToPixel(UTM)
.
mapLocationToPixel
in interface MapSource
location
- location to determine on the map
MapSource.mapLocationToPixel(LatLon)
public Point mapLocationToPixel(UTM location)
location
- the UTM coordinate to determine on the map
Point
on the stitched map cooresponding to the
given location.mapLocationToPixel(LatLon)
private String pad(int value, int digits)
value
- value to convertdigits
- minimum number of digits
digits
or more characters in length.private File computeTerraserverUsaCacheDir()
private File computeTypeCacheDir()
computeTerraserverUsaCacheDir()
private File computeTypeScaleCacheDir()
computeTypeCacheDir()
private File computeTypeScaleZoneCacheDir(int zone)
zone
- UTM zone
computeTypeScaleCacheDir()
private File computeAddrTypeScaleZoneCacheDir(int xAddr, int zone)
xAddr
- Terraserver X coordinatezone
- URM zone
computeTypeScaleZoneCacheDir(int)
private File computeCacheFile(File addrTypeScaleCacheDir, int yAddr)
addrTypeScaleCacheDir
- the cache directory for the X coordinate
within which the Y coordinate map tile
will be stored.yAddr
- the Y coordinate
computeAddrTypeScaleZoneCacheDir(int, int)
public Point computeTerraServerTileAddress(UTM location)
location
- UTM coordinate to retrieve X/Y values for.
public UTM computeUtm(int xAddr, int yAddr, int zone, char letter)
xAddr
- Terraserver map tile X coordinateyAddr
- Terraserver map tile Y coordinatezone
- UTM zoneletter
- UTM letter designator
private int getUtmMultiplier()
public Dimension getImageSize()
getImageSize
in interface MapSource
MapSource.getImageSize()
public Dimension getTileSize()
public List<MapSourcePropertyDescriptor> getProperties()
map source property descriptors
.
getProperties
in interface MapSource
MapSourcePropertyDescriptor
public void setProperty(String name, String value)
setProperty
in interface MapSource
name
- the property namevalue
- the property's value
IllegalMapSourcePropertyNameException
- if the property name is
not known
IllegalMapSourcePropertyValueException
- if the property value is
illegalpublic double getMapScale()
getMapScale
in interface MapSource
protected int getColumnCount()
getColumnCount
in class AbstractTiledUrlMapSource
AbstractTiledUrlMapSource.getColumnCount()
protected int getRowCount()
getRowCount
in class AbstractTiledUrlMapSource
AbstractTiledUrlMapSource.getRowCount()
protected File getTile(int col, int row)
getTile
in class AbstractTiledUrlMapSource
col
- 0-based column indexrow
- 0-based row index
AbstractTiledUrlMapSource.getTile(int, int)
private static MapSourcePropertyChoice[] generateScaleChoices()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |