File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
core/src/main/java/com/graphhopper/routing
web-api/src/main/java/com/graphhopper/jackson Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ public GHResponse route(GHRequest request) {
98
98
try {
99
99
checkNoLegacyParameters (request );
100
100
checkAtLeastOnePoint (request );
101
- checkIfPointsAreInBounds (request .getPoints ());
101
+ checkIfPointsAreInBoundsAndNotNull (request .getPoints ());
102
102
checkHeadings (request );
103
103
checkPointHints (request );
104
104
checkCurbsides (request );
@@ -147,13 +147,14 @@ private void checkAtLeastOnePoint(GHRequest request) {
147
147
throw new IllegalArgumentException ("You have to pass at least one point" );
148
148
}
149
149
150
- private void checkIfPointsAreInBounds (List <GHPoint > points ) {
150
+ private void checkIfPointsAreInBoundsAndNotNull (List <GHPoint > points ) {
151
151
BBox bounds = graph .getBounds ();
152
152
for (int i = 0 ; i < points .size (); i ++) {
153
153
GHPoint point = points .get (i );
154
- if (!bounds .contains (point .getLat (), point .getLon ())) {
154
+ if (point == null )
155
+ throw new IllegalArgumentException ("Point " + i + " is null" );
156
+ if (!bounds .contains (point .getLat (), point .getLon ()))
155
157
throw new PointOutOfBoundsException ("Point " + i + " is out of bounds: " + point + ", the bounds are: " + bounds , i );
156
- }
157
158
}
158
159
}
159
160
Original file line number Diff line number Diff line change 18
18
package com .graphhopper .jackson ;
19
19
20
20
import com .fasterxml .jackson .core .JsonParser ;
21
+ import com .fasterxml .jackson .core .JsonProcessingException ;
21
22
import com .fasterxml .jackson .databind .DeserializationContext ;
22
23
import com .fasterxml .jackson .databind .JsonDeserializer ;
23
24
import com .graphhopper .util .shapes .GHPoint ;
27
28
class GHPointDeserializer extends JsonDeserializer <GHPoint > {
28
29
@ Override
29
30
public GHPoint deserialize (JsonParser jsonParser , DeserializationContext deserializationContext ) throws IOException {
30
- double [] bounds = jsonParser .readValueAs (double [].class );
31
- return GHPoint .fromJson (bounds );
31
+ try {
32
+ double [] bounds = jsonParser .readValueAs (double [].class );
33
+ return GHPoint .fromJson (bounds );
34
+ } catch (JsonProcessingException ex ) {
35
+ throw new IllegalArgumentException ("point is invalid: " + ex .getMessage ());
36
+ }
32
37
}
33
38
}
You can’t perform that action at this time.
0 commit comments