|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.placelab.demo.mapview.WadData
This class reads a map wad and gets out all the maps and allows accessing of all the maps and places in it. Alternatively, it can write a map wad.
Wads are zip files with the following structure: + map.wad - apcache.txt (a text file of the aps like from placelab.org) - defaults.txt (a SectionedFile described below) + maps - maps.index (a SectionedFile described below) - mapname.jpg/gif/png/png OR mapname.tiger.zip (us census tiger format data) - mapname.meta (a SectionedFile described below) + places - places.index (a SectionedFile described below) - place-set-name.txt (a SectionedFile described below) - icons - beer-icon.jpg/gif/png maps.index has the following structure [Maps] mapname=mapname.meta mapname.meta has the following structure [Map] # origin_lat and origin_lon are lower left corner values origin_lat=47.349829 origin_lon=-122.98327 pixels_per_lat=100.01 pixels_per_lon=9994.39828 # OR you may specify the upper right corner's lat and lon upper_right_lat=47.449829 upper_right_lon=-122.99327 image=images/mapimage1.jpg/gif/png NEW: alternatively you can specify the following structure for us census tiger data embedded in a mapwad: [TigerMap] data=maps/mapname.tiger.txt The Tiger data is the type 1 and type 2 record files concatenated together in that order. This is likely to change in the future. places.index has the following structure [Places] place-set-name=place-set-name.txt place-set-name.txt has the following structure [place name] # image references are relative to the root of the wad icon_file=places/icons/beer_icon.jpg lat=46.19829 lon=-122.8132 text=Some descriptive text url=http://www.whitehouse.gov type=radical/AP/etc [other place name] etc ... NEW: Regions can specify rectangular areas on the map. They do not have types like places do In a directory called regions ... regions.index has the following structure [Regions] region_name=region_name.meta region.meta has the following structure [Region] origin_lat=47.1 origin_lon=-122.1 upper_right_lat=47.8 upper_right_lon=-122.0 text=Some descriptive text url=http://www.whitehouse.gov defaults.txt has the following structure [Map] mapname=1 [Places] placeset1=1 placeset2=1 placeset3=1 # ... and as many place sets as you would like to specifythe defaults file specifies what the wad author thinks should be the first set of things that people might want to see. There is no guarantee that they will be the first things displayed, it is only a suggestion. Also note that while you must specify a map if you have a defaults file, you needn't specify any place sets. Defaults files are not required.
Note that while place set definition file references in places.index are relative references, the image file references actually in the place set files are relative to the root of the wad. This is done so that people can put their images wherever they want in the wad, since ../ type references are not allowed.
| Field Summary | |
protected java.lang.String |
defaultMap
|
protected java.util.Hashtable |
defaultPlaces
|
protected java.util.Hashtable |
imageResources
|
protected java.util.Hashtable |
maps
|
protected java.util.Hashtable |
places
|
protected java.util.Hashtable |
regions
|
protected java.util.zip.ZipFile |
wad
|
protected java.lang.String |
wadPath
|
| Constructor Summary | |
WadData()
|
|
WadData(java.lang.String pathToWad)
|
|
| Method Summary | |
void |
addPlace(java.lang.String setName,
PlaceBacking place)
|
java.util.Hashtable |
allPlaceSets()
|
boolean |
containsAPCache()
Find out whether the map wad contains an ap cache or not |
java.io.InputStream |
getArbitraryResource(java.lang.String path)
|
MapBacking |
getDefaultMap()
Returns the MapBacking specified as the default for the wad or null if no MapBacking is specified |
java.util.Hashtable |
getDefaultPlaceSets()
Returns a Hashtable containing the default place sets (Hashtables of PlaceBackings) for the wad or null if no default place sets are specified. |
org.eclipse.swt.graphics.ImageData |
getImageData(java.lang.String path)
Returns an ImageData for the file at path in the wad |
MapBacking |
getMap(java.lang.String mapName)
|
java.util.Hashtable |
getMaps()
|
PlaceBacking |
getPlace(java.lang.String setName,
java.lang.String placeName)
|
java.util.Hashtable |
getPlaceSet(java.lang.String setName)
|
java.util.Enumeration |
getPlaceSetNames()
|
RegionBacking |
getRegion(java.lang.String regionName)
|
java.util.Hashtable |
getRegions()
|
java.util.Hashtable |
loadAPCacheAsPlaces(org.eclipse.swt.graphics.ImageData useIcon)
Loads the ap cache into a special place set accessable under the place set name APs. |
JDBMMapper |
loadAPCacheIntoMapper(java.lang.String dbPath)
Uses JDBMMapLoader to load the ap cache into the WifiMapper |
void |
putMap(BitmapMapBacking map)
|
void |
putPlaceSet(java.lang.String setName,
java.util.Hashtable set)
|
void |
putRegion(RegionBacking region)
|
void |
saveWad()
|
void |
saveWad(java.io.OutputStream out)
Writes out the current state of the waddata as a zip file to the supplied OutputStream Note that since images from waddata are lazily loaded you should not do this:
WadData wad = new WadData(somePath);
wad.putRegion(someRegionYouWantToAdd);
wad.saveWad(new FileOutputStream(somePath)));
If you do the above, it will break because the wad may need to load the image data
from disk as it is copying them, but those images are now gone. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.util.Hashtable maps
protected java.util.Hashtable places
protected java.util.Hashtable regions
protected java.util.Hashtable imageResources
protected java.lang.String defaultMap
protected java.util.Hashtable defaultPlaces
protected java.util.zip.ZipFile wad
protected java.lang.String wadPath
| Constructor Detail |
public WadData(java.lang.String pathToWad)
throws java.io.IOException,
WadDataFormatException
public WadData()
| Method Detail |
public org.eclipse.swt.graphics.ImageData getImageData(java.lang.String path)
throws java.io.IOException
java.io.IOExceptionpublic boolean containsAPCache()
public JDBMMapper loadAPCacheIntoMapper(java.lang.String dbPath)
throws java.io.IOException,
WadDataFormatException
java.io.IOException
WadDataFormatException
public java.util.Hashtable loadAPCacheAsPlaces(org.eclipse.swt.graphics.ImageData useIcon)
throws java.io.IOException,
WadDataFormatException
useIcon - you must provide an ImageData to use as an
icon for the place, because every place must have an icon, and
I surely don't have one laying around.
java.io.IOException
WadDataFormatExceptionpublic MapBacking getMap(java.lang.String mapName)
public java.util.Hashtable getMaps()
public void putMap(BitmapMapBacking map)
public java.util.Enumeration getPlaceSetNames()
public RegionBacking getRegion(java.lang.String regionName)
public java.util.Hashtable getRegions()
public void putRegion(RegionBacking region)
public void saveWad(java.io.OutputStream out)
throws java.io.IOException
WadData wad = new WadData(somePath);
wad.putRegion(someRegionYouWantToAdd);
wad.saveWad(new FileOutputStream(somePath)));
If you do the above, it will break because the wad may need to load the image data
from disk as it is copying them, but those images are now gone. If you want to do this
use the saveWad() method instead, which will manage setting up a temporary file
for you to get around this problem.
java.io.IOException
public void saveWad()
throws java.io.IOException
java.io.IOExceptionpublic java.util.Hashtable allPlaceSets()
public java.util.Hashtable getPlaceSet(java.lang.String setName)
public PlaceBacking getPlace(java.lang.String setName,
java.lang.String placeName)
public void putPlaceSet(java.lang.String setName,
java.util.Hashtable set)
public void addPlace(java.lang.String setName,
PlaceBacking place)
public MapBacking getDefaultMap()
public java.util.Hashtable getDefaultPlaceSets()
public java.io.InputStream getArbitraryResource(java.lang.String path)
throws java.io.IOException
java.io.IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||