61
61
import org .heigit .bigspatialdata .oshdb .util .tagtranslator .OSMTag ;
62
62
import org .heigit .bigspatialdata .oshdb .util .tagtranslator .TagTranslator ;
63
63
import org .heigit .bigspatialdata .oshdb .util .time .TimestampFormatter ;
64
- import org .heigit .ohsome .filter .FilterExpression ;
65
64
import org .heigit .ohsome .ohsomeapi .Application ;
66
65
import org .heigit .ohsome .ohsomeapi .controller .rawdata .ElementsGeometry ;
67
66
import org .heigit .ohsome .ohsomeapi .exception .DatabaseAccessException ;
@@ -123,10 +122,10 @@ public MapReducer<OSMEntitySnapshot> snapshotFilter(MapReducer<OSMEntitySnapshot
123
122
*/
124
123
public MapAggregator <OSHDBCombinedIndex <OSHDBTimestamp , Integer >, OSMEntitySnapshot >
125
124
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 ) {
130
129
return mapRed .filter (
131
130
snapshot -> snapshotMatches (snapshot , osmTypes1 , simpleFeatureTypes1 , keysInt1 , valuesInt1 )
132
131
|| snapshotMatches (snapshot , osmTypes2 , simpleFeatureTypes2 , keysInt2 , valuesInt2 ));
@@ -226,16 +225,15 @@ SortedMap<V, SortedMap<U, A>> nest(Map<OSHDBCombinedIndex<U, V>, A> result) {
226
225
* {@link com.fasterxml.jackson.core.JsonGenerator#writeObject(Object) writeObject},
227
226
* {@link javax.servlet.ServletResponse#getOutputStream() getOutputStream},
228
227
* {@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)
231
229
* writeStreamResponse}, {@link javax.servlet.ServletOutputStream#print(String) print},
232
230
* and {@link javax.servlet.ServletResponse#flushBuffer() flushBuffer}
233
231
* @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}
236
234
* @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}
239
237
*/
240
238
public void streamResponse (HttpServletResponse servletResponse , DataResponse osmData ,
241
239
Stream <org .wololo .geojson .Feature > resultStream ) throws Exception {
@@ -450,10 +448,10 @@ public org.wololo.geojson.Feature createOSMFeature(OSMEntity entity, Geometry ge
450
448
*/
451
449
@ SuppressWarnings ({"unchecked" }) // intentionally suppressed as type format is valid
452
450
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 {
457
455
switch (requestResource ) {
458
456
case COUNT :
459
457
return (SortedMap <OSHDBCombinedIndex <OSHDBTimestamp , K >, V >) preResult .count ();
@@ -486,28 +484,27 @@ SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, K>, V> computeResult(
486
484
@ SuppressWarnings ({"unchecked" }) // intentionally suppressed as type format is valid
487
485
public <K extends Comparable <K > & Serializable , V extends Number >
488
486
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 {
493
490
switch (requestResource ) {
494
491
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 ();
497
494
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 -> {
500
497
if (!(geom instanceof Polygonal )) {
501
498
return 0.0 ;
502
499
}
503
500
return cacheInUserData (geom , () -> Geo .lengthOf (geom .getBoundary ()));
504
501
});
505
502
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 )));
508
505
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 )));
511
508
default :
512
509
return null ;
513
510
}
@@ -587,8 +584,7 @@ public Double[] fillElementsRatioGroupByBoundaryResultValues(
587
584
DecimalFormat df ) {
588
585
Double [] resultValues = new Double [resultSet .size ()];
589
586
int valueCount = 0 ;
590
- for (Entry <OSHDBCombinedIndex <OSHDBTimestamp , Integer >, ? extends Number > innerEntry :
591
- resultSet ) {
587
+ for (Entry <OSHDBCombinedIndex <OSHDBTimestamp , Integer >, ? extends Number > innerEntry : resultSet ) {
592
588
resultValues [valueCount ] = Double .parseDouble (df .format (innerEntry .getValue ().doubleValue ()));
593
589
valueCount ++;
594
590
}
@@ -746,8 +742,8 @@ public String combineFiltersWithOr(String firstFilter, String secondFilter) {
746
742
* containing <code>ElementsResult</code> objects
747
743
* @return <code>Pair</code> containing the column names (left) and the data rows (right)
748
744
*/
749
- private ImmutablePair <List <String >, List <String []>> createCsvResponseForElementsGroupBy (
750
- GroupByObject [] resultSet ) {
745
+ private ImmutablePair <List <String >, List <String []>>
746
+ createCsvResponseForElementsGroupBy ( GroupByObject [] resultSet ) {
751
747
List <String > columnNames = new LinkedList <>();
752
748
columnNames .add ("timestamp" );
753
749
List <String []> rows = new LinkedList <>();
@@ -782,8 +778,8 @@ private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElements
782
778
* objects containing <code>RatioResult</code> objects
783
779
* @return <code>Pair</code> containing the column names (left) and the data rows (right)
784
780
*/
785
- private ImmutablePair <List <String >, List <String []>> createCsvResponseForElementsRatioGroupBy (
786
- GroupByObject [] resultSet ) {
781
+ private ImmutablePair <List <String >, List <String []>>
782
+ createCsvResponseForElementsRatioGroupBy ( GroupByObject [] resultSet ) {
787
783
List <String > columnNames = new LinkedList <>();
788
784
columnNames .add ("timestamp" );
789
785
List <String []> rows = new LinkedList <>();
@@ -792,8 +788,8 @@ private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElements
792
788
columnNames .add (ratioGroupByResult .getGroupByObject () + "_value" );
793
789
columnNames .add (ratioGroupByResult .getGroupByObject () + "_value2" );
794
790
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 ];
797
793
if (i == 0 ) {
798
794
String [] row = new String [resultSet .length * 3 + 1 ];
799
795
row [0 ] = ratioResult .getTimestamp ();
@@ -819,8 +815,8 @@ private ImmutablePair<List<String>, List<String[]>> createCsvResponseForElements
819
815
* containing <code>UsersResult</code> objects
820
816
* @return <code>Pair</code> containing the column names (left) and the data rows (right)
821
817
*/
822
- private ImmutablePair <List <String >, List <String []>> createCsvResponseForUsersGroupBy (
823
- GroupByObject [] resultSet ) {
818
+ private ImmutablePair <List <String >, List <String []>>
819
+ createCsvResponseForUsersGroupBy ( GroupByObject [] resultSet ) {
824
820
List <String > columnNames = new LinkedList <>();
825
821
columnNames .add ("fromTimestamp" );
826
822
columnNames .add ("toTimestamp" );
0 commit comments