[core, node, android] Remove used "base" parameter from setStyleJSON
This commit is contained in:
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
|
||||
HeadlessView view(pixelRatio, width, height);
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
|
||||
map.setStyleJSON(style, ".");
|
||||
map.setStyleJSON(style);
|
||||
map.setClasses(classes);
|
||||
|
||||
map.setLatLngZoom({ lat, lon }, zoom);
|
||||
|
||||
@@ -57,8 +57,8 @@ public:
|
||||
bool hasClass(const std::string&) const;
|
||||
std::vector<std::string> getClasses() const;
|
||||
|
||||
void setStyleURL(const std::string& url);
|
||||
void setStyleJSON(const std::string& json, const std::string& base = "");
|
||||
void setStyleURL(const std::string&);
|
||||
void setStyleJSON(const std::string&);
|
||||
std::string getStyleURL() const;
|
||||
std::string getStyleJSON() const;
|
||||
|
||||
|
||||
@@ -194,11 +194,7 @@ final class NativeMapView {
|
||||
}
|
||||
|
||||
public void setStyleJson(String newStyleJson) {
|
||||
setStyleJson(newStyleJson, "");
|
||||
}
|
||||
|
||||
public void setStyleJson(String newStyleJson, String base) {
|
||||
nativeSetStyleJson(mNativeMapViewPtr, newStyleJson, base);
|
||||
nativeSetStyleJson(mNativeMapViewPtr, newStyleJson);
|
||||
}
|
||||
|
||||
public String getStyleJson() {
|
||||
@@ -528,8 +524,7 @@ final class NativeMapView {
|
||||
|
||||
private native void nativeSetStyleUrl(long nativeMapViewPtr, String url);
|
||||
|
||||
private native void nativeSetStyleJson(long nativeMapViewPtr,
|
||||
String newStyleJson, String base);
|
||||
private native void nativeSetStyleJson(long nativeMapViewPtr, String newStyleJson);
|
||||
|
||||
private native String nativeGetStyleJson(long nativeMapViewPtr);
|
||||
|
||||
|
||||
@@ -427,13 +427,11 @@ void nativeSetStyleUrl(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, j
|
||||
nativeMapView->getMap().setStyleURL(std_string_from_jstring(env, url));
|
||||
}
|
||||
|
||||
void nativeSetStyleJson(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr,
|
||||
jni::jstring* newStyleJson, jni::jstring* base) {
|
||||
void nativeSetStyleJson(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jni::jstring* newStyleJson) {
|
||||
mbgl::Log::Debug(mbgl::Event::JNI, "nativeSetStyleJSON");
|
||||
assert(nativeMapViewPtr != 0);
|
||||
NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
|
||||
nativeMapView->getMap().setStyleJSON(std_string_from_jstring(env, newStyleJson),
|
||||
std_string_from_jstring(env, base));
|
||||
nativeMapView->getMap().setStyleJSON(std_string_from_jstring(env, newStyleJson));
|
||||
}
|
||||
|
||||
jni::jstring* nativeGetStyleJson(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr) {
|
||||
@@ -1686,7 +1684,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
MAKE_NATIVE_METHOD(nativeSetClasses, "(JLjava/util/List;)V"),
|
||||
MAKE_NATIVE_METHOD(nativeGetClasses, "(J)Ljava/util/List;"),
|
||||
MAKE_NATIVE_METHOD(nativeSetStyleUrl, "(JLjava/lang/String;)V"),
|
||||
MAKE_NATIVE_METHOD(nativeSetStyleJson, "(JLjava/lang/String;Ljava/lang/String;)V"),
|
||||
MAKE_NATIVE_METHOD(nativeSetStyleJson, "(JLjava/lang/String;)V"),
|
||||
MAKE_NATIVE_METHOD(nativeGetStyleJson, "(J)Ljava/lang/String;"),
|
||||
MAKE_NATIVE_METHOD(nativeSetAccessToken, "(JLjava/lang/String;)V"),
|
||||
MAKE_NATIVE_METHOD(nativeGetAccessToken, "(J)Ljava/lang/String;"),
|
||||
|
||||
@@ -188,7 +188,7 @@ NAN_METHOD(NodeMap::Load) {
|
||||
}
|
||||
|
||||
try {
|
||||
nodeMap->map->setStyleJSON(style, ".");
|
||||
nodeMap->map->setStyleJSON(style);
|
||||
} catch (const std::exception &ex) {
|
||||
return Nan::ThrowError(ex.what());
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
void update();
|
||||
void render();
|
||||
|
||||
void loadStyleJSON(const std::string& json, const std::string& base);
|
||||
void loadStyleJSON(const std::string&);
|
||||
|
||||
View& view;
|
||||
FileSource& fileSource;
|
||||
@@ -297,13 +297,7 @@ void Map::setStyleURL(const std::string& url) {
|
||||
|
||||
impl->style = std::make_unique<Style>(impl->fileSource, impl->pixelRatio);
|
||||
|
||||
const size_t pos = impl->styleURL.rfind('/');
|
||||
std::string base = "";
|
||||
if (pos != std::string::npos) {
|
||||
base = impl->styleURL.substr(0, pos + 1);
|
||||
}
|
||||
|
||||
impl->styleRequest = impl->fileSource.request(Resource::style(impl->styleURL), [this, base](Response res) {
|
||||
impl->styleRequest = impl->fileSource.request(Resource::style(impl->styleURL), [this](Response res) {
|
||||
if (res.error) {
|
||||
if (res.error->reason == Response::Error::Reason::NotFound &&
|
||||
util::mapbox::isMapboxURL(impl->styleURL)) {
|
||||
@@ -314,12 +308,12 @@ void Map::setStyleURL(const std::string& url) {
|
||||
} else if (res.notModified || res.noContent) {
|
||||
return;
|
||||
} else {
|
||||
impl->loadStyleJSON(*res.data, base);
|
||||
impl->loadStyleJSON(*res.data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Map::setStyleJSON(const std::string& json, const std::string& base) {
|
||||
void Map::setStyleJSON(const std::string& json) {
|
||||
if (impl->styleJSON == json) {
|
||||
return;
|
||||
}
|
||||
@@ -332,11 +326,11 @@ void Map::setStyleJSON(const std::string& json, const std::string& base) {
|
||||
impl->styleJSON.clear();
|
||||
impl->style = std::make_unique<Style>(impl->fileSource, impl->pixelRatio);
|
||||
|
||||
impl->loadStyleJSON(json, base);
|
||||
impl->loadStyleJSON(json);
|
||||
}
|
||||
|
||||
void Map::Impl::loadStyleJSON(const std::string& json, const std::string& base) {
|
||||
style->setJSON(json, base);
|
||||
void Map::Impl::loadStyleJSON(const std::string& json) {
|
||||
style->setJSON(json);
|
||||
style->setObserver(this);
|
||||
styleJSON = json;
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ Style::Style(FileSource& fileSource_, float pixelRatio)
|
||||
spriteStore->setObserver(this);
|
||||
}
|
||||
|
||||
void Style::setJSON(const std::string& json, const std::string&) {
|
||||
void Style::setJSON(const std::string& json) {
|
||||
sources.clear();
|
||||
layers.clear();
|
||||
classes.clear();
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
Style(FileSource&, float pixelRatio);
|
||||
~Style();
|
||||
|
||||
void setJSON(const std::string& data, const std::string& base);
|
||||
void setJSON(const std::string&);
|
||||
|
||||
void setObserver(Observer*);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
TEST(Annotations, SymbolAnnotation) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" });
|
||||
test.checkRendering("point_annotation");
|
||||
@@ -51,7 +51,7 @@ TEST(Annotations, LineAnnotation) {
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
annotation.width = 5;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotation(annotation);
|
||||
test.checkRendering("line_annotation");
|
||||
}
|
||||
@@ -63,7 +63,7 @@ TEST(Annotations, FillAnnotation) {
|
||||
FillAnnotation annotation { polygon };
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotation(annotation);
|
||||
test.checkRendering("fill_annotation");
|
||||
}
|
||||
@@ -73,7 +73,7 @@ TEST(Annotations, StyleSourcedShapeAnnotation) {
|
||||
|
||||
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/annotation.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/annotation.json"));
|
||||
test.map.addAnnotation(StyleSourcedAnnotation { polygon, "annotation" });
|
||||
test.checkRendering("style_sourced_shape_annotation");
|
||||
}
|
||||
@@ -81,7 +81,7 @@ TEST(Annotations, StyleSourcedShapeAnnotation) {
|
||||
TEST(Annotations, AddMultiple) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { -10, 0 }, "default_marker" });
|
||||
|
||||
@@ -94,7 +94,7 @@ TEST(Annotations, AddMultiple) {
|
||||
TEST(Annotations, NonImmediateAdd) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test::render(test.map);
|
||||
|
||||
Polygon<double> polygon = {{ {{ { 0, 0 }, { 0, 45 }, { 45, 45 }, { 45, 0 } }} }};
|
||||
@@ -108,7 +108,7 @@ TEST(Annotations, NonImmediateAdd) {
|
||||
TEST(Annotations, UpdateIcon) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("flipped_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "flipped_marker" });
|
||||
|
||||
@@ -124,7 +124,7 @@ TEST(Annotations, UpdateIcon) {
|
||||
TEST(Annotations, UpdatePoint) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotationIcon("flipped_marker", namedMarker("flipped_marker.png"));
|
||||
AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
@@ -138,7 +138,7 @@ TEST(Annotations, UpdatePoint) {
|
||||
TEST(Annotations, RemovePoint) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
AnnotationID point = test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
@@ -156,7 +156,7 @@ TEST(Annotations, RemoveShape) {
|
||||
annotation.color = {{ 255, 0, 0, 1 }};
|
||||
annotation.width = 5;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
AnnotationID shape = test.map.addAnnotation(annotation);
|
||||
|
||||
test::render(test.map);
|
||||
@@ -169,7 +169,7 @@ TEST(Annotations, ImmediateRemoveShape) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.removeAnnotation(test.map.addAnnotation(LineAnnotation { LineString<double>() }));
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
test::render(test.map);
|
||||
}
|
||||
@@ -177,20 +177,20 @@ TEST(Annotations, ImmediateRemoveShape) {
|
||||
TEST(Annotations, SwitchStyle) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
test::render(test.map);
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.checkRendering("switch_style");
|
||||
}
|
||||
|
||||
TEST(Annotations, QueryRenderedFeatures) {
|
||||
AnnotationTest test;
|
||||
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
|
||||
test.map.addAnnotation(SymbolAnnotation { Point<double> { 0, 0 }, "default_marker" });
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ TEST(CustomLayer, Basic) {
|
||||
StubFileSource fileSource;
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
map.addLayer(std::make_unique<CustomLayer>(
|
||||
"custom",
|
||||
[] (void* context) {
|
||||
|
||||
@@ -40,7 +40,7 @@ TEST(API, TEST_REQUIRES_SERVER(RenderMissingTile)) {
|
||||
std::string message;
|
||||
|
||||
// This host does not respond (== connection error).
|
||||
map.setStyleJSON(style, "");
|
||||
map.setStyleJSON(style);
|
||||
map.renderStill([&](std::exception_ptr err, PremultipliedImage&&) {
|
||||
ASSERT_TRUE(err.operator bool());
|
||||
try {
|
||||
|
||||
@@ -32,7 +32,7 @@ TEST(API, RepeatedRender) {
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
|
||||
{
|
||||
map.setStyleJSON(style, "");
|
||||
map.setStyleJSON(style);
|
||||
PremultipliedImage result;
|
||||
map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) {
|
||||
result = std::move(image);
|
||||
@@ -50,7 +50,7 @@ TEST(API, RepeatedRender) {
|
||||
}
|
||||
|
||||
{
|
||||
map.setStyleJSON(style, "");
|
||||
map.setStyleJSON(style);
|
||||
PremultipliedImage result;
|
||||
map.renderStill([&result](std::exception_ptr, PremultipliedImage&& image) {
|
||||
result = std::move(image);
|
||||
|
||||
@@ -21,7 +21,7 @@ TEST(API, SetStyle) {
|
||||
|
||||
{
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleJSON("invalid", "");
|
||||
map.setStyleJSON("invalid");
|
||||
}
|
||||
|
||||
auto observer = Log::removeObserver();
|
||||
|
||||
@@ -56,15 +56,15 @@ TEST(Map, DoubleStyleLoad) {
|
||||
MapTest test;
|
||||
|
||||
Map map(test.view, test.fileSource, MapMode::Still);
|
||||
map.setStyleJSON("", "");
|
||||
map.setStyleJSON("", "");
|
||||
map.setStyleJSON("");
|
||||
map.setStyleJSON("");
|
||||
}
|
||||
|
||||
TEST(Map, AddLayer) {
|
||||
MapTest test;
|
||||
|
||||
Map map(test.view, test.fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
auto layer = std::make_unique<BackgroundLayer>("background");
|
||||
layer->setBackgroundColor({{{ 1, 0, 0, 1 }}});
|
||||
@@ -77,7 +77,7 @@ TEST(Map, RemoveLayer) {
|
||||
MapTest test;
|
||||
|
||||
Map map(test.view, test.fileSource, MapMode::Still);
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
|
||||
|
||||
auto layer = std::make_unique<BackgroundLayer>("background");
|
||||
layer->setBackgroundColor({{{ 1, 0, 0, 1 }}});
|
||||
|
||||
@@ -16,7 +16,7 @@ TEST(Style, UnusedSource) {
|
||||
|
||||
auto now = Clock::now();
|
||||
|
||||
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"), "");
|
||||
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
style.cascade(now, MapMode::Still);
|
||||
style.recalculate(0, now, MapMode::Still);
|
||||
|
||||
@@ -35,7 +35,7 @@ TEST(Style, UnusedSourceActiveViaClassUpdate) {
|
||||
StubFileSource fileSource;
|
||||
Style style { fileSource, 1.0 };
|
||||
|
||||
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"), "");
|
||||
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
EXPECT_TRUE(style.addClass("visible"));
|
||||
EXPECT_TRUE(style.hasClass("visible"));
|
||||
|
||||
@@ -49,7 +49,7 @@ TEST(Style, UnusedSourceActiveViaClassUpdate) {
|
||||
EXPECT_TRUE(unusedSource->isLoaded());
|
||||
|
||||
// Style classes should be cleared upon new style load.
|
||||
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"), "");
|
||||
style.setJSON(util::read_file("test/fixtures/resources/style-unused-sources.json"));
|
||||
EXPECT_FALSE(style.hasClass("visible"));
|
||||
|
||||
now = Clock::now();
|
||||
|
||||
Reference in New Issue
Block a user