[mapguide-internals] Please review RFC 103

Christine Bao Christine.Bao at autodesk.com
Wed Jul 14 05:16:53 EDT 2010


Hi Zac,

I think RFC 103 is different from RFC 98.

RFC 98 adds some functions to get EPSG code for a supported coordinate system. This coordinate should be supported by MapGuide's coordinate system first, and now it's easy to get the EPSG information by the newly added API:
INT32 MgCoordinateSystem::GetEpsgCode (void);
INT32 MgCoordinateSystem::GetSridCode (void);
INT16 MgCoordinateSystem::GetEpsgQuadrant (void);
INT32 MgCoordinateSystemDatum::GetEpsgCode (void);
INT32 MgCoordinateSystemEllipsoid::GetEpsgCode (void);
However RFC 103 is to let user define customized EPSG code:

1.       This EPSG code is unknown to MapGuide's coordinate system.

2.       This EPSG code is already in MapGuide's coordinate system, but user want to override it to another WKT.
In either of the above scenarios, user can add an entry in Wms:OgcWmsService.config file:

<!-- This definition allows a site to override the behavior of -->

 <!-- the SRS= parameter of requests.                           -->

 <!-- Add translate elements here to map any particularly       -->

 <!-- troublesome SRS to some appropriate WKT.                  -->

 <Define item="SRS.WKT.map">

  <!-- This example fixes a problem with EPSG:21781 not

       finding the WKT for EPSG:21781 in the CS library.

  -->

  <translate from="EPSG:21781">PROJCS["CH1903.LV03/01",GEOGCS["LLCH1903",DATUM["CH-1903",SPHEROID["BESSEL",6377397.155,299.15281535],TOWGS84[660.0770,13.5510,369.3440,0.804816,0.577692,0.952236,5.66000000]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Swiss_Oblique_Cylindrical"],PARAMETER["false_easting",600000.000],PARAMETER["false_northing",200000.000],PARAMETER["latitude_of_origin",46.95240555555556],PARAMETER["central_meridian",7.43958333333333],UNIT["Meter",1.00000000000000]]</translate>



 </Define>
Then WMS/WFS publish service will consider the customized mapping before using MapGuide's coordinate system:

void MgWmsMapUtil::SrsToWktMapping(MgOgcServer& oWms,STRING sSRS,REFSTRING sWKT)
{
    // Plan A is to look for a user-defined mapping.  This allows a config
    // file to contain overrides for incorrect, incomplete, or new reference
    // systems.  Input is an SRS string, output is (user-defined) WKT.
    // This is turned inside-out from previous algorithm.
    if(!UserDefinedSrsToWktMapping(oWms,sSRS,sWKT) || sWKT.length() == 0) {
        // If no user mapping, let's do the default thing, which is to
        // have the underlying library make the conversion.  It may fail
        // and throw an exception, which we would then report.

        // ConvertCoordinateSystemCodeToWkt used to be static, but PHP
        // couldn't support that, so this is "the way" to get a "this"
        // pointer to use for the method.
        Ptr<MgCoordinateSystemFactory> factory = new MgCoordinateSystemFactory();
        // Now, try to convert it to WKT.
        // This may throw an exception, which is caught outside.
        sWKT = factory->ConvertCoordinateSystemCodeToWkt(sSRS);
    }
}
bool MgWmsMapUtil::UserDefinedSrsToWktMapping(MgOgcServer& oWms,STRING sSrs,REFSTRING sWkt)
{
    // Makes srs arg "case insensitive"
    sSrs = MgUtil::ToUpper(sSrs);

    // Allows customer to provide overridden WKT for any given SRS value.
    // If none such, the return is false.

    // TODO: performance optimization: grab and cache the dictionary definition,
    // and use the other MapValue overload against that cached definition.
    return (oWms.MapValue(_("SRS.WKT.map"),sSrs.c_str(),sWkt));
}

SRS.WKT.map is the entry defined in Wms:OgcWmsService.config file, please refer to the above sample.

Thanks & regards,
Christine


From: Zac Spitzer <zac.spitzer at gmail.com>

Subject: Re: [mapguide-internals] Please review RFC 103

To: MapGuide Internals Mail List <mapguide-internals at lists.osgeo.org>

Message-ID:

      <AANLkTimEajGHxPTjMVsyT--hzbUj3c4mVKT2g8kzei-B at mail.gmail.com>

Content-Type: text/plain; charset=ISO-8859-1



taking a step back for a second,



how does this relate to the upcoming changes in



RFC 98 - EPSG/SRID Code Upgrade

https://trac.osgeo.org/mapguide/wiki/MapGuideRfc98



>From the motivation section of RFC 103 "For example, user can define

an EPSG code

mapping to a WKT if this EPSG code is not supported by MapGuide's

coordinate system. "







z





More information about the mapguide-internals mailing list