
Код: Выделить всё
bool TraverseTracker::addLabel(QPointF point) // in meters
{
if (!_userMap)
{
PRINT_DEBUG("No map", 7);
return false;
}
//Add label
QList<QPointF> points;
points << point;
QList<semanticPair> semantic;
int local = LOCAL_POINT;
long excode = GLOBAL::labelOperator;
if (!GisApi::addObject(_userMap, local, excode, points, semantic))
{
PRINT_DEBUG("Cant add label",5);
return false;
}
return true;
}
bool GisApi::addObject(HMAP map, long local, long excode, QList<QPointF> points, QList<semanticPair> semantic)
{
//Check da values
if (0 == excode)
{
PRINT_DEBUG("Wrong object excode", 5);
return false;
}
if ((local < LOCAL_LINE) && (local > LOCAL_MIXED))
{
PRINT_DEBUG("Wrong object local", 5);
return false;
}
if (points.count() < 1)
{
PRINT_DEBUG("Not enough object metric points count", 5);
return false;
}
//Create empty object on the map
HOBJ insertObject = mapCreateObject(map);
if (0 == insertObject)
{
PRINT_DEBUG("Cant create object",5);
return false;
}
//Add semantics to insert object
for (int i = 0; i < semantic.count(); i++)
{
long semanticCode = semantic.at(i).first;
if (0 == semanticCode)
continue;
// char *semanticValue = new char[semantic.at(i).second.size()];
// semanticValue = semantic.at(i).second.toAscii().data();
// PRINT_DEBUG(QString("Semantic: %1, %2. Str = %3").arg(semanticCode).arg(QString(semanticValue)).arg(semantic.at(i).second), 10);
// Q_ASSERT(mapAppendSemantic(insertObject, semanticCode, semanticValue, semantic.at(i).second.size()) != 0);
Q_ASSERT(mapAppendSemantic(insertObject, semanticCode, semantic.at(i).second.toAscii().data(), semantic.at(i).second.size()) != 0);
// delete []semanticValue;
}
//Register object
// PRINT_DEBUG(QString("Gaf map = %1, insertObject = %2, excode = %3, local = %4, GAf = %5").arg(map).arg(insertObject).arg(excode).arg(local).arg(mapGetMapX2(map)), 10 );
if (!mapRegisterObject(insertObject, excode, local))
{
PRINT_DEBUG("Cant register object",5);
return false;
}
//Add points to the object
for (int i = 0; i < points.count(); i++)
{
if (!mapAppendPointPlane(insertObject, points.at(i).x(), points.at(i).y(), 0))
{
PRINT_DEBUG("Cant append metric point to the object",5);
return false;
}
}
//Commit object to the map file
if(!mapCommitObjectAsNew(insertObject)) // !!!ПРОБЛЕМА ВОТ В ЭТОМ МЕСТЕ, Ф_ЦИЯ ВОЗВРАЩАЕТ 0
{
PRINT_DEBUG("Cant commit object",5);
return false;
}
//Free memory
mapFreeObject(insertObject);
return true;
}
void TraverseTracker::setProject(ProjectInfo *pInfo)
{
_pInfo = pInfo;
refreshParams();
//Load user map from whole project.
QString userMapPath = pInfo->getPath() + GLOBAL::operSitCat + QDir::separator() + pInfo->getUserMapFileName();
userMapPath = QDir::cleanPath(userMapPath);
if (_userMap)
mapCloseData(_userMap);
_userMap = mapOpenData(userMapPath.toAscii().data());
if (0 == _userMap)
PRINT_DEBUG("Cant open userMap :" + userMapPath, 5);
......
}
Подскажите пожалуйста в чем проблема может быть.