Skip to content

Commit d2b61c0

Browse files
author
Peter
committed
added test for GraphHopperWeb; add missing license header to some more files
1 parent 11ca248 commit d2b61c0

26 files changed

+257
-40
lines changed

tools/src/main/java/com/graphhopper/tools/Bzip2.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
package com.graphhopper.bzip2plugin;
1+
/*
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except
8+
* in compliance with the License. You may obtain a copy of the
9+
* License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package com.graphhopper.tools;
220

321
import com.graphhopper.util.Helper;
422
import java.io.FileInputStream;

tools/src/main/java/com/graphhopper/ui/DebugAStar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/DebugAStarBi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/DebugAlgo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/DebugDijkstraBidirection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/DebugDijkstraSimple.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at
@@ -18,7 +18,6 @@
1818
*/
1919
package com.graphhopper.ui;
2020

21-
import com.graphhopper.routing.AStar;
2221
import com.graphhopper.routing.Dijkstra;
2322
import com.graphhopper.routing.util.EdgePropertyEncoder;
2423
import com.graphhopper.storage.Graph;

tools/src/main/java/com/graphhopper/ui/DebugLocation2IDQuadtree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/DefaultMapLayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/GraphicsWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/LayeredPanel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/MapLayer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

tools/src/main/java/com/graphhopper/ui/MiniGraphUI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

web/nb-configuration.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-shared-configuration>
3+
<!--
4+
This file contains additional configuration written by modules in the NetBeans IDE.
5+
The configuration is intended to be shared among all the users of project and
6+
therefore it is assumed to be part of version control checkout.
7+
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
8+
-->
9+
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
10+
<!--
11+
Properties that influence various parts of the IDE, especially code formatting and the like.
12+
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
13+
That way multiple projects can share the same settings (useful for formatting rules for example).
14+
Any value defined here will override the pom.xml file value but is only applicable to the current project.
15+
-->
16+
<netbeans.compile.on.save>all</netbeans.compile.on.save>
17+
</properties>
18+
</project-shared-configuration>

web/src/main/java/com/graphhopper/http/DefaultModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

web/src/main/java/com/graphhopper/http/GHThreadPool.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except
8+
* in compliance with the License. You may obtain a copy of the
9+
* License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
119
package com.graphhopper.http;
220

321
import java.util.ArrayList;

web/src/main/java/com/graphhopper/http/GraphHopperServlet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

web/src/main/java/com/graphhopper/http/GraphHopperWeb.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at
@@ -30,6 +30,7 @@
3030
import java.util.zip.GZIPInputStream;
3131
import java.util.zip.Inflater;
3232
import java.util.zip.InflaterInputStream;
33+
import org.json.JSONArray;
3334
import org.json.JSONObject;
3435
import org.slf4j.Logger;
3536
import org.slf4j.LoggerFactory;
@@ -45,11 +46,12 @@ public static void main(String[] args) {
4546
GraphHopperAPI gh = new GraphHopperWeb();
4647
gh.load("http://localhost:8989/api");
4748
//GHResponse ph = gh.route(new GHRequest(53.080827, 9.074707, 50.597186, 11.184082));
48-
GHResponse ph = gh.route(new GHRequest( 49.6724, 11.3494, 49.6550, 11.4180));
49+
GHResponse ph = gh.route(new GHRequest(49.6724, 11.3494, 49.6550, 11.4180));
4950
System.out.println(ph);
5051
}
5152
private Logger logger = LoggerFactory.getLogger(getClass());
5253
private String serviceUrl;
54+
private boolean encodePolyline = true;
5355

5456
public GraphHopperWeb() {
5557
}
@@ -62,6 +64,11 @@ public GraphHopperWeb() {
6264
return true;
6365
}
6466

67+
public GraphHopperWeb encodePolyline(boolean b) {
68+
encodePolyline = b;
69+
return this;
70+
}
71+
6572
@Override
6673
public GHResponse route(GHRequest request) {
6774
request.check();
@@ -72,15 +79,28 @@ public GHResponse route(GHRequest request) {
7279
+ "?from=" + request.from().lat + "," + request.from().lon
7380
+ "&to=" + request.to().lat + "," + request.to().lon
7481
+ "&type=json"
75-
+ "&encodedPolyline=true"
82+
+ "&encodedPolyline=" + encodePolyline
7683
+ "&minPathPrecision=" + request.getHint("douglas.minprecision", 1)
7784
+ "&algo=" + request.algorithm();
78-
JSONObject json = new JSONObject(WebHelper.readString(new URL(url).openStream()));
85+
String str = WebHelper.readString(fetch(url));
86+
JSONObject json = new JSONObject(str);
7987
took = json.getJSONObject("info").getDouble("took");
8088
JSONObject route = json.getJSONObject("route");
8189
double distance = route.getDouble("distance");
8290
int timeInSeconds = route.getInt("time");
83-
PointList list = WebHelper.decodePolyline(route.getString("coordinates"), 100);
91+
PointList list;
92+
if (encodePolyline)
93+
list = WebHelper.decodePolyline(route.getString("coordinates"), 100);
94+
else {
95+
JSONArray coords = route.getJSONObject("data").getJSONArray("coordinates");
96+
list = new PointList(coords.length());
97+
for (int i = 0; i < coords.length(); i++) {
98+
JSONArray arr = coords.getJSONArray(i);
99+
double lon = arr.getDouble(0);
100+
double lat = arr.getDouble(1);
101+
list.add(lat, lon);
102+
}
103+
}
84104
return new GHResponse().points(list).distance(distance).time(timeInSeconds);
85105
} catch (Exception ex) {
86106
throw new RuntimeException("Problem while fetching path " + request.from() + "->" + request.to(), ex);

web/src/main/java/com/graphhopper/http/GuiceServletConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

web/src/main/java/com/graphhopper/http/JSONBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

web/src/main/java/com/graphhopper/http/MyGZIPHook.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
2-
* Licensed to Peter Karich under one or more contributor license
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
33
* agreements. See the NOTICE file distributed with this work for
44
* additional information regarding copyright ownership.
55
*
6-
* Peter Karich licenses this file to you under the Apache License,
6+
* GraphHopper licenses this file to you under the Apache License,
77
* Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the
99
* License at

web/src/main/java/com/graphhopper/http/NominatimGeocoder.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except
8+
* in compliance with the License. You may obtain a copy of the
9+
* License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
119
package com.graphhopper.http;
220

321
import com.graphhopper.search.Geocoding;

web/src/main/java/com/graphhopper/http/WebHelper.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Licensed to GraphHopper and Peter Karich under one or more contributor license
3+
* agreements. See the NOTICE file distributed with this work for
4+
* additional information regarding copyright ownership.
5+
*
6+
* GraphHopper licenses this file to you under the Apache License,
7+
* Version 2.0 (the "License"); you may not use this file except
8+
* in compliance with the License. You may obtain a copy of the
9+
* License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
119
package com.graphhopper.http;
220

321
import com.graphhopper.util.PointList;

0 commit comments

Comments
 (0)