Changeset 5895
- Timestamp:
- Oct 1, 2015, 2:54:12 PM (9 years ago)
- Location:
- geovis/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/FileUtil.cpp
r4376 r5895 58 58 } 59 59 } 60 61 /** 62 * \brief Get the file path part of a local:// URL 63 * 64 * This implementation assumes a relative path if there is no leading slash, 65 * rather than assuming there is a server name. 66 */ 67 std::string GeoVis::getLocalFilePath(const std::string& url) 68 { 69 std::string::size_type pos(url.find("://")); 70 71 if (pos != std::string::npos) { 72 return url.substr(pos+3, std::string::npos); 73 } 74 return url; 75 } -
geovis/trunk/FileUtil.h
r4376 r5895 7 7 #ifndef GEOVIS_FILEUTIL_H 8 8 #define GEOVIS_FILEUTIL_H 9 10 #include <string> 9 11 10 12 #include <osgEarth/FileUtils> … … 45 47 46 48 extern void removeDirectory(const char *path); 49 std::string getLocalFilePath(const std::string& url); 47 50 48 51 } -
geovis/trunk/RenderServer.cpp
r5890 r5895 476 476 g_renderer = NULL; 477 477 // Clean up cache directory after renderer's threads have finished 478 removeDirectory(cacheDir.c_str()); 478 if (!cacheDir.empty()) { 479 removeDirectory(cacheDir.c_str()); 480 } 479 481 480 482 TRACE("Exiting GeoVis Server"); -
geovis/trunk/Renderer.cpp
r5890 r5895 15 15 #include <limits> 16 16 #include <set> 17 #include <fstream> 18 #include <sstream> 17 19 18 20 #include <sys/types.h> … … 172 174 } 173 175 174 std::string Renderer::getBaseImage() 176 std::string Renderer::getBaseImage() const 175 177 { 176 178 std::ostringstream oss; … … 179 181 } 180 182 181 std::string Renderer::getPinIcon() 183 std::string Renderer::getPinIcon() const 182 184 { 183 185 std::ostringstream oss; … … 2719 2721 retStr = ""; 2720 2722 } 2721 } else { 2723 } else if (proto == "local") { 2724 INFO("Local protocol: '%s'", getLocalFilePath(url).c_str()); 2725 std::ostringstream oss; 2726 oss << getCacheDirectory() << "/" << getLocalFilePath(url); 2727 retStr = oss.str(); 2728 } else if (proto == "file") { 2729 INFO("File: '/%s'", osgDB::getServerFileName(url).c_str()); 2730 std::ostringstream oss; 2731 oss << "/" << osgDB::getServerFileName(url); 2732 retStr = oss.str(); 2733 } else if (proto == "idata") { 2734 std::string fileName = osgDB::getServerFileName(url); 2735 INFO("IData protocol: coll: '%s', '%s'", osgDB::getServerAddress(url).c_str(), fileName.c_str()); 2736 int collection = atoi(osgDB::getServerAddress(url).c_str()); 2737 { 2738 std::ostringstream oss; 2739 oss << getCacheDirectory() << "/" << fileName; 2740 retStr = oss.str(); 2741 std::string dirPath = osgDB::getFilePath(retStr); 2742 osgDB::makeDirectory(dirPath); 2743 } 2744 if (!osgDB::fileExists(retStr)) { 2745 std::ostringstream oss; 2746 oss << "//" << fileName; 2747 IData::Buffer buf; 2748 IData::getFile(collection, oss.str().c_str(), &buf); 2749 std::ofstream file(retStr.c_str()); 2750 file.write((char *)buf.data, buf.size); 2751 file.close(); 2752 } 2753 } else { 2754 INFO("Protocol: '%s' url: '%s'", proto.c_str(), url.c_str()); 2722 2755 retStr = url; 2723 2756 } -
geovis/trunk/Renderer.h
r5888 r5895 151 151 } 152 152 153 std::string getCacheDirectory() 153 std::string getCacheDirectory() const 154 154 { 155 155 return _cacheDir; 156 156 } 157 157 158 std::string getBaseImage(); 159 160 std::string getPinIcon(); 158 void setupCache(); 159 160 std::string getBaseImage() const; 161 162 std::string getPinIcon() const; 161 163 162 164 void setAttribution(const std::string& attrib); … … 535 537 typedef std::tr1::unordered_map<ColorMapId, osg::ref_ptr<osg::TransferFunction1D> > ColorMapHashmap; 536 538 typedef std::tr1::unordered_map<ViewpointId, osgEarth::Viewpoint> ViewpointHashmap; 537 538 void setupCache();539 539 540 540 void initAnnotations(); -
geovis/trunk/RendererCmd.cpp
r5889 r5895 363 363 364 364 static int 365 CameraCenterOp(ClientData clientData, Tcl_Interp *interp, int objc, 366 Tcl_Obj *const *objv) 367 { 368 double x, y; 369 if (Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK || 370 Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK) { 371 return TCL_ERROR; 372 } 373 double zoom = 1.0; 374 if (objc > 4) { 375 if (Tcl_GetDoubleFromObj(interp, objv[4], &zoom) != TCL_OK) { 376 return TCL_ERROR; 377 } 378 } 379 double duration = 1.0; 380 if (objc > 5) { 381 if (Tcl_GetDoubleFromObj(interp, objv[5], &duration) != TCL_OK) { 382 return TCL_ERROR; 383 } 384 } 385 386 osgEarth::Viewpoint vpt = g_renderer->getViewpoint(); 387 #ifdef NEW_VIEWPOINT_API 388 vpt.focalPoint()->x() = x; 389 vpt.focalPoint()->y() = y; 390 //vpt.focalPoint()->z() = mapPoint.z(); 391 vpt.range()->set(vpt.range()->getValue() * zoom, osgEarth::Units::METERS); 392 #else 393 vpt.x() = x; 394 vpt.y() = y; 395 //vpt.z() = mapPoint.z(); 396 vpt.setRange(vpt.getRange() * zoom); 397 398 #endif 399 g_renderer->setViewpoint(vpt, duration); 400 401 return TCL_OK; 402 } 403 404 static int 365 405 CameraGetViewpointOp(ClientData clientData, Tcl_Interp *interp, int objc, 366 406 Tcl_Obj *const *objv) … … 633 673 634 674 static CmdSpec cameraOps[] = { 675 {"center", 1, CameraCenterOp, 4, 6, "x y ?zoomFactor? ?duration?"}, 635 676 {"delete", 2, CameraDeleteViewpointOp, 3, 3, "name"}, 636 677 {"dist", 2, CameraSetDistanceOp, 3, 3, "distance"}, … … 896 937 return TCL_ERROR; 897 938 } 939 if (g_renderer->getCacheDirectory().empty()) { 940 g_renderer->setupCache(); 941 } 942 std::string dirPath = osgDB::getFilePath(path); 943 std::string fileName = osgDB::getSimpleFileName(path); 898 944 std::ostringstream fullPath; 899 //fullPath << "/tmp/" << path; 900 fullPath << path; 945 fullPath << g_renderer->getCacheDirectory() << "/" << dirPath; 946 if (!dirPath.empty()) { 947 INFO("Make dir: %s", fullPath.str().c_str()); 948 osgDB::makeDirectory(fullPath.str()); 949 fullPath << "/"; 950 } 951 fullPath << fileName; 901 952 FILE *fp = fopen(fullPath.str().c_str(), "wb"); 902 953 if (fp == NULL) { … … 907 958 fclose(fp); 908 959 free(data); 960 INFO("Wrote %d bytes to %s", bytesWritten, fullPath.str().c_str()); 909 961 return (bytesWritten == size) ? TCL_OK : TCL_ERROR; 910 962 } 911 963 912 964 static CmdSpec fileOps[] = { 913 {"put", 1, FilePutOp, 5, 5, " nametype size"}965 {"put", 1, FilePutOp, 5, 5, "path type size"} 914 966 }; 915 967 static int nFileOps = NumCmdSpecs(fileOps); -
geovis/trunk/idatatest.cpp
r5873 r5895 3 3 #include <iostream> 4 4 #include <fstream> 5 6 #include <osgDB/FileNameUtils> 5 7 6 8 #include "IData.h"
Note: See TracChangeset
for help on using the changeset viewer.