Changeset 6649


Ignore:
Timestamp:
Dec 1, 2016 12:47:31 PM (8 years ago)
Author:
ldelgass
Message:

Fix validation of map extents

Location:
geovis/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Renderer.cpp

    r6647 r6649  
    794794                        const osg::Vec4f& bgColor,
    795795                        const char *profile,
    796                         double bounds[4])
     796                        double bounds[4],
     797                        const char *boundsSRS)
    797798{
    798799    TRACE("Restting map with type %d, profile %s", type, profile);
     
    814815                mapOpts.profile()->srsString() = profile;
    815816            }
    816             TRACE("Setting profile bounds: %g %g %g %g",
    817                   bounds[0], bounds[1], bounds[2], bounds[3]);
    818             if (1) {
    819                 osg::ref_ptr<osgEarth::SpatialReference> fromSRS = osgEarth::SpatialReference::create("wgs84");
     817            TRACE("Input bounds: %g %g %g %g srs:\"%s\"",
     818                  bounds[0], bounds[1], bounds[2], bounds[3], boundsSRS);
     819            if (boundsSRS != NULL) {
     820                osg::ref_ptr<osgEarth::SpatialReference> fromSRS = osgEarth::SpatialReference::create(boundsSRS);
    820821                osg::ref_ptr<osgEarth::SpatialReference> toSRS = osgEarth::SpatialReference::create(mapOpts.profile()->srsString().get());
    821822                osgEarth::Bounds extents(bounds[0], bounds[1], bounds[2], bounds[3]);
     
    828829                    osgEarth::Bounds(bounds[0], bounds[1], bounds[2], bounds[3]);
    829830            }
     831            TRACE("Setting profile bounds: %g %g %g %g",
     832                  bounds[0], bounds[1], bounds[2], bounds[3]);
    830833        } else {
    831834            mapOpts.profile() = osgEarth::ProfileOptions(profile);
  • geovis/trunk/Renderer.h

    r6647 r6649  
    200200                  const osg::Vec4f& bgColor = osg::Vec4f(1,1,1,1),
    201201                  const char *profile = NULL,
    202                   double bounds[4] = NULL);
     202                  double bounds[4] = NULL,
     203                  const char *boundsSRS = NULL);
    203204
    204205    void clearMap();
  • geovis/trunk/RendererCmd.cpp

    r6562 r6649  
    31033103                return TCL_ERROR;
    31043104            }
     3105            if (bounds[0] < -180. || bounds[0] > 180. ||
     3106                bounds[2] < -180. || bounds[2] > 180. ||
     3107                bounds[1] < -90. || bounds[1] > 90. ||
     3108                bounds[3] < -90. || bounds[3] > 90.) {
     3109                Tcl_AppendResult(interp, "invalid bounds", (char*)NULL);
     3110                return TCL_ERROR;
     3111            }
    31053112            // Note: plate-carre generates same SRS as others, but with
    31063113            // _is_plate_carre flag set
     
    31123119                strcmp(profile, "plate-carre") == 0 ||
    31133120                strcmp(profile, "plate-carree") == 0) {
    3114                 if (bounds[0] < -180. || bounds[0] > 180. ||
    3115                     bounds[2] < -180. || bounds[2] > 180. ||
    3116                     bounds[1] < -90. || bounds[1] > 90. ||
    3117                     bounds[3] < -90. || bounds[3] > 90.) {
    3118                     Tcl_AppendResult(interp, "invalid bounds", (char*)NULL);
    3119                     return TCL_ERROR;
    3120                 }
    31213121                // As of osgearth 2.7, these are not permitted as map profiles.
    31223122                // Use epsg:32663 instead
    31233123                Tcl_AppendResult(interp, "Invalid profile: can't use geographic coordinate system as projection.  Consider using an equirectangular projection (epsg:32663) instead.", (char*)NULL);
    31243124                return TCL_ERROR;
    3125             } else if (strcmp(profile, "spherical-mercator") == 0 ||
    3126                        strcmp(profile, "epsg:900913") == 0 ||
    3127                        strcmp(profile, "epsg:3785") == 0 ||
    3128                        strcmp(profile, "epsg:3857") == 0 ||
    3129                        strcmp(profile, "epsg:102113") == 0) {
    3130                 for (int i = 0; i < 4; i++) {
    3131                     if (bounds[i] < -20037508.34278925 || bounds[i] > 20037508.34278925) {
    3132                         Tcl_AppendResult(interp, "invalid bounds", (char*)NULL);
    3133                         return TCL_ERROR;
    3134                     }
    3135                 }
    3136             } else if (strcmp(profile, "epsg:32662") == 0 ||
    3137                        strcmp(profile, "epsg:32663") == 0) {
    3138                 // epsg:32662 is deprecated: spherical method applied to ellipsoid WGS84
    3139                 // Equirectangular projection (WGS84/World Equidistant Cylindrical)
    3140                 if (bounds[0] < -20037508.34278925 || bounds[0] > 20037508.34278925 ||
    3141                     bounds[2] < -20037508.34278925 || bounds[2] > 20037508.34278925 ||
    3142                     bounds[1] < -10018754.17139463 || bounds[1] > 10018754.17139463 ||
    3143                     bounds[3] < -10018754.17139463 || bounds[3] > 10018754.17139463) {
    3144                     Tcl_AppendResult(interp, "invalid bounds", (char*)NULL);
    3145                     return TCL_ERROR;
    3146                 }
    3147             }
    3148             g_renderer->resetMap(type, bgColor, profile, bounds);
     3125            }
     3126            g_renderer->resetMap(type, bgColor, profile, bounds, "wgs84");
    31493127        } else {
    31503128            // If no bounds are given, this must be a named profile with implicit bounds
Note: See TracChangeset for help on using the changeset viewer.