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


C++ Way::size方法代码示例

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


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

示例1: snapMousePressEvent

void ScaleInteraction::snapMousePressEvent(QMouseEvent * anEvent, Feature* aLast)
{
    QList<Feature*> sel;
    if (view()->isSelectionLocked()) {
        if (theMain->properties()->selection(0))
            sel.append(theMain->properties()->selection(0));
        else
            sel.append(aLast);
    } else {
        sel = theMain->properties()->selection();
        if (!sel.size() && aLast)
            sel.append(aLast);
    }
    Radius = 1.0;
    clearNoSnap();
    Scaling.clear();
    OriginalPosition.clear();

    if (!sel.size())
        return;

    view()->setInteracting(true);

    StartDragPosition = XY_TO_COORD(anEvent->pos());
    OriginNode = NULL;
    NodeOrigin  = false;
    CoordBox selBB = sel[0]->boundingBox();
    for (int j=0; j<sel.size(); j++) {
        selBB.merge(sel[j]->boundingBox());
        if (CHECK_WAY(sel[j])) {
            Way* R = STATIC_CAST_WAY(sel[j]);
            for (int i=0; i<R->size(); ++i)
                if (std::find(Scaling.begin(),Scaling.end(),R->get(i)) == Scaling.end())
                    Scaling.push_back(R->getNode(i));
            addToNoSnap(R);
        } else if (CHECK_NODE(sel[j])) {
            if (!OriginNode && !NodeOrigin) {
                OriginNode = STATIC_CAST_NODE(sel[j]);
                NodeOrigin = true;
            } else {
                NodeOrigin = false;
            }
        }
    }
    if (Scaling.size() > 1) {
        if (NodeOrigin) {
            ScaleCenter = COORD_TO_XY(OriginNode->position());
        } else {
            ScaleCenter = COORD_TO_XY(selBB.center());
        }
        for (int i=0; i<Scaling.size(); ++i)
        {
            OriginalPosition.push_back(Scaling[i]->position());
            addToNoSnap(Scaling[i]);
        }
    } else
        Scaling.clear();
}
开发者ID:Harpalus,项目名称:merkaartor,代码行数:58,代码来源:ScaleInteraction.cpp

示例2: export_

// export
bool ImportExportGdal::export_(const QList<Feature *>& featList)
{
    const char *pszDriverName = "SQLite";
    OGRSFDriver *poDriver;

    OGRRegisterAll();

    poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(pszDriverName);
    if( poDriver == NULL )
    {
        qDebug( "%s driver not available.", pszDriverName );
        return false;
    }

    OGRDataSource *poDS;

    QFile::remove(QString(HOMEDIR + "/test.sqlite"));
    poDS = poDriver->CreateDataSource( QString(HOMEDIR + "/test.sqlite").toUtf8().constData(), NULL );
    if( poDS == NULL )
    {
        qDebug( "Creation of output file failed." );
        return false;
    }
    poDS->ExecuteSQL("PRAGMA synchronous = OFF", NULL, NULL);

    OGRSpatialReference *poSRS;
    poSRS = new OGRSpatialReference();
    poSRS->importFromEPSG(4326);

    char **papszOptions = NULL;
    papszOptions = CSLSetNameValue( papszOptions, "SPATIALITE", "YES" );
    papszOptions = CSLSetNameValue( papszOptions, "FORMAT", "SPATIALITE" );
    papszOptions = CSLSetNameValue( papszOptions, "SPATIAL_INDEX", "YES" );

    OGRLayer *poLayer;
    poLayer = poDS->CreateLayer( "osm", poSRS, wkbUnknown, papszOptions);
    CSLDestroy( papszOptions );

    if( poLayer == NULL )
    {
        qDebug( "Layer creation failed." );
        return false;
    }

    OGRFieldDefn oField("osm_id", OFTReal);
    if( poLayer->CreateField( &oField ) != OGRERR_NONE )
    {
        qDebug( "Creating field failed." );
        return false;
    }
    oField.Set("osm_version", OFTInteger );
    poLayer->CreateField( &oField );
    oField.Set("osm_timestamp", OFTInteger );
    poLayer->CreateField( &oField );

    OGRFeature *poFeature;
    foreach (Feature* F, featList) {
        poFeature = OGRFeature::CreateFeature( poLayer->GetLayerDefn() );
        poFeature->SetField( "osm_id", (qreal)(F->id().numId));
#ifndef FRISIUS_BUILD
        poFeature->SetField( "osm_version", F->versionNumber());
        poFeature->SetField( "osm_timestamp", (int)F->time().toTime_t());
#endif

        if (CHECK_NODE(F)) {
            Node* N = STATIC_CAST_NODE(F);

            OGRPoint pt;
            pt.setX(N->position().x());
            pt.setY(N->position().y());

            poFeature->SetGeometry( &pt );
        } else if (CHECK_WAY(F)) {
            Way* W = STATIC_CAST_WAY(F);

            OGRLineString ls;
            ls.setNumPoints(W->size());
            for (int i=0; i<W->size(); ++i) {
                ls.setPoint(i, W->getNode(i)->position().x(), W->getNode(i)->position().y(), 0);
            }
            poFeature->SetGeometry( &ls );
        }

        if( poLayer->CreateFeature( poFeature ) != OGRERR_NONE )
        {
           qDebug( "Failed to create feature in output." );
           return false;
        }
        OGRFeature::DestroyFeature( poFeature );
    }
开发者ID:4x4falcon,项目名称:fosm-merkaartor,代码行数:91,代码来源:ImportExportGdal.cpp

示例3: snapMouseMoveEvent

void CreateSingleWayInteraction::snapMouseMoveEvent(QMouseEvent* ev, Feature* lastSnap)
{
    if (Node* Pt = dynamic_cast<Node*>(lastSnap))
        LastCursor = COORD_TO_XY(Pt);
    else if (Way* R = dynamic_cast<Way*>(lastSnap))
    {
        Coord P(XY_TO_COORD(ev->pos()));
        findSnapPointIndex(R, P);
        LastCursor = COORD_TO_XY(P);
    }
    else if (theRoad && theRoad->size() > 1 && SnapAngle)
    {
        QLineF l1(COORD_TO_XY(theRoad->getNode(theRoad->size()-1)), COORD_TO_XY(theRoad->getNode(theRoad->size()-2)));
        QLineF l2(COORD_TO_XY(theRoad->getNode(theRoad->size()-1)), ev->pos());
        qreal a = l1.angleTo(l2);
        a = qRound(a/SnapAngle) * SnapAngle;
        l2.setAngle(l1.angle() + a);
        LastCursor = l2.p2().toPoint();
    }
    else if (HaveFirst && ParallelMode)
    {
#define CLEAR_DISTANCE 200
        QPointF PreviousPoint;
        if (theRoad && theRoad->size() && !Prepend)
            PreviousPoint = COORD_TO_XY(CAST_NODE(theRoad->get(theRoad->size()-1))->position());
        else
            PreviousPoint = COORD_TO_XY(FirstPoint);

        CoordBox HotZone(XY_TO_COORD(ev->pos()-QPoint(CLEAR_DISTANCE, CLEAR_DISTANCE)),XY_TO_COORD(ev->pos()+QPoint(CLEAR_DISTANCE, CLEAR_DISTANCE)));
        qreal BestDistanceNW = 9999, AngleNW = 0;
        qreal BestDistanceNE = 9999, AngleNE = 0;
        qreal* BestDistance = &BestDistanceNW;
        qreal* BestAngle = &BestDistanceNE;
        qreal curAngle = 666;

        Way* R;
        for (int j=0; j<document()->layerSize(); ++j) {
            QList < Feature* > ret = g_backend.indexFind(document()->getLayer(j), HotZone);
            foreach(Feature* F, ret) {
                if (!(R = CAST_WAY(F)))
                    continue;

                if (R->isHidden())
                    continue;
                if (R->notEverythingDownloaded())
                    continue;

                for (int i=0; i<R->size()-1; ++i)
                {
                    LineF F(COORD_TO_XY(R->getNode(i)),COORD_TO_XY(R->getNode(i+1)));
                    qreal D = F.capDistance(ev->pos());
                    if (D < CLEAR_DISTANCE) {
                        QLineF l(COORD_TO_XY(R->getNode(i)), COORD_TO_XY(R->getNode(i+1)));
                        qreal a = l.angle();
                        if ((a >= 0 && a < 90) || (a < -270 && a >= -360)) {
                            BestDistance = &BestDistanceNE;
                            BestAngle = &AngleNE;
                            curAngle = a;
                        } else if ((a >= 90 && a < 180) || (a < -180 && a >= -270)) {
                            BestDistance = &BestDistanceNW;
                            BestAngle = &AngleNW;
                            curAngle = a;
                        } else if ((a >= 180 && a < 270) || (a < -90 && a >= -180)) {
                            BestDistance = &BestDistanceNE;
                            BestAngle = &AngleNE;
                            curAngle = a - 180;
                        } else if ((a >= 270 && a < 360) || (a < 0 && a >= -90)) {
                            BestDistance = &BestDistanceNW;
                            BestAngle = &AngleNW;
                            curAngle = a - 180;
                        }

                        if (D < *BestDistance) {
                            *BestDistance = D;
                            *BestAngle = curAngle;
                        }
                    }
                }

                qDebug() << BestDistanceNE << BestDistanceNW << AngleNE << AngleNW;
            }
        }

        /* Check if for some reason not a single angle was found. */
        Q_ASSERT(curAngle >= -360 && curAngle <= 360);

        QLineF l(PreviousPoint, ev->pos());
        qreal a = l.angle();
        if ((a >= 0 && a < 90) || (a < -270 && a >= -360)) {
            if (BestDistanceNE < 9999)
                a = AngleNE;
        } else if ((a >= 90 && a < 180) || (a < -180 && a >= -270)) {
            if (BestDistanceNW < 9999)
                a = AngleNW;
        } else if ((a >= 180 && a < 270) || (a < -90 && a >= -180)) {
            if (BestDistanceNE < 9999)
                a = AngleNE - 180;
        } else if ((a >= 270 && a < 360) || (a < 0 && a >= -90)) {
            if (BestDistanceNW < 9999)
                a = AngleNW - 180;
//.........这里部分代码省略.........
开发者ID:chxyfish,项目名称:merkaartor,代码行数:101,代码来源:CreateSingleWayInteraction.cpp


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