bool CXML_Element::GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const { CFX_ByteStringC bsSpace; CFX_ByteStringC bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return GetAttrValue(bsSpace, bsName, attribute); }
already_AddRefed<nsIURI> XMLStylesheetProcessingInstruction::GetStyleSheetURL(bool* aIsInline) { *aIsInline = false; nsAutoString href; if (!GetAttrValue(nsGkAtoms::href, href)) { return nullptr; } nsIURI *baseURL; nsAutoCString charset; nsIDocument *document = OwnerDoc(); baseURL = mOverriddenBaseURI ? mOverriddenBaseURI.get() : document->GetDocBaseURI(); charset = document->GetDocumentCharacterSet(); nsCOMPtr<nsIURI> aURI; NS_NewURI(getter_AddRefs(aURI), href, charset.get(), baseURL); return aURI.forget(); }
NS_IMETHODIMP XMLStylesheetProcessingInstruction::GetCharset(nsAString& aCharset) { return GetAttrValue(nsGkAtoms::charset, aCharset) ? NS_OK : NS_ERROR_FAILURE; }
OGRErr OGRSpatialReference::exportToERM( char *pszProj, char *pszDatum, char *pszUnits ) { strcpy( pszProj, "RAW" ); strcpy( pszDatum, "RAW" ); strcpy( pszUnits, "METERS" ); if( !IsProjected() && !IsGeographic() ) return TRUE; /* -------------------------------------------------------------------- */ /* Try to find the EPSG code. */ /* -------------------------------------------------------------------- */ int nEPSGCode = 0; if( IsProjected() ) { const char *pszAuthName = GetAuthorityName( "PROJCS" ); if( pszAuthName != NULL && EQUAL(pszAuthName,"epsg") ) { nEPSGCode = atoi(GetAuthorityCode( "PROJCS" )); } } else if( IsGeographic() ) { const char *pszAuthName = GetAuthorityName( "GEOGCS" ); if( pszAuthName != NULL && EQUAL(pszAuthName,"epsg") ) { nEPSGCode = atoi(GetAuthorityCode( "GEOGCS" )); } } /* -------------------------------------------------------------------- */ /* Is our GEOGCS name already defined in ecw_cs.dat? */ /* -------------------------------------------------------------------- */ OGRSpatialReference oSRSWork; const char *pszWKTDatum = GetAttrValue( "DATUM" ); if( pszWKTDatum != NULL && oSRSWork.importFromDict( "ecw_cs.wkt", pszWKTDatum ) == OGRERR_NONE) { strncpy( pszDatum, pszWKTDatum, 32 ); pszDatum[31] = '\0'; } /* -------------------------------------------------------------------- */ /* Is this a "well known" geographic coordinate system? */ /* -------------------------------------------------------------------- */ if( EQUAL(pszDatum,"RAW") ) { int nEPSGGCSCode = GetEPSGGeogCS(); if( nEPSGGCSCode == 4326 ) strcpy( pszDatum, "WGS84" ); else if( nEPSGGCSCode == 4322 ) strcpy( pszDatum, "WGS72DOD" ); else if( nEPSGGCSCode == 4267 ) strcpy( pszDatum, "NAD27" ); else if( nEPSGGCSCode == 4269 ) strcpy( pszDatum, "NAD83" ); else if( nEPSGGCSCode == 4277 ) strcpy( pszDatum, "OSGB36" ); else if( nEPSGGCSCode == 4278 ) strcpy( pszDatum, "OSGB78" ); else if( nEPSGGCSCode == 4201 ) strcpy( pszDatum, "ADINDAN" ); else if( nEPSGGCSCode == 4202 ) strcpy( pszDatum, "AGD66" ); else if( nEPSGGCSCode == 4203 ) strcpy( pszDatum, "AGD84" ); else if( nEPSGGCSCode == 4209 ) strcpy( pszDatum, "ARC1950" ); else if( nEPSGGCSCode == 4210 ) strcpy( pszDatum, "ARC1960" ); else if( nEPSGGCSCode == 4275 ) strcpy( pszDatum, "NTF" ); else if( nEPSGGCSCode == 4283 ) strcpy( pszDatum, "GDA94" ); else if( nEPSGGCSCode == 4284 ) strcpy( pszDatum, "PULKOVO" ); } /* -------------------------------------------------------------------- */ /* Are we working with a geographic (geodetic) coordinate system? */ /* -------------------------------------------------------------------- */ if( IsGeographic() ) { if( EQUAL(pszDatum,"RAW") ) return OGRERR_UNSUPPORTED_SRS; else { strcpy( pszProj, "GEODETIC" ); return OGRERR_NONE; } } /* -------------------------------------------------------------------- */ /* Is this a UTM projection? */ /* -------------------------------------------------------------------- */ int bNorth, nZone; nZone = GetUTMZone( &bNorth ); if( nZone > 0 ) { if( EQUAL(pszDatum,"GDA94") && !bNorth && nZone >= 48 && nZone <= 58) { sprintf( pszProj, "MGA%02d", nZone ); } else { if( bNorth ) sprintf( pszProj, "NUTM%02d", nZone ); else sprintf( pszProj, "SUTM%02d", nZone ); } } /* -------------------------------------------------------------------- */ /* Is our PROJCS name already defined in ecw_cs.dat? */ /* -------------------------------------------------------------------- */ else { const char *pszPROJCS = GetAttrValue( "PROJCS" ); if( pszPROJCS != NULL && oSRSWork.importFromDict( "ecw_cs.wkt", pszPROJCS ) == OGRERR_NONE && oSRSWork.IsProjected() ) { strncpy( pszProj, pszPROJCS, 32 ); pszProj[31] = '\0'; } } /* -------------------------------------------------------------------- */ /* If we have not translated it yet, but we have an EPSG code */ /* then use EPSG:n notation. */ /* -------------------------------------------------------------------- */ if( (EQUAL(pszDatum,"RAW") || EQUAL(pszProj,"RAW")) && nEPSGCode != 0 ) { sprintf( pszProj, "EPSG:%d", nEPSGCode ); sprintf( pszDatum, "EPSG:%d", nEPSGCode ); } /* -------------------------------------------------------------------- */ /* Handle the units. */ /* -------------------------------------------------------------------- */ double dfUnits = GetLinearUnits(); if( fabs(dfUnits-0.3048) < 0.0001 ) strcpy( pszUnits, "FEET" ); else strcpy( pszUnits, "METERS" ); if( EQUAL(pszProj,"RAW") ) return OGRERR_UNSUPPORTED_SRS; else return OGRERR_NONE; }
OGRErr OGRSpatialReference::exportToUSGS( long *piProjSys, long *piZone, double **ppadfPrjParams, long *piDatum ) const { const char *pszProjection = GetAttrValue("PROJECTION"); /* -------------------------------------------------------------------- */ /* Fill all projection parameters with zero. */ /* -------------------------------------------------------------------- */ int i; *ppadfPrjParams = (double *)CPLMalloc( 15 * sizeof(double) ); for ( i = 0; i < 15; i++ ) (*ppadfPrjParams)[i] = 0.0; *piZone = 0L; /* ==================================================================== */ /* Handle the projection definition. */ /* ==================================================================== */ if( IsLocal() ) *piProjSys = GEO; else if( pszProjection == NULL ) { #ifdef DEBUG CPLDebug( "OSR_USGS", "Empty projection definition, considered as Geographic" ); #endif *piProjSys = GEO; } else if( EQUAL(pszProjection, SRS_PT_ALBERS_CONIC_EQUAL_AREA) ) { *piProjSys = ALBERS; (*ppadfPrjParams)[2] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ) ); (*ppadfPrjParams)[3] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 ) ); (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) ) { *piProjSys = LAMCC; (*ppadfPrjParams)[2] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ) ); (*ppadfPrjParams)[3] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 ) ); (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_MERCATOR_1SP) ) { *piProjSys = MERCAT; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_POLAR_STEREOGRAPHIC) ) { *piProjSys = PS; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_POLYCONIC) ) { *piProjSys = POLYC; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_EQUIDISTANT_CONIC) ) { *piProjSys = EQUIDC; (*ppadfPrjParams)[2] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ) ); (*ppadfPrjParams)[3] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 ) ); (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); (*ppadfPrjParams)[8] = 1.0; } else if( EQUAL(pszProjection, SRS_PT_TRANSVERSE_MERCATOR) ) { int bNorth; *piZone = GetUTMZone( &bNorth ); if( *piZone != 0 ) { *piProjSys = UTM; if( !bNorth ) *piZone = - *piZone; } else { *piProjSys = TM; (*ppadfPrjParams)[2] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } } else if( EQUAL(pszProjection, SRS_PT_STEREOGRAPHIC) ) { *piProjSys = STEREO; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA) ) { *piProjSys = LAMAZ; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_AZIMUTHAL_EQUIDISTANT) ) { *piProjSys = AZMEQD; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_GNOMONIC) ) { *piProjSys = GNOMON; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_ORTHOGRAPHIC) ) { *piProjSys = ORTHO; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_SINUSOIDAL) ) { *piProjSys = SNSOID; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_EQUIRECTANGULAR) ) { *piProjSys = EQRECT; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_MILLER_CYLINDRICAL) ) { *piProjSys = MILLER; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_VANDERGRINTEN) ) { *piProjSys = VGRINT; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_HOTINE_OBLIQUE_MERCATOR) ) { *piProjSys = HOM; (*ppadfPrjParams)[2] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); (*ppadfPrjParams)[3] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_AZIMUTH, 0.0 ) ); (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); (*ppadfPrjParams)[12] = 1.0; } else if( EQUAL(pszProjection, SRS_PT_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN) ) { *piProjSys = HOM; (*ppadfPrjParams)[2] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); (*ppadfPrjParams)[5] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); (*ppadfPrjParams)[8] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_POINT_1, 0.0 ) ); (*ppadfPrjParams)[9] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_POINT_1, 0.0 ) ); (*ppadfPrjParams)[10] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_POINT_2, 0.0 ) ); (*ppadfPrjParams)[11] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LATITUDE_OF_POINT_2, 0.0 ) ); (*ppadfPrjParams)[12] = 0.0; } else if( EQUAL(pszProjection, SRS_PT_ROBINSON) ) { *piProjSys = ROBIN; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_MOLLWEIDE) ) { *piProjSys = MOLL; (*ppadfPrjParams)[4] = CPLDecToPackedDMS( GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) ); (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_WAGNER_IV) ) { *piProjSys = WAGIV; (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_WAGNER_VII) ) { *piProjSys = WAGVII; (*ppadfPrjParams)[6] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); (*ppadfPrjParams)[7] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } // Projection unsupported by GCTP else { CPLDebug( "OSR_USGS", "Projection \"%s\" unsupported by USGS GCTP. " "Geographic system will be used.", pszProjection ); *piProjSys = GEO; } /* -------------------------------------------------------------------- */ /* Translate the datum. */ /* -------------------------------------------------------------------- */ const char *pszDatum = GetAttrValue( "DATUM" ); if ( pszDatum ) { if( EQUAL( pszDatum, SRS_DN_NAD27 ) ) *piDatum = CLARKE1866; else if( EQUAL( pszDatum, SRS_DN_NAD83 ) ) *piDatum = GRS1980; else if( EQUAL( pszDatum, SRS_DN_WGS84 ) ) *piDatum = WGS84; // If not found well known datum, translate ellipsoid else { double dfSemiMajor = GetSemiMajor(); double dfInvFlattening = GetInvFlattening(); #ifdef DEBUG CPLDebug( "OSR_USGS", "Datum \"%s\" unsupported by USGS GCTP. " "Try to translate ellipsoid definition.", pszDatum ); #endif for ( i = 0; i < NUMBER_OF_ELLIPSOIDS; i++ ) { double dfSM; double dfIF; if ( OSRGetEllipsoidInfo( aoEllips[i], NULL, &dfSM, &dfIF ) == OGRERR_NONE && CPLIsEqual( dfSemiMajor, dfSM ) && CPLIsEqual( dfInvFlattening, dfIF ) ) { *piDatum = i; break; } } if ( i == NUMBER_OF_ELLIPSOIDS ) // Didn't found matches; set { // custom ellipsoid parameters #ifdef DEBUG CPLDebug( "OSR_USGS", "Ellipsoid \"%s\" unsupported by USGS GCTP. " "Custom ellipsoid definition will be used.", pszDatum ); #endif *piDatum = -1; (*ppadfPrjParams)[0] = dfSemiMajor; if ( ABS( dfInvFlattening ) < 0.000000000001 ) { (*ppadfPrjParams)[1] = dfSemiMajor; } else { (*ppadfPrjParams)[1] = dfSemiMajor * (1.0 - 1.0/dfInvFlattening); } } } } else *piDatum = -1; return OGRERR_NONE; }
OGRErr OGRSpatialReference::exportToPanorama( long *piProjSys, long *piDatum, long *piEllips, long *piZone, double *padfPrjParams ) const { CPLAssert( padfPrjParams ); const char *pszProjection = GetAttrValue("PROJECTION"); /* -------------------------------------------------------------------- */ /* Fill all projection parameters with zero. */ /* -------------------------------------------------------------------- */ int i; *piDatum = 0L; *piEllips = 0L; *piZone = 0L; for ( i = 0; i < 7; i++ ) padfPrjParams[i] = 0.0; /* ==================================================================== */ /* Handle the projection definition. */ /* ==================================================================== */ if( IsLocal() ) *piProjSys = PAN_PROJ_NONE; else if( pszProjection == NULL ) { #ifdef DEBUG CPLDebug( "OSR_Panorama", "Empty projection definition, considered as Geographic" ); #endif *piProjSys = PAN_PROJ_NONE; } else if( EQUAL(pszProjection, SRS_PT_MERCATOR_1SP) ) { *piProjSys = PAN_PROJ_MERCAT; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[4] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_POLAR_STEREOGRAPHIC) ) { *piProjSys = PAN_PROJ_PS; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[4] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_POLYCONIC) ) { *piProjSys = PAN_PROJ_POLYC; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_EQUIDISTANT_CONIC) ) { *piProjSys = PAN_PROJ_EC; padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ); padfPrjParams[1] = TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 ); padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) ) { *piProjSys = PAN_PROJ_LCC; padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ); padfPrjParams[1] = TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 ); padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_TRANSVERSE_MERCATOR) ) { int bNorth; *piZone = GetUTMZone( &bNorth ); if( *piZone != 0 ) { *piProjSys = PAN_PROJ_UTM; if( !bNorth ) *piZone = - *piZone; } else { *piProjSys = PAN_PROJ_TM; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[4] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } } else if( EQUAL(pszProjection, SRS_PT_WAGNER_I) ) { *piProjSys = PAN_PROJ_WAG1; padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_STEREOGRAPHIC) ) { *piProjSys = PAN_PROJ_STEREO; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[4] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_AZIMUTHAL_EQUIDISTANT) ) { *piProjSys = PAN_PROJ_AE; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_LONGITUDE_OF_CENTER, 0.0 ); padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_CENTER, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_GNOMONIC) ) { *piProjSys = PAN_PROJ_GNOMON; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_MOLLWEIDE) ) { *piProjSys = PAN_PROJ_MOLL; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_LAMBERT_AZIMUTHAL_EQUAL_AREA) ) { *piProjSys = PAN_PROJ_LAEA; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_EQUIRECTANGULAR) ) { *piProjSys = PAN_PROJ_EQC; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_CYLINDRICAL_EQUAL_AREA) ) { *piProjSys = PAN_PROJ_CEA; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[2] = TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } else if( EQUAL(pszProjection, SRS_PT_IMW_POLYCONIC) ) { *piProjSys = PAN_PROJ_IMWP; padfPrjParams[3] = TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ); padfPrjParams[0] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_1ST_POINT, 0.0 ); padfPrjParams[1] = TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_2ND_POINT, 0.0 ); padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 ); padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 ); } // Projection unsupported by "Panorama" GIS else { CPLDebug( "OSR_Panorama", "Projection \"%s\" unsupported by \"Panorama\" GIS. " "Geographic system will be used.", pszProjection ); *piProjSys = PAN_PROJ_NONE; } /* -------------------------------------------------------------------- */ /* Translate the datum. */ /* -------------------------------------------------------------------- */ const char *pszDatum = GetAttrValue( "DATUM" ); if ( pszDatum == NULL ) { *piDatum = PAN_DATUM_NONE; *piEllips = PAN_ELLIPSOID_NONE; } else if ( EQUAL( pszDatum, "Pulkovo_1942" ) ) { *piDatum = PAN_DATUM_PULKOVO42; *piEllips = PAN_ELLIPSOID_KRASSOVSKY; } else if( EQUAL( pszDatum, SRS_DN_WGS84 ) ) { *piDatum = PAN_DATUM_WGS84; *piEllips = PAN_ELLIPSOID_WGS84; } // If not found well known datum, translate ellipsoid else { double dfSemiMajor = GetSemiMajor(); double dfInvFlattening = GetInvFlattening(); size_t i; #ifdef DEBUG CPLDebug( "OSR_Panorama", "Datum \"%s\" unsupported by \"Panorama\" GIS. " "Try to translate ellipsoid definition.", pszDatum ); #endif for ( i = 0; i < NUMBER_OF_ELLIPSOIDS; i++ ) { if ( aoEllips[i] ) { double dfSM = 0.0; double dfIF = 1.0; if ( OSRGetEllipsoidInfo( aoEllips[i], NULL, &dfSM, &dfIF ) == OGRERR_NONE && CPLIsEqual(dfSemiMajor, dfSM) && CPLIsEqual(dfInvFlattening, dfIF) ) { *piEllips = i; break; } } } if ( i == NUMBER_OF_ELLIPSOIDS ) // Didn't found matches. { #ifdef DEBUG CPLDebug( "OSR_Panorama", "Ellipsoid \"%s\" unsupported by \"Panorama\" GIS.", pszDatum ); #endif *piDatum = PAN_DATUM_NONE; *piEllips = PAN_ELLIPSOID_NONE; } } return OGRERR_NONE; }
CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, bool bStartTag) { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (IsEOF()) { return nullptr; } CFX_ByteString tag_name, tag_space; bool bEndTag; GetTagName(tag_space, tag_name, bEndTag, bStartTag); if (tag_name.IsEmpty() || bEndTag) { return nullptr; } CXML_Element* pElement = new CXML_Element; pElement->m_pParent = pParent; pElement->SetTag(tag_space.AsStringC(), tag_name.AsStringC()); do { CFX_ByteString attr_space, attr_name; while (m_dwIndex < m_dwBufferSize) { SkipWhiteSpaces(); if (IsEOF()) { break; } if (!g_FXCRT_XML_IsNameIntro(m_pBuffer[m_dwIndex])) { break; } GetName(attr_space, attr_name); SkipWhiteSpaces(); if (IsEOF()) { break; } if (m_pBuffer[m_dwIndex] != '=') { break; } m_dwIndex++; SkipWhiteSpaces(); if (IsEOF()) { break; } CFX_WideString attr_value; GetAttrValue(attr_value); pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value); } m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (m_dwIndex < m_dwBufferSize || IsEOF()) { break; } } while (ReadNextBlock()); SkipWhiteSpaces(); if (IsEOF()) { return pElement; } uint8_t ch = m_pBuffer[m_dwIndex++]; if (ch == '/') { m_dwIndex++; m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; return pElement; } if (ch != '>') { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; delete pElement; return nullptr; } SkipWhiteSpaces(); if (IsEOF()) { return pElement; } CFX_UTF8Decoder decoder; CFX_WideTextBuf content; bool bCDATA = false; int32_t iState = 0; do { while (m_dwIndex < m_dwBufferSize) { ch = m_pBuffer[m_dwIndex++]; switch (iState) { case 0: if (ch == '<') { iState = 1; } else if (ch == '&') { decoder.ClearStatus(); decoder.AppendChar(GetCharRef()); } else { decoder.Input(ch); } break; case 1: if (ch == '!') { iState = 2; } else if (ch == '?') { SkipLiterals("?>"); SkipWhiteSpaces(); iState = 0; } else if (ch == '/') { CFX_ByteString space, name; GetName(space, name); SkipWhiteSpaces(); m_dwIndex++; iState = 10; } else { content << decoder.GetResult(); CFX_WideString dataStr = content.MakeString(); if (!bCDATA && !m_bSaveSpaceChars) { dataStr.TrimRight(L" \t\r\n"); } InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); content.Clear(); decoder.Clear(); bCDATA = false; iState = 0; m_dwIndex--; CXML_Element* pSubElement = ParseElement(pElement, true); if (!pSubElement) { break; } pSubElement->m_pParent = pElement; pElement->m_Children.push_back( {CXML_Element::Element, pSubElement}); SkipWhiteSpaces(); } break; case 2: if (ch == '[') { SkipLiterals("]]>"); } else if (ch == '-') { m_dwIndex++; SkipLiterals("-->"); } else { SkipLiterals(">"); } decoder.Clear(); SkipWhiteSpaces(); iState = 0; break; } if (iState == 10) { break; } } m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { break; } } while (ReadNextBlock()); content << decoder.GetResult(); CFX_WideString dataStr = content.MakeString(); if (!m_bSaveSpaceChars) { dataStr.TrimRight(L" \t\r\n"); } InsertContentSegment(bCDATA, dataStr.AsStringC(), pElement); content.Clear(); decoder.Clear(); bCDATA = false; return pElement; }
CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, FX_BOOL bStartTag) { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (IsEOF()) { return NULL; } CFX_ByteString tag_name, tag_space; FX_BOOL bEndTag; GetTagName(tag_space, tag_name, bEndTag, bStartTag); if (tag_name.IsEmpty() || bEndTag) { return NULL; } CXML_Element* pElement; pElement = FX_NEW CXML_Element; if (pElement) { pElement->m_pParent = pParent; pElement->SetTag(tag_space, tag_name); } if (!pElement) { return NULL; } do { CFX_ByteString attr_space, attr_name; while (m_dwIndex < m_dwBufferSize) { SkipWhiteSpaces(); if (IsEOF()) { break; } if (!g_FXCRT_XML_IsNameIntro(m_pBuffer[m_dwIndex])) { break; } GetName(attr_space, attr_name); SkipWhiteSpaces(); if (IsEOF()) { break; } if (m_pBuffer[m_dwIndex] != '=') { break; } m_dwIndex ++; SkipWhiteSpaces(); if (IsEOF()) { break; } CFX_WideString attr_value; GetAttrValue(attr_value); pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value); } m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (m_dwIndex < m_dwBufferSize || IsEOF()) { break; } } while (ReadNextBlock()); SkipWhiteSpaces(); if (IsEOF()) { return pElement; } FX_BYTE ch = m_pBuffer[m_dwIndex ++]; if (ch == '/') { m_dwIndex ++; m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; return pElement; } if (ch != '>') { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; delete pElement; return NULL; } SkipWhiteSpaces(); if (IsEOF()) { return pElement; } CFX_UTF8Decoder decoder; CFX_WideTextBuf content; FX_BOOL bCDATA = FALSE; FX_INT32 iState = 0; do { while (m_dwIndex < m_dwBufferSize) { ch = m_pBuffer[m_dwIndex ++]; switch (iState) { case 0: if (ch == '<') { iState = 1; } else if (ch == '&') { decoder.ClearStatus(); decoder.AppendChar(GetCharRef()); } else { decoder.Input(ch); } break; case 1: if (ch == '!') { iState = 2; } else if (ch == '?') { SkipLiterals(FX_BSTRC("?>")); SkipWhiteSpaces(); iState = 0; } else if (ch == '/') { CFX_ByteString space, name; GetName(space, name); SkipWhiteSpaces(); m_dwIndex ++; iState = 10; } else { content << decoder.GetResult(); CFX_WideString dataStr = content.GetWideString(); if (!bCDATA && !m_bSaveSpaceChars) { dataStr.TrimRight((FX_LPCWSTR)L" \t\r\n"); } InsertContentSegment(bCDATA, dataStr, pElement); content.Clear(); decoder.Clear(); bCDATA = FALSE; iState = 0; m_dwIndex --; CXML_Element* pSubElement = ParseElement(pElement, TRUE); if (pSubElement == NULL) { break; } pSubElement->m_pParent = pElement; pElement->m_Children.Add((FX_LPVOID)CXML_Element::Element); pElement->m_Children.Add(pSubElement); SkipWhiteSpaces(); } break; case 2: if (ch == '[') { SkipLiterals(FX_BSTRC("]]>")); } else if (ch == '-') { m_dwIndex ++; SkipLiterals(FX_BSTRC("-->")); } else { SkipLiterals(FX_BSTRC(">")); } decoder.Clear(); SkipWhiteSpaces(); iState = 0; break; } if (iState == 10) { break; } } m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (iState == 10 || m_dwIndex < m_dwBufferSize || IsEOF()) { break; } } while (ReadNextBlock()); content << decoder.GetResult(); CFX_WideString dataStr = content.GetWideString(); if (!m_bSaveSpaceChars) { dataStr.TrimRight((FX_LPCWSTR)L" \t\r\n"); } InsertContentSegment(bCDATA, dataStr, pElement); content.Clear(); decoder.Clear(); bCDATA = FALSE; return pElement; }
NS_IMETHODIMP nsXMLStylesheetPI::GetCharset(nsAString& aCharset) { return GetAttrValue(nsGkAtoms::charset, aCharset) ? NS_OK : NS_ERROR_FAILURE; }