Skip to content

Commit

Permalink
First cut of private implementation for geosolutions-it#199
Browse files Browse the repository at this point in the history
  • Loading branch information
cschroedl-gov committed Sep 12, 2016
1 parent 25759e8 commit 8496756
Showing 1 changed file with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3206,4 +3206,75 @@ public void postImport(int i) throws Exception {
importerManager.postImport(i);
}

/**
* Defines multiple modes of recalculating bounding boxes.
*
* @author Carl Schroedl - [email protected]
*/
public enum BBoxRecalculationMode {
/**
* Do not calculate any fields, regardless of the projection, projection
* policy, etc. This might be useful to avoid slow recalculation when
* operating against large datasets.
*/
NONE(""),

/**
* Recalculate the native bounding box, but do not recalculate the
* lat/long bounding box.
*/
NATIVE_BBOX("nativebbox"),

/**
* Recalculate both the native bounding box and the lat/long bounding
* box.
*/
NATIVE_AND_LAT_LON_BBOX("nativebbox,latlonbbox")
;

private final String paramValue;

/**
* Associates the enum value with a URL query string parameter value
* @param paramValue
*/
BBoxRecalculationMode(String paramValue){
this.paramValue = paramValue;
}

/**
* Get the URL param value
* @return The query string parameter value
*/
public String getParamValue(){
return paramValue;
}
}

/**
*
* Recalculate the bounding box for a feature or a type
*
* @param type
* @param workspace
* @param storeName
* @param layerName
* @param calculationMode
* @return true if recalculation succeeded, false otherwise.
*/
private boolean recalculateBBox(StoreType type, String workspace, String storeName, String layerName, BBoxRecalculationMode calculationMode){

String sUrl = restURL + "/rest/workspaces/" + workspace + "/" +
type.getType() +"s/" + storeName + "/" +
type.getTypeName() + "/" +
layerName + "." + Format.XML.toString() + "?recalculate=" +
calculationMode.getParamValue();

LOGGER.debug("Constructed the following url for bounding box recalculation: ");

String sendResult = HTTPUtils.put(sUrl, "", "text/plain", gsuser,
gspass);

return sendResult != null;
}
}

0 comments on commit 8496756

Please sign in to comment.