void SuperMapConnection::CreateSpatialContext( FdoString* name, FdoString* description, FdoString* coordinateSystem, FdoString* coordinateSystemWkt, FdoSpatialContextExtentType extentType, FdoByteArray * extent, double xyTolerance, double zTolerance, bool update ) { bool found = false; // 检查是否有同一个WKT空间语义存在 for(FdoInt32 i = 0; i < m_SpatialContextColl->GetCount() && !found; ++i) { FdoPtr<SuperMapSpatialContext> sp = m_SpatialContextColl->GetItem(i); found = (coordinateSystemWkt == sp->GetCoordinateSystemWkt()); } // 赋新的坐标系 if(!found) { FdoPtr<SuperMapSpatialContext> newSp = new SuperMapSpatialContext(); FdoInt32 idxGenName = 1; FdoStringP newName = name; // 查找重复的空间语义名,在名字后加数字避免重名 while(m_SpatialContextColl->FindItem(newName)) { newName = FdoStringP::Format(L"%ls_%d", (FdoString*)name, idxGenName); idxGenName++; } //设置新的空间语义 newSp->SetName(newName); newSp->SetCoordSysName(coordinateSystem); newSp->SetCoordinateSystemWkt(coordinateSystemWkt); newSp->SetDescription(description); newSp->SetExtent(extent); newSp->SetExtentType(extentType); newSp->SetXYTolerance(xyTolerance); newSp->SetZTolerance(zTolerance); m_SpatialContextColl->Add(newSp); //Todo: 往物理数据源中添加投影信息是否在此做? } }
void FdoRfpSpatialContextCollection::ReadXml(FdoXmlReader* reader) { FdoXmlSpatialContextReaderP spreader = FdoXmlSpatialContextReader::Create(reader); // Read the one and ond supported spatial context while (spreader->ReadNext()) { FdoPtr<FdoRfpSpatialContext> context = new FdoRfpSpatialContext(); context->SetName(spreader->GetName()); context->SetDescription(spreader->GetDescription()); context->SetCoordinateSystem(spreader->GetCoordinateSystem()); context->SetCoordinateSystemWkt(spreader->GetCoordinateSystemWkt()); context->SetExtent(spreader->GetExtent()); context->SetExtentType(spreader->GetExtentType()); context->SetXYTolerance(spreader->GetXYTolerance()); context->SetZTolerance(spreader->GetZTolerance()); Add(context); } }