Пример #1
0
void OsmConverter::processPolygon(GeoDataPolygon *polygon,
                                  const OsmPlacemarkData& osmData,
                                  GeoDataPlacemark* placemark)
{
    int index = -1;

    // Writing all the outerRing's nodes
    const GeoDataLinearRing &outerRing = polygon->outerBoundary();
    const OsmPlacemarkData outerRingOsmData = osmData.memberReference( index );
    for (auto const &coordinates: outerRing) {
        m_nodes << OsmConverter::Node(coordinates, outerRingOsmData.nodeReference(coordinates));
    }
    m_ways << OsmConverter::Way(&outerRing, outerRingOsmData);

    // Writing all nodes for each innerRing
    for (auto const &innerRing: polygon->innerBoundaries() ) {
        ++index;
        const OsmPlacemarkData innerRingOsmData = osmData.memberReference( index );
        for (auto const &coordinates: innerRing) {
            m_nodes << OsmConverter::Node(coordinates, innerRingOsmData.nodeReference(coordinates));
        }
        m_ways << OsmConverter::Way(&innerRing, innerRingOsmData);
    }
    m_relations.append(OsmConverter::Relation(placemark, osmData));
}
Пример #2
0
void OsmRelationTagWriter::writeMultipolygon( const GeoDataPolygon& polygon,
                                              const OsmPlacemarkData& osmData, GeoWriter& writer )
{
    writer.writeStartElement( osm::osmTag_relation );

    OsmObjectAttributeWriter::writeAttributes( osmData, writer );
    OsmTagTagWriter::writeTags( osmData, writer );

    writer.writeStartElement( osm::osmTag_member );
    QString memberId = QString::number( osmData.memberReference( -1 ).id() );
    writer.writeAttribute( "type", "way" );
    writer.writeAttribute( "ref", memberId );
    writer.writeAttribute( "role", "outer" );
    writer.writeEndElement();

    for ( int index = 0; index < polygon.innerBoundaries().size(); ++index ) {
        writer.writeStartElement( osm::osmTag_member );
        QString memberId = QString::number( osmData.memberReference( index ).id() );
        writer.writeAttribute( "type", "way" );
        writer.writeAttribute( "ref", memberId );
        writer.writeAttribute( "role", "inner" );
        writer.writeEndElement();
    }
    writer.writeEndElement();
 }