|
[code]void GeographicLocationMarker( )
{
/*Map Projection type*/
const AcString csId(L"UTM84-43N");
/*Creating the projected Coordinate Sytem */
Acad::ErrorStatus es;
AcDbGeoCoordinateSystem* pGeoCS;
AcDbGeoCoordinateSystem::create(csId, pGeoCS);
if (NULL == pGeoCS)
return;
AcString xmlStr;
/*Get XML type*/
es = pGeoCS->getXmlRepresentation(xmlStr);
/*Checking the output of CRS*/
acutPrintf(_T("\ncrsName: %s"),xmlStr.kACharPtr());
if(xmlStr.isEmpty()) return;
AcDbObjectId geoId;
AcDbObjectPointer<AcDbGeoData> pGeoData;
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
acdbGetGeoDataObjId(pDb, geoId);
/*Post our Geodata to Database,
AcDbGeoData is not an Entity, it is stored in Model-Space's Extension Dictionary*/
if (geoId.isNull())
{
pGeoData.create();
pGeoData->setBlockTableRecordId(acdbSymUtil()->blockModelSpaceId(pDb));
pGeoData->postToDb(geoId);
}
else
{
pGeoData.open(geoId, AcDb::kForWrite);
}
if (NULL == pGeoData.object())
return;
/* The spatial coordinate system string.
It can be the id of the coordinate system or the XML/WKT representation*/
es = pGeoData->setCoordinateSystem(xmlStr);
/* The design coordinate system is considered to be local, aka
an engineering coordinate system.*/
es = pGeoData->setCoordinateType(AcDbGeoData::kCoordTypLocal);
es = pGeoData->setHorizontalUnits(AcDb::kUnitsMillimeters);
es = pGeoData->setVerticalUnits(AcDb::kUnitsMillimeters);
es = pGeoData->setDesignPoint(AcGePoint3d::kOrigin);
es = pGeoData->setUpDirection(AcGeVector3d::kZAxis);
/*Lat and Long of Hyderabad : 17.434586,78.384402*/
/*Note: AcGePoint3d expected to be Long,Lat,alt*/
AcGePoint3d refPtInUTM84, refPtInLatLong(78.384402,17.434586,0.0);
/*Get WCS point*/
pGeoData->transformFromLonLatAlt(refPtInLatLong,refPtInUTM84);
pGeoData->setReferencePoint(refPtInUTM84);
pGeoData->setNorthDirectionVector(AcGeVector2d::kYAxis);
/*clean up*/
delete pGeoCS;
pGeoData.close();
}[/code] |
|