本文整理汇总了C++中RelationPtr类的典型用法代码示例。如果您正苦于以下问题:C++ RelationPtr类的具体用法?C++ RelationPtr怎么用?C++ RelationPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RelationPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void Network::consolidateRelations(bool discard_if_missing_reference) {
std::map<unsigned long long int, RelationPtr>::iterator relIt = relations.begin();
//loop through the relations
while (relIt != relations.end()) {
RelationPtr relation = relIt->second;
try {
relation->consolidate(this);
relIt++;
} catch (RefNotFoundException e) {
//the relation references a node, way or relation that doesn't exist
if (discard_if_missing_reference) {
//discard relations referencing this relation
std::map<unsigned long long int, RelationPtr>::iterator relIt2 = relations.begin();
while (relIt2 != relations.end() && relIt2 != relIt) {
if (relIt2->second->contains(relation)) {
relations.erase(relIt2++);
} else {
relIt2++;
}
}
//discard the relation itself
std::map<unsigned long long int, RelationPtr>::iterator rel_to_delete = relIt++;
relations.erase(rel_to_delete);
} else {
relIt++;
}
}
}
}
示例2: runEscapeTags
void runEscapeTags()
{
OsmMapPtr map(new OsmMap());
Coordinate coords[] = { Coordinate(0, 0), Coordinate(0, 1), Coordinate(1, 1), Coordinate(1, 0), Coordinate::getNull() };
Tags tags;
tags.set("note", "<2>");
tags.set("aerialway", "t-bar");
tags.set("first name", "first name goes here");
tags.set("full_name", "\"Hacksaw\" Jim Duggan");
WayPtr way = TestUtils::createWay(map, Status::Unknown1, coords);
way->setTags(tags);
QList<ElementPtr> nodes;
NodePtr node1(new Node(Status::Unknown1, map->createNextNodeId(), Coordinate(0.0, 0.1), 15));
node1->getTags().appendValue("name", "test1");
nodes.append(node1);
NodePtr node2(new Node(Status::Unknown1, map->createNextNodeId(), Coordinate(0.1, 0.0), 15));
node2->getTags().appendValue("name", "test2");
nodes.append(node2);
RelationPtr relation = TestUtils::createRelation(map, nodes);
relation->setType("review");
relation->getTags().appendValue("name", "Test Review");
std::vector<RelationData::Entry> members = relation->getMembers();
members[0].role = "reviewee";
members[1].role = "reviewee";
relation->setMembers(members);
QString output = OsmPgCsvWriter::toString(map);
// Compare the results
HOOT_STR_EQUALS(expected_runEscapeTags, output);
}
示例3: GetParentRelation
// Get parent of relation D3MetaDatabase
//
D3MetaDatabasePtr D3DatabasePermissionBase::GetD3MetaDatabase()
{
RelationPtr pRelation;
pRelation = GetParentRelation(D3MDDB_D3DatabasePermission_PR_D3MetaDatabase);
if (!pRelation)
return NULL;
return (D3MetaDatabasePtr) pRelation->GetParent();
}
示例4: GetParentRelation
// Get parent of relation D3MetaColumn
//
D3MetaColumnPtr D3ColumnPermissionBase::GetD3MetaColumn()
{
RelationPtr pRelation;
pRelation = GetParentRelation(D3MDDB_D3ColumnPermission_PR_D3MetaColumn);
if (!pRelation)
return NULL;
return (D3MetaColumnPtr) pRelation->GetParent();
}
示例5: convertPolygonToRelation
void GeometryConverter::convertPolygonToRelation(const Polygon* polygon,
const OsmMapPtr& map, const RelationPtr& r, Status s, double circularError)
{
WayPtr outer = convertLineStringToWay(polygon->getExteriorRing(), map, s, circularError);
if (outer != NULL)
{
r->addElement(MetadataTags::RoleOuter(), outer);
for (size_t i = 0; i < polygon->getNumInteriorRing(); i++)
{
WayPtr inner = convertLineStringToWay(polygon->getInteriorRingN(i), map, s, circularError);
r->addElement(MetadataTags::RoleInner(), inner);
}
}
}
示例6: MapJointPriv
MapJoint::MapJoint(
RelationPtr &rel,
AbstractKeyValSetMapPtr &emap,
ExpressionPtr &key,
ExpressionPtr &val
)
:Listener()
{
jp_=new MapJointPriv(rel,emap,key,val);
rel->registerListener( this );
}
示例7: _calculateHilbertValue
void AddHilbertReviewSortOrderOp::apply(shared_ptr<OsmMap>& map)
{
_mapEnvelope.reset();
MapReprojector::reprojectToPlanar(map);
const RelationMap& relations = map->getRelationMap();
Envelope e = map->calculateEnvelope();
vector< pair<ElementId, int64_t> > reviewOrder;
// reserves at least as much as we need.
reviewOrder.reserve(relations.size());
for (RelationMap::const_iterator it = relations.begin(); it != relations.end(); ++it)
{
RelationPtr r = it->second;
if (ReviewMarker::isReviewUid(map, r->getElementId()))
{
int64_t hv = _calculateHilbertValue(map,
ReviewMarker::getReviewElements(map, r->getElementId()));
pair<ElementId, int64_t> p(r->getElementId(), hv);
reviewOrder.push_back(p);
}
}
sort(reviewOrder.begin(), reviewOrder.end(), reviewLess);
for (size_t i = 0; i < reviewOrder.size(); ++i)
{
RelationPtr r = map->getRelation(reviewOrder[i].first.getId());
r->getTags().set(ReviewMarker::reviewSortOrderKey, (long)i);
}
}
示例8: paintRelation
QSize LegendItem::paintRelation(QString name, RelationPtr relation, QPainter *painter, bool draw) {
Label::Parsed *parsed = Label::parse(name);
parsed->chunk->attributes.color = _color;
int fontHeight = painter->fontMetrics().height();
int fontAscent = painter->fontMetrics().ascent();
QSize symbol_size = relation->legendSymbolSize(painter);
int label_width = 0;
int paddingValue = fontHeight / 4;
if (relation->symbolLabelOnTop()) {
Label::RenderContext tmprc(painter->font(), painter);
Label::renderLabel(tmprc, parsed->chunk, false, false);
label_width = tmprc.x;
painter->translate(paddingValue, fontHeight+paddingValue / 2);
symbol_size.setWidth(qMax(label_width, symbol_size.width()));
} else {
painter->translate(paddingValue, paddingValue / 2);
}
if (draw) {
relation->paintLegendSymbol(painter, symbol_size);
}
if (relation->symbolLabelOnTop()) {
painter->translate((symbol_size.width()-label_width)/2, fontAscent - fontHeight);
} else {
painter->translate(symbol_size.width() + paddingValue, 0);
}
Label::RenderContext rc(painter->font(), painter);
if (relation->symbolLabelOnTop()) {
rc.y = 0;
} else {
rc.y = (symbol_size.height()+painter->fontMetrics().boundingRect('M').height())/2;
}
if (parsed) {
Label::renderLabel(rc, parsed->chunk, false, draw);
delete parsed;
parsed = 0;
}
double h = symbol_size.height() + paddingValue;
if (relation->symbolLabelOnTop()) {
h += fontHeight;
}
if (relation->symbolLabelOnTop()) {
return QSize(qMax(rc.x,(symbol_size.width())) + (paddingValue * 2), h);
} else {
return QSize((symbol_size.width()) + (paddingValue * 3) + rc.x, h);
}
}
示例9: verifyFullReadOutput
void verifyFullReadOutput(OsmMapPtr map)
{
//nodes
CPPUNIT_ASSERT_EQUAL(2, (int)map->getNodes().size());
HOOT_STR_EQUALS(true, map->containsNode(1));
NodePtr node = map->getNode(1);
CPPUNIT_ASSERT_EQUAL((long)1, node->getId());
CPPUNIT_ASSERT_EQUAL(38.4, node->getY());
CPPUNIT_ASSERT_EQUAL(-106.5, node->getX());
CPPUNIT_ASSERT_EQUAL(15.0, node->getCircularError());
CPPUNIT_ASSERT_EQUAL(2, node->getTags().size());
NodePtr node1 = map->getNode(2);
CPPUNIT_ASSERT_EQUAL((long)2, node1->getId());
CPPUNIT_ASSERT_EQUAL(38.0, node1->getY());
CPPUNIT_ASSERT_EQUAL(-104.0, node1->getX());
//ways
HOOT_STR_EQUALS(true, map->containsWay(1));
WayPtr way = map->getWay(1);
CPPUNIT_ASSERT_EQUAL((long)1, way->getId());
CPPUNIT_ASSERT_EQUAL(2, (int)way->getNodeCount());
CPPUNIT_ASSERT_EQUAL((long)1, way->getNodeId(0));
CPPUNIT_ASSERT_EQUAL((long)2, way->getNodeId(1));
CPPUNIT_ASSERT_EQUAL(15.0, way->getCircularError());
CPPUNIT_ASSERT_EQUAL(1, way->getTags().size());
//relations
HOOT_STR_EQUALS(true, map->containsRelation(1));
RelationPtr relation = map->getRelation(1);
CPPUNIT_ASSERT_EQUAL((long)1, relation->getId());
vector<RelationData::Entry> relationData = relation->getMembers();
CPPUNIT_ASSERT_EQUAL(2, (int)relation->getMembers().size());
HOOT_STR_EQUALS("wayrole", relationData[0].getRole());
HOOT_STR_EQUALS("noderole",relationData[1].getRole());
CPPUNIT_ASSERT_EQUAL(15.0, relation->getCircularError());
}
示例10: plot
void LegendItem::paint(QPainter *painter) {
if (!isVisible()) {
return;
}
RelationList legendItems;
if (_auto) {
legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList();
} else {
legendItems = _relations;
}
int count = legendItems.count();
if (count <= 0) { // no legend or box if there are no legend items
return;
}
QList<DrawnLegendItem> legendPixmaps;
QSize legendSize(0, 0);
QFont font(_font);
font.setPointSizeF(view()->viewScaledFontSize(_fontScale));
// generate string list of relation names
QStringList names;
bool allAuto = true;
bool sameX = true;
bool sameYUnits = true;
LabelInfo label_info = legendItems.at(0)->xLabelInfo();
QString yUnits = legendItems.at(0)->yLabelInfo().units;
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
if (relation->descriptiveNameIsManual()) {
allAuto = false;
}
if (relation->xLabelInfo() != label_info) {
sameX = false;
}
// sameYUnits is false if any non empty units are defined differently.
if (yUnits.isEmpty()) {
yUnits = relation->yLabelInfo().units;
} else if (relation->yLabelInfo().units != yUnits) {
if (!relation->yLabelInfo().units.isEmpty()) {
sameYUnits = false;
}
}
}
if (!allAuto) {
for (int i = 0; i<count; i++) {
names.append(legendItems.at(i)->descriptiveName());
}
} else {
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
QString label = relation->titleInfo().singleRenderItemLabel();
if (label.isEmpty()) {
label_info = relation->yLabelInfo();
QString y_label = label_info.name;
if (!sameYUnits) {
if (!label_info.units.isEmpty()) {
y_label = i18n("%1 \\[%2\\]").arg(y_label).arg(label_info.units);
}
}
if (!y_label.isEmpty()) {
LabelInfo xlabel_info = relation->xLabelInfo();
if (!sameX) {
label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
} else if (xlabel_info.quantity.isEmpty()) {
label = y_label;
} else if (xlabel_info.quantity != xlabel_info.name) {
label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
} else {
label = y_label;
}
} else {
label = relation->descriptiveName();
}
}
int i_dup = names.indexOf(label);
if (i_dup<0) {
names.append(label);
} else {
RelationPtr dup_relation = legendItems.at(i_dup);
if (!dup_relation->yLabelInfo().file.isEmpty()) {
names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().file + ')');
}
if (!relation->yLabelInfo().file.isEmpty()) {
names.append(label + " (" + relation->yLabelInfo().file + ')');
}
}
}
}
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
DrawnLegendItem item;
//.........这里部分代码省略.........
示例11: StringArrayListenerPriv
StringArrayListener::StringArrayListener( StringArrayPtr &sa, RelationPtr &r )
{
d_=new StringArrayListenerPriv ( sa, r );
r->registerListener( this );
}
示例12: runPartialReadTest
void runPartialReadTest()
{
//The differences in tag counts here when compared to
//ServiceHootApiDbReaderTest::runPartialReadTest are due to differences between the way
//HootApiDbWriter and OsmApiDbBulkInserter handle metadata tags, which is by design.
populatePartialMap();
OsmApiDbReader reader;
const int chunkSize = 3;
reader.setMaxElementsPerMap(chunkSize);
reader.open(ServicesDbTestUtils::getOsmApiDbUrl().toString());
reader.initializePartial();
int ctr = 0;
OsmMapPtr map(new OsmMap());
//3 nodes
CPPUNIT_ASSERT(reader.hasMoreElements());
reader.readPartial(map);
CPPUNIT_ASSERT_EQUAL(3, (int)map->getNodes().size());
CPPUNIT_ASSERT_EQUAL(0, (int)map->getWays().size());
CPPUNIT_ASSERT_EQUAL(0, (int)map->getRelations().size());
NodePtr node = map->getNode(1);
CPPUNIT_ASSERT_EQUAL((long)1, node->getId());
CPPUNIT_ASSERT_EQUAL(0.0, node->getX());
CPPUNIT_ASSERT_EQUAL(0.0, node->getY());
CPPUNIT_ASSERT_EQUAL(0, node->getTags().size());
node = map->getNode(2);
CPPUNIT_ASSERT_EQUAL((long)2, node->getId());
CPPUNIT_ASSERT_EQUAL(0.1, node->getX());
CPPUNIT_ASSERT_EQUAL(0.0, node->getY());
CPPUNIT_ASSERT_EQUAL(1, node->getTags().size());
HOOT_STR_EQUALS("n2b", node->getTags().get("noteb"));
node = map->getNode(3);
CPPUNIT_ASSERT_EQUAL((long)3, node->getId());
CPPUNIT_ASSERT_EQUAL(0.2, node->getX());
CPPUNIT_ASSERT_EQUAL(0.0, node->getY());
CPPUNIT_ASSERT_EQUAL(1, node->getTags().size());
HOOT_STR_EQUALS("n3", node->getTags().get("note"));
ctr++;
//2 nodes, 1 way
map.reset(new OsmMap());
CPPUNIT_ASSERT(reader.hasMoreElements());
reader.readPartial(map);
CPPUNIT_ASSERT_EQUAL(2, (int)map->getNodes().size());
CPPUNIT_ASSERT_EQUAL(1, (int)map->getWays().size());
CPPUNIT_ASSERT_EQUAL(0, (int)map->getRelations().size());
node = map->getNode(4);
CPPUNIT_ASSERT_EQUAL((long)4, node->getId());
CPPUNIT_ASSERT_EQUAL(0.3, node->getX());
CPPUNIT_ASSERT_EQUAL(0.0, node->getY());
CPPUNIT_ASSERT_EQUAL(1, node->getTags().size());
HOOT_STR_EQUALS("n4", node->getTags().get("note"));
node = map->getNode(5);
CPPUNIT_ASSERT_EQUAL((long)5, node->getId());
CPPUNIT_ASSERT_EQUAL(0.4, node->getX());
CPPUNIT_ASSERT_EQUAL(0.0, node->getY());
CPPUNIT_ASSERT_EQUAL(0, node->getTags().size());
WayPtr way = map->getWay(1);
CPPUNIT_ASSERT_EQUAL((long)1, way->getId());
CPPUNIT_ASSERT(way->hasNode(1));
CPPUNIT_ASSERT(way->hasNode(2));
CPPUNIT_ASSERT_EQUAL(1, way->getTags().size());
HOOT_STR_EQUALS("w1b", way->getTags().get("noteb"));
ctr++;
//2 ways, 1 relation
map.reset(new OsmMap());
CPPUNIT_ASSERT(reader.hasMoreElements());
reader.readPartial(map);
CPPUNIT_ASSERT_EQUAL(0, (int)map->getNodes().size());
CPPUNIT_ASSERT_EQUAL(2, (int)map->getWays().size());
CPPUNIT_ASSERT_EQUAL(1, (int)map->getRelations().size());
way = map->getWay(2);
CPPUNIT_ASSERT_EQUAL((long)2, way->getId());
CPPUNIT_ASSERT(way->hasNode(2));
CPPUNIT_ASSERT(way->hasNode(3));
CPPUNIT_ASSERT_EQUAL(1, way->getTags().size());
HOOT_STR_EQUALS("w2", way->getTags().get("note"));
way = map->getWay(3);
CPPUNIT_ASSERT_EQUAL((long)3, way->getId());
CPPUNIT_ASSERT(way->hasNode(2));
CPPUNIT_ASSERT_EQUAL(0, way->getTags().size());
RelationPtr relation = map->getRelation(1);
//.........这里部分代码省略.........
示例13: getAdministrativeBoundaries
std::map<unsigned long long int, std::pair<RelationPtr, std::map<unsigned long long int, WayPtr> > > Network::getWaysByAdminBoundary(int admin_level)
{
typedef std::map<unsigned long long int, WayPtr> WayMap;
typedef std::pair<unsigned long long int, WayPtr> WayType;
typedef std::map<unsigned long long int, RelationPtr> RelationMap;
typedef std::pair<RelationPtr, WayMap> RelationWayPair;
typedef std::map<unsigned long long int, RelationWayPair> GlobalMap;
GlobalMap ret;
util::Log::GetInstance().info("extracting administrative boundaries");
RelationMap adminBoundaries = getAdministrativeBoundaries(admin_level);
util::Log::GetInstance().info("finished extracting administrative boundaries");
WayMap waysList;
BOOST_FOREACH(WayType w, ways)
{
if(
w.second->getNodes()->size() > 1 &&
w.second->hasTag(Element::TAG_HIGHWAY) &&
Way::highwayTypes.find(w.second->getTag(Element::TAG_HIGHWAY)) != Way::highwayTypes.end()
)
{
waysList[w.second->getId()] = w.second;
}
}
util::Log::GetInstance().info("extracting ways by administrative boundaries");
RelationMap::iterator boundaryIterator = adminBoundaries.begin();
while(boundaryIterator != adminBoundaries.end())
{
RelationPtr boundary = boundaryIterator->second;
ret[boundaryIterator->first] = RelationWayPair(boundary, WayMap());
boundaryIterator++;
}
WayMap::iterator wayIterator = waysList.begin();
while(wayIterator != waysList.end())
{
WayPtr way = wayIterator->second;
boost::shared_ptr<const geos::geom::Geometry> wayGeom = way->toGeometry();
boundaryIterator = adminBoundaries.begin();
while(boundaryIterator != adminBoundaries.end())
{
RelationPtr boundary = boundaryIterator->second;
boost::shared_ptr<const geos::geom::prep::PreparedGeometry> boundaryPrepGeom = boundary->toPreparedGeometry();
if(boundaryPrepGeom->covers(wayGeom.get()) || boundaryPrepGeom->intersects(wayGeom.get()))
{
//the way is inside or intersected by the boundary, keep it
ret[boundaryIterator->first].second[wayIterator->first] = way;
//mark the nodes of this way for next step reference counting
way->referenceWithNodes();
break;
}
else //no interaction with current boundary
boundaryIterator++;
}
++wayIterator;
}
util::Log::GetInstance().info("finished extracting ways by administrative boundaries");
return ret;
}
示例14: plot
void LegendItem::paint(QPainter *painter) {
if (!isVisible()) {
return;
}
RelationList legendItems;
if (_auto) {
legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList();
} else {
legendItems = _relations;
}
int count = legendItems.count();
if (count <= 0) { // no legend or box if there are no legend items
return;
}
QFont font(_font);
font.setPointSizeF(view()->scaledFontSize(_fontScale, *painter->device()));
painter->setFont(font);
// generate string list of relation names
QStringList names;
bool allAuto = true;
bool sameX = true;
bool sameYUnits = true;
LabelInfo label_info = legendItems.at(0)->xLabelInfo();
QString yUnits = legendItems.at(0)->yLabelInfo().units;
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
if (relation->descriptiveNameIsManual()) {
allAuto = false;
}
if (relation->xLabelInfo() != label_info) {
sameX = false;
}
// sameYUnits is false if any non empty units are defined differently.
if (yUnits.isEmpty()) {
yUnits = relation->yLabelInfo().units;
} else if (relation->yLabelInfo().units != yUnits) {
if (!relation->yLabelInfo().units.isEmpty()) {
sameYUnits = false;
}
}
}
if (!allAuto) {
for (int i = 0; i<count; i++) {
names.append(legendItems.at(i)->descriptiveName());
}
} else {
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
QString label = relation->titleInfo().singleRenderItemLabel();
if (label.isEmpty()) {
label_info = relation->yLabelInfo();
QString y_label = label_info.name;
if (!sameYUnits) {
if (!label_info.units.isEmpty()) {
y_label = tr("%1 \\[%2\\]", "axis labels. %1 is quantity, %2 is units. eg Time [s]. '[' must be escaped.").arg(y_label).arg(label_info.units);
}
}
if (!y_label.isEmpty()) {
LabelInfo xlabel_info = relation->xLabelInfo();
if (!sameX) {
label = tr("%1 vs %2", "describes a plot. %1 is X axis. %2 is Y axis").arg(y_label).arg(xlabel_info.name);
} else if (xlabel_info.quantity.isEmpty()) {
label = y_label;
} else if (xlabel_info.quantity != xlabel_info.name) {
label = tr("%1 vs %2", "describes a plot. %1 is X axis. %2 is Y axis").arg(y_label).arg(xlabel_info.name);
} else {
label = y_label;
}
} else {
label = relation->descriptiveName();
}
}
int i_dup = names.indexOf(label);
if (i_dup<0) {
names.append(label);
} else {
RelationPtr dup_relation = legendItems.at(i_dup);
if (!dup_relation->yLabelInfo().file.isEmpty()) {
names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().escapedFile() + ')');
}
if (!relation->yLabelInfo().file.isEmpty()) {
names.append(label + " (" + relation->yLabelInfo().escapedFile() + ')');
}
}
}
}
QSize legendSize(0, 0);
QSize titleSize(0,0);
Label::Parsed *parsed = Label::parse(_title);
//.........这里部分代码省略.........
示例15: foreach
foreach (RelationPtr s, objectStore()->getObjects<Relation>()) {
s->save(xml);
}