Exemplo n.º 1
0
QString OsmApiDbSqlChangesetFileWriter::_getUpdateValuesNodeStr(ConstNodePtr node) const
{
  return
    QString("latitude=%2, longitude=%3, changeset_id=%4, visible=%5, \"timestamp\"=%8, tile=%6, version=%7 WHERE id=%1;\n")
      .arg(node->getId())
      .arg((qlonglong)OsmApiDb::toOsmApiDbCoord(node->getY()))
      .arg((qlonglong)OsmApiDb::toOsmApiDbCoord(node->getX()))
      .arg(node->getChangeset())
      .arg(_getVisibleStr(node->getVisible()))
      .arg(ApiDb::tileForPoint(node->getY(), node->getX()))
      .arg(node->getVersion())
      .arg(OsmApiDb::TIMESTAMP_FUNCTION);
}
Exemplo n.º 2
0
QString OsmApiDbSqlChangesetFileWriter::_getInsertValuesNodeStr(ConstNodePtr node) const
{
  return
    QString("latitude, longitude, changeset_id, visible, \"timestamp\", "
      "tile, version) VALUES (%1, %2, %3, %4, %5, %8, %6, %7);\n")
      .arg(node->getId())
      .arg((qlonglong)OsmApiDb::toOsmApiDbCoord(node->getY()))
      .arg((qlonglong)OsmApiDb::toOsmApiDbCoord(node->getX()))
      .arg(node->getChangeset())
      .arg(_getVisibleStr(node->getVisible()))
      .arg(ApiDb::tileForPoint(node->getY(), node->getX()))
      .arg(node->getVersion())
      .arg(OsmApiDb::TIMESTAMP_FUNCTION);
}
Exemplo n.º 3
0
void GeometryPainter::drawWay(QPainter& pt, const OsmMap* map, const Way* way, const QMatrix& m)
{
  int size = way->getNodeCount();
  QPolygonF a(size);

  for (int j = 0; j < size; j++)
  {
    ConstNodePtr n = map->getNode(way->getNodeId(j));
    a[j] = QPointF(m.map(QPointF(n->getX(), n->getY())) - QPointF(0.5, 0.5));
  }

  pt.drawPolyline(a);
}
Exemplo n.º 4
0
void OsmApiDbSqlChangesetFileWriter::write(const QString path,
                                           ChangesetProviderPtr changesetProvider)
{
  LOG_DEBUG("Writing changeset to " << path);

  LOG_VARD(path);
  LOG_VARD(changesetProvider->hasMoreChanges());

  _changesetBounds.init();

  _outputSql.setFileName(path);
  if (_outputSql.open(QIODevice::WriteOnly | QIODevice::Text) == false)
  {
    throw HootException(QObject::tr("Error opening %1 for writing").arg(path));
  }

  int changes = 0;
  _createChangeSet();

  while (changesetProvider->hasMoreChanges())
  {
    LOG_TRACE("Reading next SQL change...");
    Change change = changesetProvider->readNextChange();
    switch (change.getType())
    {
      case Change::Create:
        _createNewElement(change.getElement());
        break;
      case Change::Modify:
        _updateExistingElement(change.getElement());
        break;
      case Change::Delete:
        _deleteExistingElement(change.getElement());
        break;
      case Change::Unknown:
        //see comment in ChangesetDeriver::_nextChange() when
        //_fromE->getElementId() < _toE->getElementId() as to why we do a no-op here.
        break;
      default:
        throw IllegalArgumentException("Unexpected change type.");
    }

    if (change.getType() != Change::Unknown)
    {
      if (change.getElement()->getElementType().getEnum() == ElementType::Node)
      {
        ConstNodePtr node = boost::dynamic_pointer_cast<const Node>(change.getElement());
        _changesetBounds.expandToInclude(node->getX(), node->getY());
      }
      changes++;
    }

    if (changes > _changesetMaxSize)
    {
      _updateChangeset(changes);
      _createChangeSet();
      changes = 0;
    }
  }

  _updateChangeset(changes);

  _outputSql.close();
}