All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vfny.geoserver.action.data.CalculateBoundingBoxAction Maven / Gradle / Ivy

There is a newer version: 1.7.0
Show newest version
/*
 * Created on Feb 9, 2004
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package org.vfny.geoserver.action.data;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.geotools.data.DataStore;
import org.geotools.data.FeatureSource;
import org.geotools.feature.FeatureType;
import org.vfny.geoserver.action.ConfigAction;
import org.vfny.geoserver.config.DataConfig;
import org.vfny.geoserver.config.DataStoreConfig;
import org.vfny.geoserver.config.FeatureTypeConfig;
import org.vfny.geoserver.global.UserContainer;
import org.vfny.geoserver.util.DataStoreUtils;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * CalculateBoundingBoxAction purpose.
 * 

* Description of CalculateBoundingBoxAction ... *

* *

* Capabilities: *

*
    *
  • * Feature: description *
  • *
*

* Example Use: *

*

 * CalculateBoundingBoxAction x = new CalculateBoundingBoxAction(...);
 * 
* * @author rgould, Refractions Research, Inc. * @author $Author: dmzwiers $ (last modification) * @version $Id: CalculateBoundingBoxAction.java 7693 2007-11-01 09:31:11Z aaime $ */ public final class CalculateBoundingBoxAction extends ConfigAction { public ActionForward execute(ActionMapping mapping, ActionForm form, UserContainer user, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { FeatureTypeConfig ftConfig = (FeatureTypeConfig) request.getSession() .getAttribute(DataConfig.SELECTED_FEATURE_TYPE); DataConfig dataConfig = getDataConfig(); DataStoreConfig dsConfig = dataConfig.getDataStore(ftConfig.getDataStoreId()); DataStore dataStore = null; try { dataStore = dsConfig.findDataStore(request.getSession().getServletContext()); FeatureType featureType = dataStore.getSchema(ftConfig.getName()); FeatureSource fs = dataStore.getFeatureSource(featureType.getTypeName()); ftConfig.setLatLongBBox(DataStoreUtils.getBoundingBoxEnvelope(fs)); request.getSession().setAttribute(DataConfig.SELECTED_FEATURE_TYPE, ftConfig); return mapping.findForward("config.data.type.editor"); } finally { if(dataStore != null) dataStore.dispose(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy