Skip to content

Commit

Permalink
changing method names to better fit their purpose
Browse files Browse the repository at this point in the history
some code gets also split up and/or replaced through new methods
  • Loading branch information
kowatsch committed May 18, 2018
1 parent 0a991ed commit e6958eb
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ public static ShareResponse executeCountLengthPerimeterAreaShare(RequestResource

long startTime = System.currentTimeMillis();
ExecutionUtils exeUtils = new ExecutionUtils();
values2 = exeUtils.shareParamEvaluation(keys2, values2);

SortedMap<OSHDBTimestampAndIndex<Boolean>, ? extends Number> result = null;
MapAggregatorByTimestampAndIndex<Boolean, OSMEntitySnapshot> preResult;
MapReducer<OSMEntitySnapshot> mapRed = null;
Expand All @@ -800,6 +800,8 @@ public static ShareResponse executeCountLengthPerimeterAreaShare(RequestResource
String requestURL = null;
DecimalFormat df = exeUtils.defineDecimalFormat("#.##");
TagTranslator tt = DbConnData.tagTranslator;
iP.checkKeysValues(keys2, values2, true);
values2 = iP.createEmptyArrayIfNull(values2);
Integer[] keysInt2 = new Integer[keys2.length];
Integer[] valuesInt2 = new Integer[values2.length];
if (!rPs.isPost())
Expand Down Expand Up @@ -943,7 +945,6 @@ public static ShareGroupByBoundaryResponse executeCountLengthPerimeterAreaShareG

long startTime = System.currentTimeMillis();
ExecutionUtils exeUtils = new ExecutionUtils();
values2 = exeUtils.shareParamEvaluation(keys2, values2);
SortedMap<OSHDBTimestampAndIndex<Pair<Integer, Boolean>>, ? extends Number> result = null;
SortedMap<Pair<Integer, Boolean>, ? extends SortedMap<OSHDBTimestamp, ? extends Number>> groupByResult;
MapReducer<OSMEntitySnapshot> mapRed = null;
Expand All @@ -952,6 +953,8 @@ public static ShareGroupByBoundaryResponse executeCountLengthPerimeterAreaShareG
String requestURL = null;
DecimalFormat df = exeUtils.defineDecimalFormat("#.##");
TagTranslator tt = DbConnData.tagTranslator;
iP.checkKeysValues(keys2, values2, true);
values2 = iP.createEmptyArrayIfNull(values2);
Integer[] keysInt2 = new Integer[keys2.length];
Integer[] valuesInt2 = new Integer[values2.length];
if (!rPs.isPost())
Expand Down Expand Up @@ -1038,13 +1041,12 @@ public static ShareGroupByBoundaryResponse executeCountLengthPerimeterAreaShareG
* @return {@link org.heigit.bigspatialdata.ohsome.ohsomeApi.output.dataAggregationResponse.DefaultAggregationResponse
* DefaultAggregationResponse}
*/
public static RatioResponse executeCountLengthPerimeterAreaRatio(
RequestResource requestResource, RequestParameters rPs, String[] types2, String[] keys2,
String[] values2) throws UnsupportedOperationException, Exception {
public static RatioResponse executeCountLengthPerimeterAreaRatio(RequestResource requestResource,
RequestParameters rPs, String[] types2, String[] keys2, String[] values2)
throws UnsupportedOperationException, Exception {

long startTime = System.currentTimeMillis();
ExecutionUtils exeUtils = new ExecutionUtils();
values2 = exeUtils.ratioParamEvaluation(keys2, values2);
SortedMap<OSHDBTimestampAndIndex<MatchType>, ? extends Number> result = null;
MapAggregatorByTimestampAndIndex<MatchType, OSMEntitySnapshot> preResult;
MapReducer<OSMEntitySnapshot> mapRed = null;
Expand All @@ -1056,6 +1058,8 @@ public static RatioResponse executeCountLengthPerimeterAreaRatio(
TagTranslator tt = DbConnData.tagTranslator;
rPs = iP.fillWithEmptyIfNull(rPs);
iP.processParameters(mapRed, rPs);
iP.checkKeysValues(keys2, values2, false);
values2 = iP.createEmptyArrayIfNull(values2);
Integer[] keysInt1 = new Integer[rPs.getKeys().length];
Integer[] valuesInt1 = new Integer[rPs.getValues().length];
Integer[] keysInt2 = new Integer[keys2.length];
Expand All @@ -1073,7 +1077,7 @@ public static RatioResponse executeCountLengthPerimeterAreaRatio(
valuesInt2[i] = tt.getOSHDBTagOf(keys2[i], values2[i]).getValue();
}
EnumSet<OSMType> osmTypes1 = iP.getOsmTypes();
EnumSet<OSMType> osmTypes2 = iP.checkTypes(types2);
EnumSet<OSMType> osmTypes2 = iP.extractOSMTypes(types2);
EnumSet<OSMType> osmTypes = osmTypes1.clone();
osmTypes.addAll(osmTypes2);
String[] osmTypesString =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,47 +43,6 @@ public DecimalFormat defineDecimalFormat(String format) {
return decForm;
}

/**
* Evaluates the keys2 and values2 <code>String</code> arrays from /share requests.
*
* @param keys2 <code>String</code> array containing the provided keys2 parameters.
* @param values2 <code>String</code> array containing the provided values2 parameters.
* @return <code>String</code> array containing the given (or an empty) values2 array, which is
* not null.
*/
public String[] shareParamEvaluation(String[] keys2, String[] values2) {

if (keys2 == null || keys2.length < 1)
throw new BadRequestException(
"You need to define at least one key if you want to use this resource.");
if (values2 == null)
values2 = new String[0];
if (keys2.length < values2.length)
throw new BadRequestException(
"There cannot be more input values in values2 than in keys2 as values2n must fit to keys2n.");

return values2;
}

/**
* Evaluates the keys2 and values2 <code>String</code> arrays from /ratio requests.
*
* @param keys2 <code>String</code> array containing the provided keys2 parameters.
* @param values2 <code>String</code> array containing the provided values2 parameters.
* @return <code>String</code> array containing the given (or an empty) values2 array, which is
* not null.
*/
public String[] ratioParamEvaluation(String[] keys2, String[] values2) {

if (values2 == null)
values2 = new String[0];
if (keys2.length < values2.length)
throw new BadRequestException(
"There cannot be more input values in values2 than in keys2 as values2n must fit to keys2n.");

return values2;
}

/**
* Gets the geometry from the currently in-use boundary object(s).
*
Expand Down
Loading

0 comments on commit e6958eb

Please sign in to comment.