Skip to content

Commit

Permalink
src: Remove deprecated use of URL constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlin1 committed Sep 26, 2024
1 parent 0b89fa0 commit 46b8f83
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main/java/MapServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import org.locationtech.spatial4j.shape.Point;
import org.locationtech.spatial4j.shape.ShapeFactory;

import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.util.List;

Expand Down Expand Up @@ -98,7 +96,7 @@ private static int port() {
* @throws MalformedURLException if the URL is invalid.
*/
private static URL url(Point center, int zoom, int width, int height, List<Point> route, List<Point> locations)
throws MalformedURLException {
throws MalformedURLException, URISyntaxException {
StringBuilder overlay = new StringBuilder();
if (route != null && !route.isEmpty()) {
overlay.append("path-4+6cb5e6-1(");
Expand All @@ -118,7 +116,7 @@ private static URL url(Point center, int zoom, int width, int height, List<Point
// Replace the trailing comma with a forward slash
overlay.setCharAt(overlay.length() - 1, '/');
}
return new URL(String.format(
return new URI(String.format(
"https://api.mapbox.com/"
// {username}/{style_id} and {overlay} (must include trailing slash)
+ "styles/v1/%s/%s/static/%s"
Expand All @@ -132,7 +130,7 @@ private static URL url(Point center, int zoom, int width, int height, List<Point
center.getLon(), center.getLat(), zoom,
(int) Math.ceil(width / 2.), (int) Math.ceil(height / 2.), "@2x",
System.getenv("TOKEN")
));
)).toURL();
}

/**
Expand Down

0 comments on commit 46b8f83

Please sign in to comment.