forked from geosolutions-it/geoserver-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First cut of private implementation for geosolutions-it#199
- Loading branch information
1 parent
25759e8
commit 8496756
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
} | ||
} |