Ejemplo n.º 1
0
VxTile * BuildRootTile(uint8_t const level,
                       double const minLon,
                       double const minLat,
                       double const maxLon,
                       double const maxLat)
{
    VxTile * t = new VxTile;
    t->level = level;
    t->minLon = minLon;
    t->minLat = minLat;
    t->maxLon = maxLon;
    t->maxLat = maxLat;

    t->midLon = (minLon+maxLon)*0.5;
    t->midLat = (minLat+maxLat)*0.5;

    t->p_ecef_LT = new osg::Vec3d;
    *(t->p_ecef_LT) = ConvLLAToECEF(PointLLA(minLon,maxLat));

    t->p_ecef_LB = new osg::Vec3d;
    *(t->p_ecef_LB) = ConvLLAToECEF(PointLLA(minLon,minLat));

    t->p_ecef_RB = new osg::Vec3d;
    *(t->p_ecef_RB) = ConvLLAToECEF(PointLLA(maxLon,minLat));

    t->p_ecef_RT = new osg::Vec3d;
    *(t->p_ecef_RT) = ConvLLAToECEF(PointLLA(maxLon,maxLat));

    t->ecef_LM = ConvLLAToECEF(PointLLA(minLon,t->midLat));
    t->ecef_MB = ConvLLAToECEF(PointLLA(t->midLon,minLat));
    t->ecef_RM = ConvLLAToECEF(PointLLA(maxLon,t->midLat));
    t->ecef_MT = ConvLLAToECEF(PointLLA(t->midLon,maxLat));
    t->ecef_MM = ConvLLAToECEF(PointLLA(t->midLon,t->midLat));

    CalcTileOBB(t);

    return t;
}
Ejemplo n.º 2
0
void buildEarthSurfGeom(double minLon,double minLat,
                        double maxLon,double maxLat,
                        unsigned int lonSegments,
                        unsigned int latSegments,
                        std::vector<Vec3> &vertexArray,
                        std::vector<Vec2> &texCoords,
                        std::vector<size_t> &triIdx)
{
    double lonStep = (maxLon-minLon)/lonSegments;
    double latStep = (maxLat-minLat)/latSegments;

    vertexArray.clear();
    texCoords.clear();
    triIdx.clear();

    // build vertex attributes
    Vec3 sVert;
    for(int i=0; i <= latSegments; i++)   {
        for(int j=0; j <= lonSegments; j++)   {
            // surface vertex
            vertexArray.push_back(convLLAToECEF(PointLLA((i*latStep)+minLat,
                                                         (j*lonStep)+minLon)));
            // surface tex coord
            texCoords.push_back(Vec2((j*lonStep)/(maxLon-minLon),
                                     (i*latStep)/(maxLat-minLat)));
        }
    }

    // stitch faces together
    unsigned int vIdx=0;
    for(int i=0; i < latSegments; i++)   {
        for(int j=0; j < lonSegments; j++)   {
            triIdx.push_back(vIdx);
            triIdx.push_back(vIdx+lonSegments+1);
            triIdx.push_back(vIdx+lonSegments+2);

            triIdx.push_back(vIdx);
            triIdx.push_back(vIdx+lonSegments+2);
            triIdx.push_back(vIdx+1);

            vIdx++;
        }
        vIdx++;
    }
}
Ejemplo n.º 3
0
std::unique_ptr<VxTile> BuildChildTile(VxTile * parent,
                                       uint8_t const quadrant)
{
    std::unique_ptr<VxTile> t(new VxTile);

    if(quadrant == 0) {
        // LT
        t->minLon = parent->minLon;
        t->maxLon = parent->midLon;
        t->minLat = parent->midLat;
        t->maxLat = parent->maxLat;

        t->p_ecef_LT = parent->p_ecef_LT;
        t->p_ecef_LB = &(parent->ecef_LM);
        t->p_ecef_RB = &(parent->ecef_MM);
        t->p_ecef_RT = &(parent->ecef_MT);
    }
    else if(quadrant == 1) {
        // LB
        t->minLon = parent->minLon;
        t->maxLon = parent->midLon;
        t->minLat = parent->minLat;
        t->maxLat = parent->midLat;

        t->p_ecef_LT = &(parent->ecef_LM);
        t->p_ecef_LB = parent->p_ecef_LB;
        t->p_ecef_RB = &(parent->ecef_MB);
        t->p_ecef_RT = &(parent->ecef_MM);
    }
    else if(quadrant == 2) {
        // RB
        t->minLon = parent->midLon;
        t->maxLon = parent->maxLon;
        t->minLat = parent->minLat;
        t->maxLat = parent->midLat;

        t->p_ecef_LT = &(parent->ecef_MM);
        t->p_ecef_LB = &(parent->ecef_MB);
        t->p_ecef_RB = parent->p_ecef_RB;
        t->p_ecef_RT = &(parent->ecef_RM);
    }
    else {
        // RT
        t->minLon = parent->midLon;
        t->maxLon = parent->maxLon;
        t->minLat = parent->midLat;
        t->maxLat = parent->maxLat;

        t->p_ecef_LT = &(parent->ecef_MT);
        t->p_ecef_LB = &(parent->ecef_MM);
        t->p_ecef_RB = &(parent->ecef_RM);
        t->p_ecef_RT = parent->p_ecef_RT;
    }

    t->level = parent->level + 1;
    t->midLon = (t->minLon+t->maxLon)*0.5;
    t->midLat = (t->minLat+t->maxLat)*0.5;

    t->ecef_LM = ConvLLAToECEF(PointLLA(t->minLon,t->midLat));
    t->ecef_MB = ConvLLAToECEF(PointLLA(t->midLon,t->minLat));
    t->ecef_RM = ConvLLAToECEF(PointLLA(t->maxLon,t->midLat));
    t->ecef_MT = ConvLLAToECEF(PointLLA(t->midLon,t->maxLat));
    t->ecef_MM = ConvLLAToECEF(PointLLA(t->midLon,t->midLat));

    CalcTileOBB(t.get());

    return t;
}
Ejemplo n.º 4
0
void GetStreetVx(std::vector<Vec3> &listVx)
{
    std::vector<PointLLA> wayPointsLLA;

    // WAY ID 22688985
//    wayPointsLLA.push_back(PointLLA(43.6762198, -79.3998242));
//    wayPointsLLA.push_back(PointLLA(43.6763392, -79.3994667));
//    wayPointsLLA.push_back(PointLLA(43.6766179, -79.3981721));

    // ??
//    wayPointsLLA.push_back(PointLLA(43.67622, -79.399824));
//    wayPointsLLA.push_back(PointLLA(43.676339, -79.399467));
//    wayPointsLLA.push_back(PointLLA(43.676618, -79.398172));
    wayPointsLLA.push_back(PointLLA(43.676987, -79.398323));
    wayPointsLLA.push_back(PointLLA(43.677038, -79.398343));
    wayPointsLLA.push_back(PointLLA(43.676987, -79.398323));
//    wayPointsLLA.push_back(PointLLA(43.676618, -79.398172));
//    wayPointsLLA.push_back(PointLLA(43.676636, -79.397989));
//    wayPointsLLA.push_back(PointLLA(43.676556, -79.397963));
//    wayPointsLLA.push_back(PointLLA(43.676244, -79.397838));
//    wayPointsLLA.push_back(PointLLA(43.675483, -79.397543));
//    wayPointsLLA.push_back(PointLLA( 43.675437, -79.397525));

    // WAY ID 69844700
//    wayPointsLLA.push_back(PointLLA(43.6690187, -79.3843227));
//    wayPointsLLA.push_back(PointLLA(43.6689848, -79.3843065));
//    wayPointsLLA.push_back(PointLLA(43.668562, -79.3841442));
//    wayPointsLLA.push_back(PointLLA(43.6684823, -79.3841087));
//    wayPointsLLA.push_back(PointLLA(43.6687109, -79.383001));
//    wayPointsLLA.push_back(PointLLA(43.6692003, -79.3832128));
//    wayPointsLLA.push_back(PointLLA(43.669247, -79.383233));

    // DENVER PLACE, SCARBOROUGH (LOOP)
//    wayPointsLLA.push_back(PointLLA(43.7682636, -79.2488975));
//    wayPointsLLA.push_back(PointLLA(43.7682264, -79.2490949));
//    wayPointsLLA.push_back(PointLLA(43.768183, -79.2491464));
//    wayPointsLLA.push_back(PointLLA(43.7681148, -79.2491722));
//    wayPointsLLA.push_back(PointLLA(43.7680529, -79.2491035));
//    wayPointsLLA.push_back(PointLLA(43.7680281, -79.2489834));
//    wayPointsLLA.push_back(PointLLA(43.7680529, -79.248889));
//    wayPointsLLA.push_back(PointLLA(43.7681768, -79.2488546));
//    wayPointsLLA.push_back(PointLLA(43.7682636, -79.2488975));

    // STELVIO PASS ITALY
//    wayPointsLLA.push_back(PointLLA(46.5315501, 10.4564453));
//    wayPointsLLA.push_back(PointLLA(46.5315220, 10.4564494));
//    wayPointsLLA.push_back(PointLLA(46.5314896, 10.4564166));
//    wayPointsLLA.push_back(PointLLA(46.5313572, 10.4561587));
//    wayPointsLLA.push_back(PointLLA(46.5312671, 10.4559397));
//    wayPointsLLA.push_back(PointLLA(46.5311671, 10.4558128));
//    wayPointsLLA.push_back(PointLLA(46.5310362, 10.4557330));
//    wayPointsLLA.push_back(PointLLA(46.5304194, 10.4555181));
//    wayPointsLLA.push_back(PointLLA(46.5301335, 10.4552397));
//    wayPointsLLA.push_back(PointLLA(46.5300884, 10.4552233));
//    wayPointsLLA.push_back(PointLLA(46.5300068, 10.4552315));
//    wayPointsLLA.push_back(PointLLA(46.5298772, 10.4552622));
//    wayPointsLLA.push_back(PointLLA(46.5296026, 10.4553093));
//    wayPointsLLA.push_back(PointLLA(46.5294699, 10.4553312));
//    wayPointsLLA.push_back(PointLLA(46.5294350, 10.4553525));
//    wayPointsLLA.push_back(PointLLA(46.5294192, 10.4553885));
//    wayPointsLLA.push_back(PointLLA(46.5294192, 10.4554343));
//    wayPointsLLA.push_back(PointLLA(46.5294328, 10.4554622));
//    wayPointsLLA.push_back(PointLLA(46.5294598, 10.4554704));
//    wayPointsLLA.push_back(PointLLA(46.5299544, 10.4553508));
//    wayPointsLLA.push_back(PointLLA(46.5299746, 10.4553508));
//    wayPointsLLA.push_back(PointLLA(46.5299904, 10.4553705));
//    wayPointsLLA.push_back(PointLLA(46.5300006, 10.4554114));
//    wayPointsLLA.push_back(PointLLA(46.5299938, 10.4554458));
//    wayPointsLLA.push_back(PointLLA(46.5299713, 10.4554785));
//    wayPointsLLA.push_back(PointLLA(46.5299082, 10.4555015));
//    wayPointsLLA.push_back(PointLLA(46.5295071, 10.4555981));
//    wayPointsLLA.push_back(PointLLA(46.5294508, 10.4556325));
//    wayPointsLLA.push_back(PointLLA(46.5294226, 10.4556734));
//    wayPointsLLA.push_back(PointLLA(46.5294238, 10.4557127));
//    wayPointsLLA.push_back(PointLLA(46.5294395, 10.4557373));
//    wayPointsLLA.push_back(PointLLA(46.5294711, 10.4557422));
//    wayPointsLLA.push_back(PointLLA(46.5295758, 10.4557258));
//    wayPointsLLA.push_back(PointLLA(46.5298124, 10.4556587));
//    wayPointsLLA.push_back(PointLLA(46.5298823, 10.4556701));
//    wayPointsLLA.push_back(PointLLA(46.5299431, 10.4556865));
//    wayPointsLLA.push_back(PointLLA(46.5300006, 10.4557438));
//    wayPointsLLA.push_back(PointLLA(46.5301110, 10.4558928));
//    wayPointsLLA.push_back(PointLLA(46.5302901, 10.4561352));
//    wayPointsLLA.push_back(PointLLA(46.5306033, 10.4564070));

    // convert to ECEF
    listVx.resize(wayPointsLLA.size());
    Vec3 xlateVec = convLLAToECEF(wayPointsLLA[0]);
    for(size_t i=0; i < wayPointsLLA.size(); i++)   {
        listVx[i] = convLLAToECEF(wayPointsLLA[i]);     // convert from LLA
//        listVx[i] = listVx[i]-xlateVec;                 // xlate to center
    }
}