Skip to content

Commit d8ca442

Browse files
author
Rosario Trischitta
committed
style: change object names in responses
1 parent 90e6637 commit d8ca442

File tree

5 files changed

+42
-46
lines changed

5 files changed

+42
-46
lines changed

src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ExecutionUtils.java

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import org.heigit.bigspatialdata.oshdb.util.tagtranslator.OSMTag;
6262
import org.heigit.bigspatialdata.oshdb.util.tagtranslator.TagTranslator;
6363
import org.heigit.bigspatialdata.oshdb.util.time.TimestampFormatter;
64-
import org.heigit.ohsome.filter.FilterExpression;
6564
import org.heigit.ohsome.ohsomeapi.Application;
6665
import org.heigit.ohsome.ohsomeapi.controller.rawdata.ElementsGeometry;
6766
import org.heigit.ohsome.ohsomeapi.exception.DatabaseAccessException;
@@ -123,10 +122,10 @@ public MapReducer<OSMEntitySnapshot> snapshotFilter(MapReducer<OSMEntitySnapshot
123122
*/
124123
public MapAggregator<OSHDBCombinedIndex<OSHDBTimestamp, Integer>, OSMEntitySnapshot>
125124
snapshotFilter(
126-
MapAggregator<OSHDBCombinedIndex<OSHDBTimestamp, Integer>, OSMEntitySnapshot> mapRed,
127-
Set<OSMType> osmTypes1, Set<OSMType> osmTypes2, Set<SimpleFeatureType> simpleFeatureTypes1,
128-
Set<SimpleFeatureType> simpleFeatureTypes2, Integer[] keysInt1, Integer[] keysInt2,
129-
Integer[] valuesInt1, Integer[] valuesInt2) {
125+
MapAggregator<OSHDBCombinedIndex<OSHDBTimestamp, Integer>, OSMEntitySnapshot> mapRed,
126+
Set<OSMType> osmTypes1, Set<OSMType> osmTypes2,
127+
Set<SimpleFeatureType> simpleFeatureTypes1, Set<SimpleFeatureType> simpleFeatureTypes2,
128+
Integer[] keysInt1, Integer[] keysInt2, Integer[] valuesInt1, Integer[] valuesInt2) {
130129
return mapRed.filter(
131130
snapshot -> snapshotMatches(snapshot, osmTypes1, simpleFeatureTypes1, keysInt1, valuesInt1)
132131
|| snapshotMatches(snapshot, osmTypes2, simpleFeatureTypes2, keysInt2, valuesInt2));
@@ -226,16 +225,15 @@ SortedMap<V, SortedMap<U, A>> nest(Map<OSHDBCombinedIndex<U, V>, A> result) {
226225
* {@link com.fasterxml.jackson.core.JsonGenerator#writeObject(Object) writeObject},
227226
* {@link javax.servlet.ServletResponse#getOutputStream() getOutputStream},
228227
* {@link java.io.OutputStream#write(byte[]) write},
229-
* {@link org.heigit.ohsome.ohsomeapi.executor.ExecutionUtils
230-
* #writeStreamResponse(ThreadLocal, Stream, ThreadLocal, ServletOutputStream)
228+
* {@link org.heigit.ohsome.ohsomeapi.executor.ExecutionUtils #writeStreamResponse(ThreadLocal, Stream, ThreadLocal, ServletOutputStream)
231229
* writeStreamResponse}, {@link javax.servlet.ServletOutputStream#print(String) print},
232230
* and {@link javax.servlet.ServletResponse#flushBuffer() flushBuffer}
233231
* @throws ExecutionException thrown by
234-
* {@link org.heigit.ohsome.ohsomeapi.executor.ExecutionUtils#writeStreamResponse(
235-
* ThreadLocal, Stream, ThreadLocal, ServletOutputStream) writeStreamResponse}
232+
* {@link org.heigit.ohsome.ohsomeapi.executor.ExecutionUtils#writeStreamResponse( ThreadLocal, Stream, ThreadLocal, ServletOutputStream)
233+
* writeStreamResponse}
236234
* @throws InterruptedException thrown by
237-
* {@link org.heigit.ohsome.ohsomeapi.executor.ExecutionUtils#writeStreamResponse(
238-
* ThreadLocal, Stream, ThreadLocal, ServletOutputStream) writeStreamResponse}
235+
* {@link org.heigit.ohsome.ohsomeapi.executor.ExecutionUtils#writeStreamResponse( ThreadLocal, Stream, ThreadLocal, ServletOutputStream)
236+
* writeStreamResponse}
239237
*/
240238
public void streamResponse(HttpServletResponse servletResponse, DataResponse osmData,
241239
Stream<org.wololo.geojson.Feature> resultStream) throws Exception {
@@ -450,10 +448,10 @@ public org.wololo.geojson.Feature createOSMFeature(OSMEntity entity, Geometry ge
450448
*/
451449
@SuppressWarnings({"unchecked"}) // intentionally suppressed as type format is valid
452450
public <K extends Comparable<K> & Serializable, V extends Number>
453-
SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, K>, V> computeResult(
454-
RequestResource requestResource,
455-
MapAggregator<OSHDBCombinedIndex<OSHDBTimestamp, K>, OSMEntitySnapshot> preResult)
456-
throws Exception {
451+
SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, K>, V>
452+
computeResult(RequestResource requestResource,
453+
MapAggregator<OSHDBCombinedIndex<OSHDBTimestamp, K>, OSMEntitySnapshot> preResult)
454+
throws Exception {
457455
switch (requestResource) {
458456
case COUNT:
459457
return (SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, K>, V>) preResult.count();
@@ -486,28 +484,27 @@ SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, K>, V> computeResult(
486484
@SuppressWarnings({"unchecked"}) // intentionally suppressed as type format is valid
487485
public <K extends Comparable<K> & Serializable, V extends Number>
488486
SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>
489-
computeNestedResult(
490-
RequestResource requestResource,
491-
MapAggregator<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, Geometry>
492-
preResult) throws Exception {
487+
computeNestedResult(RequestResource requestResource,
488+
MapAggregator<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, Geometry> preResult)
489+
throws Exception {
493490
switch (requestResource) {
494491
case COUNT:
495-
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>)
496-
preResult.count();
492+
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>) preResult
493+
.count();
497494
case PERIMETER:
498-
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>)
499-
preResult.sum(geom -> {
495+
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>) preResult
496+
.sum(geom -> {
500497
if (!(geom instanceof Polygonal)) {
501498
return 0.0;
502499
}
503500
return cacheInUserData(geom, () -> Geo.lengthOf(geom.getBoundary()));
504501
});
505502
case LENGTH:
506-
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>)
507-
preResult.sum(geom -> cacheInUserData(geom, () -> Geo.lengthOf(geom)));
503+
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>) preResult
504+
.sum(geom -> cacheInUserData(geom, () -> Geo.lengthOf(geom)));
508505
case AREA:
509-
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>)
510-
preResult.sum(geom -> cacheInUserData(geom, () -> Geo.areaOf(geom)));
506+
return (SortedMap<OSHDBCombinedIndex<OSHDBCombinedIndex<Integer, K>, OSHDBTimestamp>, V>) preResult
507+
.sum(geom -> cacheInUserData(geom, () -> Geo.areaOf(geom)));
511508
default:
512509
return null;
513510
}
@@ -587,8 +584,7 @@ public Double[] fillElementsRatioGroupByBoundaryResultValues(
587584
DecimalFormat df) {
588585
Double[] resultValues = new Double[resultSet.size()];
589586
int valueCount = 0;
590-
for (Entry<OSHDBCombinedIndex<OSHDBTimestamp, Integer>, ? extends Number> innerEntry :
591-
resultSet) {
587+
for (Entry<OSHDBCombinedIndex<OSHDBTimestamp, Integer>, ? extends Number> innerEntry : resultSet) {
592588
resultValues[valueCount] = Double.parseDouble(df.format(innerEntry.getValue().doubleValue()));
593589
valueCount++;
594590
}
@@ -746,8 +742,8 @@ public String combineFiltersWithOr(String firstFilter, String secondFilter) {
746742
* containing <code>ElementsResult</code> objects
747743
* @return <code>Pair</code> containing the column names (left) and the data rows (right)
748744
*/
749-
private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElementsGroupBy(
750-
GroupByObject[] resultSet) {
745+
private ImmutablePair<List<String>, List<String[]>>
746+
createCsvResponseForElementsGroupBy(GroupByObject[] resultSet) {
751747
List<String> columnNames = new LinkedList<>();
752748
columnNames.add("timestamp");
753749
List<String[]> rows = new LinkedList<>();
@@ -782,8 +778,8 @@ private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElements
782778
* objects containing <code>RatioResult</code> objects
783779
* @return <code>Pair</code> containing the column names (left) and the data rows (right)
784780
*/
785-
private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElementsRatioGroupBy(
786-
GroupByObject[] resultSet) {
781+
private ImmutablePair<List<String>, List<String[]>>
782+
createCsvResponseForElementsRatioGroupBy(GroupByObject[] resultSet) {
787783
List<String> columnNames = new LinkedList<>();
788784
columnNames.add("timestamp");
789785
List<String[]> rows = new LinkedList<>();
@@ -792,8 +788,8 @@ private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElements
792788
columnNames.add(ratioGroupByResult.getGroupByObject() + "_value");
793789
columnNames.add(ratioGroupByResult.getGroupByObject() + "_value2");
794790
columnNames.add(ratioGroupByResult.getGroupByObject() + "_ratio");
795-
for (int j = 0; j < ratioGroupByResult.getRatioResult().length; j++) {
796-
RatioResult ratioResult = ratioGroupByResult.getRatioResult()[j];
791+
for (int j = 0; j < ratioGroupByResult.getResult().length; j++) {
792+
RatioResult ratioResult = ratioGroupByResult.getResult()[j];
797793
if (i == 0) {
798794
String[] row = new String[resultSet.length * 3 + 1];
799795
row[0] = ratioResult.getTimestamp();
@@ -819,8 +815,8 @@ private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElements
819815
* containing <code>UsersResult</code> objects
820816
* @return <code>Pair</code> containing the column names (left) and the data rows (right)
821817
*/
822-
private ImmutablePair<List<String>, List<String[]>> createCsvResponseForUsersGroupBy(
823-
GroupByObject[] resultSet) {
818+
private ImmutablePair<List<String>, List<String[]>>
819+
createCsvResponseForUsersGroupBy(GroupByObject[] resultSet) {
824820
List<String> columnNames = new LinkedList<>();
825821
columnNames.add("fromTimestamp");
826822
columnNames.add("toTimestamp");

src/main/lombok/org/heigit/ohsome/ohsomeapi/output/dataaggregationresponse/RatioResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ public class RatioResponse implements Response {
2626
@ApiModelProperty(notes = "Metadata describing the output")
2727
private Metadata metadata;
2828
@ApiModelProperty(notes = "ElementsResult for /ratio requests", required = true)
29-
private RatioResult[] ratioResult;
29+
private RatioResult[] result;
3030
}

src/main/lombok/org/heigit/ohsome/ohsomeapi/output/dataaggregationresponse/groupbyresponse/RatioGroupByBoundaryResponse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public class RatioGroupByBoundaryResponse implements Response {
3939
private Feature[] features;
4040
@ApiModelProperty(notes = "RatioGroupByResult array holding the respective objects "
4141
+ "with their timestamp-value-value2-ratio values", required = true)
42-
private RatioGroupByResult[] groupByBoundaryResult;
42+
private RatioGroupByResult[] groupByResult;
4343

4444
public RatioGroupByBoundaryResponse(Attribution attribution, String apiVersion, Metadata metadata,
45-
RatioGroupByResult[] groupByBoundaryResult) {
45+
RatioGroupByResult[] groupByResult) {
4646
this.attribution = attribution;
4747
this.apiVersion = apiVersion;
4848
this.metadata = metadata;
49-
this.groupByBoundaryResult = groupByBoundaryResult;
49+
this.groupByResult = groupByResult;
5050
}
5151

5252
/** Static factory method returning the whole GeoJSON response. */

src/main/lombok/org/heigit/ohsome/ohsomeapi/output/dataaggregationresponse/groupbyresponse/RatioGroupByResult.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public class RatioGroupByResult extends GroupByObject {
1414

1515
@ApiModelProperty(notes = "RatioResult array holding timestamp, whole and part values",
1616
required = true)
17-
private RatioResult[] ratioResult;
17+
private RatioResult[] result;
1818

19-
public RatioGroupByResult(Object groupByObject, RatioResult[] ratioResult) {
19+
public RatioGroupByResult(Object groupByObject, RatioResult[] result) {
2020
super(groupByObject);
21-
this.ratioResult = ratioResult;
21+
this.result = result;
2222
}
2323
}

src/main/lombok/org/heigit/ohsome/ohsomeapi/utils/GroupByBoundaryGeoJsonGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ private static Feature[] generateRatioGroupByResultGeoJson(GroupByObject[] resul
3838
int tstampCount) {
3939
Feature[] features;
4040
RatioGroupByResult[] groupByResults = (RatioGroupByResult[]) results;
41-
int resultLength = groupByResults[0].getRatioResult().length;
41+
int resultLength = groupByResults[0].getResult().length;
4242
int featuresLength = groupByResultsLength * resultLength;
4343
features = new Feature[featuresLength];
4444
for (int i = 0; i < featuresLength; i++) {
45-
RatioResult result = groupByResults[groupByResultCount].getRatioResult()[tstampCount];
45+
RatioResult result = groupByResults[groupByResultCount].getResult()[tstampCount];
4646
String tstamp = result.getTimestamp();
4747
Feature feature = fillGeojsonFeature(results, groupByResultCount, tstamp);
4848
feature.setProperty("value", result.getValue());

0 commit comments

Comments
 (0)