예제 #1
0
bool QGeoCodeXmlParser::parseBoundingBox(QGeoBoundingBox *bounds)
{
    /*
    <xsd:complexType name="GeoBox">
        <xsd:sequence>
            <xsd:element name="northWest" type="gc:GeoCoord"/>
            <xsd:element name="southEast" type="gc:GeoCoord"/>
        </xsd:sequence>
    </xsd:complexType>
    */

    Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "boundingBox");

    if (!m_reader->readNextStartElement()) {
        m_reader->raiseError("The element \"boundingBox\" was expected to have 2 child elements (0 found)");
        return false;
    }

    QGeoCoordinate nw;

    if (m_reader->name() == "topLeft") {
        if (!parseCoordinate(&nw, "topLeft"))
            return false;
    } else {
        m_reader->raiseError(QString("The element \"boundingBox\" expected this child element to be named \"topLeft\" (found an element named \"%1\")").arg(m_reader->name().toString()));
        return false;
    }

    if (!m_reader->readNextStartElement()) {
        m_reader->raiseError("The element \"boundingBox\" was expected to have 2 child elements (1 found)");
        return false;
    }

    QGeoCoordinate se;

    if (m_reader->name() == "bottomRight") {
        if (!parseCoordinate(&se, "bottomRight"))
            return false;
    } else {
        m_reader->raiseError(QString("The element \"boundingBox\" expected this child element to be named \"bottomRight\" (found an element named \"%1\")").arg(m_reader->name().toString()));
        return false;
    }

    if (m_reader->readNextStartElement()) {
        m_reader->raiseError("The element \"boundingBox\" was expected to have 2 child elements (more than 2 found)");
        return false;
    }

    *bounds = QGeoBoundingBox(nw, se);

    return true;
}
void QDeclarativePolylineMapItem::setPath(const QJSValue &value)
{
    if (!value.isArray())
        return;

    QList<QGeoCoordinate> pathList;
    quint32 length = value.property(QStringLiteral("length")).toUInt();
    for (quint32 i = 0; i < length; ++i) {
        bool ok;
        QGeoCoordinate c = parseCoordinate(value.property(i), &ok);

        if (!ok || !c.isValid()) {
            qmlInfo(this) << "Unsupported path type";
            return;
        }

        pathList.append(c);
    }

    if (path_ == pathList)
        return;

    path_ = pathList;

    geometry_.markSourceDirty();
    updateMapItem();
    emit pathChanged();
}
예제 #3
0
void QDeclarativeGeoRoute::setPath(const QJSValue &value)
{
    if (!value.isArray())
        return;

    QList<QGeoCoordinate> pathList;
    quint32 length = value.property(QStringLiteral("length")).toUInt();
    for (quint32 i = 0; i < length; ++i) {
        bool ok;
        QGeoCoordinate c = parseCoordinate(value.property(i), &ok);

        if (!ok || !c.isValid()) {
            qmlInfo(this) << "Unsupported path type";
            return;
        }

        pathList.append(c);
    }

    if (route_.path() == pathList)
        return;

    route_.setPath(pathList);

    emit pathChanged();
}
예제 #4
0
    void
    PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::FollowPath& man)
    {
      // Get configurable parameters
      parseCoordinate(cfg, id, man);
      parseSpeed(cfg, id, man);
      parseTimeout(cfg, id, man);
      parseZ(cfg, id, man);
      parseZUnits(cfg, id, man);

      int n_points;

      cfg.get(id, "Number of Points", "0", n_points);

      Math::Matrix W(n_points, 3);

      W.readFromConfig(cfg, id, "Points");

      IMC::MessageList<IMC::PathPoint>* list = &man.points;

      for (int i = 0; i < W.rows(); ++i)
      {
        IMC::PathPoint* p = new IMC::PathPoint;
        p->x = W(i, 0);
        p->y = W(i, 1);
        p->z = W(i, 2);

        list->push_back(*p);
      }
    }
예제 #5
0
  /// Parses coordinates list. If input data is invalid, return false.
  static std::vector<utymap::GeoCoordinate> parseCoordinates(const ptree &geometry) {
    std::vector<utymap::GeoCoordinate> coordinates;
    for (const ptree::value_type &coordinate : geometry) {
      coordinates.emplace_back(parseCoordinate(coordinate.second));
    }

    // TODO check orientation
    std::reverse(coordinates.begin(), coordinates.end());
    return coordinates;
  }
예제 #6
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::Goto& man)
 {
   // Get configurable parameters
   parseCoordinate(cfg, id, man);
   parseSpeed(cfg, id, man);
   parseTimeout(cfg, id, man);
   parseZ(cfg, id, man);
   parseZUnits(cfg, id, man);
 }
예제 #7
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string section, IMC::YoYo& man)
 {
   parseCoordinate(cfg, section, man);
   parseZ(cfg, section, man);
   parseZUnits(cfg, section, man);
   cfg.get(section, "Amplitude (meters)", "0.0", man.amplitude);
   parseAngle(cfg, section, "Pitch (degrees)", man.pitch, (fp32_t)15.0);
   parseSpeed(cfg, section, man);
 }
예제 #8
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string section, IMC::LblBeaconSetup& bs)
 {
   bs.beacon = section;
   parseCoordinate(cfg, section, bs);
   parseZ(cfg, section);
   cfg.get(section, "Transponder Delay (msecs)", "", bs.transponder_delay);
   cfg.get(section, "Interrogation Channel", "", bs.query_channel);
   cfg.get(section, "Reply Channel", "", bs.reply_channel);
 }
예제 #9
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::StationKeeping& man)
 {
   // Get configurable parameters
   parseCoordinate(cfg, id, man);
   parseSpeed(cfg, id, man);
   parseZ(cfg, id, man);
   parseZUnits(cfg, id, man);
   parseDuration(cfg, id, man);
   cfg.get(id, "Radius (meters)", "15.0", man.radius);
 }
예제 #10
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::PopUp& man)
 {
   parseCoordinate(cfg, id, man);
   parseSpeed(cfg, id, man);
   parseTimeout(cfg, id, man);
   parseDuration(cfg, id, man);
   parseZ(cfg, id, man);
   parseZUnits(cfg, id, man);
   cfg.get(id, "Radius (meters)", "15.0", man.radius);
   cfg.get(id, "Flags", "0x00", man.flags);
 }
예제 #11
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string section, IMC::Elevator& man)
 {
   parseSpeed(cfg, section, man);
   parseCoordinate(cfg, section, man);
   cfg.get(section, "Flags", "0x00", man.flags);
   parseZUnits(cfg, section, man.start_z_units, "Start Z Units");
   parseZUnits(cfg, section, man.end_z_units, "End Z Units");
   cfg.get(section, "Start Z (meters)", "0.0", man.start_z);
   cfg.get(section, "End Z (meters)", "0.0", man.end_z);
   cfg.get(section, "Radius (meters)", "15.0", man.radius);
 }
예제 #12
0
 void
 PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::Rows& man)
 {
   // Get configurable parameters
   parseCoordinate(cfg, id, man);
   parseSpeed(cfg, id, man);
   parseZ(cfg, id, man);
   parseZUnits(cfg, id, man);
   parseAngle(cfg, id, "Bearing (degrees)", man.bearing, 0.0);
   parseAngle(cfg, id, "Cross Angle (degrees)", man.cross_angle, 0.0);
   cfg.get(id, "Width (meters)", "150", man.width);
   cfg.get(id, "Length (meters)", "100", man.length);
   cfg.get(id, "Curve Offset (meters)", "15", man.coff);
   cfg.get(id, "Alternation (%)", "100", man.alternation);
   cfg.get(id, "Horizontal Step (meters)", "30", man.hstep);
   cfg.get(id, "Flags", "3", man.flags);
 }
예제 #13
0
void SUROpener::Parser::dispatch(QString line)
{
    switch (state)
    {
    case GROUPS:
        parseGroup(line);
        break;
    case INCIDENCE:
        parseIncidence(line);
        break;
    case COORDINATES:
        parseCoordinate(line);
        break;
    case VOLUME:
        ignoreLine(line);
        break;
    default:
        ignoreLine(line);
    }
}
예제 #14
0
    void
    PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::Loiter& man)
    {
      // Get configurable parameters
      parseCoordinate(cfg, id, man);
      parseSpeed(cfg, id, man);
      parseTimeout(cfg, id, man);
      parseDuration(cfg, id, man);
      parseZ(cfg, id, man);
      parseZUnits(cfg, id, man);

      int8_t type;
      cfg.get(id, "Loiter Type", "0", type);

      switch (type)
      {
        case 1:
          man.type = IMC::Loiter::LT_RACETRACK; break;
        case 2:
          man.type = IMC::Loiter::LT_HOVER; break;
        case 3:
          man.type = IMC::Loiter::LT_EIGHT; break;
        case 0:
        default:
          man.type = IMC::Loiter::LT_CIRCULAR; break;
      }

      std::string ldir;
      cfg.get(id, "Loiter Direction", "Clock", ldir);

      if (ldir == "Clockwise")
        man.direction = IMC::Loiter::LD_CLOCKW;
      else
        man.direction = IMC::Loiter::LD_CCLOCKW;

      cfg.get(id, "Radius (meters)", "50", man.radius);
      parseAngle(cfg, id, "Bearing (degrees)", man.bearing, 0.0);
      cfg.get(id, "Length (meters)", "100", man.length);
    }
예제 #15
0
    void
    PlanConfigParser::parse(Parsers::Config& cfg, std::string id, IMC::CompassCalibration& man)
    {
      // Get configurable parameters
      parseCoordinate(cfg, id, man);
      parseSpeed(cfg, id, man);
      parseTimeout(cfg, id, man);
      parseDuration(cfg, id, man);
      parseZ(cfg, id, man);
      parseZUnits(cfg, id, man);

      std::string ldir;
      cfg.get(id, "Loiter Direction", "Clock", ldir);

      if (ldir == "Clockwise")
        man.direction = IMC::Loiter::LD_CLOCKW;
      else
        man.direction = IMC::Loiter::LD_CCLOCKW;

      cfg.get(id, "Radius (meters)", "50", man.radius);
      cfg.get(id, "Amplitude (meters)", "1", man.amplitude);
      parseAngle(cfg, id, "Pitch (degrees)", man.pitch, (fp32_t)0.0);
    }
예제 #16
0
파일: RenJS.cpp 프로젝트: gomoku/RenLib
void RenJS::parseParam(const CString& strParam, RenJS::Node& node)
{
	int index = strParam.Find("=");

	CString strKey(strParam.Left(index));
	CString strValue(strParam.Right(strParam.GetLength() - 1 - index));

	if (strKey == "i")
	{
		parseId(strValue, node);
	}
	else if (strKey == "p")
	{
		parseCoordinate(strValue, node);
	}
	else if (strKey == "m")
	{
		parseNumber(strValue, node);
	}
	else if (strKey == "f")
	{
		parseParent(strValue, node);
	}
	else if (strKey == "c")
	{
		parseChildren(strValue, node);
	}
	else if (strKey == "co")
	{
		parseComment(strValue, node);
	}
	else if (strKey == "k")
	{
		parseBoardText(strValue, node);
	}
}
예제 #17
0
 /// Parses node from point and notifies visitor.
 void parsePoint(Visitor &visitor, std::uint32_t featureId, const ptree &feature) const {
   utymap::entities::Node node;
   parseProperties(node, featureId, feature.get_child("properties"));
   node.coordinate = parseCoordinate(feature.get_child("geometry.coordinates"));
   visitor.add(node);
 }
예제 #18
0
bool QGeoCodeXmlParser::parseLocation(QGeoPlace *place)
{
    /*
    <xsd:complexType name="Location">
        <xsd:all>
            <xsd:element name="position" type="gc:GeoCoord"/>
            <xsd:element minOccurs="0" name="boundingBox" type="gc:GeoBox"/>
        </xsd:all>
    </xsd:complexType>

    <xsd:complexType name="GeoBox">
        <xsd:sequence>
            <xsd:element name="northWest" type="gc:GeoCoord"/>
            <xsd:element name="southEast" type="gc:GeoCoord"/>
        </xsd:sequence>
    </xsd:complexType>
    */

    Q_ASSERT(m_reader->isStartElement() && m_reader->name() == "location");

    bool parsedPosition = false;
    bool parsedBounds = false;

    while (m_reader->readNextStartElement()) {
        QString name = m_reader->name().toString();
        if (name == "position") {
            if (parsedPosition) {
                m_reader->raiseError("The element \"location\" has multiple child elements named \"position\" (exactly one expected)");
                return false;
            }

            QGeoCoordinate coord;
            if (!parseCoordinate(&coord, "position"))
                return false;

            place->setCoordinate(coord);

            parsedPosition = true;
        } else if (name == "boundingBox") {
            if (parsedBounds) {
                m_reader->raiseError("The element \"location\" has multiple child elements named \"boundingBox\" (at most one expected)");
                return false;
            }

            QGeoBoundingBox bounds;

            if (!parseBoundingBox(&bounds))
                return false;

            place->setViewport(bounds);

            parsedBounds = true;
        } else {
            m_reader->raiseError(QString("The element \"location\" did not expect a child element named \"%1\".").arg(m_reader->name().toString()));
            return false;
        }
    }

    if (!parsedPosition) {
        m_reader->raiseError("The element \"location\" has no child elements named \"position\" (exactly one expected)");
        return false;
    }

    return true;
}
예제 #19
0
파일: mesh.cpp 프로젝트: tsong/viewer
Mesh *Mesh::fromObjFile(QString filename) {
    QFile file(filename);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
        return 0;

    Mesh *M = new Mesh();
    vector<Vector3f> normals;

    //first pass to add all vertices and normals to mesh
    while (!file.atEnd()) {
        QByteArray lineBytes = file.readLine();

        if (lineBytes.at(0) == 'v' && lineBytes.at(1) == 'n') {
            // parse normal if line starts with 'vn'
            Vector3f normal;

            if (!parseCoordinate(QString(lineBytes), normal)) {
                delete M;
                return false;
            }

            normals.push_back(normal);
        } else if (lineBytes.at(0) == 'v' && lineBytes.at(1) == ' ') {
            // parse vertex if line starts with just 'v'
            Vertex V;
            if (!parseCoordinate(QString(lineBytes), V.pos)) {
                delete M;
                return false;
            }
            M->m_vertices.push_back(V);
        }
    }

    //second pass to add faces to the mesh
    file.reset();
    while (!file.atEnd()) {
        QByteArray lineBytes = file.readLine();
        if (lineBytes.at(0) == 'f') {
            uint V[4];
            uint N[4];
            bool hasNormals;

            if (!parseFace(QString(lineBytes), V, N, hasNormals)) {
                delete M;
                return false;
            }

            if (hasNormals) {
                //use normals if they are provided
                Vector3f faceNormals[4];
                for (uint i = 0; i < 4; i++) {
                    if (N[i] < normals.size())
                        faceNormals[i] = normals[N[i]];
                }
                M->addFace(V[0],V[1],V[2],V[3], faceNormals);
            } else {
                //interpolate normals if they are not provided
                M->addFace(V[0],V[1],V[2],V[3]);
            }
        }
    }

    return M;
}