/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.geoforge.worldwindogc.layer;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.avlist.AVListImpl;
import gov.nasa.worldwind.exception.WWRuntimeException;
import gov.nasa.worldwind.util.Logging;
import gov.nasa.worldwind.wms.WMSTiledImageLayer;
import org.geoforge.worldwindogc.capabilities.GfrWMSCapabilities;
import org.geoforge.worldwindogc.util.GfrDataConfigurationUtils;
/**
*
* @author bantchao
*/
abstract public class GfrWMSTiledImageLayer extends WMSTiledImageLayer
{
private static final String[] formatOrderPreference = new String[]
{
"image/dds",
"image/png",
"image/jpeg"
};
protected GfrWMSTiledImageLayer(GfrWMSCapabilities caps, AVList params)
throws Exception
{
super(wmsGetParamsFromCapsDoc(caps, params));
}
public static AVList wmsGetParamsFromCapsDoc(
GfrWMSCapabilities caps, AVList params) throws
WWRuntimeException,
IllegalArgumentException
{
if (caps == null)
{
String message = Logging.getMessage("nullValue.WMSCapabilities");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
if (params == null)
params = new AVListImpl();
//try
{
GfrDataConfigurationUtils.s_getWMSLayerConfigParams(caps, formatOrderPreference, params);
}
/*catch (IllegalArgumentException e)
{
String message = Logging.getMessage("WMS.MissingLayerParameters");
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
throw new IllegalArgumentException(message, e);
}
catch (WWRuntimeException e)
{
String message = Logging.getMessage("WMS.MissingCapabilityValues");
Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
throw new IllegalArgumentException(message, e);
}*/
setFallbacks(params);
// Setup WMS URL builder.
params.setValue(AVKey.WMS_VERSION, caps.getVersion());
params.setValue(AVKey.TILE_URL_BUILDER, new URLBuilder(params));
// Setup default WMS tiled image layer behaviors.
params.setValue(AVKey.USE_TRANSPARENT_TEXTURES, true);
return params;
}
}