From ada8ffdb3c41350eaec825390362806d46686ed7 Mon Sep 17 00:00:00 2001 From: Jason Beverage Date: Wed, 31 May 2017 17:47:59 -0400 Subject: [PATCH] Reworked some StringExpression code to support StringExpression literals without having to use double quotes. If a script fails to execute then it will fall back on the source as the string literal. ../src/osgEarthDrivers/script_engine_duktape/DuktapeEngine.cpp ../data/splat/nlcd_2011_landcover_2011_edition_2014_03_31_tiled.tif ../data/splat/nlcd_2011_landcover_2011_edition_2014_03_31_tiled.tif.ovr --- .../script_engine_duktape/DuktapeEngine.cpp | 2 +- src/osgEarthFeatures/Feature.cpp | 12 ++++++++++-- tests/roads-flattened.earth | 4 ++-- tests/roads.earth | 4 ++-- tests/splat-with-mask-layer.earth | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/osgEarthDrivers/script_engine_duktape/DuktapeEngine.cpp b/src/osgEarthDrivers/script_engine_duktape/DuktapeEngine.cpp index 5eab4189b6..533ad74f0a 100644 --- a/src/osgEarthDrivers/script_engine_duktape/DuktapeEngine.cpp +++ b/src/osgEarthDrivers/script_engine_duktape/DuktapeEngine.cpp @@ -308,7 +308,7 @@ DuktapeEngine::run(const std::string& code, if ( !ok ) { - OE_WARN << LC << "Error: source =" << std::endl << code << std::endl; + OE_DEBUG << LC << "Error: source =" << std::endl << code << std::endl; } // pop the return value: diff --git a/src/osgEarthFeatures/Feature.cpp b/src/osgEarthFeatures/Feature.cpp index 14cac0311a..0c5f860822 100644 --- a/src/osgEarthFeatures/Feature.cpp +++ b/src/osgEarthFeatures/Feature.cpp @@ -402,7 +402,11 @@ Feature::eval( StringExpression& expr, FilterContext const* context ) const if (result.success()) val = result.asString(); else - OE_WARN << LC << "Feature Script error on '" << expr.expr() << "': " << result.message() << std::endl; + { + // Couldn't execute it as code, just take it as a string literal. + val = i->first; + OE_DEBUG << LC << "Feature Script error on '" << expr.expr() << "': " << result.message() << std::endl; + } } } @@ -434,7 +438,11 @@ Feature::eval(StringExpression& expr, Session* session) const if (result.success()) val = result.asString(); else - OE_WARN << LC << "Feature Script error on '" << expr.expr() << "': " << result.message() << std::endl; + { + // Couldn't execute it as code, just take it as a string literal. + val = i->first; + OE_DEBUG << LC << "Feature Script error on '" << expr.expr() << "': " << result.message() << std::endl; + } } } diff --git a/tests/roads-flattened.earth b/tests/roads-flattened.earth index e4a3f06767..b96aedaef2 100644 --- a/tests/roads-flattened.earth +++ b/tests/roads-flattened.earth @@ -74,12 +74,12 @@ default { stroke: #ffffff; stroke-width: 12m; - stroke-image: ""../data/road.png""; + stroke-image: ../data/road.png; } asphalt { stroke: #ffffff; stroke-width: 4m; - stroke-image: ""../data/asphalt.jpg""; + stroke-image: ../data/asphalt.jpg; } diff --git a/tests/roads.earth b/tests/roads.earth index eb8c7dfda5..365cbae263 100644 --- a/tests/roads.earth +++ b/tests/roads.earth @@ -34,7 +34,7 @@ http://readymap.org default { stroke: #ffffff; stroke-width: 65m; - stroke-image: ""../data/road.png""; + stroke-image: "../data/road.png"; } @@ -65,7 +65,7 @@ http://readymap.org stroke-width: 65m; render-depth-test: false; render-order: 2; - stroke-image: ""../data/grid.png""; + stroke-image: "../data/grid.png"; } diff --git a/tests/splat-with-mask-layer.earth b/tests/splat-with-mask-layer.earth index 5c607eef0b..41dd2ae374 100644 --- a/tests/splat-with-mask-layer.earth +++ b/tests/splat-with-mask-layer.earth @@ -69,7 +69,7 @@