Skip to content

Commit

Permalink
Reworked some StringExpression code to support StringExpression
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jasonbeverage committed May 31, 2017
1 parent 8160871 commit ada8ffd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions src/osgEarthFeatures/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down Expand Up @@ -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;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/roads-flattened.earth
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>
</styles>
Expand Down
4 changes: 2 additions & 2 deletions tests/roads.earth
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ http://readymap.org
default {
stroke: #ffffff;
stroke-width: 65m;
stroke-image: ""../data/road.png"";
stroke-image: "../data/road.png";
}
</style>
</styles>
Expand Down Expand Up @@ -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";
}
</style>
</styles>
Expand Down
2 changes: 1 addition & 1 deletion tests/splat-with-mask-layer.earth
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<style type="text/css">
default {
stroke-width: 10m;
stroke-image: ""../data/road.png"";
stroke-image: "../data/road.png";
}
</style>
</styles>
Expand Down

0 comments on commit ada8ffd

Please sign in to comment.