Changeset 5915


Ignore:
Timestamp:
Oct 21, 2015, 3:49:03 AM (9 years ago)
Author:
ldelgass
Message:

Add zoom camera to extent (fit to vertical FOV) by layer or by explicit bounds.
Add support for image layer using ArcGIS server driver. Map projection must
use a projected profile, and "geodetic"/"wgs84"/"plate-carre" are not permitted
as map profiles: use epsg:32663 for equirectangular instead. This has linear
units in meters, not angular units in X/Y.

Location:
geovis/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/PPMWriter.cpp

    r3998 r5915  
    5050    char header[200];
    5151
    52     TRACE("Entering (%dx%d)\n", width, height);
     52    FRAME("Entering (%dx%d)\n", width, height);
    5353    // Generate the PPM binary file header
    5454    snprintf(header, sizeof(header), "P6 %d %d %d\n", width, height,
     
    9595    response->setMessage(mesg, length, Response::DYNAMIC);
    9696    queue->enqueue(response);
    97     TRACE("Leaving (%dx%d)\n", width, height);
     97    FRAME("Leaving (%dx%d)\n", width, height);
    9898}
    9999#else
     
    127127    char header[200];
    128128
    129     TRACE("Entering (%dx%d)\n", width, height);
     129    FRAME("Entering (%dx%d)\n", width, height);
    130130    // Generate the PPM binary file header
    131131    snprintf(header, sizeof(header), "P6 %d %d %d\n", width, height,
     
    166166    free(iov);
    167167
    168     TRACE("Leaving (%dx%d)\n", width, height);
     168    FRAME("Leaving (%dx%d)\n", width, height);
    169169}
    170170
  • geovis/trunk/RenderServer.cpp

    r5895 r5915  
    292292        }
    293293        fflush(g_fOut);
     294#ifdef TRACE_RESPONSE_QUEUE
    294295        TRACE("Wrote response of type %d", response->type());
     296#endif
    295297        delete response;
    296298        if (feof(g_fOut))
     
    401403
    402404        if (g_renderer->render()) {
    403             TRACE("Rendered new frame");
     405            FRAME("Rendered new frame");
    404406            imgData = g_renderer->getRenderedFrame();
    405407            if (imgData == NULL) {
    406408                ERROR("Empty image");
    407409            } else {
    408                 TRACE("Image: %d x %d", imgData->s(), imgData->t());
     410                FRAME("Image: %d x %d", imgData->s(), imgData->t());
    409411
    410412                if (imgData->s() == g_renderer->getWindowWidth() &&
  • geovis/trunk/Renderer.cpp

    r5895 r5915  
    3535
    3636#include <osgEarth/Version>
     37#include <osgEarth/Registry>
    3738#include <osgEarth/FileUtils>
    3839#include <osgEarth/Cache>
     
    691692#if 1
    692693    osgEarth::Util::EarthManipulator::Settings *settings = _manipulator->getSettings();
     694
    693695    settings->bindMouse(osgEarth::Util::EarthManipulator::ACTION_ROTATE,
    694696                        osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON,
     
    700702                        osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON,
    701703                        osgGA::GUIEventAdapter::MODKEY_ALT, options);
     704
     705    if (_map->isGeocentric()) {
     706        settings->setMinMaxDistance(1.0, 2.0e7);
     707    } else {
     708        osgEarth::GeoExtent extent = _map->getProfile()->getExtent();
     709        settings->setMinMaxDistance(1.0, getMaxDistanceFromExtent(extent));
     710    }
     711
    702712    _manipulator->applySettings(settings);
    703713#endif
     
    762772            mapOpts.profile() = osgEarth::ProfileOptions();
    763773            if (strcmp(profile, "geodetic") == 0) {
    764                 mapOpts.profile()->srsString() = "epsg:4326";
     774                mapOpts.profile()->srsString() = "epsg:4326"; // WGS84
    765775            } else if (strcmp(profile, "spherical-mercator") == 0) {
    766776                // Projection used by Google/Bing/OSM
     
    775785                  bounds[0], bounds[1], bounds[2], bounds[3]);
    776786            if (1) {
    777                 osgEarth::SpatialReference *fromSRS = osgEarth::SpatialReference::create("wgs84");
    778                 osgEarth::SpatialReference *toSRS = osgEarth::SpatialReference::create(mapOpts.profile()->srsString().get());
     787                osg::ref_ptr<osgEarth::SpatialReference> fromSRS = osgEarth::SpatialReference::create("wgs84");
     788                osg::ref_ptr<osgEarth::SpatialReference> toSRS = osgEarth::SpatialReference::create(mapOpts.profile()->srsString().get());
    779789                osgEarth::Bounds extents(bounds[0], bounds[1], bounds[2], bounds[3]);
    780790                extents.transform(fromSRS, toSRS);
     
    22452255        // +y = zoom out, -y = zoom in
    22462256        TRACE("camDist: %g", _manipulator->getDistance());
     2257#ifdef LIMIT_ZOOM_BY_MAP_SCALE
    22472258        if ((_mapScale < 0.0 && y > 0.0) ||
    22482259            (_mapScale < 0.1 && y < 0.0) ||
    22492260            (_mapScale > 40000.0 && y > 0.0))
    22502261            return;
     2262#endif
    22512263#if 1
    22522264       _manipulator->zoom(0, y);
     
    22602272}
    22612273
     2274bool Renderer::getImageLayerExtent(const char *name, osgEarth::GeoExtent &ext)
     2275{
     2276    if (!_map.valid()) {
     2277        ERROR("No map");
     2278        return false;
     2279    }
     2280    osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);
     2281    if (layer != NULL) {
     2282        osgEarth::TileSource *ts = layer->getTileSource();
     2283        if (ts != NULL) {
     2284            ext = ts->getDataExtentsUnion();
     2285            if (!ext.isValid() && ts->getProfile() != NULL) {
     2286                ext = ts->getProfile()->getExtent();
     2287            }
     2288            INFO("Image layer %s srs: %s extent: %g %g %g %g",
     2289                 name, ext.getSRS() ? ext.getSRS()->getName().c_str() : "nil",
     2290                 ext.xMin(), ext.yMin(), ext.xMax(), ext.yMax());
     2291            return true;
     2292        }
     2293    } else {
     2294        TRACE("Image layer not found: %s", name);
     2295    }
     2296    return false;
     2297}
     2298
     2299bool Renderer::getElevationLayerExtent(const char *name, osgEarth::GeoExtent &ext)
     2300{
     2301    if (!_map.valid()) {
     2302        ERROR("No map");
     2303        return false;
     2304    }
     2305    osgEarth::ElevationLayer *layer = _map->getElevationLayerByName(name);
     2306    if (layer != NULL) {
     2307        osgEarth::TileSource *ts = layer->getTileSource();
     2308        if (ts != NULL) {
     2309            ext = ts->getDataExtentsUnion();
     2310            if (!ext.isValid() && ts->getProfile() != NULL) {
     2311                ext = ts->getProfile()->getExtent();
     2312            }
     2313            INFO("Elevation Layer %s srs: %s extent: %g %g %g %g",
     2314                 name, ext.getSRS() ? ext.getSRS()->getName().c_str() : "nil",
     2315                 ext.xMin(), ext.yMin(), ext.xMax(), ext.yMax());
     2316            return true;
     2317        }
     2318    } else {
     2319        TRACE("Image layer not found: %s", name);
     2320    }
     2321    return false;
     2322}
     2323
     2324bool Renderer::getModelLayerExtent(const char *name, osgEarth::GeoExtent &ext)
     2325{
     2326    if (!_map.valid()) {
     2327        ERROR("No map");
     2328        return false;
     2329    }
     2330    osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);
     2331    if (layer != NULL) {
     2332        osgEarth::ModelSource *ms = layer->getModelSource();
     2333        if (ms != NULL) {
     2334            osgEarth::DataExtentList& dataExtents = ms->getDataExtents();
     2335            if (dataExtents.size() > 0) {
     2336                ext = dataExtents[0];
     2337                for (unsigned int i = 1; i < dataExtents.size(); i++) {
     2338                    ext.expandToInclude(dataExtents[i]);
     2339                }
     2340            }
     2341            if (!ext.isValid()) {
     2342                ERROR("Couldn't find extent of layer %s", name);
     2343                return false;
     2344            }
     2345            INFO("Model Layer %s srs: %s extent: %g %g %g %g",
     2346                 name, ext.getSRS() ? ext.getSRS()->getName().c_str() : "nil",
     2347                 ext.xMin(), ext.yMin(), ext.xMax(), ext.yMax());
     2348            return true;
     2349        }
     2350    } else {
     2351        TRACE("Image layer not found: %s", name);
     2352    }
     2353    return false;
     2354}
     2355
     2356/**
     2357 * \brief Set view to fit a bounding rectangle
     2358 *
     2359 * A camera distance is chosen such that the extent rectangle
     2360 * will fit in the vertical field of view.
     2361 *
     2362 * \param ext input GeoExtent
     2363 * \param durationSecs Animation duration for the view change.
     2364 */
     2365void Renderer::setViewpointFromExtent(const osgEarth::GeoExtent& ext,
     2366                                      double durationSecs)
     2367{
     2368    setViewpointFromRect(ext.xMin(), ext.yMin(), ext.xMax(), ext.yMax(),
     2369                         ext.getSRS(), durationSecs);
     2370}
     2371
     2372/**
     2373 * \brief Set view to fit a bounding rectangle
     2374 *
     2375 * A camera distance is chosen such that the extent rectangle
     2376 * will fit in the vertical field of view.
     2377 *
     2378 * \param xmin Minimum X coord in the given SRS
     2379 * \param ymin Minimum Y coord in the given SRS
     2380 * \param xmax Maximum X coord in the given SRS
     2381 * \param ymax Maximum Y coord in the given SRS
     2382 * \param srs Optional SRS of bounding points.  If omitted, wgs84 is assumed.
     2383 * \param durationSecs Animation duration for the view change.
     2384 */
     2385void Renderer::setViewpointFromRect(double xmin, double ymin,
     2386                                    double xmax, double ymax,
     2387                                    const osgEarth::SpatialReference *srs,
     2388                                    double durationSecs)
     2389{
     2390    if (!_viewer.valid() || !_manipulator.valid() || getMapSRS() == NULL)
     2391        return;
     2392
     2393    double x = 0.0, y = 0.0, distance = 0.0;
     2394    double x1 = xmin, y1 = ymin, x2 = xmax, y2 = ymax;
     2395    osgEarth::Units distanceUnits = getMapSRS()->getUnits();
     2396    if (getMapSRS()->isProjected() && !getMapSRS()->isPlateCarre()) {
     2397        INFO("Projected");
     2398        osg::ref_ptr<const osgEarth::SpatialReference> fromSRS =
     2399            srs ? srs : osgEarth::SpatialReference::create("wgs84");
     2400        fromSRS->transformExtentToMBR(getMapSRS(), x1, y1, x2, y2);
     2401        double height = y2 - y1;
     2402        double fovy, aspect, near, far;
     2403        _viewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, near, far);
     2404        distance = height / (2. * tan(osg::DegreesToRadians(fovy)/2.));
     2405        INFO("fov: %g a: %g n: %g f: %g (%g, %g, %g, %g)", fovy, aspect, near, far, x1, y1, x2, y2);
     2406        x = x1 + (x2 - x1)/2.0;
     2407        y = y1 + (y2 - y1)/2.0;
     2408        INFO("x: %g y: %g, dist: %g", x, y, distance);
     2409    } else if (getMapSRS()->isGeographic() && !getMapSRS()->isPlateCarre()) {
     2410        // World coords are ECEF
     2411        INFO("Geocentric");
     2412        osg::ref_ptr<const osgEarth::SpatialReference> fromSRS =
     2413            srs ? srs : osgEarth::SpatialReference::create("wgs84");
     2414        fromSRS->transformExtentToMBR(getMapSRS(), x1, y1, x2, y2);
     2415        INFO("(%g, %g, %g, %g)", x1, y1, x2, y2);
     2416        // These are angular units
     2417        x = x1 + (x2 - x1)/2.0;
     2418        y = y1 + (y2 - y1)/2.0;
     2419        // These will be ECEF
     2420        osg::Vec3d world1, world2, world3, world4;
     2421        // bottom
     2422        getMapSRS()->transformToWorld(osg::Vec3d(x, y1, 0), world1);
     2423        // top
     2424        getMapSRS()->transformToWorld(osg::Vec3d(x, y2, 0), world2);
     2425        // Focal point on surface
     2426        getMapSRS()->transformToWorld(osg::Vec3d(x, y, 0), world3);
     2427        // point on line between top and bottom points
     2428        world4 = world1 + (world2 - world1)/2.0;
     2429        INFO("world1: %g,%g,%g world2: %g,%g,%g",
     2430             world1.x(), world1.y(), world1.z(),
     2431             world2.x(), world2.y(), world2.z());
     2432        INFO("world3: %g,%g,%g world4: %g,%g,%g",
     2433             world3.x(), world3.y(), world3.z(),
     2434             world4.x(), world4.y(), world4.z());
     2435        double height = (world2 - world1).length();
     2436        double fovy, aspect, near, far;
     2437        _viewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, near, far);
     2438        distance = height / (2. * tan(osg::DegreesToRadians(fovy)/2.));
     2439        distance -= (world4 - world3).length();
     2440        if (distance < 0.0) distance = 0.0;
     2441        distanceUnits = osgEarth::Units::METERS;
     2442        INFO("fov: %g a: %g n: %g f: %g (%g, %g, %g, %g)", fovy, aspect, near, far, x1, y1, x2, y2);
     2443        INFO("x: %g y: %g, dist: %g", x, y, distance);
     2444    } else {
     2445        assert(getMapSRS()->isPlateCarre());
     2446        ERROR("Plate Carree not supported");
     2447        return;
     2448    }
     2449    INFO("Map units: %d", getMapSRS()->getUnits().getType());
     2450    osgEarth::Viewpoint vpt;
     2451#ifdef NEW_VIEWPOINT_API
     2452    vpt.focalPoint()->set(getMapSRS(), x, y, 0.0, osgEarth::ALTMODE_ABSOLUTE);
     2453    vpt.range()->set(distance, distanceUnits);
     2454    vpt.heading()->set(0.0, osgEarth::Units::DEGREES);
     2455    vpt.pitch()->set(-90.0, osgEarth::Units::DEGREES);
     2456#else
     2457    vpt.x() = x;
     2458    vpt.y() = y;
     2459    vpt.z() = 0.0;
     2460    vpt.setRange(distance);
     2461    vpt.setHeading(0.0);
     2462    vpt.setPitch(-90.0);
     2463#endif
     2464    _manipulator->setViewpoint(vpt, durationSecs);
     2465    _needsRedraw = true;
     2466}
     2467
     2468double Renderer::getMaxDistanceFromExtent(const osgEarth::GeoExtent& extent)
     2469{
     2470    if (!_viewer.valid() || extent.getSRS() == NULL)
     2471        return 2.0e7;
     2472
     2473    double x = 0.0, y = 0.0, distance = 0.0;
     2474    double x1 = extent.xMin(), y1 = extent.yMin(), x2 = extent.xMax(), y2 = extent.yMax();
     2475    osgEarth::Units distanceUnits = extent.getSRS()->getUnits();
     2476    if (extent.getSRS()->isProjected() && !extent.getSRS()->isPlateCarre()) {
     2477        INFO("Projected");
     2478        double height = y2 - y1;
     2479        double fovy, aspect, near, far;
     2480        _viewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, near, far);
     2481        distance = height / (2. * tan(osg::DegreesToRadians(fovy)/2.));
     2482        INFO("fov: %g a: %g n: %g f: %g (%g, %g, %g, %g)", fovy, aspect, near, far, x1, y1, x2, y2);
     2483        x = x1 + (x2 - x1)/2.0;
     2484        y = y1 + (y2 - y1)/2.0;
     2485        INFO("x: %g y: %g, dist: %g", x, y, distance);
     2486    } else if (extent.getSRS()->isGeographic() && !extent.getSRS()->isPlateCarre()) {
     2487        // World coords are ECEF
     2488        INFO("Geocentric");
     2489        INFO("(%g, %g, %g, %g)", x1, y1, x2, y2);
     2490        // These are angular units
     2491        x = x1 + (x2 - x1)/2.0;
     2492        y = y1 + (y2 - y1)/2.0;
     2493        // These will be ECEF
     2494        osg::Vec3d world1, world2, world3, world4;
     2495        // bottom
     2496        getMapSRS()->transformToWorld(osg::Vec3d(x, y1, 0), world1);
     2497        // top
     2498        getMapSRS()->transformToWorld(osg::Vec3d(x, y2, 0), world2);
     2499        // Focal point on surface
     2500        getMapSRS()->transformToWorld(osg::Vec3d(x, y, 0), world3);
     2501        // point on line between top and bottom points
     2502        world4 = world1 + (world2 - world1)/2.0;
     2503        double height = (world2 - world1).length();
     2504        double fovy, aspect, near, far;
     2505        _viewer->getCamera()->getProjectionMatrixAsPerspective(fovy, aspect, near, far);
     2506        distance = height / (2. * tan(osg::DegreesToRadians(fovy)/2.));
     2507        distance -= (world4 - world3).length();
     2508        if (distance < 0.0) distance = 0.0;
     2509        distanceUnits = osgEarth::Units::METERS;
     2510        INFO("fov: %g a: %g n: %g f: %g (%g, %g, %g, %g)", fovy, aspect, near, far, x1, y1, x2, y2);
     2511        INFO("x: %g y: %g, dist: %g", x, y, distance);
     2512    } else {
     2513        assert(extent.getSRS()->isPlateCarre());
     2514        ERROR("Plate Carree not supported");
     2515    }
     2516
     2517    return distance;
     2518}
     2519
    22622520/**
    22632521 * \brief Dolly camera to set distance from focal point
    22642522 *
    2265  * \param[in] dist distance in map? coordinates
     2523 * \param[in] dist distance in world coordinate units (typically meters)
    22662524 */
    22672525void Renderer::setCameraDistance(double dist)
     
    24592717    _lastFrameTime = osg::Timer::instance()->delta_s(_startFrameTime, endFrameTick);
    24602718    if (_lastFrameTime > _minFrameTime) {
    2461         TRACE("BROKE FRAME by %.2f msec", (_lastFrameTime - _minFrameTime)*1000.0f);
    2462     } else {
    2463         TRACE("Frame time: %.2f msec", _lastFrameTime*1000.0f);
     2719        FRAME("BROKE FRAME by %.2f msec", (_lastFrameTime - _minFrameTime)*1000.0f);
     2720    } else {
     2721        FRAME("Frame time: %.2f msec", _lastFrameTime*1000.0f);
    24642722    }
    24652723#ifdef USE_THROTTLING_SLEEP
    24662724    if (_lastFrameTime < _minFrameTime) {
    2467         TRACE("Sleeping for %.2f msec", (_minFrameTime - _lastFrameTime)*1000.0f);
     2725        FRAME("Sleeping for %.2f msec", (_minFrameTime - _lastFrameTime)*1000.0f);
    24682726        OpenThreads::Thread::microSleep(static_cast<unsigned int>(1000000.0*(_minFrameTime - _lastFrameTime)));
    24692727    }
     
    24802738{
    24812739    if (_viewer.valid() && checkNeedToDoFrame()) {
    2482         TRACE("Enter needsRedraw=%d",  _needsRedraw ? 1 : 0);
     2740        FRAME("Enter needsRedraw=%d",  _needsRedraw ? 1 : 0);
    24832741        _renderStartTime = osg::Timer::instance()->tick();
    2484         TRACE("Before frame()");
     2742        FRAME("Before frame()");
    24852743        _viewer->frame();
    2486         TRACE("After frame()");
     2744        FRAME("After frame()");
    24872745        _renderStopTime = osg::Timer::instance()->tick();
    24882746        _renderTime = osg::Timer::instance()->delta_s(_renderStartTime, _renderStopTime);
    2489         TRACE("Render time: %g msec", _renderTime * 1000.0);
     2747        FRAME("Render time: %g msec", _renderTime * 1000.0);
    24902748#ifndef SLEEP_AFTER_QUEUE_FRAME
    24912749        _lastFrameTime = _renderTime;
    24922750#ifdef USE_THROTTLING_SLEEP
    24932751        if (_lastFrameTime < _minFrameTime) {
    2494             TRACE("Sleeping for %.2f msec", (_minFrameTime - _lastFrameTime)*1000.0f);
     2752            FRAME("Sleeping for %.2f msec", (_minFrameTime - _lastFrameTime)*1000.0f);
    24952753            OpenThreads::Thread::microSleep(static_cast<unsigned int>(1.0e6*(_minFrameTime - _lastFrameTime)));
    24962754        }
    24972755#endif
    24982756#endif
    2499 #ifdef WANT_TRACE
     2757#ifdef WANT_FRAME
    25002758        if (_viewer->getViewerStats() != NULL) {
    25012759            _viewer->getViewerStats()->report(std::cerr, _viewer->getViewerStats()->getLatestFrameNumber());
  • geovis/trunk/Renderer.h

    r5895 r5915  
    7272    virtual void operator()(osg::RenderInfo &renderInfo) const
    7373    {
    74         TRACE("Enter ScreenCaptureCallback");
     74        FRAME("Enter ScreenCaptureCallback");
    7575        int width, height;
    7676        if (renderInfo.getCurrentCamera() == NULL) {
     
    8484        width = (int)renderInfo.getCurrentCamera()->getViewport()->width();
    8585        height = (int)renderInfo.getCurrentCamera()->getViewport()->height();
    86         TRACE("readPixels: %d x %d", width, height);
     86        FRAME("readPixels: %d x %d", width, height);
    8787#if 0 //USE_OFFSCREEN_FRAMEBUFFER
    8888        _image = _texture->getImage();
     
    267267    void moveImageLayer(const char *name, unsigned int pos);
    268268
     269    bool getImageLayerExtent(const char *name, osgEarth::GeoExtent &ext);
     270
    269271    void setImageLayerVisibleRange(const char *name, float min, float max);
    270272
     
    309311    void moveElevationLayer(const char *name, unsigned int pos);
    310312
     313    bool getElevationLayerExtent(const char *name, osgEarth::GeoExtent &ext);
     314
    311315    void setElevationLayerVisibleRange(const char *name, float min, float max);
    312316
     
    342346    void moveModelLayer(const char *name, unsigned int pos);
    343347
     348    bool getModelLayerExtent(const char *name, osgEarth::GeoExtent &ext);
     349
    344350    //void setModelLayerVisibleRange(const char *name, float min, float max);
    345351
     
    373379
    374380    void setViewpoint(const osgEarth::Viewpoint& v, double durationSecs = 0.0);
     381
     382    double getMaxDistanceFromExtent(const osgEarth::GeoExtent& extent);
     383
     384    void setViewpointFromExtent(const osgEarth::GeoExtent& ext,
     385                                double durationSecs = 0.0);
     386
     387    void setViewpointFromRect(double xmin, double ymin,
     388                              double xmax, double ymax,
     389                              const osgEarth::SpatialReference *srs = NULL,
     390                              double durationSecs = 0.0);
    375391
    376392    void resetCamera(bool resetOrientation = true);
  • geovis/trunk/RendererCmd.cpp

    r5895 r5915  
    3737#include <osgEarthDrivers/osg/ColorRampOptions>
    3838#include <osgEarthDrivers/debug/DebugOptions>
     39#include <osgEarthDrivers/arcgis/ArcGISOptions>
    3940#include <osgEarthDrivers/gdal/GDALOptions>
    4041#include <osgEarthDrivers/tms/TMSOptions>
     
    583584
    584585static int
     586CameraSetByExtentOp(ClientData clientData, Tcl_Interp *interp, int objc,
     587                    Tcl_Obj *const *objv)
     588{
     589    double xmin, ymin, xmax, ymax;
     590    double duration = 0.0;
     591    if (Tcl_GetDoubleFromObj(interp, objv[2], &xmin) != TCL_OK ||
     592        Tcl_GetDoubleFromObj(interp, objv[3], &ymin) != TCL_OK ||
     593        Tcl_GetDoubleFromObj(interp, objv[4], &xmax) != TCL_OK ||
     594        Tcl_GetDoubleFromObj(interp, objv[5], &ymax) != TCL_OK) {
     595        return TCL_ERROR;
     596    }
     597    if (objc > 6) {
     598        if (Tcl_GetDoubleFromObj(interp, objv[6], &duration) != TCL_OK) {
     599            return TCL_ERROR;
     600        }
     601    }
     602    osg::ref_ptr<const osgEarth::SpatialReference> srs = g_renderer->getMapSRS();
     603    if (objc > 7) {
     604        char *srsInit = Tcl_GetString(objv[7]);
     605        if (strlen(srsInit) > 0) {
     606            srs = osgEarth::SpatialReference::get(srsInit);
     607        }
     608    }
     609    g_renderer->setViewpointFromRect(xmin, ymin, xmax, ymax, srs.get(), duration);
     610    return TCL_OK;
     611}
     612
     613static int
     614CameraSetByLayerExtentOp(ClientData clientData, Tcl_Interp *interp, int objc,
     615                         Tcl_Obj *const *objv)
     616{
     617    const char *name = Tcl_GetString(objv[2]);
     618    double duration = 0.0;
     619    if (objc > 3) {
     620        if (Tcl_GetDoubleFromObj(interp, objv[3], &duration) != TCL_OK) {
     621            return TCL_ERROR;
     622        }
     623    }
     624    osgEarth::GeoExtent ext;
     625    if (g_renderer->getImageLayerExtent(name, ext)) {
     626        g_renderer->setViewpointFromExtent(ext, duration);
     627        return TCL_OK;
     628    } else if (g_renderer->getElevationLayerExtent(name, ext)) {
     629        g_renderer->setViewpointFromExtent(ext, duration);
     630        return TCL_OK;
     631    } else if (g_renderer->getModelLayerExtent(name, ext)) {
     632        g_renderer->setViewpointFromExtent(ext, duration);
     633        return TCL_OK;
     634    }
     635    return TCL_ERROR;
     636}
     637
     638static int
    585639CameraSetDistanceOp(ClientData clientData, Tcl_Interp *interp, int objc,
    586640                    Tcl_Obj *const *objv)
     
    676730    {"delete",  2, CameraDeleteViewpointOp,  3, 3, "name"},
    677731    {"dist",    2, CameraSetDistanceOp,      3, 3, "distance"},
     732    {"extent",  1, CameraSetByExtentOp,      6, 8, "xmin ymin xmax ymax ?duration? ?srs?"},
    678733    {"get",     2, CameraGetViewpointOp,     2, 2, ""},
    679734    {"go",      2, CameraGoOp,               4, 6, "x y ?zoomFactor? ?duration?"},
     735    {"lextent", 1, CameraSetByLayerExtentOp, 3, 4, "layerName ?duration?"},
    680736    {"orient",  1, CameraOrientOp,           6, 6, "qw qx qy qz"},
    681737    {"pan",     1, CameraPanOp,              4, 4, "panX panY"},
     
    13911447            osgEarth::Drivers::DebugOptions opts;
    13921448            ret = g_renderer->addImageLayer(name, opts, cache, coverage, shared, visible, minLOD, maxLOD);
     1449        } else if (driver[0] == 'a' && strcmp(driver, "arcgis") == 0) {
     1450            osgEarth::Drivers::ArcGISOptions opts;
     1451            opts.url() = url;
     1452            opts.token() = Tcl_GetString(objv[9]);
     1453            //opts.format() = Tcl_GetString(objv[10]);
     1454            //opts.layers() = Tcl_GetString(objv[11]);
     1455            ret = g_renderer->addImageLayer(name, opts, cache, coverage, shared, visible, minLOD, maxLOD);
     1456            g_renderer->setImageLayerVisibleRange(name, minRange, maxRange);
    13931457        } else if (driver[0] == 'g' && strcmp(driver, "gdal") == 0) {
    13941458            osgEarth::Drivers::GDALOptions opts;
     
    25542618                }
    25552619            }
    2556 #if 1
    25572620            // Check if min > max
    25582621            if (bounds[0] > bounds[2] ||
     
    25772640                    return TCL_ERROR;
    25782641                }
     2642                // As of osgearth 2.7, these are not permitted as map profiles.
     2643                // Use epsg:32663 instead
     2644                Tcl_AppendResult(interp, "Invalid profile: can't use geographic coordinate system as projection.  Consider using an equirectangular projection (epsg:32663) instead.", (char*)NULL);
     2645                return TCL_ERROR;
    25792646            } else if (strcmp(profile, "spherical-mercator") == 0 ||
    25802647                       strcmp(profile, "epsg:900913") == 0 ||
     
    25832650                       strcmp(profile, "epsg:102113") == 0) {
    25842651                for (int i = 0; i < 4; i++) {
    2585                     if (bounds[i] < -20037508.34 || bounds[i] > 20037508.34) {
     2652                    if (bounds[i] < -20037508.34278925 || bounds[i] > 20037508.34278925) {
    25862653                        Tcl_AppendResult(interp, "invalid bounds", (char*)NULL);
    25872654                        return TCL_ERROR;
     
    25902657            } else if (strcmp(profile, "epsg:32662") == 0 ||
    25912658                       strcmp(profile, "epsg:32663") == 0) {
    2592                 if (bounds[0] < -20037508.3428 || bounds[0] > 20037508.3428 ||
    2593                     bounds[2] < -20037508.3428 || bounds[2] > 20037508.3428 ||
    2594                     bounds[1] < -10018754.1714 || bounds[1] > 10018754.1714 ||
    2595                     bounds[3] < -10018754.1714 || bounds[3] > 10018754.1714) {
     2659                // epsg:32662 is deprecated: spherical method applied to ellipsoid WGS84
     2660                // Equirectangular projection (WGS84/World Equidistant Cylindrical)
     2661                if (bounds[0] < -20037508.34278925 || bounds[0] > 20037508.34278925 ||
     2662                    bounds[2] < -20037508.34278925 || bounds[2] > 20037508.34278925 ||
     2663                    bounds[1] < -10018754.17139463 || bounds[1] > 10018754.17139463 ||
     2664                    bounds[3] < -10018754.17139463 || bounds[3] > 10018754.17139463) {
    25962665                    Tcl_AppendResult(interp, "invalid bounds", (char*)NULL);
    25972666                    return TCL_ERROR;
    25982667                }
    25992668            }
    2600 #endif
    26012669            g_renderer->resetMap(type, bgColor, profile, bounds);
    26022670        } else {
     2671            // If no bounds are given, this must be a named profile with implicit bounds
    26032672            if (osgEarth::Registry::instance()->getNamedProfile(profile) == NULL) {
    26042673                Tcl_AppendResult(interp, "bad named profile \"", profile,
  • geovis/trunk/ResponseQueue.cpp

    r4629 r5915  
    4848#ifdef QUEUE_ONLY_ONE_FRAME
    4949    /* Examine the list and remove any queued responses of the same type. */
     50#ifdef TRACE_RESPONSE_QUEUE
    5051    TRACE("Before # of elements is %d", _list.size());
     52#endif
    5153    for (std::list<Response *>::iterator itr = _list.begin();
    5254         itr != _list.end();) {
     
    7173    /* Add the new response to the end of the list. */
    7274    _list.push_back(response);
     75#ifdef TRACE_RESPONSE_QUEUE
    7376    TRACE("After # of elements is %d", _list.size());
     77#endif
    7478    if (sem_post(&_ready) < 0) {
    7579        ERROR("can't post semaphore: %s", strerror(errno));
     
    103107        response = _list.front();
    104108        _list.pop_front();
     109#ifdef TRACE_RESPONSE_QUEUE
    105110        TRACE("Dequeued response of type %d", response->type());
     111#endif
    106112    }
    107113    if (pthread_mutex_unlock(&_idle) != 0) {
  • geovis/trunk/Trace.h

    r4655 r5915  
    3737#define TRACE(...)
    3838#endif  /*WANT_TRACE*/
     39#ifdef WANT_FRAME
     40#define FRAME(...)      GeoVis::logMessage(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
     41#else
     42#define FRAME(...)
     43#endif  /*WANT_FRAME*/
    3944#define WARN(...)       GeoVis::logMessage(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    4045#define INFO(...)       GeoVis::logMessage(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
Note: See TracChangeset for help on using the changeset viewer.