当前位置: 首页>>代码示例>>C++>>正文


C++ ConstOsmMapPtr::getProjection方法代码示例

本文整理汇总了C++中ConstOsmMapPtr::getProjection方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstOsmMapPtr::getProjection方法的具体用法?C++ ConstOsmMapPtr::getProjection怎么用?C++ ConstOsmMapPtr::getProjection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConstOsmMapPtr的用法示例。


在下文中一共展示了ConstOsmMapPtr::getProjection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _isOrderedConflicting

bool ScriptMatch::_isOrderedConflicting(const ConstOsmMapPtr& map, ElementId sharedEid,
  ElementId other1, ElementId other2) const
{
  Isolate* current = v8::Isolate::GetCurrent();
  HandleScope handleScope(current);
  Context::Scope context_scope(_script->getContext(current));

  set<ElementId> eids;
  eids.insert(sharedEid);
  eids.insert(other1);
  eids.insert(other2);

  OsmMapPtr copiedMap(new OsmMap(map->getProjection()));
  CopyMapSubsetOp(map, eids).apply(copiedMap);

  Handle<Object> copiedMapJs = OsmMapJs::create(copiedMap);

  // make sure unknown1 is always first
  ElementId eid11, eid12, eid21, eid22;
  if (map->getElement(sharedEid)->getStatus() == Status::Unknown1)
  {
    eid11 = sharedEid;
    eid21 = sharedEid;
    eid12 = other1;
    eid22 = other2;
  }
  else
  {
    eid11 = other1;
    eid21 = other2;
    eid12 = sharedEid;
    eid22 = sharedEid;
  }

  boost::shared_ptr<ScriptMatch> m1(
    new ScriptMatch(_script, _plugin, copiedMap, copiedMapJs, eid11, eid12, _threshold));
  MatchSet ms;
  ms.insert(m1.get());
  vector<Merger*> mergers;
  ScriptMergerCreator creator;
  creator.createMergers(ms, mergers);
  m1.reset();

  bool conflicting = true;
  // if we got a merger, then check to see if it conflicts
  if (mergers.size() == 1)
  {
    // apply the merger to our map copy
    vector< pair<ElementId, ElementId> > replaced;
    mergers[0]->apply(copiedMap, replaced);

    // replace the element id in the second merger.
    for (size_t i = 0; i < replaced.size(); ++i)
    {
      if (replaced[i].first == eid21)
      {
        eid21 = replaced[i].second;
      }
      if (replaced[i].first == eid22)
      {
        eid22 = replaced[i].second;
      }
    }

    // if we can still find the second match after the merge was applied then it isn't a conflict
    if (copiedMap->containsElement(eid21) &&
        copiedMap->containsElement(eid22))
    {
      ScriptMatch m2(_script, _plugin, copiedMap, copiedMapJs, eid21, eid22, _threshold);
      if (m2.getType() == MatchType::Match)
      {
        conflicting = false;
      }
    }
  }

  return conflicting;
}
开发者ID:,项目名称:,代码行数:78,代码来源:

示例2: Undefined

Handle<Value> SublineStringMatcherJs::extractMatchingSublines(const Arguments& args)
{
    HandleScope scope;

    SublineStringMatcherJs* smJs = ObjectWrap::Unwrap<SublineStringMatcherJs>(args.This());
    SublineStringMatcherPtr sm = smJs->getSublineStringMatcher();

    OsmMapJs* mapJs = ObjectWrap::Unwrap<OsmMapJs>(args[0]->ToObject());
    ElementJs* e1Js = ObjectWrap::Unwrap<ElementJs>(args[1]->ToObject());
    ElementJs* e2Js = ObjectWrap::Unwrap<ElementJs>(args[2]->ToObject());
    ConstOsmMapPtr m = mapJs->getConstMap();
    ConstElementPtr e1 = e1Js->getConstElement();
    ConstElementPtr e2 = e2Js->getConstElement();

    Handle<Value> result;

    try
    {
        WaySublineMatchString match = sm->findMatch(m, e1, e2);

        if (match.isEmpty())
        {
            return Undefined();
        }

        // convert match into elements in a new map.
        set<ElementId> eids;
        eids.insert(e1->getElementId());
        eids.insert(e2->getElementId());
        OsmMapPtr copiedMap(new OsmMap(m->getProjection()));
        CopySubsetOp(m, eids).apply(copiedMap);
        WaySublineMatchString copiedMatch(match, copiedMap);

        // split the shared line based on the matching subline
        ElementPtr match1, scraps1;
        ElementPtr match2, scraps2;
        WaySublineString string1 = copiedMatch.getSublineString1();
        WaySublineString string2 = copiedMatch.getSublineString2();

        try
        {
            MultiLineStringSplitter().split(copiedMap, string1, copiedMatch.getReverseVector1(), match1,
                                            scraps1);
            MultiLineStringSplitter().split(copiedMap, string2, copiedMatch.getReverseVector2(), match2,
                                            scraps2);
        }
        catch (const IllegalArgumentException& e)
        {
            // this is unusual print out some information useful to debugging.
            MapReprojector::reprojectToWgs84(copiedMap);
            LOG_WARN(OsmWriter::toString(copiedMap));
            throw e;
        }

        if (!match1 || !match2)
        {
            result = Undefined();
        }
        else
        {
            Handle<Object> obj = Object::New();
            obj->Set(String::NewSymbol("map"), OsmMapJs::create(copiedMap));
            obj->Set(String::NewSymbol("match1"), ElementJs::New(match1));
            obj->Set(String::NewSymbol("match2"), ElementJs::New(match2));
            result = obj;
        }
    }
    catch (const HootException& e)
    {
        return v8::ThrowException(HootExceptionJs::create(e));
    }

    return scope.Close(result);
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:74,代码来源:SublineStringMatcherJs.cpp

示例3: _evaluateMatch

MaximalSublineStringMatcher::ScoredMatch MaximalSublineStringMatcher::_evaluateMatch(
  const ConstOsmMapPtr &map, Meters maxDistance, const vector<ConstWayPtr>& ways1,
  const vector<ConstWayPtr> &ways2, const vector<bool>& reversed1,
  const vector<bool> &reversed2) const
{
  vector<WaySublineMatch> matches;

  // make a copy of the map and the ways we need so we can reverse the ways as needed.
  set<ElementId> eids;
  _insertElementIds(ways1, eids);
  _insertElementIds(ways2, eids);
  OsmMapPtr copiedMap(new OsmMap(map->getProjection()));
  CopySubsetOp(map, eids).apply(copiedMap);

  vector<WayPtr> prep1 = _changeMap(ways1, copiedMap);
  vector<WayPtr> prep2 = _changeMap(ways2, copiedMap);

  // reversed ways as appropriate
  _reverseWays(prep1, reversed1);
  _reverseWays(prep2, reversed2);

  double scoreSum = 0;

  // go through and match each way against every other way
  for (size_t i = 0; i < prep1.size(); i++)
  {
    for (size_t j = 0; j < prep2.size(); j++)
    {
      double score;
      WaySublineMatchString m = _sublineMatcher->findMatch(copiedMap, prep1[i], prep2[j], score,
        maxDistance);

      scoreSum += score;
      matches.insert(matches.end(), m.getMatches().begin(), m.getMatches().end());
    }
  }

  HashMap<long, bool> wayIdToReversed1, wayIdToReversed2;
  // create a map from way id to reverse status
  for (size_t i = 0; i < prep1.size(); i++)
  {
    wayIdToReversed1[prep1[i]->getId()] = reversed1[i];
  }
  for (size_t i = 0; i < prep2.size(); i++)
  {
    wayIdToReversed2[prep2[i]->getId()] = reversed2[i];
  }

  // go through all the matches
  for (size_t i = 0; i < matches.size(); i++)
  {
    WaySubline ws1, ws2;
    // if the direction is reversed on one but not both ways then mark the match as reversed.
    long m1Id = matches[i].getSubline1().getStart().getWay()->getId();
    long m2Id = matches[i].getSubline2().getStart().getWay()->getId();

    if (wayIdToReversed1[m1Id])
    {
      // make sure the way subline is pointed to the right way (not reversed)
      ConstWayPtr w = map->getWay(matches[i].getSubline1().getElementId());
      ws1 = matches[i].getSubline1().reverse(w);
    }
    else
    {
      ws1 = WaySubline(matches[i].getSubline1(), map);
    }

    if (wayIdToReversed2[m2Id])
    {
      // make sure the way subline is pointed to the right way (not reversed)
      ConstWayPtr w = map->getWay(matches[i].getSubline2().getElementId());
      ws2 = matches[i].getSubline2().reverse(w);
    }
    else
    {
      ws2 = WaySubline(matches[i].getSubline2(), map);
    }

    if (wayIdToReversed1[m1Id] != wayIdToReversed2[m2Id])
    {
      matches[i] = WaySublineMatch(ws1, ws2, true);
    }
    else
    {
      matches[i] = WaySublineMatch(ws1, ws2, false);
    }
  }

  return ScoredMatch(scoreSum, matches);
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:90,代码来源:MaximalSublineStringMatcher.cpp


注:本文中的ConstOsmMapPtr::getProjection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。