[android] Add "localIdeographs" option to OfflineRegionDefinition.
This commit is contained in:
@@ -21,6 +21,8 @@ import com.mapbox.turf.TurfMeasurement;
|
||||
* tiles from minZoom up to the maximum zoom level provided by that source.
|
||||
* <p>
|
||||
* pixelRatio must be ≥ 0 and should typically be 1.0 or 2.0.
|
||||
* <p>
|
||||
* if includeIdeographs is false, offline region will not include CJK glyphs
|
||||
*/
|
||||
public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition, Parcelable {
|
||||
|
||||
@@ -35,6 +37,8 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
|
||||
private double maxZoom;
|
||||
@Keep
|
||||
private float pixelRatio;
|
||||
@Keep
|
||||
private boolean includeIdeographs;
|
||||
|
||||
/**
|
||||
* Constructor to create an OfflineGeometryRegionDefinition from parameters.
|
||||
@@ -47,13 +51,31 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
|
||||
*/
|
||||
@Keep
|
||||
public OfflineGeometryRegionDefinition(
|
||||
String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio) {
|
||||
String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio) {
|
||||
this(styleURL, geometry, minZoom, maxZoom, pixelRatio, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to create an OfflineGeometryRegionDefinition from parameters.
|
||||
*
|
||||
* @param styleURL the style
|
||||
* @param geometry the geometry
|
||||
* @param minZoom min zoom
|
||||
* @param maxZoom max zoom
|
||||
* @param pixelRatio pixel ratio of the device
|
||||
* @param includeIdeographs include glyphs for CJK languages
|
||||
*/
|
||||
@Keep
|
||||
public OfflineGeometryRegionDefinition(
|
||||
String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio,
|
||||
boolean includeIdeographs) {
|
||||
// Note: Also used in JNI
|
||||
this.styleURL = styleURL;
|
||||
this.geometry = geometry;
|
||||
this.minZoom = minZoom;
|
||||
this.maxZoom = maxZoom;
|
||||
this.pixelRatio = pixelRatio;
|
||||
this.includeIdeographs = includeIdeographs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,6 +132,11 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition,
|
||||
return pixelRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIncludeIdeographs() {
|
||||
return includeIdeographs;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getType() {
|
||||
|
||||
@@ -48,7 +48,20 @@ public interface OfflineRegionDefinition {
|
||||
float getPixelRatio();
|
||||
|
||||
/**
|
||||
* Gest the type of the OfflineRegionDefinition for telemetry ("tileregion", "shaperegion").
|
||||
* Specifies whether to include ideographic glyphs in downloaded font data.
|
||||
* Ideographic glyphs make up the majority of downloaded font data, but
|
||||
* it is possible to configure the renderer to use locally installed fonts
|
||||
* instead of relying on fonts downloaded as part of the offline pack.
|
||||
*
|
||||
* Defaults to `true`
|
||||
*
|
||||
* @return true if offline region will include ideographic glyphs
|
||||
* @see MapboxMapOptions localIdeographFontFamily
|
||||
*/
|
||||
boolean getIncludeIdeographs();
|
||||
|
||||
/**
|
||||
* Gets the type of the OfflineRegionDefinition for telemetry ("tileregion", "shaperegion").
|
||||
*
|
||||
* @return The type of the OfflineRegionDefinition.
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,8 @@ import com.mapbox.mapboxsdk.geometry.LatLngBounds;
|
||||
* tiles from minZoom up to the maximum zoom level provided by that source.
|
||||
* <p>
|
||||
* pixelRatio must be ≥ 0 and should typically be 1.0 or 2.0.
|
||||
* <p>
|
||||
* if includeIdeographs is false, offline region will not include CJK glyphs
|
||||
*/
|
||||
public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefinition, Parcelable {
|
||||
|
||||
@@ -31,6 +33,8 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
|
||||
private double maxZoom;
|
||||
@Keep
|
||||
private float pixelRatio;
|
||||
@Keep
|
||||
private boolean includeIdeographs;
|
||||
|
||||
/**
|
||||
* Constructor to create an OfflineTilePyramidDefinition from parameters.
|
||||
@@ -43,13 +47,31 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
|
||||
*/
|
||||
@Keep
|
||||
public OfflineTilePyramidRegionDefinition(
|
||||
String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio) {
|
||||
String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio) {
|
||||
this(styleURL, bounds, minZoom, maxZoom, pixelRatio, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to create an OfflineTilePyramidDefinition from parameters.
|
||||
*
|
||||
* @param styleURL the style
|
||||
* @param bounds the bounds
|
||||
* @param minZoom min zoom
|
||||
* @param maxZoom max zoom
|
||||
* @param pixelRatio pixel ratio of the device
|
||||
* @param includeIdeographs include glyphs for CJK languages
|
||||
*/
|
||||
@Keep
|
||||
public OfflineTilePyramidRegionDefinition(
|
||||
String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio,
|
||||
boolean includeIdeographs) {
|
||||
// Note: Also used in JNI
|
||||
this.styleURL = styleURL;
|
||||
this.bounds = bounds;
|
||||
this.minZoom = minZoom;
|
||||
this.maxZoom = maxZoom;
|
||||
this.pixelRatio = pixelRatio;
|
||||
this.includeIdeographs = includeIdeographs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +116,11 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti
|
||||
return pixelRatio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIncludeIdeographs() {
|
||||
return includeIdeographs;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getType() {
|
||||
|
||||
@@ -29,14 +29,15 @@ mbgl::OfflineRegionDefinition OfflineRegionDefinition::getDefinition(JNIEnv& env
|
||||
|
||||
jni::Local<jni::Object<OfflineRegionDefinition>> OfflineTilePyramidRegionDefinition::New(jni::JNIEnv& env, const mbgl::OfflineTilePyramidRegionDefinition& definition) {
|
||||
static auto& javaClass = jni::Class<OfflineTilePyramidRegionDefinition>::Singleton(env);
|
||||
static auto constructor = javaClass.GetConstructor<jni::String, jni::Object<LatLngBounds>, jni::jdouble, jni::jdouble, jni::jfloat>(env);
|
||||
static auto constructor = javaClass.GetConstructor<jni::String, jni::Object<LatLngBounds>, jni::jdouble, jni::jdouble, jni::jfloat, jni::jboolean>(env);
|
||||
|
||||
return javaClass.New(env, constructor,
|
||||
jni::Make<jni::String>(env, definition.styleURL),
|
||||
LatLngBounds::New(env, definition.bounds),
|
||||
definition.minZoom,
|
||||
definition.maxZoom,
|
||||
definition.pixelRatio);
|
||||
definition.pixelRatio,
|
||||
jni::jboolean(definition.includeIdeographs));
|
||||
}
|
||||
|
||||
mbgl::OfflineTilePyramidRegionDefinition OfflineTilePyramidRegionDefinition::getDefinition(jni::JNIEnv& env, const jni::Object<OfflineTilePyramidRegionDefinition>& jDefinition) {
|
||||
@@ -47,13 +48,15 @@ mbgl::OfflineTilePyramidRegionDefinition OfflineTilePyramidRegionDefinition::get
|
||||
static auto minZoomF = javaClass.GetField<jni::jdouble>(env, "minZoom");
|
||||
static auto maxZoomF = javaClass.GetField<jni::jdouble>(env, "maxZoom");
|
||||
static auto pixelRatioF = javaClass.GetField<jni::jfloat>(env, "pixelRatio");
|
||||
static auto includeIdeographsF = javaClass.GetField<jni::jboolean >(env, "includeIdeographs");
|
||||
|
||||
return mbgl::OfflineTilePyramidRegionDefinition(
|
||||
jni::Make<std::string>(env, jDefinition.Get(env, styleURLF)),
|
||||
LatLngBounds::getLatLngBounds(env, jDefinition.Get(env, boundsF)),
|
||||
jDefinition.Get(env, minZoomF),
|
||||
jDefinition.Get(env, maxZoomF),
|
||||
jDefinition.Get(env, pixelRatioF)
|
||||
jDefinition.Get(env, pixelRatioF),
|
||||
jDefinition.Get(env, includeIdeographsF)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -65,14 +68,15 @@ void OfflineTilePyramidRegionDefinition::registerNative(jni::JNIEnv& env) {
|
||||
|
||||
jni::Local<jni::Object<OfflineRegionDefinition>> OfflineGeometryRegionDefinition::New(jni::JNIEnv& env, const mbgl::OfflineGeometryRegionDefinition& definition) {
|
||||
static auto& javaClass = jni::Class<OfflineGeometryRegionDefinition>::Singleton(env);
|
||||
static auto constructor = javaClass.GetConstructor<jni::String, jni::Object<geojson::Geometry>, jni::jdouble, jni::jdouble, jni::jfloat>(env);
|
||||
static auto constructor = javaClass.GetConstructor<jni::String, jni::Object<geojson::Geometry>, jni::jdouble, jni::jdouble, jni::jfloat, jni::jboolean>(env);
|
||||
|
||||
return javaClass.New(env, constructor,
|
||||
jni::Make<jni::String>(env, definition.styleURL),
|
||||
geojson::Geometry::New(env, definition.geometry),
|
||||
definition.minZoom,
|
||||
definition.maxZoom,
|
||||
definition.pixelRatio);
|
||||
definition.pixelRatio,
|
||||
jni::jboolean(definition.includeIdeographs));
|
||||
}
|
||||
|
||||
mbgl::OfflineGeometryRegionDefinition OfflineGeometryRegionDefinition::getDefinition(jni::JNIEnv& env, const jni::Object<OfflineGeometryRegionDefinition>& jDefinition) {
|
||||
@@ -83,13 +87,15 @@ mbgl::OfflineGeometryRegionDefinition OfflineGeometryRegionDefinition::getDefini
|
||||
static auto minZoomF = javaClass.GetField<jni::jdouble>(env, "minZoom");
|
||||
static auto maxZoomF = javaClass.GetField<jni::jdouble>(env, "maxZoom");
|
||||
static auto pixelRatioF = javaClass.GetField<jni::jfloat>(env, "pixelRatio");
|
||||
static auto includeIdeographsF = javaClass.GetField<jni::jboolean>(env, "includeIdeographs");
|
||||
|
||||
return mbgl::OfflineGeometryRegionDefinition(
|
||||
jni::Make<std::string>(env, jDefinition.Get(env, styleURLF)),
|
||||
geojson::Geometry::convert(env, jDefinition.Get(env, geometryF)),
|
||||
jDefinition.Get(env, minZoomF),
|
||||
jDefinition.Get(env, maxZoomF),
|
||||
jDefinition.Get(env, pixelRatioF)
|
||||
jDefinition.Get(env, pixelRatioF),
|
||||
jDefinition.Get(env, includeIdeographsF)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user