Permalink
Browse files

Implementation of RFC 106: Support of Geomtransform JavaScript Plugin

  • Loading branch information...
Alan Boudreault
Alan Boudreault committed Oct 1, 2013
1 parent a09f2ae commit c465f6c1f8be312221642c70466ae0738322ad49
View
@@ -171,6 +171,17 @@ renderers/agg/src/agg_line_aa_basics.cpp
renderers/agg/src/clipper.cpp
)
include_directories(renderers/agg/include)
set(v8_SOURCES
mapscript/v8/v8_object_wrap.hpp
mapscript/v8/point.cpp
mapscript/v8/line.cpp
mapscript/v8/shape.cpp
mapscript/v8/v8_mapscript.cpp
mapv8.cpp
)
include_directories(mapscript/v8/)
#add_definitions(-DHASH_DEBUG=1)
if(WIN32)
set(REGEX_SOURCES ${REGEX_DIR}/regex.c)
@@ -201,18 +212,18 @@ mapogcfiltercommon.c maprendering.c mapwcs20.c mapogcsld.c
mapresample.c mapwfs.c mapgdal.c mapogcsos.c mapscale.c mapwfs11.c
mapgeomtransform.c mapogroutput.c mapsde.c mapwfslayer.c mapagg.cpp mapkml.cpp
mapgeomutil.cpp mapkmlrenderer.cpp fontcache.c textlayout.c
mapogr.cpp mapcontour.c mapsmoothing.c mapv8.cpp ${REGEX_SOURCES})
mapogr.cpp mapcontour.c mapsmoothing.c ${REGEX_SOURCES})
if(BUILD_DYNAMIC)
add_library(mapserver SHARED ${mapserver_SOURCES} ${agg_SOURCES})
add_library(mapserver SHARED ${mapserver_SOURCES} ${agg_SOURCES} ${v8_SOURCES})
set_target_properties( mapserver PROPERTIES
VERSION ${MapServer_VERSION_STRING}
SOVERSION 1
)
endif(BUILD_DYNAMIC)
if(BUILD_STATIC)
add_library(mapserver_static STATIC ${mapserver_SOURCES} ${agg_SOURCES})
add_library(mapserver_static STATIC ${mapserver_SOURCES} ${agg_SOURCES} ${v8_SOURCES})
set_target_properties( mapserver_static PROPERTIES
VERSION ${MapServer_VERSION_STRING}
SOVERSION 1
@@ -732,18 +743,18 @@ if(WITH_PYTHON)
endif(WITH_PYTHON)
if(WITH_V8)
find_package(V8)
if(V8_FOUND EQUAL 1)
set(USE_V8 1)
include_directories(${V8_INCLUDE})
ms_link_libraries( ${V8_LIBS})
else(V8_FOUND)
message(SEND_ERROR "V8 JavaScript support requested but not found.
FIND_PACKAGE(V8)
IF(V8_FOUND EQUAL 1)
SET(USE_V8_MAPSCRIPT 1)
INCLUDE_DIRECTORIES(${V8_INCLUDE})
MS_LINK_LIBRARIES( ${V8_LIBS})
ELSE(V8_FOUND)
MESSAGE(SEND_ERROR "V8 JavaScript support requested but not found.
HINTS:
- set V8_ROOT environment variable to the installation path of V8.
- add the V8 install directory to the CMAKE_PREFIX_PATH variable (-DCMAKE_PREFIX_PATH=\"/path/to/${component}-install-dir;/path/to/other/dirs\") ")
endif()
endif(WITH_V8)
ENDIF()
ENDIF(WITH_V8)
if(WITH_PHP)
add_subdirectory("mapscript/php")
@@ -867,7 +878,6 @@ status_optional_feature("Thread-safety support" "${USE_THREAD}")
status_optional_feature("KML output" "${USE_KML}")
status_optional_feature("Z+M point coordinate support" "${USE_POINT_Z_M}")
status_optional_feature("XML Mapfile support" "${USE_XMLMAPFILE}")
status_optional_feature("V8 JavaScript" "${USE_V8}")
message(STATUS " * Mapscripts")
status_optional_feature("Python" "${USE_PYTHON_MAPSCRIPT}")
@@ -876,6 +886,7 @@ status_optional_feature("PERL" "${USE_PERL_MAPSCRIPT}")
status_optional_feature("RUBY" "${USE_RUBY_MAPSCRIPT}")
status_optional_feature("JAVA" "${USE_JAVA_MAPSCRIPT}")
status_optional_feature("C#" "${USE_CSHARP_MAPSCRIPT}")
status_optional_feature("V8 Javascript" "${USE_V8_MAPSCRIPT}")
status_optional_feature("Apache Module (Experimental)" "${USE_APACHE_MODULE}")
message(STATUS "")
View
@@ -572,7 +572,7 @@ char *msGetVersion()
#ifdef USE_POINT_Z_M
strcat(version, " SUPPORTS=POINT_Z_M");
#endif
#ifdef USE_V8
#ifdef USE_V8_MAPSCRIPT
strcat(version, " SUPPORTS=V8");
#endif
#ifdef USE_JPEG
View
@@ -5896,7 +5896,7 @@ int initMap(mapObj *map)
msInitQuery(&(map->query));
#ifdef USE_V8
#ifdef USE_V8_MAPSCRIPT
map->v8context = NULL;
#endif
View
@@ -221,8 +221,21 @@ int msDrawTransformedShape(mapObj *map, imageObj *image, shapeObj *shape, styleO
int msGeomTransformShape(mapObj *map, layerObj *layer, shapeObj *shape)
{
int i;
expressionObj *e = &layer->_geomtransform;
expressionObj *e = &layer->_geomtransform;
#ifdef USE_V8_MAPSCRIPT
if (!map->v8context) {
msV8CreateContext(map);
if (!map->v8context)
{
msSetError(MS_V8ERR, "Unable to create v8 context.", "msGeomTransformShape()");
return MS_FAILURE;
}
}
msV8ContextSetLayer(map, layer);
#endif
switch(e->type) {
case MS_GEOMTRANSFORM_EXPRESSION: {
int status;
View
@@ -271,6 +271,14 @@ int msLayerNextShape(layerObj *layer, shapeObj *shape)
return rv;
}
#ifdef USE_V8_MAPSCRIPT
/* we need to force the GetItems for the geomtransform attributes */
if(!layer->items &&
layer->_geomtransform.type == MS_GEOMTRANSFORM_EXPRESSION &&
strstr(layer->_geomtransform.string, "javascript"))
msLayerGetItems(layer);
#endif
/* At the end of switch case (default -> break; -> return MS_FAILURE),
* was following TODO ITEM:
*/
@@ -868,7 +876,7 @@ int msLayerGetFeatureStyle(mapObj *map, layerObj *layer, classObj *c, shapeObj*
stylestring = msStrdup(shape->values[layer->styleitemindex]);
}
else if (strncasecmp(layer->styleitem,"javascript://",13) == 0) {
#ifdef USE_V8
#ifdef USE_V8_MAPSCRIPT
char *filename = layer->styleitem+13;
if (!map->v8context) {
View
@@ -189,6 +189,7 @@ char path[MS_MAXPATHLEN];
<EXPRESSION_STRING>simplifypt { MS_LEXER_RETURN_TOKEN(MS_TOKEN_FUNCTION_SIMPLIFYPT); }
<EXPRESSION_STRING>generalize { MS_LEXER_RETURN_TOKEN(MS_TOKEN_FUNCTION_GENERALIZE); }
<EXPRESSION_STRING>smoothsia { MS_LEXER_RETURN_TOKEN(MS_TOKEN_FUNCTION_SMOOTHSIA); }
<EXPRESSION_STRING>javascript { MS_LEXER_RETURN_TOKEN(MS_TOKEN_FUNCTION_JAVASCRIPT); }
<EXPRESSION_STRING>intersects { MS_LEXER_RETURN_TOKEN(MS_TOKEN_COMPARISON_INTERSECTS); }
<EXPRESSION_STRING>disjoint { MS_LEXER_RETURN_TOKEN(MS_TOKEN_COMPARISON_DISJOINT); }
View
@@ -137,7 +137,7 @@ void msFreeMap(mapObj *map)
msFreeQuery(&(map->query));
#ifdef USE_V8
#ifdef USE_V8_MAPSCRIPT
if (map->v8context)
msV8FreeContext(map);
#endif
View
@@ -46,7 +46,7 @@ int yyerror(parseObj *, const char *);
%left INTERSECTS DISJOINT TOUCHES OVERLAPS CROSSES WITHIN CONTAINS BEYOND DWITHIN
%left AREA LENGTH COMMIFY ROUND
%left TOSTRING
%left YYBUFFER DIFFERENCE SIMPLIFY SIMPLIFYPT GENERALIZE SMOOTHSIA
%left YYBUFFER DIFFERENCE SIMPLIFY SIMPLIFYPT GENERALIZE SMOOTHSIA JAVASCRIPT
%left '+' '-'
%left '*' '/' '%'
%left NEG
@@ -629,6 +629,17 @@ shape_exp: SHAPE
s->scratch = MS_TRUE;
$$ = s;
}
| JAVASCRIPT '(' shape_exp ',' string_exp ')' {
shapeObj *s;
s = msV8TransformShape($3, $5);
free($5);
if(!s) {
yyerror(p, "Executing javascript failed.");
return(-1);
}
s->scratch = MS_TRUE;
$$ = s;
}
;
string_exp: STRING
@@ -752,7 +763,8 @@ int yylex(YYSTYPE *lvalp, parseObj *p)
case MS_TOKEN_FUNCTION_SIMPLIFY: token = SIMPLIFY; break;
case MS_TOKEN_FUNCTION_SIMPLIFYPT: token = SIMPLIFYPT; break;
case MS_TOKEN_FUNCTION_GENERALIZE: token = GENERALIZE; break;
case MS_TOKEN_FUNCTION_SMOOTHSIA: token = SMOOTHSIA; break;
case MS_TOKEN_FUNCTION_SMOOTHSIA: token = SMOOTHSIA; break;
case MS_TOKEN_FUNCTION_JAVASCRIPT: token = JAVASCRIPT; break;
default:
break;
Oops, something went wrong.

0 comments on commit c465f6c

Please sign in to comment.