本文整理汇总了C++中HootException函数的典型用法代码示例。如果您正苦于以下问题:C++ HootException函数的具体用法?C++ HootException怎么用?C++ HootException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HootException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: HootException
void OgrWriter::_addFeatureToLayer(OGRLayer* layer, shared_ptr<Feature> f, const Geometry* g,
OGRFeature* poFeature)
{
std::string wkt = g->toString();
char* t = (char*)wkt.data();
OGRGeometry* geom;
int errCode = OGRGeometryFactory::createFromWkt(&t, layer->GetSpatialRef(), &geom) ;
if (errCode != OGRERR_NONE)
{
throw HootException(
QString("Error parsing WKT (%1). OGR Error Code: (%2)").arg(QString::fromStdString(wkt)).arg(QString::number(errCode)));
}
errCode = poFeature->SetGeometryDirectly(geom);
if (errCode != OGRERR_NONE)
{
throw HootException(
QString("Error setting geometry - OGR Error Code: (%1) Geometry: (%2)").arg(QString::number(errCode)).arg(QString::fromStdString(g->toString())));
}
errCode = layer->CreateFeature(poFeature);
if (errCode != OGRERR_NONE)
{
throw HootException(
QString("Error creating feature - OGR Error Code: (%1) \nFeature causing error: (%2)").arg(QString::number(errCode)).arg(f->toString()));
}
}
开发者ID:giserh,项目名称:hootenanny,代码行数:27,代码来源:OgrWriter.cpp
示例2: isMatchCandidate
bool isMatchCandidate(ConstElementPtr e)
{
Context::Scope context_scope(_script->getContext());
HandleScope handleScope;
Persistent<Object> plugin = getPlugin();
Handle<String> isMatchCandidateStr = String::New("isMatchCandidate");
if (plugin->Has(isMatchCandidateStr) == false)
{
throw HootException("Error finding 'isMatchCandidate' function.");
}
Handle<v8::Value> value = plugin->Get(isMatchCandidateStr);
if (value->IsFunction() == false)
{
throw HootException("isMatchCandidate is not a function.");
}
Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(value);
Handle<Value> jsArgs[2];
int argc = 0;
jsArgs[argc++] = OsmMapJs::create(_map);
jsArgs[argc++] = ElementJs::New(e);
Handle<Value> f = func->Call(plugin, argc, jsArgs);
return f->BooleanValue();
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:26,代码来源:ScriptMatchCreator.cpp
示例3: customScriptInit
/*
* This is meant to run one time when the match creator is initialized.
*/
void customScriptInit()
{
Context::Scope context_scope(_script->getContext());
HandleScope handleScope;
Persistent<Object> plugin = getPlugin();
Handle<String> initStr = String::New("init");
if (plugin->Has(initStr) == false)
{
throw HootException("Error finding 'init' function.");
}
Handle<v8::Value> value = plugin->Get(initStr);
if (value->IsFunction() == false)
{
throw HootException("init is not a function.");
}
Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(value);
Handle<Value> jsArgs[1];
int argc = 0;
HandleScope scope;
assert(_map.get());
OsmMapPtr copiedMap(new OsmMap(_map));
jsArgs[argc++] = OsmMapJs::create(copiedMap);
func->Call(plugin, argc, jsArgs);
//this is meant to have been set externally in a js rules file
_searchRadius = getNumber(plugin, "searchRadius", -1.0, 15.0);
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:33,代码来源:ScriptMatchCreator.cpp
示例4: HootException
void ServicesDb::closeChangeSet(long mapId, long changeSetId, Envelope env, int numChanges)
{
if (!changesetExists(mapId, changeSetId))
{
throw HootException("No changeset exists with ID: " + changeSetId);
}
_checkLastMapId(mapId);
if (_closeChangeSet == 0)
{
_closeChangeSet.reset(new QSqlQuery(_db));
_closeChangeSet->prepare(
QString("UPDATE %1 SET min_lat=:min_lat, max_lat=:max_lat, min_lon=:min_lon, "
"max_lon=:max_lon, closed_at=NOW(), num_changes=:num_changes WHERE id=:id")
.arg(_getChangesetsTableName(mapId)));
}
_closeChangeSet->bindValue(":min_lat", env.getMinY());
_closeChangeSet->bindValue(":max_lat", env.getMaxY());
_closeChangeSet->bindValue(":min_lon", env.getMinX());
_closeChangeSet->bindValue(":max_lon", env.getMaxX());
_closeChangeSet->bindValue(":num_changes", numChanges);
_closeChangeSet->bindValue(":id", (qlonglong)changeSetId);
if (_closeChangeSet->exec() == false)
{
LOG_ERROR("query bound values: ");
LOG_ERROR(_closeChangeSet->boundValues());
LOG_ERROR("\n");
throw HootException("Error executing close changeset: " + _closeChangeSet->lastError().text() +
" (SQL: " + _closeChangeSet->executedQuery() + ")" + " with envelope: " +
QString::fromStdString(env.toString()));
}
}
开发者ID:msorenson,项目名称:hootenanny,代码行数:33,代码来源:ServicesDb.cpp
示例5: HootException
WordCountReader::WordCountReader(QString path)
{
if (QSqlDatabase::contains(path) == false)
{
_db = QSqlDatabase::addDatabase("QSQLITE", path);
_db.setDatabaseName(path);
if (_db.open() == false)
{
throw HootException("Error opening DB. " + path);
}
}
else
{
_db = QSqlDatabase::database(path);
}
if (_db.isOpen() == false)
{
throw HootException("Error DB is not open. " + path);
}
_select = QSqlQuery(_db);
if (_select.prepare("SELECT count FROM words WHERE word=:word") == false)
{
throw HootException(QString("Error preparing query: %1").arg(_select.lastError().text()));
}
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:28,代码来源:WordCountReader.cpp
示例6: q
QSqlQuery ServicesDb::_exec(QString sql, QVariant v1, QVariant v2, QVariant v3) const
{
QSqlQuery q(_db);
LOG_VARD(sql);
if (q.prepare(sql) == false)
{
throw HootException(QString("Error preparing query: %1 (%2)").arg(q.lastError().text()).
arg(sql));
}
if (v1.isValid())
{
q.bindValue(0, v1);
}
if (v2.isValid())
{
q.bindValue(1, v2);
}
if (v3.isValid())
{
q.bindValue(2, v3);
}
if (q.exec() == false)
{
throw HootException(QString("Error executing query: %1 (%2)").arg(q.lastError().text()).
arg(sql));
}
return q;
}
开发者ID:msorenson,项目名称:hootenanny,代码行数:33,代码来源:ServicesDb.cpp
示例7: QSqlQuery
QString ServicesDb::getDbVersion()
{
if (_selectDbVersion == 0)
{
_selectDbVersion.reset(new QSqlQuery(_db));
_selectDbVersion->prepare("SELECT id || ':' || author AS version_id FROM databasechangelog "
"ORDER BY dateexecuted DESC LIMIT 1");
}
if (_selectDbVersion->exec() == false)
{
throw HootException(_selectDbVersion->lastError().text());
}
QString result;
if (_selectDbVersion->next())
{
result = _selectDbVersion->value(0).toString();
}
else
{
throw HootException("Unable to retrieve the DB version.");
}
return result;
}
开发者ID:msorenson,项目名称:hootenanny,代码行数:26,代码来源:ServicesDb.cpp
示例8: HootException
Envelope BaseCommand::parseEnvelope(QString envStr) const
{
QStringList envArr = envStr.split(",");
if (envArr.size() != 4)
{
throw HootException("Invalid bounds format, requires 4 values: " + envStr);
}
bool ok, allOk = true;
double left = envArr[0].toDouble(&ok);
allOk &= ok;
double bottom = envArr[1].toDouble(&ok);
allOk &= ok;
double right = envArr[2].toDouble(&ok);
allOk &= ok;
double top = envArr[3].toDouble(&ok);
allOk &= ok;
if (allOk == false)
{
throw HootException("Invalid bounds format: " + envStr);
}
return Envelope(left, right, bottom, top);
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:26,代码来源:BaseCommand.cpp
示例9: HootException
void ConflateMapper::_addNode(const shared_ptr<Node>& n)
{
long key = -1;
// if the node falls in one of the envelopes
for (size_t i = 0; i < _envelopes.size(); i++)
{
// set a positive key
if (_envelopes[i].contains(n->getX(), n->getY()))
{
if (key != -1)
{
throw HootException("This should never happen. Envelopes must not overlap.");
}
key = i;
}
}
// if the node is not in one of the envelopes.
if (key == -1)
{
// calculate a negative key based on node ID
key = -1 - (abs(n->getId()) % _reduceTaskCount);
}
if (key < -_reduceTaskCount || key >= (int)_envelopes.size())
{
LOG_INFO("envelope size: " << _envelopes.size());
throw HootException(QString("Key is out of range. nid: %1 key: %2").arg(n->getId()).arg(key));
}
if (Debug::isTroubledNode(n->getId()))
{
LOG_WARN("Writing a troubled node: " << n->toString());
LOG_WARN(" key: " << key)
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:35,代码来源:ConflateMapper.cpp
示例10: while
shared_ptr<OGRDataSource> OgrUtilities::createDataSource(QString url)
{
const char* driverName = NULL;
int i = 0;
while (extensions[i][0] != NULL)
{
if (url.endsWith(extensions[i][0]))
{
driverName = extensions[i][1];
}
i++;
}
i = 0;
while (beginName[i][0] != NULL)
{
if (url.startsWith(beginName[i][0]))
{
driverName = beginName[i][1];
}
i++;
}
if (driverName == NULL)
{
throw HootException("No driver found for: " + url);
}
OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driverName);
if (driver == 0)
{
throw HootException("Error getting driver by name: " + QString(driverName));
}
// if the user specifies a shapefile then crop off the .shp and create a directory.
if (url.toLower().endsWith(".shp"))
{
url = url.mid(0, url.length() - 4);
}
shared_ptr<OGRDataSource> result(driver->CreateDataSource(url.toAscii()));
if (result == NULL)
{
throw HootException("Unable to create data source: " + url +
" (" + QString(CPLGetLastErrorMsg()) + ")");
}
result->SetDriver(driver);
if (QString(driverName) == "FileGDB")
{
long v = GDAL_VERSION_MAJOR * 1000000 + GDAL_VERSION_MINOR * 1000 + GDAL_VERSION_REV;
long lowest = 1 * 1000000 + 10 * 1000 + 1;
if (v < lowest)
{
LOG_WARN("Writing to FileGDB with GDAL v" << GDAL_RELEASE_NAME << ". FileGDB with a GDAL "
"v1.9.0 is known to create files that can't be read by ArcMap 10.2. "
"GDAL v1.10.1 is known to work.");
}
}
return result;
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:60,代码来源:OgrUtilities.cpp
示例11: QSqlQuery
long SequenceIdReserver::_reserveIds()
{
if (_query == 0)
{
_query.reset(new QSqlQuery(_db));
_query->setForwardOnly(true);
////
// This query contains a race condition. It is possible that one process could call SETVAL
// between the call to CURRVAL and SETVAL. This can result in a smaller value than expected
// and duplicate IDs. See #3607 for details.
//
LOG_WARN("This query contains a race condition and may not do what you want.");
_query->prepare(
QString("SELECT NEXTVAL('%1'), "
"SETVAL('%1', CURRVAL('%1') + :count)").arg(_sequenceName));
}
_query->bindValue(0, (qlonglong)_bulkSize - 1);
if (_query->exec() == false)
{
throw HootException("Error reserving IDs. count: " +
QString::number(_bulkSize) + " Error: " + _query->lastError().text());
}
long result = -1;
if (_query->next())
{
bool ok;
result = _query->value(1).toLongLong(&ok);
if (!ok)
{
throw HootException("Did not retrieve starting reserved ID.");
}
}
else
{
LOG_VARW(_nextId);
LOG_VARW(result);
LOG_VARW(_bulkSize);
throw HootException("Error retrieving sequence value. count: " +
QString::number(_bulkSize) + " Error: " + _query->lastError().text());
}
if (result < _nextId)
{
LOG_VARW(_nextId);
LOG_VARW(result);
LOG_VARW(_bulkSize);
QString err = QString("Error allocating new sequence value. Expected to retrieve a value "
">= %1, but got %2.").arg(_nextId).arg(result);
LOG_WARN(err);
throw HootException(err);
}
_query->finish();
return result;
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:58,代码来源:SequenceIdReserver.cpp
示例12: HootException
void ServicesDbReader::open(QString urlStr)
{
if (!isSupported(urlStr))
{
throw HootException("An unsupported URL was passed in.");
}
QUrl url(urlStr);
QString osmElemId = url.queryItemValue("osm-element-id");
QString osmElemType = url.queryItemValue("osm-element-type");
QStringList pList = url.path().split("/");
bool ok;
bool ok2;
QString mapName;
_database.open(url);
_mapId = pList[pList.size() - 1].toLong(&ok);
if(osmElemId.length() > 0 && osmElemType.length() > 0)
{
_osmElemId = osmElemId.toLong(&ok2);
_osmElemType = ElementType::fromString(osmElemType);
}
if (!ok)
{
if (_email == "")
{
throw HootException("If a map name is specified then the user email must also be specified "
"via: " + emailKey());
}
mapName = pList[pList.size() - 1];
long userId = _database.getUserId(_email);
set<long> mapIds = _database.selectMapIds(mapName, userId);
if (mapIds.size() != 1)
{
QString str = QString("Expected 1 map with the name '%1' but found %2 maps.").arg(mapName)
.arg(mapIds.size());
throw HootException(str);
}
_mapId = *mapIds.begin();
}
if (!_database.mapExists(_mapId))
{
_database.close();
throw HootException("No map exists with ID: " + QString::number(_mapId));
}
//using a transaction seems to make sense here, b/c we don't want to read a map being modified
//in the middle of its modification caused by a changeset upload, which could cause the map to
//be invalid as a whole
_database.transaction();
_open = true;
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:54,代码来源:ServicesDbReader.cpp
示例13: _checkLastMapId
void ServicesDb::insertRelationMembers(long mapId, long relationId, ElementType type,
long elementId, QString role, int sequenceId)
{
_checkLastMapId(mapId);
if (_insertRelationMembers == 0)
{
_insertRelationMembers.reset(new QSqlQuery(_db));
_insertRelationMembers->prepare(
"INSERT INTO " + _getRelationMembersTableName(mapId) +
" (relation_id, member_type, member_id, member_role, sequence_id) "
"VALUES (:relation_id, :member_type, :member_id, :member_role, :sequence_id)");
}
_insertRelationMembers->bindValue(":relation_id", (qlonglong)relationId);
_insertRelationMembers->bindValue(":member_type", type.toString().toLower());
_insertRelationMembers->bindValue(":member_id", (qlonglong)elementId);
_insertRelationMembers->bindValue(":member_role", role);
_insertRelationMembers->bindValue(":sequence_id", sequenceId);
if (!_insertRelationMembers->exec())
{
throw HootException("Error inserting relation memeber: " +
_insertRelationMembers->lastError().text());
}
}
开发者ID:msorenson,项目名称:hootenanny,代码行数:26,代码来源:ServicesDb.cpp
示例14: HootException
bool TileBoundsCalculator::_isDone(vector<PixelBox> &boxes)
{
bool smallEnough = true;
bool minSize = false;
for (size_t i = 0; i < boxes.size(); i++)
{
PixelBox& b = boxes[i];
if (b.getWidth() == 1 || b.getHeight() == 1)
{
minSize = true;
}
if (_sumPixels(b) > _maxNodesPerBox)
{
smallEnough = false;
}
}
if (minSize == true && smallEnough == false)
{
throw HootException("Could not find a solution. Try reducing the pixel size or increasing the "
"max nodes per pixel value.");
}
else
{
return smallEnough;
}
}
开发者ID:drew-bower,项目名称:hootenanny,代码行数:29,代码来源:TileBoundsCalculator.cpp
示例15: generateGeometry
OsmMapPtr AlphaShapeGenerator::generateMap(OsmMapPtr inputMap)
{
boost::shared_ptr<Geometry> cutterShape = generateGeometry(inputMap);
if (cutterShape->getArea() == 0.0)
{
//would rather this be thrown than a warning logged, as the warning may go unoticed by web
//clients who are expecting the alpha shape to be generated
throw HootException("Alpha Shape area is zero. Try increasing the buffer size and/or alpha.");
}
OsmMapPtr result;
result.reset(new OsmMap(inputMap->getProjection()));
// add the resulting alpha shape for debugging.
GeometryConverter(result).convertGeometryToElement(cutterShape.get(), Status::Invalid, -1);
const RelationMap& rm = result->getRelations();
for (RelationMap::const_iterator it = rm.begin(); it != rm.end(); ++it)
{
Relation* r = result->getRelation(it->first).get();
r->setTag("area", "yes");
}
return result;
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:25,代码来源:AlphaShapeGenerator.cpp
示例16: HootException
double LogisticRegression::evaluate(map<QString, double> sample)
{
// Taken from Weka's documentation:
//
// The probability for class j with the exception of the last class is
// Pj(Xi) = exp(XiBj)/((sum[j=1..(k-1)]exp(Xi*Bj))+1)
// since we only have two classes:
// this code shamelessly modified from Weka
double prob = 0.0;
double v = 0.0;
// Log-posterior before normalizing
for (Coeff::iterator it = _coeff.begin(); it != _coeff.end(); ++it)
{
double par = it->second;
map<QString, double>::const_iterator sit = sample.find(it->first);
if (sit == sample.end())
{
throw HootException("Error finding sample key: " + it->first);
}
double data = sample.find(it->first)->second;
v += par * data;
}
v += _intercept;
// Do so to avoid scaling problems
prob = 1 / (1 + exp(-v));
return prob;
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:33,代码来源:LogisticRegression.cpp
示例17: LOG_INFO
bool OsmApiDbChangesetWriter::conflictExistsInTarget(const QString boundsStr, const QString timeStr)
{
LOG_INFO("Checking for OSM API DB conflicts for changesets within " << boundsStr << " and " <<
"created after " << timeStr << "...");
const Envelope bounds = GeometryUtils::envelopeFromConfigString(boundsStr);
LOG_VARD(bounds.toString());
const QDateTime time = QDateTime::fromString(timeStr, OsmApiDb::TIME_FORMAT);
LOG_VARD(time);
if (!time.isValid())
{
throw HootException(
"Invalid timestamp: " + time.toString() + ". Should be of the form " + OsmApiDb::TIME_FORMAT);
}
shared_ptr<QSqlQuery> changesetItr = _db.getChangesetsCreatedAfterTime(timeStr);
while (changesetItr->next())
{
shared_ptr<Envelope> changesetBounds(
new Envelope(changesetItr->value(0).toDouble(),
changesetItr->value(1).toDouble(),
changesetItr->value(2).toDouble(),
changesetItr->value(3).toDouble()));
LOG_VARD(changesetBounds->toString());
if (changesetBounds->intersects(bounds))
{
return true;
}
}
return false;
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:33,代码来源:OsmApiDbChangesetWriter.cpp
示例18: _map
WayLocation::WayLocation(ConstOsmMapPtr map, ConstWayPtr way, int segmentIndex,
double segmentFraction) :
_map(map)
{
_way = way;
_segmentIndex = segmentIndex;
_segmentFraction = segmentFraction;
if (_segmentFraction == 1.0)
{
_segmentIndex++;
_segmentFraction = 0.0;
}
if (_segmentFraction < 0.0 || _segmentFraction >= 1.0)
{
throw HootException("Segment Fraction is out of range.");
}
if (_segmentIndex < 0)
{
_segmentIndex = 0;
_segmentFraction = 0.0;
}
if (_segmentIndex >= (int)_way->getNodeCount() - 1)
{
_segmentIndex = _way->getNodeCount() - 1;
_segmentFraction = 0.0;
}
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:31,代码来源:WayLocation.cpp
示例19: if
long Hoot::_toBytes(const QString& str) const
{
QString s = str;
long multiplier = 1;
if (s.endsWith("KB"))
{
multiplier = 1000;
s = s.remove(s.size() - 2, 2);
}
else if (s.endsWith("MB"))
{
multiplier = 1000 * 1000;
s = s.remove(s.size() - 2, 2);
}
else if (s.endsWith("GB"))
{
multiplier = 1000 * 1000 * 1000;
s = s.remove(s.size() - 2, 2);
}
bool ok;
long result = s.toLong(&ok) * multiplier;
if (!ok)
{
throw HootException("Unable to parse max memory usage: " + s);
}
return result;
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:30,代码来源:Hoot.cpp
示例20: HootException
void WaySublineCollection::addSubline(const WaySubline& subline)
{
if (_sublines.size() == 0)
{
_sublines.push_back(subline);
}
else
{
for (size_t i = 0; i < _sublines.size(); i++)
{
if (subline.overlaps(_sublines[i]))
{
throw HootException("A subline string may not contain overlapping sublines.");
//use this for debugging only
/*if (logWarnCount < Log::getWarnMessageLimit())
{
LOG_WARN("A subline string may not contain overlapping sublines.");
}
else if (logWarnCount == Log::getWarnMessageLimit())
{
LOG_WARN(className() << ": " << Log::LOG_WARN_LIMIT_REACHED_MESSAGE);
}
logWarnCount++;*/
}
}
_sublines.push_back(subline);
}
}
开发者ID:ngageoint,项目名称:hootenanny,代码行数:30,代码来源:WaySublineCollection.cpp
注:本文中的HootException函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论