Add Initial PMTiles support (#2882)

Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
This commit is contained in:
tdcosta100
2025-01-07 10:32:17 -03:00
committed by GitHub
parent c7e6b0c796
commit cf9f41cf61
41 changed files with 969 additions and 32 deletions

View File

@@ -18,12 +18,13 @@ public interface HttpRequest {
* @param httpRequest callback to be invoked when we receive a response
* @param nativePtr the pointer associated to the request
* @param resourceUrl the resource url to download
* @param dataRange http header, used to indicate the part of a resource that the server should return
* @param etag http header, identifier for a specific version of a resource
* @param modified http header, used to determine if a resource hasn't been modified since
* @param offlineUsage flag to indicate a resource will be used for offline, appends offline=true as a query parameter
*/
void executeRequest(HttpResponder httpRequest, long nativePtr, String resourceUrl,
String etag, String modified, boolean offlineUsage);
String dataRange, String etag, String modified, boolean offlineUsage);
/**
* Cancels the request.

View File

@@ -19,7 +19,8 @@ public class NativeHttpRequest implements HttpResponder {
private long nativePtr;
@Keep
private NativeHttpRequest(long nativePtr, String resourceUrl, String etag, String modified, boolean offlineUsage) {
private NativeHttpRequest(long nativePtr, String resourceUrl, String dataRange, String etag, String modified,
boolean offlineUsage) {
this.nativePtr = nativePtr;
if (resourceUrl.startsWith("local://")) {
@@ -27,7 +28,7 @@ public class NativeHttpRequest implements HttpResponder {
executeLocalRequest(resourceUrl);
return;
}
httpRequest.executeRequest(this, nativePtr, resourceUrl, etag, modified, offlineUsage);
httpRequest.executeRequest(this, nativePtr, resourceUrl, dataRange, etag, modified, offlineUsage);
}
public void cancel() {

View File

@@ -58,7 +58,8 @@ public class HttpRequestImpl implements HttpRequest {
@Override
public void executeRequest(HttpResponder httpRequest, long nativePtr, @NonNull String resourceUrl,
@NonNull String etag, @NonNull String modified, boolean offlineUsage) {
@NonNull String dataRange, @NonNull String etag, @NonNull String modified,
boolean offlineUsage) {
OkHttpCallback callback = new OkHttpCallback(httpRequest);
try {
HttpUrl httpUrl = HttpUrl.parse(resourceUrl);
@@ -74,6 +75,11 @@ public class HttpRequestImpl implements HttpRequest {
.url(resourceUrl)
.tag(resourceUrl.toLowerCase(MapLibreConstants.MAPLIBRE_LOCALE))
.addHeader("User-Agent", userAgentString);
if (dataRange.length() > 0) {
builder.addHeader("Range", dataRange);
}
if (etag.length() > 0) {
builder.addHeader("If-None-Match", etag);
} else if (modified.length() > 0) {