- Timestamp:
- Mar 16, 2014, 5:57:37 PM (11 years ago)
- Location:
- trunk/packages/vizservers/geovis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/geovis/RenderServer.h
r4028 r4246 19 19 class ResponseQueue; 20 20 21 #define GEOVIS_VERSION_STRING "0. 1"21 #define GEOVIS_VERSION_STRING "0.2" 22 22 23 23 #define MSECS_ELAPSED(t1, t2) \ -
trunk/packages/vizservers/geovis/Renderer.cpp
r4087 r4246 21 21 #include <osgEarth/Version> 22 22 #include <osgEarth/MapNode> 23 #include <osgEarth/Bounds> 24 #include <osgEarth/Profile> 23 25 #include <osgEarth/TerrainLayer> 24 26 #include <osgEarth/ImageLayer> … … 28 30 #include <osgEarthUtil/AutoClipPlaneHandler> 29 31 #include <osgEarthUtil/MouseCoordsTool> 32 #include <osgEarthUtil/GLSLColorFilter> 30 33 #include <osgEarthDrivers/gdal/GDALOptions> 34 #include <osgEarthDrivers/engine_mp/MPTerrainEngineOptions> 31 35 32 36 #include "Renderer.h" … … 36 40 ((t1).tv_sec == (t2).tv_sec ? (((t2).tv_usec - (t1).tv_usec)/1.0e+3) : \ 37 41 (((t2).tv_sec - (t1).tv_sec))*1.0e+3 + (double)((t2).tv_usec - (t1).tv_usec)/1.0e+3) 42 43 #define BASE_IMAGE "/usr/share/osgearth/data/world.tif" 38 44 39 45 using namespace GeoVis; … … 58 64 osgEarth::MapOptions mapOpts; 59 65 mapOpts.coordSysType() = osgEarth::MapOptions::CSTYPE_PROJECTED; 60 mapOpts.profile() = osgEarth::ProfileOptions("global- geodetic");66 mapOpts.profile() = osgEarth::ProfileOptions("global-mercator"); 61 67 osgEarth::Map *map = new osgEarth::Map(mapOpts); 62 68 _map = map; 63 69 osgEarth::Drivers::GDALOptions bopts; 64 bopts.url() = "/usr/share/osgearth/data/world.tif";70 bopts.url() = BASE_IMAGE; 65 71 addImageLayer("base", bopts); 66 osgEarth::MapNodeOptions mapNodeOpts; 72 osgEarth::Drivers::MPTerrainEngineOptions mpOpt; 73 // Set background layer color 74 mpOpt.color() = osg::Vec4(1, 1, 1, 1); 75 //mpOpt.minLOD() = 1; 76 osgEarth::MapNodeOptions mapNodeOpts(mpOpt); 67 77 mapNodeOpts.enableLighting() = false; 68 78 osgEarth::MapNode *mapNode = new osgEarth::MapNode(map, mapNodeOpts); … … 81 91 _viewer->setUpViewInWindow(0, 0, _windowWidth, _windowHeight); 82 92 _viewer->realize(); 93 initColorMaps(); 83 94 #ifdef DEBUG 84 95 if (_viewer->getViewerStats() != NULL) { … … 110 121 111 122 TRACE("Leave"); 123 } 124 125 void Renderer::initColorMaps() 126 { 127 osg::TransferFunction1D *defaultColorMap = new osg::TransferFunction1D; 128 defaultColorMap->allocate(256); 129 defaultColorMap->setColor(0.00, osg::Vec4f(0,0,1,1), false); 130 defaultColorMap->setColor(0.25, osg::Vec4f(0,1,1,1), false); 131 defaultColorMap->setColor(0.50, osg::Vec4f(0,1,0,1), false); 132 defaultColorMap->setColor(0.75, osg::Vec4f(1,1,0,1), false); 133 defaultColorMap->setColor(1.00, osg::Vec4f(1,0,0,1), false); 134 defaultColorMap->updateImage(); 135 addColorMap("default", defaultColorMap); 136 osg::TransferFunction1D *defaultGrayColorMap = new osg::TransferFunction1D; 137 defaultGrayColorMap->allocate(256); 138 defaultGrayColorMap->setColor(0, osg::Vec4f(0,0,0,1), false); 139 defaultGrayColorMap->setColor(1, osg::Vec4f(1,1,1,1), false); 140 defaultGrayColorMap->updateImage(); 141 addColorMap("grayDefault", defaultGrayColorMap); 142 } 143 144 void Renderer::addColorMap(const ColorMapId& id, osg::TransferFunction1D *xfer) 145 { 146 _colorMaps[id] = xfer; 147 #if 0 148 osgEarth::Drivers::GDALOptions opts; 149 char *url = Tcl_GetString(objv[4]); 150 std::ostringstream oss; 151 oss << "_cmap_" << id; 152 153 opts.url() = url; 154 155 addImageLayer(oss.str().c_str(), opts); 156 #endif 157 } 158 159 void Renderer::deleteColorMap(const ColorMapId& id) 160 { 161 ColorMapHashmap::iterator itr; 162 bool doAll = false; 163 164 if (id.compare("all") == 0) { 165 itr = _colorMaps.begin(); 166 doAll = true; 167 } else { 168 itr = _colorMaps.find(id); 169 } 170 171 if (itr == _colorMaps.end()) { 172 ERROR("Unknown ColorMap %s", id.c_str()); 173 return; 174 } 175 176 do { 177 if (itr->first.compare("default") == 0 || 178 itr->first.compare("grayDefault") == 0) { 179 if (id.compare("all") != 0) { 180 WARN("Cannot delete a default color map"); 181 } 182 continue; 183 } 184 185 TRACE("Deleting ColorMap %s", itr->first.c_str()); 186 itr = _colorMaps.erase(itr); 187 } while (doAll && itr != _colorMaps.end()); 188 } 189 190 void Renderer::setColorMapNumberOfTableEntries(const ColorMapId& id, 191 int numEntries) 192 { 193 ColorMapHashmap::iterator itr; 194 bool doAll = false; 195 196 if (id.compare("all") == 0) { 197 itr = _colorMaps.begin(); 198 doAll = true; 199 } else { 200 itr = _colorMaps.find(id); 201 } 202 203 if (itr == _colorMaps.end()) { 204 ERROR("Unknown ColorMap %s", id.c_str()); 205 return; 206 } 207 208 do { 209 itr->second->allocate(numEntries); 210 itr->second->updateImage(); 211 } while (doAll && ++itr != _colorMaps.end()); 112 212 } 113 213 … … 152 252 } 153 253 154 void Renderer::resetMap(osgEarth::MapOptions::CoordinateSystemType type, const char *profile) 254 void Renderer::resetMap(osgEarth::MapOptions::CoordinateSystemType type, 255 const char *profile, 256 double bounds[4]) 155 257 { 156 258 TRACE("Restting map with type %d, profile %s", type, profile); … … 159 261 mapOpts.coordSysType() = type; 160 262 if (profile != NULL) { 161 mapOpts.profile() = osgEarth::ProfileOptions(profile); 263 if (bounds != NULL) { 264 mapOpts.profile() = osgEarth::ProfileOptions(); 265 if (strcmp(profile, "geodetic") == 0) { 266 mapOpts.profile()->srsString() = "epsg:4326"; 267 } else if (strcmp(profile, "spherical-mercator") == 0) { 268 // Projection used by Google/Bing/OSM 269 // aka epsg:900913 meters in x/y 270 // aka WGS84 Web Mercator (Auxiliary Sphere) 271 // X/Y: -20037508.34m to 20037508.34m 272 mapOpts.profile()->srsString() = "epsg:3857"; 273 } else { 274 mapOpts.profile()->srsString() = profile; 275 } 276 mapOpts.profile()->bounds() = 277 osgEarth::Bounds(bounds[0], bounds[1], bounds[2], bounds[3]); 278 } else { 279 mapOpts.profile() = osgEarth::ProfileOptions(profile); 280 } 162 281 } else if (type == osgEarth::MapOptions::CSTYPE_PROJECTED) { 163 mapOpts.profile() = osgEarth::ProfileOptions("global-geodetic"); 282 mapOpts.profile() = osgEarth::ProfileOptions("global-mercator"); 283 } 284 if (bounds != NULL) { 285 TRACE("Setting profile bounds: %g %g %g %g", 286 bounds[0], bounds[1], bounds[2], bounds[3]); 287 mapOpts.profile()->bounds() = 288 osgEarth::Bounds(bounds[0], bounds[1], bounds[2], bounds[3]); 164 289 } 165 290 osgEarth::Map *map = new osgEarth::Map(mapOpts); 166 291 _map = map; 167 osgEarth::MapNodeOptions mapNodeOpts; 292 osgEarth::Drivers::GDALOptions bopts; 293 bopts.url() = BASE_IMAGE; 294 addImageLayer("base", bopts); 295 osgEarth::Drivers::MPTerrainEngineOptions mpOpt; 296 // Set background layer color 297 mpOpt.color() = osg::Vec4(1, 1, 1, 1); 298 //mpOpt.minLOD() = 1; 299 osgEarth::MapNodeOptions mapNodeOpts(mpOpt); 168 300 mapNodeOpts.enableLighting() = false; 169 301 osgEarth::MapNode *mapNode = new osgEarth::MapNode(map, mapNodeOpts); … … 212 344 } 213 345 214 void Renderer::addImageLayer(const char *name, const osgEarth::TileSourceOptions& opts) 346 void Renderer::addImageLayer(const char *name, 347 const osgEarth::TileSourceOptions& opts, 348 bool makeShared, 349 bool visible) 215 350 { 216 351 osgEarth::ImageLayerOptions layerOpts(name, opts); 352 if (makeShared) { 353 layerOpts.shared() = true; 354 } 355 if (!visible) { 356 layerOpts.visible() = false; 357 } 217 358 _map->addImageLayer(new osgEarth::ImageLayer(layerOpts)); 359 _needsRedraw = true; 360 } 361 362 void Renderer::addColorFilter(const char *name, 363 const char *shader) 364 { 365 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name); 366 if (layer == NULL) { 367 TRACE("Image layer not found: %s", name); 368 return; 369 } 370 osgEarth::Util::GLSLColorFilter *filter = new osgEarth::Util::GLSLColorFilter; 371 filter->setCode(shader); 372 //filter->setCode("color.rgb = color.r > 0.5 ? vec3(1.0) : vec3(0.0);"); 373 layer->addColorFilter(filter); 374 _needsRedraw = true; 375 } 376 377 void Renderer::removeColorFilter(const char *name, int idx) 378 { 379 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name); 380 if (layer == NULL) { 381 TRACE("Image layer not found: %s", name); 382 return; 383 } 384 if (idx < 0) { 385 while (!layer->getColorFilters().empty()) { 386 layer->removeColorFilter(layer->getColorFilters()[0]); 387 } 388 } else { 389 layer->removeColorFilter(layer->getColorFilters().at(idx)); 390 } 218 391 _needsRedraw = true; 219 392 } … … 265 438 } 266 439 267 void Renderer::addElevationLayer(const char *name, const osgEarth::TileSourceOptions& opts) 268 { 440 void Renderer::addElevationLayer(const char *name, 441 const osgEarth::TileSourceOptions& opts) 442 { 443 // XXX: GDAL does not report vertical datum, it should be specified here 269 444 osgEarth::ElevationLayerOptions layerOpts(name, opts); 445 //layerOpts.verticalDatum() = ""; 270 446 _map->addElevationLayer(new osgEarth::ElevationLayer(layerOpts)); 271 447 _needsRedraw = true; -
trunk/packages/vizservers/geovis/Renderer.h
r4054 r4246 17 17 #include <osg/Node> 18 18 #include <osg/Image> 19 #include <osg/TransferFunction> 19 20 #include <osgViewer/Viewer> 20 21 … … 126 127 { 127 128 public: 129 typedef std::string ColorMapId; 130 128 131 Renderer(); 129 132 virtual ~Renderer(); 130 133 134 // Colormaps 135 136 void addColorMap(const ColorMapId& id, osg::TransferFunction1D *xfer); 137 138 void deleteColorMap(const ColorMapId& id); 139 140 void setColorMapNumberOfTableEntries(const ColorMapId& id, int numEntries); 141 131 142 // Scene 132 143 133 144 void loadEarthFile(const char *path); 134 145 135 void resetMap(osgEarth::MapOptions::CoordinateSystemType type, const char *profile = NULL); 146 void resetMap(osgEarth::MapOptions::CoordinateSystemType type, 147 const char *profile = NULL, 148 double bounds[4] = NULL); 136 149 137 150 void clearMap(); … … 148 161 } 149 162 150 void addImageLayer(const char *name, const osgEarth::TileSourceOptions& opts); 163 void addImageLayer(const char *name, const osgEarth::TileSourceOptions& opts, 164 bool makeShared = false, bool visible = true); 151 165 152 166 void removeImageLayer(const char *name); … … 158 172 void setImageLayerVisibility(const char *name, bool state); 159 173 174 void addColorFilter(const char *name, const char *shader); 175 176 void removeColorFilter(const char *name, int idx = -1); 177 160 178 // Elevation raster layers 161 179 … … 256 274 257 275 private: 276 typedef std::tr1::unordered_map<ColorMapId, osg::ref_ptr<osg::TransferFunction1D> > ColorMapHashmap; 277 278 void initColorMaps(); 279 258 280 void initCamera(); 259 281 … … 270 292 double _minFrameTime; 271 293 double _lastFrameTime; 294 295 ColorMapHashmap _colorMaps; 272 296 273 297 osg::ref_ptr<osg::Node> _sceneRoot; -
trunk/packages/vizservers/geovis/RendererCmd.cpp
r4110 r4246 19 19 #include <tcl.h> 20 20 21 #include <osgEarth/Registry> 21 22 #include <osgEarthFeatures/FeatureModelSource> 22 23 #include <osgEarthSymbology/Color> … … 27 28 28 29 #include <osgEarthDrivers/gdal/GDALOptions> 30 #include <osgEarthDrivers/tms/TMSOptions> 31 #include <osgEarthDrivers/wms/WMSOptions> 29 32 #include <osgEarthDrivers/model_feature_geom/FeatureGeomModelOptions> 30 33 #include <osgEarthDrivers/feature_ogr/OGRFeatureOptions> … … 333 336 334 337 static int 338 ColorMapAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 339 Tcl_Obj *const *objv) 340 { 341 const char *name = Tcl_GetString(objv[2]); 342 int cmapc, omapc; 343 Tcl_Obj **cmapv = NULL; 344 Tcl_Obj **omapv = NULL; 345 346 if (Tcl_ListObjGetElements(interp, objv[3], &cmapc, &cmapv) != TCL_OK) { 347 return TCL_ERROR; 348 } 349 if ((cmapc % 4) != 0) { 350 Tcl_AppendResult(interp, "wrong # elements in colormap: should be ", 351 "{ value r g b ... }", (char*)NULL); 352 return TCL_ERROR; 353 } 354 355 osg::TransferFunction1D *colorMap = new osg::TransferFunction1D; 356 colorMap->allocate(256); 357 358 for (int i = 0; i < cmapc; i += 4) { 359 double val[4]; 360 for (int j = 0; j < 4; j++) { 361 if (Tcl_GetDoubleFromObj(interp, cmapv[i+j], &val[j]) != TCL_OK) { 362 delete colorMap; 363 return TCL_ERROR; 364 } 365 if ((val[j] < 0.0) || (val[j] > 1.0)) { 366 Tcl_AppendResult(interp, "bad colormap value \"", 367 Tcl_GetString(cmapv[i+j]), 368 "\": should be in the range [0,1]", (char*)NULL); 369 delete colorMap; 370 return TCL_ERROR; 371 } 372 } 373 colorMap->setColor(val[0], osg::Vec4f(val[1], val[2], val[3], 1.0), false); 374 } 375 376 colorMap->updateImage(); 377 378 if (Tcl_ListObjGetElements(interp, objv[4], &omapc, &omapv) != TCL_OK) { 379 delete colorMap; 380 return TCL_ERROR; 381 } 382 if ((omapc % 2) != 0) { 383 Tcl_AppendResult(interp, "wrong # elements in opacitymap: should be ", 384 "{ value alpha ... }", (char*)NULL); 385 delete colorMap; 386 return TCL_ERROR; 387 } 388 for (int i = 0; i < omapc; i += 2) { 389 double val[2]; 390 for (int j = 0; j < 2; j++) { 391 if (Tcl_GetDoubleFromObj(interp, omapv[i+j], &val[j]) != TCL_OK) { 392 delete colorMap; 393 return TCL_ERROR; 394 } 395 if ((val[j] < 0.0) || (val[j] > 1.0)) { 396 Tcl_AppendResult(interp, "bad opacitymap value \"", 397 Tcl_GetString(omapv[i+j]), 398 "\": should be in the range [0,1]", (char*)NULL); 399 delete colorMap; 400 return TCL_ERROR; 401 } 402 } 403 #if 0 404 ColorMap::OpacityControlPoint ocp; 405 ocp.value = val[0]; 406 ocp.alpha = val[1]; 407 colorMap->addOpacityControlPoint(ocp); 408 #endif 409 } 410 411 //colorMap->build(); 412 g_renderer->addColorMap(name, colorMap); 413 return TCL_OK; 414 } 415 416 static int 417 ColorMapDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 418 Tcl_Obj *const *objv) 419 { 420 if (objc == 3) { 421 const char *name = Tcl_GetString(objv[2]); 422 g_renderer->deleteColorMap(name); 423 } else { 424 g_renderer->deleteColorMap("all"); 425 } 426 427 return TCL_OK; 428 } 429 430 static int 431 ColorMapNumTableEntriesOp(ClientData clientData, Tcl_Interp *interp, int objc, 432 Tcl_Obj *const *objv) 433 { 434 int numEntries; 435 if (Tcl_GetIntFromObj(interp, objv[2], &numEntries) != TCL_OK) { 436 const char *str = Tcl_GetString(objv[2]); 437 if (str[0] == 'd' && strcmp(str, "default") == 0) { 438 numEntries = -1; 439 } else { 440 Tcl_AppendResult(interp, "bad colormap resolution value \"", str, 441 "\": should be a positive integer or \"default\"", (char*)NULL); 442 return TCL_ERROR; 443 } 444 } else if (numEntries < 1) { 445 Tcl_AppendResult(interp, "bad colormap resolution value \"", Tcl_GetString(objv[2]), 446 "\": should be a positive integer or \"default\"", (char*)NULL); 447 return TCL_ERROR; 448 } 449 if (objc == 4) { 450 const char *name = Tcl_GetString(objv[3]); 451 452 g_renderer->setColorMapNumberOfTableEntries(name, numEntries); 453 } else { 454 g_renderer->setColorMapNumberOfTableEntries("all", numEntries); 455 } 456 return TCL_OK; 457 } 458 459 static CmdSpec colorMapOps[] = { 460 {"add", 1, ColorMapAddOp, 5, 5, "colorMapName colormap alphamap"}, 461 {"define", 3, ColorMapAddOp, 5, 5, "colorMapName colormap alphamap"}, 462 {"delete", 3, ColorMapDeleteOp, 2, 3, "?colorMapName?"}, 463 {"res", 1, ColorMapNumTableEntriesOp, 3, 4, "numTableEntries ?colorMapName?"} 464 }; 465 static int nColorMapOps = NumCmdSpecs(colorMapOps); 466 467 static int 468 ColorMapCmd(ClientData clientData, Tcl_Interp *interp, int objc, 469 Tcl_Obj *const *objv) 470 { 471 Tcl_ObjCmdProc *proc; 472 473 proc = GetOpFromObj(interp, nColorMapOps, colorMapOps, 474 CMDSPEC_ARG1, objc, objv, 0); 475 if (proc == NULL) { 476 return TCL_ERROR; 477 } 478 return (*proc) (clientData, interp, objc, objv); 479 } 480 481 static int 335 482 ImageFlushCmd(ClientData clientData, Tcl_Interp *interp, int objc, 336 483 Tcl_Obj *const *objv) … … 399 546 400 547 g_renderer->addImageLayer(name, opts); 548 } else if (type[0] == 't' && strcmp(type, "tms") == 0) { 549 osgEarth::Drivers::TMSOptions opts; 550 char *url = Tcl_GetString(objv[4]); 551 //char *tmsType = Tcl_GetString(objv[5]); 552 //char *format = Tcl_GetString(objv[6]); 553 char *name = Tcl_GetString(objv[5]); 554 555 opts.url() = url; 556 //opts.tmsType() = tmsType; 557 //opts.format() = format; 558 559 g_renderer->addImageLayer(name, opts); 560 } else if (type[0] == 'w' && strcmp(type, "wms") == 0) { 561 osgEarth::Drivers::WMSOptions opts; 562 char *url = Tcl_GetString(objv[4]); 563 char *wmsLayers = Tcl_GetString(objv[5]); 564 char *format = Tcl_GetString(objv[6]); 565 bool transparent; 566 if (GetBooleanFromObj(interp, objv[7], &transparent) != TCL_OK) { 567 return TCL_ERROR; 568 } 569 char *name = Tcl_GetString(objv[8]); 570 571 opts.url() = url; 572 opts.layers() = wmsLayers; 573 opts.format() = format; 574 opts.transparent() = transparent; 575 576 g_renderer->addImageLayer(name, opts); 401 577 } else if (type[0] == 'e' && strcmp(type, "elevation") == 0) { 402 578 osgEarth::Drivers::GDALOptions opts; … … 407 583 408 584 g_renderer->addElevationLayer(name, opts); 409 } else if (type[0] == ' m' && strcmp(type, "model") == 0) {585 } else if (type[0] == 'p' && strcmp(type, "point") == 0) { 410 586 osgEarth::Drivers::OGRFeatureOptions opts; 411 587 char *url = Tcl_GetString(objv[4]); … … 414 590 415 591 osgEarth::Symbology::Style style; 592 osgEarth::Symbology::PointSymbol *ls = style.getOrCreateSymbol<osgEarth::Symbology::PointSymbol>(); 593 ls->fill()->color() = osgEarth::Symbology::Color::Black; 594 ls->size() = 2.0f; 595 596 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); 597 rs->depthOffset()->enabled() = true; 598 rs->depthOffset()->minBias() = 1000; 599 600 osgEarth::Drivers::FeatureGeomModelOptions geomOpts; 601 geomOpts.featureOptions() = opts; 602 geomOpts.styles() = new osgEarth::Symbology::StyleSheet(); 603 geomOpts.styles()->addStyle(style); 604 geomOpts.enableLighting() = false; 605 g_renderer->addModelLayer(name, geomOpts); 606 } else if (type[0] == 'p' && strcmp(type, "polygon") == 0) { 607 osgEarth::Drivers::OGRFeatureOptions opts; 608 char *url = Tcl_GetString(objv[4]); 609 char *name = Tcl_GetString(objv[5]); 610 opts.url() = url; 611 612 osgEarth::Symbology::Style style; 613 osgEarth::Symbology::PolygonSymbol *ls = style.getOrCreateSymbol<osgEarth::Symbology::PolygonSymbol>(); 614 ls->fill()->color() = osgEarth::Symbology::Color::White; 615 616 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); 617 rs->depthOffset()->enabled() = true; 618 rs->depthOffset()->minBias() = 1000; 619 620 osgEarth::Drivers::FeatureGeomModelOptions geomOpts; 621 geomOpts.featureOptions() = opts; 622 geomOpts.styles() = new osgEarth::Symbology::StyleSheet(); 623 geomOpts.styles()->addStyle(style); 624 geomOpts.enableLighting() = false; 625 g_renderer->addModelLayer(name, geomOpts); 626 } else if (type[0] == 'l' && strcmp(type, "line") == 0) { 627 osgEarth::Drivers::OGRFeatureOptions opts; 628 char *url = Tcl_GetString(objv[4]); 629 char *name = Tcl_GetString(objv[5]); 630 opts.url() = url; 631 632 osgEarth::Symbology::Style style; 416 633 osgEarth::Symbology::LineSymbol *ls = style.getOrCreateSymbol<osgEarth::Symbology::LineSymbol>(); 417 634 ls->stroke()->color() = osgEarth::Symbology::Color::Black; 418 635 ls->stroke()->width() = 2.0f; 636 637 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); 638 rs->depthOffset()->enabled() = true; 639 rs->depthOffset()->minBias() = 1000; 640 641 osgEarth::Drivers::FeatureGeomModelOptions geomOpts; 642 geomOpts.featureOptions() = opts; 643 geomOpts.styles() = new osgEarth::Symbology::StyleSheet(); 644 geomOpts.styles()->addStyle(style); 645 geomOpts.enableLighting() = false; 646 g_renderer->addModelLayer(name, geomOpts); 647 } else if (type[0] == 't' && strcmp(type, "text") == 0) { 648 osgEarth::Drivers::OGRFeatureOptions opts; 649 char *url = Tcl_GetString(objv[4]); 650 char *name = Tcl_GetString(objv[5]); 651 opts.url() = url; 652 653 osgEarth::Symbology::Style style; 654 osgEarth::Symbology::TextSymbol *ts = style.getOrCreateSymbol<osgEarth::Symbology::TextSymbol>(); 655 ts->halo()->color() = osgEarth::Symbology::Color::White; 656 ts->halo()->width() = 2.0f; 657 ts->fill()->color() = osgEarth::Symbology::Color::Black; 419 658 420 659 osgEarth::Symbology::RenderSymbol* rs = style.getOrCreateSymbol<osgEarth::Symbology::RenderSymbol>(); … … 511 750 512 751 static CmdSpec mapLayerOps[] = { 513 {"add", 1, MapLayerAddOp, 6, 6, "type urlname"},752 {"add", 1, MapLayerAddOp, 6, 9, "type url ?args? name"}, 514 753 {"delete", 1, MapLayerDeleteOp, 3, 4, "?name?"}, 515 754 {"move", 1, MapLayerMoveOp, 5, 5, "pos name"}, … … 584 823 } else { 585 824 Tcl_AppendResult(interp, "bad map type \"", typeStr, 586 "\": must be geocentric, geocentric_cube or projected", (char*)NULL); 587 return TCL_ERROR; 588 } 589 590 char *profile = NULL; 591 if (objc > 3) { 592 profile = Tcl_GetString(objv[3]); 593 } 594 595 g_renderer->resetMap(type, profile); 825 "\": must be geocentric or projected", (char*)NULL); 826 return TCL_ERROR; 827 } 828 829 if (type == osgEarth::MapOptions::CSTYPE_PROJECTED) { 830 if (objc < 4) { 831 Tcl_AppendResult(interp, "wrong # arguments: profile required for projected maps", (char*)NULL); 832 return TCL_ERROR; 833 } 834 char *profile = Tcl_GetString(objv[3]); 835 if (objc > 4) { 836 if (objc < 8) { 837 Tcl_AppendResult(interp, "wrong # arguments: 4 bounds arguments required", (char*)NULL); 838 return TCL_ERROR; 839 } 840 double bounds[4]; 841 for (int i = 0; i < 4; i++) { 842 if (Tcl_GetDoubleFromObj(interp, objv[4+i], &bounds[i]) != TCL_OK) { 843 return TCL_ERROR; 844 } 845 } 846 // Check if min > max 847 if (bounds[0] > bounds[2] || 848 bounds[1] > bounds[3]) { 849 Tcl_AppendResult(interp, "invalid bounds", (char*)NULL); 850 return TCL_ERROR; 851 } 852 if (strcmp(profile, "geodetic") == 0 || 853 strcmp(profile, "epsg:4326") == 0 ) { 854 if (bounds[0] < -180. || bounds[0] > 180. || 855 bounds[2] < -180. || bounds[2] > 180. || 856 bounds[1] < -90. || bounds[1] > 90. || 857 bounds[3] < -90. || bounds[3] > 90.) { 858 Tcl_AppendResult(interp, "invalid bounds", (char*)NULL); 859 return TCL_ERROR; 860 } 861 } else if (strcmp(profile, "spherical-mercator") == 0 || 862 strcmp(profile, "epsg:900913") == 0 || 863 strcmp(profile, "epsg:3857") == 0) { 864 for (int i = 0; i < 4; i++) { 865 if (bounds[i] < -20037508.34 || bounds[i] > 20037508.34) { 866 Tcl_AppendResult(interp, "invalid bounds", (char*)NULL); 867 return TCL_ERROR; 868 } 869 } 870 } 871 872 g_renderer->resetMap(type, profile, bounds); 873 } else { 874 if (osgEarth::Registry::instance()->getNamedProfile(profile) == NULL) { 875 Tcl_AppendResult(interp, "bad named profile \"", profile, 876 "\": must be e.g. 'global-geodetic', 'global-mercator'...", (char*)NULL); 877 return TCL_ERROR; 878 } 879 g_renderer->resetMap(type, profile); 880 } 881 } else { 882 // No profile required for geocentric (3D) maps 883 g_renderer->resetMap(type); 884 } 596 885 597 886 return TCL_OK; … … 599 888 600 889 static CmdSpec mapOps[] = { 601 {"layer", 2, MapLayerOp, 3, 6, "op ?params...?"},890 {"layer", 2, MapLayerOp, 3, 9, "op ?params...?"}, 602 891 {"load", 2, MapLoadOp, 4, 5, "options"}, 603 {"reset", 1, MapResetOp, 3, 4, "type ?profile?"},892 {"reset", 1, MapResetOp, 3, 8, "type ?profile xmin ymin xmax ymax?"}, 604 893 }; 605 894 static int nMapOps = NumCmdSpecs(mapOps); … … 913 1202 } 914 1203 while (inBufPtr->isLineAvailable() || 915 ( select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr) > 0)) {1204 (ret = select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr)) > 0) { 916 1205 size_t numBytes; 917 1206 unsigned char *buffer; … … 1021 1310 Tcl_CreateObjCommand(interp, "camera", CameraCmd, clientData, NULL); 1022 1311 Tcl_CreateObjCommand(interp, "clientinfo", ClientInfoCmd, clientData, NULL); 1312 Tcl_CreateObjCommand(interp, "colormap", ColorMapCmd, clientData, NULL); 1023 1313 Tcl_CreateObjCommand(interp, "imgflush", ImageFlushCmd, clientData, NULL); 1024 1314 Tcl_CreateObjCommand(interp, "key", KeyCmd, clientData, NULL); … … 1036 1326 Tcl_DeleteCommand(interp, "camera"); 1037 1327 Tcl_DeleteCommand(interp, "clientinfo"); 1328 Tcl_DeleteCommand(interp, "colormap"); 1038 1329 Tcl_DeleteCommand(interp, "imgflush"); 1039 1330 Tcl_DeleteCommand(interp, "key"); -
trunk/packages/vizservers/geovis/geovis_protocol.txt
r4053 r4246 59 59 screen size <width> <height> 60 60 61 map layer add <type> <url> <layerName> 61 General form: 62 map layer add <type> <url> ... <layerName> 63 <type> = image|wms|tms|elevation|point|polygon|line|text 64 65 map layer add image <url> <layerName> 62 66 Add a GDAL image layer from a file or URL 63 <type> = image|terrain|model 67 map layer add wms <url> <layers> <format> <transparent> <layerName> 68 Add a WMS image layer from a URL/layer string 69 <url> = URL of WMS service 70 <layers> = layers string for WMS server 71 <format> = Image format to return (e.g. 'png') 72 <transparent> = bool 73 map layer add tms <url> <tmsType> <format> <layerName> 74 Add a WMS image layer from a URL/layer string 75 <url> = URL of WMS service 76 <layers> = layers string for WMS server 77 map layer add elevation <url> <layerName> 78 Add a GDAL elevation image layer from a file or URL 79 map layer add point <url> <layerName> 80 Add a point feature layer from a file or URL 81 map layer add polygon <url> <layerName> 82 Add a polygon feature layer from a file or URL 83 map layer add line <url> <layerName> 84 Add a line feature layer from a file or URL 85 map layer add text <url> <layerName> 86 Add a GDAL image layer from a file or URL 87 64 88 map layer delete <layerName> 65 89 map layer opacity <opacity> <layerName> … … 72 96 map load url <url> 73 97 Load an .earth file from a network address 74 map reset <type> <?profile?> 98 map reset <type> <?profile?> <?xmin?> <?ymin?> <?xmax?> <?ymax?> 75 99 type = geocentric|projected 76 profile = Well known profile string, e.g. 'global-geodetic' (default) 77 'global-mercator' 100 profile = Well known profile string, e.g. 'global-geodetic', 101 'global-mercator' 102 xmin,ymin,xmax,ymax = map bounds (in profile projection/units) 78 103 79 104 ================================================================================
Note: See TracChangeset
for help on using the changeset viewer.