use of de.fhg.igd.mapviewer.server.MapServer in project hale by halestudio.
the class BBOXPage method updateMap.
/**
* Update the map (i.e. set the map server).
*
* @param caps the WFS capabilities
*/
private void updateMap(WFSCapabilities caps) {
CustomTileMapServer tileServer = new CustomTileMapServer();
// use Stamen Terrain as default map here
tileServer.setUrlPattern("http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg");
tileServer.setAttributionText("Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.");
tileServer.setZoomLevel(16);
MapServer server = tileServer;
Set<GeoPosition> positions = null;
if (caps != null) {
/*
* TODO optimal solution would be using the WMS that serves the
* layers corresponding to the feature types
*/
// collect BBs from feature types
Set<QName> types = new HashSet<>(getWizard().getConfiguration().getTypeNames());
if (types.isEmpty()) {
// no features will be selected
} else {
List<BBox> bbs = new ArrayList<>();
for (QName type : types) {
FeatureTypeInfo info = caps.getFeatureTypes().get(type);
if (info != null && info.getWgs84BBox() != null) {
bbs.add(info.getWgs84BBox());
}
}
if (!bbs.isEmpty()) {
double minX, maxX, minY, maxY;
Iterator<BBox> it = bbs.iterator();
BBox bb = it.next();
minX = bb.getX1();
minY = bb.getY1();
maxX = bb.getX2();
maxY = bb.getY2();
while (it.hasNext()) {
bb = it.next();
minX = Math.min(minX, bb.getX1());
minY = Math.min(minY, bb.getY1());
maxX = Math.max(maxX, bb.getX2());
maxY = Math.max(maxY, bb.getY2());
}
GeoPosition topLeft = new GeoPosition(minX, maxY, 4326);
GeoPosition bottomRight = new GeoPosition(maxX, minY, 4326);
Color back = mapKit.getBackground();
server = new ClippingMapServer(server, topLeft, bottomRight, new Color(back.getRed(), back.getGreen(), back.getBlue(), 170));
positions = new HashSet<>();
positions.add(topLeft);
positions.add(bottomRight);
} else {
// ignore BBs, provide full map
}
}
}
mapKit.setServer(server, true);
if (positions != null) {
try {
mapKit.zoomToPositions(positions);
} catch (Exception e) {
// ignore error
}
}
mapKit.refresh();
}
use of de.fhg.igd.mapviewer.server.MapServer in project hale by halestudio.
the class ConfigurationMapServerFactory method createExtensionObject.
/**
* @see AbstractConfigurationFactory#createExtensionObject()
*/
@Override
public MapServer createExtensionObject() throws Exception {
MapServer server = super.createExtensionObject();
// set name
server.setName(getDisplayName());
// configure map server
IConfigurationElement[] properties = conf.getChildren();
for (IConfigurationElement property : properties) {
// $NON-NLS-1$
String name = property.getAttribute("name");
// $NON-NLS-1$
String value = property.getAttribute("value");
BeanUtils.setProperty(server, name, value);
}
return server;
}
use of de.fhg.igd.mapviewer.server.MapServer in project hale by halestudio.
the class MapFileServerFactory method loadServer.
/**
* Load a map file server with the given name
*
* @param name the server name
* @return the map server or null
*/
private MapServer loadServer(String name) {
String filename = mapFiles.get(name, null);
if (filename == null) {
mapFiles.remove(name);
} else {
File file = new File(filename);
if (file.exists()) {
TileProvider tp;
try {
tp = MapFileTileProvider.createMapFileTileProvider(file);
MapServer server = new TileProviderMapServer(tp);
server.setName(name);
prefServers.put(server, name);
return server;
} catch (MalformedURLException e) {
log.error("Invalid file name", e);
} catch (IOException e) {
log.error("Error loading map file", e);
}
} else {
log.info("Map file not found, removing map: " + filename);
}
}
return null;
}
use of de.fhg.igd.mapviewer.server.MapServer in project hale by halestudio.
the class BasicMapKit method setTileCache.
/**
* Set the tile cache
*
* @param cache the tile cache to use
*/
public void setTileCache(TileCache cache) {
this.cache = cache;
// re-set current map
MapServer server = getServer();
setServer(server, false);
}
Aggregations