?? ogr_srs_xml.cpp
字號:
/* Add the parameter value itself. */
/* -------------------------------------------------------------------- */
double dfParmValue
= poSRS->GetNormProjParm( pszWKTName, dfDefault, NULL );
CPLCreateXMLNode( psValue, CXT_Text,
CPLSPrintf( "%.16g", dfParmValue ) );
/* -------------------------------------------------------------------- */
/* Add the valueOfParameter. */
/* -------------------------------------------------------------------- */
AddValueIDWithURN( psNode, "gml:valueOfParameter", "EPSG", "parameter",
nParameterID );
}
/************************************************************************/
/* addAxis() */
/* */
/* Added the <usesAxis> element and down. */
/************************************************************************/
static CPLXMLNode *addAxis( CPLXMLNode *psXMLParent,
const char *pszAxis, // "Lat", "Long", "E" or "N"
const OGR_SRSNode * /* poUnitsSrc */ )
{
CPLXMLNode *psAxisXML;
psAxisXML =
CPLCreateXMLNode(
CPLCreateXMLNode( psXMLParent, CXT_Element, "gml:usesAxis" ),
CXT_Element, "gml:CoordinateSystemAxis" );
addGMLId( psAxisXML );
if( EQUAL(pszAxis,"Lat") )
{
CPLCreateXMLNode(
CPLCreateXMLNode( psAxisXML, CXT_Attribute, "gml:uom" ),
CXT_Text, "urn:ogc:def:uom:EPSG::9102" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:name",
"Geodetic latitude" );
addAuthorityIDBlock( psAxisXML, "gml:axisID", "EPSG", "axis", 9901 );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisAbbrev", "Lat" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisDirection", "north" );
}
else if( EQUAL(pszAxis,"Long") )
{
CPLCreateXMLNode(
CPLCreateXMLNode( psAxisXML, CXT_Attribute, "gml:uom" ),
CXT_Text, "urn:ogc:def:uom:EPSG::9102" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:name",
"Geodetic longitude" );
addAuthorityIDBlock( psAxisXML, "gml:axisID", "EPSG", "axis", 9902 );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisAbbrev", "Lon" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisDirection", "east" );
}
else if( EQUAL(pszAxis,"E") )
{
CPLCreateXMLNode(
CPLCreateXMLNode( psAxisXML, CXT_Attribute, "gml:uom" ),
CXT_Text, "urn:ogc:def:uom:EPSG::9001" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:name", "Easting" );
addAuthorityIDBlock( psAxisXML, "gml:axisID", "EPSG", "axis", 9906 );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisAbbrev", "E" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisDirection", "east" );
}
else if( EQUAL(pszAxis,"N") )
{
CPLCreateXMLNode(
CPLCreateXMLNode( psAxisXML, CXT_Attribute, "gml:uom" ),
CXT_Text, "urn:ogc:def:uom:EPSG::9001" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:name", "Northing" );
addAuthorityIDBlock( psAxisXML, "gml:axisID", "EPSG", "axis", 9907 );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisAbbrev", "N" );
CPLCreateXMLElementAndValue( psAxisXML, "gml:axisDirection", "north" );
}
else
{
CPLAssert( FALSE );
}
return psAxisXML;
}
/************************************************************************/
/* exportGeogCSToXML() */
/************************************************************************/
static CPLXMLNode *exportGeogCSToXML( const OGRSpatialReference *poSRS )
{
CPLXMLNode *psGCS_XML;
const OGR_SRSNode *poGeogCS = poSRS->GetAttrNode( "GEOGCS" );
if( poGeogCS == NULL )
return NULL;
/* -------------------------------------------------------------------- */
/* Establish initial infrastructure. */
/* -------------------------------------------------------------------- */
psGCS_XML = CPLCreateXMLNode( NULL, CXT_Element, "gml:GeographicCRS" );
addGMLId( psGCS_XML );
/* -------------------------------------------------------------------- */
/* Attach symbolic name (srsName). */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue( psGCS_XML, "gml:srsName",
poGeogCS->GetChild(0)->GetValue() );
/* -------------------------------------------------------------------- */
/* Does the overall coordinate system have an authority? If so */
/* attach as an identification section. */
/* -------------------------------------------------------------------- */
exportAuthorityToXML( poGeogCS, "gml:srsID", psGCS_XML, "crs" );
/* -------------------------------------------------------------------- */
/* Insert a big whack of fixed stuff defining the */
/* ellipsoidalCS. Basically this defines the axes and their */
/* units. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psECS;
psECS = CPLCreateXMLNode(
CPLCreateXMLNode( psGCS_XML, CXT_Element, "gml:usesEllipsoidalCS" ),
CXT_Element, "gml:EllipsoidalCS" );
addGMLId( psECS );
CPLCreateXMLElementAndValue( psECS, "gml:csName", "ellipsoidal" );
addAuthorityIDBlock( psECS, "gml:csID", "EPSG", "cs", 6402 );
addAxis( psECS, "Lat", NULL );
addAxis( psECS, "Long", NULL );
/* -------------------------------------------------------------------- */
/* Start with the datum. */
/* -------------------------------------------------------------------- */
const OGR_SRSNode *poDatum = poGeogCS->GetNode( "DATUM" );
CPLXMLNode *psDatumXML;
if( poDatum == NULL )
{
CPLDestroyXMLNode( psGCS_XML );
return NULL;
}
psDatumXML = CPLCreateXMLNode(
CPLCreateXMLNode( psGCS_XML, CXT_Element, "gml:usesGeodeticDatum" ),
CXT_Element, "gml:GeodeticDatum" );
addGMLId( psDatumXML );
/* -------------------------------------------------------------------- */
/* Set the datumName. */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue( psDatumXML, "gml:datumName",
poDatum->GetChild(0)->GetValue() );
/* -------------------------------------------------------------------- */
/* Set authority id info if available. */
/* -------------------------------------------------------------------- */
exportAuthorityToXML( poDatum, "gml:datumID", psDatumXML, "datum" );
/* -------------------------------------------------------------------- */
/* Setup prime meridian information. */
/* -------------------------------------------------------------------- */
const OGR_SRSNode *poPMNode = poGeogCS->GetNode( "PRIMEM" );
CPLXMLNode *psPM;
char *pszPMName = "Greenwich";
double dfPMOffset = poSRS->GetPrimeMeridian( &pszPMName );
psPM = CPLCreateXMLNode(
CPLCreateXMLNode( psDatumXML, CXT_Element, "gml:usesPrimeMeridian" ),
CXT_Element, "gml:PrimeMeridian" );
addGMLId( psPM );
CPLCreateXMLElementAndValue( psPM, "gml:meridianName", pszPMName );
if( poPMNode )
exportAuthorityToXML( poPMNode, "gml:meridianID", psPM, "meridian" );
CPLXMLNode *psAngle;
psAngle =
CPLCreateXMLNode(
CPLCreateXMLNode( psPM, CXT_Element, "gml:greenwichLongitude" ),
CXT_Element, "gml:angle" );
CPLCreateXMLNode( CPLCreateXMLNode( psAngle, CXT_Attribute, "gml:uom" ),
CXT_Text, "urn:ogc:def:uom:EPSG::9102" );
CPLCreateXMLNode( psAngle, CXT_Text, CPLSPrintf( "%.16g", dfPMOffset ) );
/* -------------------------------------------------------------------- */
/* Translate the ellipsoid. */
/* -------------------------------------------------------------------- */
const OGR_SRSNode *poEllipsoid = poDatum->GetNode( "SPHEROID" );
if( poEllipsoid != NULL )
{
CPLXMLNode *psEllipseXML;
psEllipseXML =
CPLCreateXMLNode(
CPLCreateXMLNode(psDatumXML,CXT_Element,"gml:usesEllipsoid" ),
CXT_Element, "gml:Ellipsoid" );
addGMLId( psEllipseXML );
CPLCreateXMLElementAndValue( psEllipseXML, "gml:ellipsoidName",
poEllipsoid->GetChild(0)->GetValue() );
exportAuthorityToXML( poEllipsoid, "gml:ellipsoidID", psEllipseXML,
"ellipsoid");
CPLXMLNode *psParmXML;
psParmXML = CPLCreateXMLNode( psEllipseXML, CXT_Element,
"gml:semiMajorAxis" );
CPLCreateXMLNode( CPLCreateXMLNode(psParmXML,CXT_Attribute,"gml:uom"),
CXT_Text, "urn:ogc:def:uom:EPSG::9001" );
CPLCreateXMLNode( psParmXML, CXT_Text,
poEllipsoid->GetChild(1)->GetValue() );
psParmXML =
CPLCreateXMLNode(
CPLCreateXMLNode( psEllipseXML, CXT_Element,
"gml:secondDefiningParameter" ),
CXT_Element, "gml:inverseFlattening" );
CPLCreateXMLNode( CPLCreateXMLNode(psParmXML,CXT_Attribute,"gml:uom"),
CXT_Text, "urn:ogc:def:uom:EPSG::9201" );
CPLCreateXMLNode( psParmXML, CXT_Text,
poEllipsoid->GetChild(2)->GetValue() );
}
return psGCS_XML;
}
/************************************************************************/
/* exportProjCSToXML() */
/************************************************************************/
static CPLXMLNode *exportProjCSToXML( const OGRSpatialReference *poSRS )
{
const OGR_SRSNode *poProjCS = poSRS->GetAttrNode( "PROJCS" );
if( poProjCS == NULL )
return NULL;
/* -------------------------------------------------------------------- */
/* Establish initial infrastructure. */
/* -------------------------------------------------------------------- */
CPLXMLNode *psCRS_XML;
psCRS_XML = CPLCreateXMLNode( NULL, CXT_Element, "gml:ProjectedCRS" );
addGMLId( psCRS_XML );
/* -------------------------------------------------------------------- */
/* Attach symbolic name (a name in a nameset). */
/* -------------------------------------------------------------------- */
CPLCreateXMLElementAndValue( psCRS_XML, "gml:srsName",
poProjCS->GetChild(0)->GetValue() );
/* -------------------------------------------------------------------- */
/* Add authority info if we have it. */
/* -------------------------------------------------------------------- */
exportAuthorityToXML( poProjCS, "gml:srsID", psCRS_XML, "crs" );
/* -------------------------------------------------------------------- */
/* Use the GEOGCS as a <baseCRS> */
/* -------------------------------------------------------------------- */
CPLXMLNode *psBaseCRSXML =
CPLCreateXMLNode( psCRS_XML, CXT_Element, "gml:baseCRS" );
CPLAddXMLChild( psBaseCRSXML, exportGeogCSToXML( poSRS ) );
/* -------------------------------------------------------------------- */
/* Our projected coordinate system is "defined by Conversion". */
/* -------------------------------------------------------------------- */
CPLXMLNode *psDefinedBy;
psDefinedBy = CPLCreateXMLNode( psCRS_XML, CXT_Element,
"gml:definedByConversion" );
/* -------------------------------------------------------------------- */
/* Projections are handled as ParameterizedTransformations. */
/* -------------------------------------------------------------------- */
const char *pszProjection = poSRS->GetAttrValue("PROJECTION");
CPLXMLNode *psConv;
psConv = CPLCreateXMLNode( psDefinedBy, CXT_Element, "gml:Conversion");
addGMLId( psConv );
/* -------------------------------------------------------------------- */
/* Transverse Mercator */
/* -------------------------------------------------------------------- */
if( EQUAL(pszProjection,SRS_PT_TRANSVERSE_MERCATOR) )
{
AddValueIDWithURN( psConv, "gml:usesMethod", "EPSG", "method",
9807 );
addProjArg( poSRS, psConv, "Angular", 0.0,
8801, SRS_PP_LATITUDE_OF_ORIGIN );
addProjArg( poSRS, psConv, "Angular", 0.0,
8802, SRS_PP_CENTRAL_MERIDIAN );
addProjArg( poSRS, psConv, "Unitless", 1.0,
8805, SRS_PP_SCALE_FACTOR );
addProjArg( poSRS, psConv, "Linear", 0.0,
8806, SRS_PP_FALSE_EASTING );
addProjArg( poSRS, psConv, "Linear", 0.0,
8807, SRS_PP_FALSE_NORTHING );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -